src/osd/sdl/debugosx.c
| r2639 | r2640 | |
| 17 | 17 | #define OSX_DEBUGGER_FONT_NAME "Monaco" |
| 18 | 18 | #define OSX_DEBUGGER_FONT_SIZE 10 |
| 19 | 19 | |
| 20 | #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 |
| 21 | #define OSX_LEOPARD 1 |
| 22 | #else |
| 23 | #define OSX_LEOPARD 0 |
| 24 | #endif |
| 25 | |
| 20 | 26 | // standard windows headers |
| 21 | 27 | #include <Carbon/Carbon.h> |
| 22 | 28 | |
| r2639 | r2640 | |
| 534 | 540 | static debugwin_info *debug_window_create(const char *title, void *unused) |
| 535 | 541 | { |
| 536 | 542 | CGDirectDisplayID mainID = CGMainDisplayID(); |
| 537 | | GDHandle mainDevice; |
| 538 | 543 | |
| 539 | 544 | debugwin_info *info = NULL; |
| 540 | 545 | Rect work_bounds; |
| r2639 | r2640 | |
| 579 | 584 | } |
| 580 | 585 | |
| 581 | 586 | // fill in some defaults |
| 582 | | DMGetGDeviceByDisplayID((DisplayIDType)mainID, &mainDevice, TRUE); |
| 583 | | GetAvailableWindowPositioningBounds(mainDevice, &work_bounds); |
| 587 | { |
| 588 | #if OSX_LEOPARD |
| 589 | HIRect mainBounds; |
| 590 | HIWindowGetAvailablePositioningBounds( mainID, kHICoordSpaceScreenPixel, &mainBounds ); |
| 591 | work_bounds.left = mainBounds.origin.x; |
| 592 | work_bounds.top = mainBounds.origin.y; |
| 593 | work_bounds.right = mainBounds.origin.x + mainBounds.size.width; |
| 594 | work_bounds.bottom = mainBounds.origin.y + mainBounds.size.height; |
| 595 | #else |
| 596 | GDHandle mainDevice; |
| 597 | DMGetGDeviceByDisplayID((DisplayIDType)mainID, &mainDevice, TRUE); |
| 598 | GetAvailableWindowPositioningBounds(mainDevice, &work_bounds); |
| 599 | #endif |
| 600 | } |
| 584 | 601 | info->minwidth = 200; |
| 585 | 602 | info->minheight = 200; |
| 586 | 603 | info->maxwidth = work_bounds.right - work_bounds.left; |
| r2639 | r2640 | |
| 3023 | 3040 | ControlFontStyleRec style; |
| 3024 | 3041 | Str255 fontName; |
| 3025 | 3042 | CGDirectDisplayID mainID = CGMainDisplayID(); |
| 3026 | | GDHandle mainDevice; |
| 3027 | 3043 | MenuItemIndex menuIndex; |
| 3028 | 3044 | ControlButtonContentInfo content; |
| 3029 | 3045 | |
| r2639 | r2640 | |
| 3144 | 3160 | } |
| 3145 | 3161 | |
| 3146 | 3162 | // get the work bounds |
| 3147 | | DMGetGDeviceByDisplayID((DisplayIDType)mainID, &mainDevice, TRUE); |
| 3148 | | GetAvailableWindowPositioningBounds(mainDevice, &work_bounds); |
| 3163 | { |
| 3164 | #if OSX_LEOPARD |
| 3165 | HIRect mainBounds; |
| 3166 | HIWindowGetAvailablePositioningBounds( mainID, kHICoordSpaceScreenPixel, &mainBounds ); |
| 3167 | work_bounds.left = mainBounds.origin.x; |
| 3168 | work_bounds.top = mainBounds.origin.y; |
| 3169 | work_bounds.right = mainBounds.origin.x + mainBounds.size.width; |
| 3170 | work_bounds.bottom = mainBounds.origin.y + mainBounds.size.height; |
| 3171 | #else |
| 3172 | GDHandle mainDevice; |
| 3173 | DMGetGDeviceByDisplayID((DisplayIDType)mainID, &mainDevice, TRUE); |
| 3174 | GetAvailableWindowPositioningBounds(mainDevice, &work_bounds); |
| 3175 | #endif |
| 3176 | } |
| 3149 | 3177 | |
| 3150 | 3178 | // adjust the min/max sizes for the window style |
| 3151 | 3179 | bounds.top = bounds.left = 0; |
src/mess/osd/sdl/sdlmess.c
| r2639 | r2640 | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | #if defined(SDLMAME_UNIX) && !defined(SDLMAME_MACOSX) |
| 25 | #include <SDL_timer.h> |
| 26 | #include <X11/Xlib.h> |
| 25 | 27 | #include <X11/Xatom.h> |
| 28 | #include <SDL_syswm.h> |
| 26 | 29 | #endif |
| 27 | 30 | |
| 28 | 31 | //============================================================ |
| r2639 | r2640 | |
| 381 | 384 | } |
| 382 | 385 | #endif |
| 383 | 386 | |
| 384 | | #if defined(SDLMAME_UNIX) && !defined(SDLMAME_MACOSX) |
| 387 | #if defined(SDL_VIDEO_DRIVER_X11) |
| 385 | 388 | //============================================================ |
| 386 | 389 | // osd_get_clipboard_text |
| 387 | 390 | //============================================================ |
| 388 | 391 | |
| 389 | 392 | char *osd_get_clipboard_text(void) |
| 390 | 393 | { |
| 394 | SDL_SysWMinfo info; |
| 395 | Display* display; |
| 396 | Window our_win; |
| 397 | Window selection_win; |
| 398 | Atom data_type; |
| 399 | int data_format; |
| 400 | unsigned long nitems; |
| 401 | unsigned long bytes_remaining; |
| 402 | unsigned char* prop; |
| 403 | char* result; |
| 404 | XEvent event; |
| 405 | Uint32 t0, t1; |
| 406 | Atom types[2]; |
| 407 | int i; |
| 408 | |
| 409 | /* get & validate SDL sys-wm info */ |
| 410 | SDL_VERSION(&info.version); |
| 411 | if ( ! SDL_GetWMInfo( &info ) ) |
| 412 | return NULL; |
| 413 | if ( info.subsystem != SDL_SYSWM_X11 ) |
| 414 | return NULL; |
| 415 | if ( (display = info.info.x11.display) == NULL ) |
| 416 | return NULL; |
| 417 | if ( (our_win = info.info.x11.window) == None ) |
| 418 | return NULL; |
| 419 | |
| 420 | /* request data to owner */ |
| 421 | selection_win = XGetSelectionOwner( display, XA_PRIMARY ); |
| 422 | if ( selection_win == None ) |
| 423 | return NULL; |
| 424 | |
| 425 | /* first, try UTF-8, then latin-1 */ |
| 426 | types[0] = XInternAtom( display, "UTF8_STRING", False ); |
| 427 | types[1] = XA_STRING; /* latin-1 */ |
| 428 | |
| 429 | for ( i = 0; i < sizeof( types ) / sizeof( types[0] ); i++ ) |
| 430 | { |
| 431 | |
| 432 | XConvertSelection( display, XA_PRIMARY, types[i], types[i], our_win, CurrentTime ); |
| 433 | |
| 434 | /* wait for SelectionNotify, but no more than 100 ms */ |
| 435 | t0 = t1 = SDL_GetTicks(); |
| 436 | while ( 1 ) |
| 437 | { |
| 438 | if ( XCheckTypedWindowEvent( display, our_win, SelectionNotify, &event ) ) break; |
| 439 | SDL_Delay( 1 ); |
| 440 | t1 = SDL_GetTicks(); |
| 441 | if ( t1 - t0 > 100 ) |
| 442 | return NULL; |
| 443 | } |
| 444 | if ( event.xselection.property == None ) |
| 445 | continue; |
| 446 | |
| 447 | /* get property & check its type */ |
| 448 | if ( XGetWindowProperty( display, our_win, types[i], 0, 65536, False, types[i], |
| 449 | &data_type, &data_format, &nitems, &bytes_remaining, &prop ) |
| 450 | != Success ) |
| 451 | continue; |
| 452 | if ( ! prop ) |
| 453 | continue; |
| 454 | if ( (data_format != 8) || (data_type != types[i]) ) |
| 455 | { |
| 456 | XFree( prop ); |
| 457 | continue; |
| 458 | } |
| 459 | |
| 460 | /* return a copy & free original */ |
| 461 | result = core_strdup( (char*) prop ); |
| 462 | XFree( prop ); |
| 463 | return result; |
| 464 | } |
| 465 | |
| 466 | return NULL; |
| 467 | } |
| 468 | |
| 469 | #endif |
| 470 | |
| 471 | #if defined(SDLMAME_UNIX) && !defined(SDLMAME_MACOSX) && !defined(SDL_VIDEO_DRIVER_X11) |
| 472 | //============================================================ |
| 473 | // osd_get_clipboard_text |
| 474 | //============================================================ |
| 475 | |
| 476 | char *osd_get_clipboard_text(void) |
| 477 | { |
| 391 | 478 | char *result = NULL; |
| 392 | 479 | |
| 393 | 480 | return result; |