src/video/x11/SDL_x11messagebox.c
changeset 7522 b186724247dd
parent 7191 75360622e65f
child 7827 a03ec8de0426
equal deleted inserted replaced
7521:03bca9a4180d 7522:b186724247dd
    76     int width;                          /* Width of this text line */
    76     int width;                          /* Width of this text line */
    77     int length;                         /* String length of this text line */
    77     int length;                         /* String length of this text line */
    78     const char *text;                   /* Text for this line */
    78     const char *text;                   /* Text for this line */
    79 } TextLineData;
    79 } TextLineData;
    80 
    80 
    81 typedef struct SDL_MessageBoxDataX11 {
    81 typedef struct SDL_MessageBoxDataX11
    82     XFontSet font_set;                  /* for UTF-8 systems */
    82 {
    83     XFontStruct *font_struct;            /* Latin1 (ASCII) fallback. */
    83     Display *display;
       
    84     int screen;
    84     Window window;
    85     Window window;
    85     Display *display;
       
    86     long event_mask;
    86     long event_mask;
    87     Atom wm_protocols;
    87     Atom wm_protocols;
    88     Atom wm_delete_message;
    88     Atom wm_delete_message;
    89 
    89 
    90     int dialog_width;                   /* Dialog box width. */
    90     int dialog_width;                   /* Dialog box width. */
    91     int dialog_height;                  /* Dialog box height. */
    91     int dialog_height;                  /* Dialog box height. */
    92 
    92 
       
    93     XFontSet font_set;                  /* for UTF-8 systems */
       
    94     XFontStruct *font_struct;           /* Latin1 (ASCII) fallback. */
    93     int xtext, ytext;                   /* Text position to start drawing at. */
    95     int xtext, ytext;                   /* Text position to start drawing at. */
    94     int numlines;                       /* Count of Text lines. */
    96     int numlines;                       /* Count of Text lines. */
    95     int text_height;                    /* Height for text lines. */
    97     int text_height;                    /* Height for text lines. */
    96     TextLineData linedata[ MAX_TEXT_LINES ];
    98     TextLineData linedata[ MAX_TEXT_LINES ];
    97 
    99 
   345         data->font_struct = NULL;
   347         data->font_struct = NULL;
   346     }
   348     }
   347 
   349 
   348     if ( data->display ) {
   350     if ( data->display ) {
   349         if ( data->window != None ) {
   351         if ( data->window != None ) {
   350             XUnmapWindow( data->display, data->window );
   352             XWithdrawWindow( data->display, data->window, data->screen );
   351             XDestroyWindow( data->display, data->window );
   353             XDestroyWindow( data->display, data->window );
   352             data->window = None;
   354             data->window = None;
   353         }
   355         }
   354 
   356 
   355         XCloseDisplay( data->display );
   357         XCloseDisplay( data->display );
   367     Display *display = data->display;
   369     Display *display = data->display;
   368     SDL_WindowData *windowdata = NULL;
   370     SDL_WindowData *windowdata = NULL;
   369     const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
   371     const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
   370 
   372 
   371     if ( messageboxdata->window ) {
   373     if ( messageboxdata->window ) {
       
   374         SDL_DisplayData *displaydata =
       
   375             (SDL_DisplayData *) SDL_GetDisplayForWindow(messageboxdata->window)->driverdata;
   372         windowdata = (SDL_WindowData *)messageboxdata->window->driverdata;
   376         windowdata = (SDL_WindowData *)messageboxdata->window->driverdata;
       
   377         data->screen = displaydata->screen;
       
   378     } else {
       
   379         data->screen = DefaultScreen( display );
   373     }
   380     }
   374 
   381 
   375     data->event_mask = ExposureMask |
   382     data->event_mask = ExposureMask |
   376                        ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
   383                        ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
   377                        StructureNotifyMask | FocusChangeMask | PointerMotionMask;
   384                        StructureNotifyMask | FocusChangeMask | PointerMotionMask;
   378     wnd_attr.event_mask = data->event_mask;
   385     wnd_attr.event_mask = data->event_mask;
   379 
   386 
   380     data->window = XCreateWindow(
   387     data->window = XCreateWindow(
   381                        display, DefaultRootWindow( display ),
   388                        display, RootWindow(display, data->screen),
   382                        0, 0,
   389                        0, 0,
   383                        data->dialog_width, data->dialog_height,
   390                        data->dialog_width, data->dialog_height,
   384                        0, CopyFromParent, InputOutput, CopyFromParent,
   391                        0, CopyFromParent, InputOutput, CopyFromParent,
   385                        CWEventMask, &wnd_attr );
   392                        CWEventMask, &wnd_attr );
   386     if ( data->window == None ) {
   393     if ( data->window == None ) {
   404         Window dummy;
   411         Window dummy;
   405 
   412 
   406         XGetWindowAttributes(display, windowdata->xwindow, &attrib);
   413         XGetWindowAttributes(display, windowdata->xwindow, &attrib);
   407         x = attrib.x + ( attrib.width - data->dialog_width ) / 2;
   414         x = attrib.x + ( attrib.width - data->dialog_width ) / 2;
   408         y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ;
   415         y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ;
   409         XTranslateCoordinates(display, windowdata->xwindow, DefaultRootWindow( display ), x, y, &x, &y, &dummy);
   416         XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy);
   410     } else {
   417     } else {
   411         int screen = DefaultScreen( display );
   418         x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2;
   412         x = ( DisplayWidth( display, screen ) - data->dialog_width ) / 2;
   419         y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ;
   413         y = ( DisplayHeight( display, screen ) - data->dialog_height ) / 3 ;
       
   414     }
   420     }
   415     XMoveWindow( display, data->window, x, y );
   421     XMoveWindow( display, data->window, x, y );
   416 
   422 
   417     sizehints = XAllocSizeHints();
   423     sizehints = XAllocSizeHints();
   418     if ( sizehints ) {
   424     if ( sizehints ) {