src/video/x11/SDL_x11messagebox.c
changeset 7827 a03ec8de0426
parent 7522 b186724247dd
child 7860 2b0bcdea3a79
     1.1 --- a/src/video/x11/SDL_x11messagebox.c	Thu Oct 17 20:49:30 2013 -0700
     1.2 +++ b/src/video/x11/SDL_x11messagebox.c	Fri Oct 18 01:36:41 2013 -0400
     1.3 @@ -124,13 +124,13 @@
     1.4  {
     1.5      if (SDL_X11_HAVE_UTF8) {
     1.6          XRectangle overall_ink, overall_logical;
     1.7 -        Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical);
     1.8 +        X11_Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical);
     1.9          *pwidth = overall_logical.width;
    1.10          *pheight = overall_logical.height;
    1.11      } else {
    1.12          XCharStruct text_structure;
    1.13          int font_direction, font_ascent, font_descent;
    1.14 -        XTextExtents( data->font_struct, str, nbytes,
    1.15 +        X11_XTextExtents( data->font_struct, str, nbytes,
    1.16                        &font_direction, &font_ascent, &font_descent,
    1.17                        &text_structure );
    1.18          *pwidth = text_structure.width;
    1.19 @@ -180,7 +180,7 @@
    1.20      data->numbuttons = numbuttons;
    1.21      data->pbuttonid = pbuttonid;
    1.22  
    1.23 -    data->display = XOpenDisplay( NULL );
    1.24 +    data->display = X11_XOpenDisplay( NULL );
    1.25      if ( !data->display ) {
    1.26          return SDL_SetError("Couldn't open X11 display");
    1.27      }
    1.28 @@ -188,16 +188,16 @@
    1.29      if (SDL_X11_HAVE_UTF8) {
    1.30          char **missing = NULL;
    1.31          int num_missing = 0;
    1.32 -        data->font_set = XCreateFontSet(data->display, g_MessageBoxFont,
    1.33 +        data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont,
    1.34                                          &missing, &num_missing, NULL);
    1.35          if ( missing != NULL ) {
    1.36 -            XFreeStringList(missing);
    1.37 +            X11_XFreeStringList(missing);
    1.38          }
    1.39          if ( data->font_set == NULL ) {
    1.40              return SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
    1.41          }
    1.42      } else {
    1.43 -        data->font_struct = XLoadQueryFont( data->display, g_MessageBoxFontLatin1 );
    1.44 +        data->font_struct = X11_XLoadQueryFont( data->display, g_MessageBoxFontLatin1 );
    1.45          if ( data->font_struct == NULL ) {
    1.46              return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1);
    1.47          }
    1.48 @@ -338,23 +338,23 @@
    1.49  X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
    1.50  {
    1.51      if ( data->font_set != NULL ) {
    1.52 -        XFreeFontSet( data->display, data->font_set );
    1.53 +        X11_XFreeFontSet( data->display, data->font_set );
    1.54          data->font_set = NULL;
    1.55      }
    1.56  
    1.57      if ( data->font_struct != NULL ) {
    1.58 -        XFreeFont( data->display, data->font_struct );
    1.59 +        X11_XFreeFont( data->display, data->font_struct );
    1.60          data->font_struct = NULL;
    1.61      }
    1.62  
    1.63      if ( data->display ) {
    1.64          if ( data->window != None ) {
    1.65 -            XWithdrawWindow( data->display, data->window, data->screen );
    1.66 -            XDestroyWindow( data->display, data->window );
    1.67 +            X11_XWithdrawWindow( data->display, data->window, data->screen );
    1.68 +            X11_XDestroyWindow( data->display, data->window );
    1.69              data->window = None;
    1.70          }
    1.71  
    1.72 -        XCloseDisplay( data->display );
    1.73 +        X11_XCloseDisplay( data->display );
    1.74          data->display = NULL;
    1.75      }
    1.76  }
    1.77 @@ -384,7 +384,7 @@
    1.78                         StructureNotifyMask | FocusChangeMask | PointerMotionMask;
    1.79      wnd_attr.event_mask = data->event_mask;
    1.80  
    1.81 -    data->window = XCreateWindow(
    1.82 +    data->window = X11_XCreateWindow(
    1.83                         display, RootWindow(display, data->screen),
    1.84                         0, 0,
    1.85                         data->dialog_width, data->dialog_height,
    1.86 @@ -396,31 +396,31 @@
    1.87  
    1.88      if ( windowdata ) {
    1.89          /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */
    1.90 -        XSetTransientForHint( display, data->window, windowdata->xwindow );
    1.91 +        X11_XSetTransientForHint( display, data->window, windowdata->xwindow );
    1.92      }
    1.93  
    1.94 -    XStoreName( display, data->window, messageboxdata->title );
    1.95 +    X11_XStoreName( display, data->window, messageboxdata->title );
    1.96  
    1.97      /* Allow the window to be deleted by the window manager */
    1.98 -    data->wm_protocols = XInternAtom( display, "WM_PROTOCOLS", False );
    1.99 -    data->wm_delete_message = XInternAtom( display, "WM_DELETE_WINDOW", False );
   1.100 -    XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 );
   1.101 +    data->wm_protocols = X11_XInternAtom( display, "WM_PROTOCOLS", False );
   1.102 +    data->wm_delete_message = X11_XInternAtom( display, "WM_DELETE_WINDOW", False );
   1.103 +    X11_XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 );
   1.104  
   1.105      if ( windowdata ) {
   1.106          XWindowAttributes attrib;
   1.107          Window dummy;
   1.108  
   1.109 -        XGetWindowAttributes(display, windowdata->xwindow, &attrib);
   1.110 +        X11_XGetWindowAttributes(display, windowdata->xwindow, &attrib);
   1.111          x = attrib.x + ( attrib.width - data->dialog_width ) / 2;
   1.112          y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ;
   1.113 -        XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy);
   1.114 +        X11_XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy);
   1.115      } else {
   1.116          x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2;
   1.117          y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ;
   1.118      }
   1.119 -    XMoveWindow( display, data->window, x, y );
   1.120 +    X11_XMoveWindow( display, data->window, x, y );
   1.121  
   1.122 -    sizehints = XAllocSizeHints();
   1.123 +    sizehints = X11_XAllocSizeHints();
   1.124      if ( sizehints ) {
   1.125          sizehints->flags = USPosition | USSize | PMaxSize | PMinSize;
   1.126          sizehints->x = x;
   1.127 @@ -431,12 +431,12 @@
   1.128          sizehints->min_width = sizehints->max_width = data->dialog_width;
   1.129          sizehints->min_height = sizehints->max_height = data->dialog_height;
   1.130  
   1.131 -        XSetWMNormalHints( display, data->window, sizehints );
   1.132 +        X11_XSetWMNormalHints( display, data->window, sizehints );
   1.133  
   1.134 -        XFree( sizehints );
   1.135 +        X11_XFree( sizehints );
   1.136      }
   1.137  
   1.138 -    XMapRaised( display, data->window );
   1.139 +    X11_XMapRaised( display, data->window );
   1.140      return 0;
   1.141  }
   1.142  
   1.143 @@ -448,19 +448,19 @@
   1.144      Window window = data->window;
   1.145      Display *display = data->display;
   1.146  
   1.147 -    XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
   1.148 -    XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
   1.149 +    X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
   1.150 +    X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
   1.151  
   1.152 -    XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   1.153 +    X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   1.154      for ( i = 0; i < data->numlines; i++ ) {
   1.155          TextLineData *plinedata = &data->linedata[ i ];
   1.156  
   1.157          if (SDL_X11_HAVE_UTF8) {
   1.158 -            Xutf8DrawString( display, window, data->font_set, ctx,
   1.159 +            X11_Xutf8DrawString( display, window, data->font_set, ctx,
   1.160                               data->xtext, data->ytext + i * data->text_height,
   1.161                               plinedata->text, plinedata->length );
   1.162          } else {
   1.163 -            XDrawString( display, window, ctx,
   1.164 +            X11_XDrawString( display, window, ctx,
   1.165                           data->xtext, data->ytext + i * data->text_height,
   1.166                           plinedata->text, plinedata->length );
   1.167          }
   1.168 @@ -472,27 +472,27 @@
   1.169          int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0;
   1.170          int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0;
   1.171  
   1.172 -        XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] );
   1.173 -        XFillRectangle( display, window, ctx,
   1.174 +        X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] );
   1.175 +        X11_XFillRectangle( display, window, ctx,
   1.176                          buttondatax11->rect.x - border, buttondatax11->rect.y - border,
   1.177                          buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border );
   1.178  
   1.179 -        XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] );
   1.180 -        XDrawRectangle( display, window, ctx,
   1.181 +        X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] );
   1.182 +        X11_XDrawRectangle( display, window, ctx,
   1.183                          buttondatax11->rect.x, buttondatax11->rect.y,
   1.184                          buttondatax11->rect.w, buttondatax11->rect.h );
   1.185  
   1.186 -        XSetForeground( display, ctx, ( data->mouse_over_index == i ) ?
   1.187 +        X11_XSetForeground( display, ctx, ( data->mouse_over_index == i ) ?
   1.188                          data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] :
   1.189                          data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   1.190  
   1.191          if (SDL_X11_HAVE_UTF8) {
   1.192 -            Xutf8DrawString( display, window, data->font_set, ctx,
   1.193 +            X11_Xutf8DrawString( display, window, data->font_set, ctx,
   1.194                               buttondatax11->x + offset,
   1.195                               buttondatax11->y + offset,
   1.196                               buttondata->text, buttondatax11->length );
   1.197          } else {
   1.198 -            XDrawString( display, window, ctx,
   1.199 +            X11_XDrawString( display, window, ctx,
   1.200                           buttondatax11->x + offset, buttondatax11->y + offset,
   1.201                           buttondata->text, buttondatax11->length );
   1.202          }
   1.203 @@ -519,7 +519,7 @@
   1.204          ctx_vals.font = data->font_struct->fid;
   1.205      }
   1.206  
   1.207 -    ctx = XCreateGC( data->display, data->window, gcflags, &ctx_vals );
   1.208 +    ctx = X11_XCreateGC( data->display, data->window, gcflags, &ctx_vals );
   1.209      if ( ctx == None ) {
   1.210          return SDL_SetError("Couldn't create graphics context");
   1.211      }
   1.212 @@ -531,11 +531,11 @@
   1.213          XEvent e;
   1.214          SDL_bool draw = SDL_TRUE;
   1.215  
   1.216 -        XWindowEvent( data->display, data->window, data->event_mask, &e );
   1.217 +        X11_XWindowEvent( data->display, data->window, data->event_mask, &e );
   1.218  
   1.219 -        /* If XFilterEvent returns True, then some input method has filtered the
   1.220 +        /* If X11_XFilterEvent returns True, then some input method has filtered the
   1.221             event, and the client should discard the event. */
   1.222 -        if ( ( e.type != Expose ) && XFilterEvent( &e, None ) )
   1.223 +        if ( ( e.type != Expose ) && X11_XFilterEvent( &e, None ) )
   1.224              continue;
   1.225  
   1.226          switch( e.type ) {
   1.227 @@ -574,12 +574,12 @@
   1.228  
   1.229          case KeyPress:
   1.230              /* Store key press - we make sure in key release that we got both. */
   1.231 -            last_key_pressed = XLookupKeysym( &e.xkey, 0 );
   1.232 +            last_key_pressed = X11_XLookupKeysym( &e.xkey, 0 );
   1.233              break;
   1.234  
   1.235          case KeyRelease: {
   1.236              Uint32 mask = 0;
   1.237 -            KeySym key = XLookupKeysym( &e.xkey, 0 );
   1.238 +            KeySym key = X11_XLookupKeysym( &e.xkey, 0 );
   1.239  
   1.240              /* If this is a key release for something we didn't get the key down for, then bail. */
   1.241              if ( key != last_key_pressed )
   1.242 @@ -637,7 +637,7 @@
   1.243          }
   1.244      }
   1.245  
   1.246 -    XFreeGC( data->display, ctx );
   1.247 +    X11_XFreeGC( data->display, ctx );
   1.248      return 0;
   1.249  }
   1.250  
   1.251 @@ -667,7 +667,7 @@
   1.252  #endif
   1.253  
   1.254      /* This code could get called from multiple threads maybe? */
   1.255 -    XInitThreads();
   1.256 +    X11_XInitThreads();
   1.257  
   1.258      /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */
   1.259      *buttonid = -1;
   1.260 @@ -707,7 +707,7 @@
   1.261      int status = 0;
   1.262  
   1.263      /* Need to flush here in case someone has turned grab off and it hasn't gone through yet, etc. */
   1.264 -    XFlush(data->display);
   1.265 +    X11_XFlush(data->display);
   1.266  
   1.267      if (pipe(fds) == -1) {
   1.268          return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */