src/video/x11/SDL_x11window.c
changeset 6167 c071e1372341
parent 6138 4c64952a58fb
child 6188 e82023802002
     1.1 --- a/src/video/x11/SDL_x11window.c	Sat Jan 07 01:28:06 2012 -0500
     1.2 +++ b/src/video/x11/SDL_x11window.c	Mon Jun 27 19:30:52 2011 +0200
     1.3 @@ -258,11 +258,12 @@
     1.4      int depth;
     1.5      XSetWindowAttributes xattr;
     1.6      Window w;
     1.7 -    XSizeHints *sizehints;
     1.8 -    XWMHints *wmhints;
     1.9 -    XClassHint *classhints;
    1.10 +    XSizeHints sizehints;
    1.11 +    XWMHints wmhints;
    1.12 +    XClassHint classhints;
    1.13      Atom _NET_WM_WINDOW_TYPE;
    1.14      Atom _NET_WM_WINDOW_TYPE_NORMAL;
    1.15 +    Atom _NET_WM_PID;
    1.16      int wmstate_count;
    1.17      Atom wmstate_atoms[3];
    1.18      Uint32 fevent = 0;
    1.19 @@ -414,20 +415,6 @@
    1.20      }
    1.21  #endif
    1.22  
    1.23 -    sizehints = XAllocSizeHints();
    1.24 -    if (sizehints) {
    1.25 -        if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
    1.26 -            sizehints->min_width = sizehints->max_width = window->w;
    1.27 -            sizehints->min_height = sizehints->max_height = window->h;
    1.28 -            sizehints->flags = PMaxSize | PMinSize;
    1.29 -        }
    1.30 -        sizehints->x = window->x;
    1.31 -        sizehints->y = window->y;
    1.32 -        sizehints->flags |= USPosition;
    1.33 -        XSetWMNormalHints(display, w, sizehints);
    1.34 -        XFree(sizehints);
    1.35 -    }
    1.36 -
    1.37      if (window->flags & SDL_WINDOW_BORDERLESS) {
    1.38          SDL_bool set;
    1.39          Atom WM_HINTS;
    1.40 @@ -511,22 +498,32 @@
    1.41          }
    1.42      }
    1.43  
    1.44 -    /* Set the input hints so we get keyboard input */
    1.45 -    wmhints = XAllocWMHints();
    1.46 -    if (wmhints) {
    1.47 -        wmhints->input = True;
    1.48 -        wmhints->flags = InputHint;
    1.49 -        XSetWMHints(display, w, wmhints);
    1.50 -        XFree(wmhints);
    1.51 +    /* Setup the normal size hints */
    1.52 +    if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
    1.53 +        sizehints.min_width = sizehints.max_width = window->w;
    1.54 +        sizehints.min_height = sizehints.max_height = window->h;
    1.55 +        sizehints.flags = PMaxSize | PMinSize;
    1.56      }
    1.57 +    sizehints.x = window->x;
    1.58 +    sizehints.y = window->y;
    1.59 +    sizehints.flags |= USPosition;
    1.60  
    1.61 -    /* Set the class hints so we can get an icon (AfterStep) */
    1.62 -    classhints = XAllocClassHint();
    1.63 -    if (classhints != NULL) {
    1.64 -        classhints->res_name = data->classname;
    1.65 -        classhints->res_class = data->classname;
    1.66 -        XSetClassHint(display, w, classhints);
    1.67 -        XFree(classhints);
    1.68 +    /* Setup the input hints so we get keyboard input */
    1.69 +    wmhints.input = True;
    1.70 +    wmhints.flags = InputHint;
    1.71 +
    1.72 +    /* Setup the class hints so we can get an icon (AfterStep) */
    1.73 +    classhints.res_name = data->classname;
    1.74 +    classhints.res_class = data->classname;
    1.75 +
    1.76 +    /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */
    1.77 +    XSetWMProperties(display, w, NULL, NULL, NULL, 0, &sizehints, &wmhints, &classhints);
    1.78 +
    1.79 +    /* Set the PID related to the window for the given hostname, if possible */
    1.80 +    if (data->pid > 0) {
    1.81 +        _NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False);
    1.82 +        XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
    1.83 +                        (unsigned char *)&data->pid, 1);
    1.84      }
    1.85  
    1.86      /* Set the window manager state */