allocate *Hint structures per Xlib docs
authorEdward Rudd <urkle@outoforder.cc>
Wed, 26 Sep 2012 14:08:46 -0400
changeset 6462 5e09ac1aba80
parent 6461 6d17371235d3
child 6463 051403ca44cc
allocate *Hint structures per Xlib docs
src/video/x11/SDL_x11sym.h
src/video/x11/SDL_x11window.c
--- a/src/video/x11/SDL_x11sym.h	Tue Sep 25 20:58:23 2012 -0700
+++ b/src/video/x11/SDL_x11sym.h	Wed Sep 26 14:08:46 2012 -0400
@@ -23,6 +23,8 @@
 
 SDL_X11_MODULE(BASEXLIB)
 SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void),(),return)
+SDL_X11_SYM(XWMHints*,XAllocWMHints,(void),(),return)
+SDL_X11_SYM(XClassHint*,XAllocClassHint,(void),(),return)
 SDL_X11_SYM(int,XAutoRepeatOn,(Display* a),(a),return)
 SDL_X11_SYM(int,XAutoRepeatOff,(Display* a),(a),return)
 SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return)
--- a/src/video/x11/SDL_x11window.c	Tue Sep 25 20:58:23 2012 -0700
+++ b/src/video/x11/SDL_x11window.c	Wed Sep 26 14:08:46 2012 -0400
@@ -290,9 +290,9 @@
     int depth;
     XSetWindowAttributes xattr;
     Window w;
-    XSizeHints sizehints;
-    XWMHints wmhints;
-    XClassHint classhints;
+    XSizeHints *sizehints;
+    XWMHints *wmhints;
+    XClassHint *classhints;
     Atom _NET_WM_WINDOW_TYPE;
     Atom _NET_WM_WINDOW_TYPE_NORMAL;
     Atom _NET_WM_PID;
@@ -446,28 +446,34 @@
     SetWindowBordered(display, screen, w,
                       (window->flags & SDL_WINDOW_BORDERLESS) == 0);
 
+    sizehints = XAllocSizeHints();
     /* Setup the normal size hints */
-    sizehints.flags = 0;
+    sizehints->flags = 0;
     if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
-        sizehints.min_width = sizehints.max_width = window->w;
-        sizehints.min_height = sizehints.max_height = window->h;
-        sizehints.flags |= (PMaxSize | PMinSize);
+        sizehints->min_width = sizehints->max_width = window->w;
+        sizehints->min_height = sizehints->max_height = window->h;
+        sizehints->flags |= (PMaxSize | PMinSize);
     }
-    sizehints.x = window->x;
-    sizehints.y = window->y;
-    sizehints.flags |= USPosition;
+    sizehints->x = window->x;
+    sizehints->y = window->y;
+    sizehints->flags |= USPosition;
 
     /* Setup the input hints so we get keyboard input */
-    wmhints.input = True;
-    wmhints.flags = InputHint;
+    wmhints = XAllocWMHints();
+    wmhints->input = True;
+    wmhints->flags = InputHint;
 
     /* Setup the class hints so we can get an icon (AfterStep) */
-    classhints.res_name = data->classname;
-    classhints.res_class = data->classname;
+    classhints = XAllocClassHint();
+    classhints->res_name = data->classname;
+    classhints->res_class = data->classname;
 
     /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */
-    XSetWMProperties(display, w, NULL, NULL, NULL, 0, &sizehints, &wmhints, &classhints);
+    XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints);
 
+    XFree(sizehints);
+    XFree(wmhints);
+    XFree(classhints);
     /* Set the PID related to the window for the given hostname, if possible */
     if (data->pid > 0) {
         _NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False);