Previous 15994 Revisions Next

r2640 Friday 16th May, 2008 at 23:38:12 UTC by R. Belmont
[SDLMESS] Various improvements, including improved Mac debugger, Unix/X11 paste capability, and more.
[src/mess/osd/sdl]sdlmess.c
[src/osd/sdl]debugosx.c sdl.mak

src/osd/sdl/sdl.mak
r2639r2640
6060ifdef BIGENDIAN
6161X86_MIPS3_DRC =
6262X86_PPC_DRC =
63FORCE_DRC_C_BACKEND = 1
6364endif
6465
6566# OS/2 can't have OpenGL (aww)
src/osd/sdl/debugosx.c
r2639r2640
1717#define OSX_DEBUGGER_FONT_NAME      "Monaco"
1818#define OSX_DEBUGGER_FONT_SIZE      10
1919
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
2026// standard windows headers
2127#include <Carbon/Carbon.h>
2228
r2639r2640
534540static debugwin_info *debug_window_create(const char *title, void *unused)
535541{
536542   CGDirectDisplayID   mainID = CGMainDisplayID();
537   GDHandle         mainDevice;
538543
539544   debugwin_info *info = NULL;
540545   Rect work_bounds;
r2639r2640
579584   }
580585   
581586   // 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   }
584601   info->minwidth = 200;
585602   info->minheight = 200;
586603   info->maxwidth = work_bounds.right - work_bounds.left;
r2639r2640
30233040   ControlFontStyleRec      style;
30243041   Str255      fontName;
30253042   CGDirectDisplayID   mainID = CGMainDisplayID();
3026   GDHandle         mainDevice;
30273043   MenuItemIndex   menuIndex;
30283044   ControlButtonContentInfo   content;
30293045
r2639r2640
31443160      }
31453161
31463162   // 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}
31493177
31503178   // adjust the min/max sizes for the window style
31513179   bounds.top = bounds.left = 0;
src/mess/osd/sdl/sdlmess.c
r2639r2640
2222#endif
2323
2424#if defined(SDLMAME_UNIX) && !defined(SDLMAME_MACOSX)
25#include <SDL_timer.h>
26#include <X11/Xlib.h>
2527#include <X11/Xatom.h>
28#include <SDL_syswm.h>
2629#endif
2730
2831//============================================================
r2639r2640
381384}
382385#endif
383386
384#if defined(SDLMAME_UNIX) && !defined(SDLMAME_MACOSX)
387#if defined(SDL_VIDEO_DRIVER_X11)
385388//============================================================
386389//   osd_get_clipboard_text
387390//============================================================
388391
389392char *osd_get_clipboard_text(void)
390393{
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
476char *osd_get_clipboard_text(void)
477{
391478   char *result = NULL;
392479
393480   return result;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team