src/video/x11/SDL_x11window.c
author Edgar Simo <bobbens@gmail.com>
Sun, 06 Jul 2008 17:06:37 +0000
branchgsoc2008_force_feedback
changeset 2498 ab567bd667bf
parent 2325 c7bcf84ba1b9
child 2710 44e49d3fa6cf
child 3760 64f346a83ed3
permissions -rw-r--r--
Fixed various mistakes in the doxygen.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_syswm.h"
    25 #include "../SDL_sysvideo.h"
    26 #include "../../events/SDL_keyboard_c.h"
    27 
    28 #include "SDL_x11video.h"
    29 #include "../Xext/extensions/StdCmap.h"
    30 
    31 static int
    32 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
    33 {
    34     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    35     SDL_WindowData *data;
    36     int numwindows = videodata->numwindows;
    37     int windowlistlength = videodata->windowlistlength;
    38     SDL_WindowData **windowlist = videodata->windowlist;
    39     int index;
    40 
    41     /* Allocate the window data */
    42     data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
    43     if (!data) {
    44         SDL_OutOfMemory();
    45         return -1;
    46     }
    47     data->windowID = window->id;
    48     data->window = w;
    49 #ifdef X_HAVE_UTF8_STRING
    50     if (SDL_X11_HAVE_UTF8) {
    51         data->ic =
    52             pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w,
    53                        XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
    54                        XNResourceName, videodata->classname, XNResourceClass,
    55                        videodata->classname, NULL);
    56     }
    57 #endif
    58     data->created = created;
    59     data->videodata = videodata;
    60 
    61     /* Associate the data with the window */
    62 
    63     if (numwindows < windowlistlength) {
    64         windowlist[numwindows] = data;
    65         videodata->numwindows++;
    66     } else {
    67         windowlist =
    68             (SDL_WindowData **) SDL_realloc(windowlist,
    69                                             (numwindows +
    70                                              1) * sizeof(*windowlist));
    71         if (!windowlist) {
    72             SDL_OutOfMemory();
    73             SDL_free(data);
    74             return -1;
    75         }
    76         windowlist[numwindows] = data;
    77         videodata->numwindows++;
    78         videodata->windowlistlength++;
    79         videodata->windowlist = windowlist;
    80     }
    81 
    82     /* Fill in the SDL window with the window data */
    83     {
    84         XWindowAttributes attrib;
    85 
    86         XGetWindowAttributes(data->videodata->display, w, &attrib);
    87         window->x = attrib.x;
    88         window->y = attrib.y;
    89         window->w = attrib.width;
    90         window->h = attrib.height;
    91         if (attrib.map_state != IsUnmapped) {
    92             window->flags |= SDL_WINDOW_SHOWN;
    93         } else {
    94             window->flags &= ~SDL_WINDOW_SHOWN;
    95         }
    96     }
    97     /* FIXME: How can I tell?
    98        {
    99        DWORD style = GetWindowLong(hwnd, GWL_STYLE);
   100        if (style & WS_VISIBLE) {
   101        if (style & (WS_BORDER | WS_THICKFRAME)) {
   102        window->flags &= ~SDL_WINDOW_BORDERLESS;
   103        } else {
   104        window->flags |= SDL_WINDOW_BORDERLESS;
   105        }
   106        if (style & WS_THICKFRAME) {
   107        window->flags |= SDL_WINDOW_RESIZABLE;
   108        } else {
   109        window->flags &= ~SDL_WINDOW_RESIZABLE;
   110        }
   111        if (style & WS_MAXIMIZE) {
   112        window->flags |= SDL_WINDOW_MAXIMIZED;
   113        } else {
   114        window->flags &= ~SDL_WINDOW_MAXIMIZED;
   115        }
   116        if (style & WS_MINIMIZE) {
   117        window->flags |= SDL_WINDOW_MINIMIZED;
   118        } else {
   119        window->flags &= ~SDL_WINDOW_MINIMIZED;
   120        }
   121        }
   122        if (GetFocus() == hwnd) {
   123        int index = data->videodata->keyboard;
   124        window->flags |= SDL_WINDOW_INPUT_FOCUS;
   125        SDL_SetKeyboardFocus(index, data->windowID);
   126 
   127        if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
   128        RECT rect;
   129        GetClientRect(hwnd, &rect);
   130        ClientToScreen(hwnd, (LPPOINT) & rect);
   131        ClientToScreen(hwnd, (LPPOINT) & rect + 1);
   132        ClipCursor(&rect);
   133        }
   134        }
   135      */
   136 
   137     /* All done! */
   138     window->driverdata = data;
   139     return 0;
   140 }
   141 
   142 int
   143 X11_CreateWindow(_THIS, SDL_Window * window)
   144 {
   145     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   146     SDL_DisplayData *displaydata =
   147         (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   148     Visual *visual;
   149     int depth;
   150     XSetWindowAttributes xattr;
   151     int x, y;
   152     Window w;
   153     XSizeHints *sizehints;
   154     XWMHints *wmhints;
   155     XClassHint *classhints;
   156 
   157 #if SDL_VIDEO_DRIVER_X11_XINERAMA
   158 /* FIXME
   159     if ( use_xinerama ) {
   160         x = xinerama_info.x_org;
   161         y = xinerama_info.y_org;
   162     }
   163 */
   164 #endif
   165 #ifdef SDL_VIDEO_OPENGL_GLX
   166     if (window->flags & SDL_WINDOW_OPENGL) {
   167         XVisualInfo *vinfo;
   168 
   169         if (X11_GL_Initialize(_this) < 0) {
   170             return -1;
   171         }
   172         vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen);
   173         if (!vinfo) {
   174             return -1;
   175         }
   176         visual = vinfo->visual;
   177         depth = vinfo->depth;
   178         XFree(vinfo);
   179     } else
   180 #endif
   181     {
   182         visual = displaydata->visual;
   183         depth = displaydata->depth;
   184     }
   185 
   186     if (window->flags & SDL_WINDOW_FULLSCREEN) {
   187         xattr.override_redirect = True;
   188     } else {
   189         xattr.override_redirect = False;
   190     }
   191     xattr.background_pixel = 0;
   192     xattr.border_pixel = 0;
   193 
   194     if (visual->class == DirectColor || visual->class == PseudoColor) {
   195         int nmaps;
   196         XStandardColormap cmap;
   197         XStandardColormap *stdmaps;
   198         XColor *colorcells;
   199         Colormap colormap;
   200         Bool found = False;
   201         int i;
   202         int ncolors;
   203         int rmax, gmax, bmax;
   204         int rmul, gmul, bmul;
   205 
   206         if (colormap =
   207             X11_LookupColormap(data->display, displaydata->screen,
   208                                visual->visualid)) {
   209             xattr.colormap = colormap;
   210         } else {
   211             /* check to see if the colormap we need already exists */
   212             if (0 != XGetRGBColormaps(data->display,
   213                                       RootWindow(data->display,
   214                                                  displaydata->screen),
   215                                       &stdmaps, &nmaps, XA_RGB_BEST_MAP)) {
   216                 for (i = 0; i < nmaps; i++) {
   217                     if (stdmaps[i].visualid == visual->visualid) {
   218                         SDL_memcpy(&cmap, &stdmaps[i],
   219                                    sizeof(XStandardColormap));
   220                         found = True;
   221                         break;
   222                     }
   223                 }
   224                 XFree(stdmaps);
   225             }
   226 
   227             /* it doesn't exist, so create it */
   228             if (!found) {
   229                 int max = visual->map_entries - 1;
   230                 stdmaps =
   231                     XmuStandardColormap(data->display, displaydata->screen,
   232                                         visual->visualid, depth,
   233                                         XA_RGB_BEST_MAP, None, max, max, max);
   234                 if (NULL == stdmaps || stdmaps->visualid != visual->visualid) {
   235                     SDL_SetError
   236                         ("Couldn't create window:XA_RGB_BEST_MAP not found and could not be created");
   237                     return -1;
   238                 }
   239                 SDL_memcpy(&cmap, stdmaps, sizeof(XStandardColormap));
   240                 XFree(stdmaps);
   241             }
   242 
   243             /* OK, we have the best color map, now copy it for use by the
   244                program */
   245 
   246             colorcells = SDL_malloc(visual->map_entries * sizeof(XColor));
   247             if (NULL == colorcells) {
   248                 SDL_SetError("out of memory in X11_CreateWindow");
   249                 return -1;
   250             }
   251             ncolors = visual->map_entries;
   252             rmax = cmap.red_max + 1;
   253             gmax = cmap.blue_max + 1;
   254             bmax = cmap.green_max + 1;
   255 
   256             rmul = cmap.red_mult;
   257             gmul = cmap.blue_mult;
   258             bmul = cmap.green_mult;
   259 
   260             /* build the color table pixel values */
   261             for (i = 0; i < ncolors; i++) {
   262                 Uint32 red = (rmax * i) / ncolors;
   263                 Uint32 green = (gmax * i) / ncolors;
   264                 Uint32 blue = (bmax * i) / ncolors;
   265 
   266                 colorcells[i].pixel =
   267                     (red * rmul) | (green * gmul) | (blue * bmul);
   268             }
   269             XQueryColors(data->display, cmap.colormap, colorcells, ncolors);
   270             colormap = XCreateColormap(data->display,
   271                                        RootWindow(data->display,
   272                                                   displaydata->screen),
   273                                        visual, AllocAll);
   274             XStoreColors(data->display, colormap, colorcells, ncolors);
   275             SDL_free(colorcells);
   276 
   277             xattr.colormap = colormap;
   278             X11_TrackColormap(data->display, displaydata->screen, colormap,
   279                               &cmap, visual);
   280         }
   281     } else {
   282         xattr.colormap =
   283             XCreateColormap(data->display,
   284                             RootWindow(data->display, displaydata->screen),
   285                             visual, AllocNone);
   286     }
   287 
   288     if (window->x == SDL_WINDOWPOS_CENTERED) {
   289         x = (DisplayWidth(data->display, displaydata->screen) -
   290              window->w) / 2;
   291     } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
   292         x = 0;
   293     } else {
   294         x = window->x;
   295     }
   296     if (window->y == SDL_WINDOWPOS_CENTERED) {
   297         y = (DisplayHeight(data->display, displaydata->screen) -
   298              window->h) / 2;
   299     } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
   300         y = 0;
   301     } else {
   302         y = window->y;
   303     }
   304 
   305     w = XCreateWindow(data->display,
   306                       RootWindow(data->display, displaydata->screen), x, y,
   307                       window->w, window->h, 0, depth, InputOutput, visual,
   308                       (CWOverrideRedirect | CWBackPixel | CWBorderPixel |
   309                        CWColormap), &xattr);
   310     if (!w) {
   311 #ifdef SDL_VIDEO_OPENGL_GLX
   312         if (window->flags & SDL_WINDOW_OPENGL) {
   313             X11_GL_Shutdown(_this);
   314         }
   315 #endif
   316         SDL_SetError("Couldn't create window");
   317         return -1;
   318     }
   319 
   320     sizehints = XAllocSizeHints();
   321     if (sizehints) {
   322         if (window->flags & SDL_WINDOW_RESIZABLE) {
   323             sizehints->min_width = 32;
   324             sizehints->min_height = 32;
   325             sizehints->max_height = 4096;
   326             sizehints->max_width = 4096;
   327         } else {
   328             sizehints->min_width = sizehints->max_width = window->w;
   329             sizehints->min_height = sizehints->max_height = window->h;
   330         }
   331         sizehints->flags = PMaxSize | PMinSize;
   332         if (!(window->flags & SDL_WINDOW_FULLSCREEN)
   333             && window->x != SDL_WINDOWPOS_UNDEFINED
   334             && window->y != SDL_WINDOWPOS_UNDEFINED) {
   335             sizehints->x = x;
   336             sizehints->y = y;
   337             sizehints->flags |= USPosition;
   338         }
   339         XSetWMNormalHints(data->display, w, sizehints);
   340         XFree(sizehints);
   341     }
   342 
   343     if (window->flags & SDL_WINDOW_BORDERLESS) {
   344         SDL_bool set;
   345         Atom WM_HINTS;
   346 
   347         /* We haven't modified the window manager hints yet */
   348         set = SDL_FALSE;
   349 
   350         /* First try to set MWM hints */
   351         WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True);
   352         if (WM_HINTS != None) {
   353             /* Hints used by Motif compliant window managers */
   354             struct
   355             {
   356                 unsigned long flags;
   357                 unsigned long functions;
   358                 unsigned long decorations;
   359                 long input_mode;
   360                 unsigned long status;
   361             } MWMHints = {
   362             (1L << 1), 0, 0, 0, 0};
   363 
   364             XChangeProperty(data->display, w, WM_HINTS, WM_HINTS, 32,
   365                             PropModeReplace, (unsigned char *) &MWMHints,
   366                             sizeof(MWMHints) / sizeof(long));
   367             set = SDL_TRUE;
   368         }
   369         /* Now try to set KWM hints */
   370         WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True);
   371         if (WM_HINTS != None) {
   372             long KWMHints = 0;
   373 
   374             XChangeProperty(data->display, w,
   375                             WM_HINTS, WM_HINTS, 32,
   376                             PropModeReplace,
   377                             (unsigned char *) &KWMHints,
   378                             sizeof(KWMHints) / sizeof(long));
   379             set = SDL_TRUE;
   380         }
   381         /* Now try to set GNOME hints */
   382         WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True);
   383         if (WM_HINTS != None) {
   384             long GNOMEHints = 0;
   385 
   386             XChangeProperty(data->display, w,
   387                             WM_HINTS, WM_HINTS, 32,
   388                             PropModeReplace,
   389                             (unsigned char *) &GNOMEHints,
   390                             sizeof(GNOMEHints) / sizeof(long));
   391             set = SDL_TRUE;
   392         }
   393         /* Finally set the transient hints if necessary */
   394         if (!set) {
   395             XSetTransientForHint(data->display, w,
   396                                  RootWindow(data->display,
   397                                             displaydata->screen));
   398         }
   399     } else {
   400         SDL_bool set;
   401         Atom WM_HINTS;
   402 
   403         /* We haven't modified the window manager hints yet */
   404         set = SDL_FALSE;
   405 
   406         /* First try to unset MWM hints */
   407         WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True);
   408         if (WM_HINTS != None) {
   409             XDeleteProperty(data->display, w, WM_HINTS);
   410             set = SDL_TRUE;
   411         }
   412         /* Now try to unset KWM hints */
   413         WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True);
   414         if (WM_HINTS != None) {
   415             XDeleteProperty(data->display, w, WM_HINTS);
   416             set = SDL_TRUE;
   417         }
   418         /* Now try to unset GNOME hints */
   419         WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True);
   420         if (WM_HINTS != None) {
   421             XDeleteProperty(data->display, w, WM_HINTS);
   422             set = SDL_TRUE;
   423         }
   424         /* Finally unset the transient hints if necessary */
   425         if (!set) {
   426             /* NOTE: Does this work? */
   427             XSetTransientForHint(data->display, w, None);
   428         }
   429     }
   430 
   431     /* Tell KDE to keep fullscreen windows on top */
   432     if (window->flags & SDL_WINDOW_FULLSCREEN) {
   433         XEvent ev;
   434         long mask;
   435 
   436         SDL_zero(ev);
   437         ev.xclient.type = ClientMessage;
   438         ev.xclient.window = RootWindow(data->display, displaydata->screen);
   439         ev.xclient.message_type =
   440             XInternAtom(data->display, "KWM_KEEP_ON_TOP", False);
   441         ev.xclient.format = 32;
   442         ev.xclient.data.l[0] = w;
   443         ev.xclient.data.l[1] = CurrentTime;
   444         XSendEvent(data->display,
   445                    RootWindow(data->display, displaydata->screen), False,
   446                    SubstructureRedirectMask, &ev);
   447     }
   448 
   449     /* Set the input hints so we get keyboard input */
   450     wmhints = XAllocWMHints();
   451     if (wmhints) {
   452         wmhints->input = True;
   453         wmhints->flags = InputHint;
   454         XSetWMHints(data->display, w, wmhints);
   455         XFree(wmhints);
   456     }
   457 
   458     /* Set the class hints so we can get an icon (AfterStep) */
   459     classhints = XAllocClassHint();
   460     if (classhints != NULL) {
   461         classhints->res_name = data->classname;
   462         classhints->res_class = data->classname;
   463         XSetClassHint(data->display, w, classhints);
   464         XFree(classhints);
   465     }
   466 
   467     /* Allow the window to be deleted by the window manager */
   468     XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1);
   469 
   470     if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
   471 #ifdef SDL_VIDEO_OPENGL_GLX
   472         if (window->flags & SDL_WINDOW_OPENGL) {
   473             X11_GL_Shutdown(_this);
   474         }
   475 #endif
   476         XDestroyWindow(data->display, w);
   477         return -1;
   478     }
   479 #ifdef X_HAVE_UTF8_STRING
   480     {
   481         Uint32 fevent = 0;
   482         pXGetICValues(((SDL_WindowData *) window->driverdata)->ic,
   483                       XNFilterEvents, &fevent, NULL);
   484         XSelectInput(data->display, w,
   485                      (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
   486                       ExposureMask | ButtonPressMask | ButtonReleaseMask |
   487                       PointerMotionMask | KeyPressMask | KeyReleaseMask |
   488                       PropertyChangeMask | StructureNotifyMask |
   489                       KeymapStateMask | fevent));
   490     }
   491 #else
   492     XSelectInput(data->display, w,
   493                  (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
   494                   ExposureMask | ButtonPressMask | ButtonReleaseMask |
   495                   PointerMotionMask | KeyPressMask | KeyReleaseMask |
   496                   PropertyChangeMask | StructureNotifyMask |
   497                   KeymapStateMask));
   498 #endif
   499 
   500     return 0;
   501 }
   502 
   503 int
   504 X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
   505 {
   506     Window w = (Window) data;
   507 
   508     /* FIXME: Query the title from the existing window */
   509 
   510     if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) {
   511         return -1;
   512     }
   513     return 0;
   514 }
   515 
   516 void
   517 X11_SetWindowTitle(_THIS, SDL_Window * window)
   518 {
   519     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   520     Display *display = data->videodata->display;
   521     XTextProperty titleprop, iconprop;
   522     Status status;
   523     const char *title = window->title;
   524     const char *icon = NULL;
   525 
   526 #ifdef X_HAVE_UTF8_STRING
   527     Atom _NET_WM_NAME = 0;
   528     Atom _NET_WM_ICON_NAME = 0;
   529 
   530     /* Look up some useful Atoms */
   531     if (SDL_X11_HAVE_UTF8) {
   532         _NET_WM_NAME = XInternAtom(display, "_NET_WM_NAME", False);
   533         _NET_WM_ICON_NAME = XInternAtom(display, "_NET_WM_ICON_NAME", False);
   534     }
   535 #endif
   536 
   537     if (title != NULL) {
   538         char *title_locale = SDL_iconv_utf8_locale(title);
   539         if (!title_locale) {
   540             SDL_OutOfMemory();
   541             return;
   542         }
   543         status = XStringListToTextProperty(&title_locale, 1, &titleprop);
   544         SDL_free(title_locale);
   545         if (status) {
   546             XSetTextProperty(display, data->window, &titleprop, XA_WM_NAME);
   547             XFree(titleprop.value);
   548         }
   549 #ifdef X_HAVE_UTF8_STRING
   550         if (SDL_X11_HAVE_UTF8) {
   551             status =
   552                 Xutf8TextListToTextProperty(display, (char **) &title, 1,
   553                                             XUTF8StringStyle, &titleprop);
   554             if (status == Success) {
   555                 XSetTextProperty(display, data->window, &titleprop,
   556                                  _NET_WM_NAME);
   557                 XFree(titleprop.value);
   558             }
   559         }
   560 #endif
   561     }
   562     if (icon != NULL) {
   563         char *icon_locale = SDL_iconv_utf8_locale(icon);
   564         if (!icon_locale) {
   565             SDL_OutOfMemory();
   566             return;
   567         }
   568         status = XStringListToTextProperty(&icon_locale, 1, &iconprop);
   569         SDL_free(icon_locale);
   570         if (status) {
   571             XSetTextProperty(display, data->window, &iconprop,
   572                              XA_WM_ICON_NAME);
   573             XFree(iconprop.value);
   574         }
   575 #ifdef X_HAVE_UTF8_STRING
   576         if (SDL_X11_HAVE_UTF8) {
   577             status =
   578                 Xutf8TextListToTextProperty(display, (char **) &icon, 1,
   579                                             XUTF8StringStyle, &iconprop);
   580             if (status == Success) {
   581                 XSetTextProperty(display, data->window, &iconprop,
   582                                  _NET_WM_ICON_NAME);
   583                 XFree(iconprop.value);
   584             }
   585         }
   586 #endif
   587     }
   588 }
   589 
   590 void
   591 X11_SetWindowPosition(_THIS, SDL_Window * window)
   592 {
   593     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   594     SDL_DisplayData *displaydata =
   595         (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   596     Display *display = data->videodata->display;
   597 
   598     XMoveWindow(display, data->window, window->x, window->y);
   599 }
   600 
   601 void
   602 X11_SetWindowSize(_THIS, SDL_Window * window)
   603 {
   604     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   605     Display *display = data->videodata->display;
   606 
   607     XMoveWindow(display, data->window, window->w, window->h);
   608 }
   609 
   610 void
   611 X11_ShowWindow(_THIS, SDL_Window * window)
   612 {
   613     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   614     Display *display = data->videodata->display;
   615 
   616     XMapRaised(display, data->window);
   617 }
   618 
   619 void
   620 X11_HideWindow(_THIS, SDL_Window * window)
   621 {
   622     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   623     Display *display = data->videodata->display;
   624 
   625     XUnmapWindow(display, data->window);
   626 }
   627 
   628 void
   629 X11_RaiseWindow(_THIS, SDL_Window * window)
   630 {
   631     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   632     Display *display = data->videodata->display;
   633 
   634     XRaiseWindow(display, data->window);
   635 }
   636 
   637 void
   638 X11_MaximizeWindow(_THIS, SDL_Window * window)
   639 {
   640     /* FIXME: is this even possible? */
   641 }
   642 
   643 void
   644 X11_MinimizeWindow(_THIS, SDL_Window * window)
   645 {
   646     X11_HideWindow(_this, window);
   647 }
   648 
   649 void
   650 X11_RestoreWindow(_THIS, SDL_Window * window)
   651 {
   652     X11_ShowWindow(_this, window);
   653 }
   654 
   655 void
   656 X11_SetWindowGrab(_THIS, SDL_Window * window)
   657 {
   658     /* FIXME */
   659 }
   660 
   661 void
   662 X11_DestroyWindow(_THIS, SDL_Window * window)
   663 {
   664     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   665     window->driverdata = NULL;
   666 
   667     if (data) {
   668         SDL_VideoData *videodata = (SDL_VideoData *) data->videodata;
   669         Display *display = videodata->display;
   670         int numwindows = videodata->numwindows;
   671         SDL_WindowData **windowlist = videodata->windowlist;
   672         int i;
   673 
   674         if (windowlist) {
   675             for (i = 0; i < numwindows; ++i) {
   676                 if (windowlist[i] && (windowlist[i]->windowID == window->id)) {
   677                     windowlist[i] = windowlist[numwindows - 1];
   678                     windowlist[numwindows - 1] = NULL;
   679                     videodata->numwindows--;
   680                     break;
   681                 }
   682             }
   683         }
   684 #ifdef SDL_VIDEO_OPENGL_GLX
   685         if (window->flags & SDL_WINDOW_OPENGL) {
   686             X11_GL_Shutdown(_this);
   687         }
   688 #endif
   689 #ifdef X_HAVE_UTF8_STRING
   690         if (data->ic) {
   691             XDestroyIC(data->ic);
   692         }
   693 #endif
   694         if (data->created) {
   695             XDestroyWindow(display, data->window);
   696         }
   697         SDL_free(data);
   698     }
   699 }
   700 
   701 SDL_bool
   702 X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
   703 {
   704     if (info->version.major <= SDL_MAJOR_VERSION) {
   705         /* FIXME! */
   706         return SDL_TRUE;
   707     } else {
   708         SDL_SetError("Application not compiled with SDL %d.%d\n",
   709                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   710         return SDL_FALSE;
   711     }
   712 }
   713 
   714 /* vi: set ts=4 sw=4 expandtab: */