changeset 35648:238c621810b6

Simplify wsSizeHint() by dropping parameter 'hints'. Set values analogously to vo_x11_sizehint(), using the same hints for all windows, and remove PResizeInc.
author ib
date Tue, 15 Jan 2013 09:21:23 +0000
parents a30496350cb9
children 90c0ec2f2f8a
files gui/wm/ws.c
diffstat 1 files changed, 23 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/gui/wm/ws.c	Mon Jan 14 17:27:45 2013 +0000
+++ b/gui/wm/ws.c	Tue Jan 15 09:21:23 2013 +0000
@@ -440,54 +440,52 @@
  * @brief Replace the size hints for the WM_NORMAL_HINTS property of a window.
  *
  * @param win pointer to a ws window structure
- * @param hints size hints bits
  */
-static void wsSizeHint(wsTWindow *win, long hints)
+static void wsSizeHint(wsTWindow *win)
 {
-    win->SizeHint.flags = hints;
+    win->SizeHint.flags = 0;
 
-    if (hints & PPosition) {
+    /* obsolete, solely for compatibility reasons */
+    win->SizeHint.flags |= PPosition;
         win->SizeHint.x = win->X;
         win->SizeHint.y = win->Y;
-    }
 
-    if (hints & PSize) {
+    /* obsolete, solely for compatibility reasons */
+    win->SizeHint.flags |= PSize;
         win->SizeHint.width  = win->Width;
         win->SizeHint.height = win->Height;
-    }
 
-    if (hints & PMinSize || win->Property & wsMinSize) {
+    /* a minimum of 4 is said to avoid off-by-one errors and be required by mga_vid */
         win->SizeHint.flags     |= PMinSize;
+    win->SizeHint.min_width  = 4;
+    win->SizeHint.min_height = 4;
+
+    if (win->Property & wsMinSize) {
         win->SizeHint.min_width  = win->Width;
         win->SizeHint.min_height = win->Height;
     }
 
-    if (hints & PMaxSize || win->Property & wsMaxSize) {
+    if (win->Property & wsMaxSize) {
         win->SizeHint.flags     |= PMaxSize;
         win->SizeHint.max_width  = win->Width;
         win->SizeHint.max_height = win->Height;
     }
 
-    if (hints & PResizeInc) {
-        win->SizeHint.width_inc  = 1;
-        win->SizeHint.height_inc = 1;
-    }
-
-    if (hints & PAspect) {
+    if (vo_keepaspect /*&& (win->Property & wsAspect)*/) {
+        win->SizeHint.flags |= PAspect;
         win->SizeHint.min_aspect.x = win->Width;
         win->SizeHint.min_aspect.y = win->Height;
         win->SizeHint.max_aspect.x = win->Width;
         win->SizeHint.max_aspect.y = win->Height;
     }
 
-//  if (hints & PBaseSize)
-    {
-        win->SizeHint.base_width  = win->Width;
-        win->SizeHint.base_height = win->Height;
-    }
+    /* fluxbox e.g. is said to be unable to handle the (more natural) values width/height */
+    win->SizeHint.flags      |= PBaseSize;
+    win->SizeHint.base_width  = 0;
+    win->SizeHint.base_height = 0;
 
-    if (hints & PWinGravity)
-        win->SizeHint.win_gravity = StaticGravity;
+    win->SizeHint.flags      |= PWinGravity;
+    win->SizeHint.win_gravity = StaticGravity;
 
     XSetWMNormalHints(wsDisplay, win->WindowID, &win->SizeHint);
 }
@@ -597,7 +595,7 @@
     wsClassHint.res_class = "MPlayer";
     XSetClassHint(wsDisplay, win->WindowID, &wsClassHint);
 
-    wsSizeHint(win, PPosition | PSize | PResizeInc /* | PBaseSize */ | PWinGravity);
+    wsSizeHint(win);
 
     win->WMHints.flags = InputHint | StateHint;
     win->WMHints.input = True;
@@ -1076,7 +1074,7 @@
     /* restore window if window manager doesn't support EWMH */
     if (!(vo_fs_type & vo_wm_FULLSCREEN)) {
         wsWindowDecoration(win, win->Decorations && !win->isFullScreen);
-        wsSizeHint(win, PPosition | PSize /* | PBaseSize */ | PWinGravity | (vo_keepaspect ? PAspect : 0));
+        wsSizeHint(win);
         wsSetLayer(wsDisplay, win->WindowID, win->isFullScreen);
         XMoveResizeWindow(wsDisplay, win->WindowID, win->X, win->Y, win->Width, win->Height);
     }
@@ -1241,7 +1239,7 @@
     if (vo_wm_type == 0)
         XUnmapWindow(wsDisplay, win->WindowID);
 
-    wsSizeHint(win, PPosition | PSize /* | PBaseSize */ | PWinGravity);
+    wsSizeHint(win);
     XResizeWindow(wsDisplay, win->WindowID, sx, sy);
 
     if (win->ReSize)