Hi Samir/All

I found a quirk when trying to maximize vetically then horizontally
then unmaximize vertically and cycling so on.
This doesn't work all time not all combinations at least.
I obtain sometimes a different window size when going back to the
original size, pretty complicated to explain.

OK, I believe I have fixed the inconsistencies here. Some testing and feedback by someone else would be useful.

Yes, there is still some ironing out to do. I also discovered that my patch
breaks the "Run" dialog, it comes up but does not accept any keyboard input.

I managed to fix this, but I fixed the problem in a file unrelated to my patch. The offending lines were 1702 & 1703 in window.c (wManageInternalWindow):

    if (wwin->flags.is_gnustep == 0)
        wFrameWindowChangeState(wwin->frame, WS_UNFOCUSED);

This causes internal windows (like the run dialog) to immediately lose focus, and thus lose keyboard input. I commented these and have seen no ill effects, but they have obviously been put there for a reason. According to "hg annotate" those lines were last touched by Dan Pascu in 2004 to convert tabs to spaces so the real purpose is hidden.

Anyway, let me know if this breaks anything for anyone. I am getting to know the code a bit better by now so future fixes should be a bit quicker :)

Regards,

Johann
P.S. patch is against current tip, and not on top of my previous patch
diff -r 5a2507602c48 -r 647a234dc2c9 WPrefs.app/KeyboardShortcuts.c
--- a/WPrefs.app/KeyboardShortcuts.c    Sun Dec 14 19:59:05 2008 -0800
+++ b/WPrefs.app/KeyboardShortcuts.c    Tue Feb 03 00:41:17 2009 +0200
@@ -79,6 +79,8 @@
     "MaximizeKey",
     "VMaximizeKey",
     "HMaximizeKey",
+    "LHMaximizeKey",
+    "RHMaximizeKey",
     "RaiseKey",
     "LowerKey",
     "RaiseLowerKey",
@@ -507,6 +509,8 @@
     WMAddListItem(panel->actLs, _("Maximize active window"));
     WMAddListItem(panel->actLs, _("Maximize active window vertically"));
     WMAddListItem(panel->actLs, _("Maximize active window horizontally"));
+    WMAddListItem(panel->actLs, _("Maximize active window left half"));
+    WMAddListItem(panel->actLs, _("Maximize active window right half"));
     WMAddListItem(panel->actLs, _("Raise active window"));
     WMAddListItem(panel->actLs, _("Lower active window"));
     WMAddListItem(panel->actLs, _("Raise/Lower window under mouse pointer"));
diff -r 5a2507602c48 -r 647a234dc2c9 src/actions.c
--- a/src/actions.c     Sun Dec 14 19:59:05 2008 -0800
+++ b/src/actions.c     Tue Feb 03 00:41:17 2009 +0200
@@ -367,7 +367,6 @@
 {
     int new_x, new_y;
     unsigned int new_width, new_height;
-    int changed_h, changed_v, shrink_h, shrink_v;
     WArea usableArea, totalArea;
 
     if (!IS_RESIZABLE(wwin))
@@ -400,12 +399,7 @@
         wUnshadeWindow(wwin);
     }
     /* Only save directions, not kbd or xinerama hints */
-    directions &= (MAX_HORIZONTAL|MAX_VERTICAL);
-
-    changed_h = ((wwin->flags.maximized ^ directions) & MAX_HORIZONTAL);
-    changed_v = ((wwin->flags.maximized ^ directions) & MAX_VERTICAL);
-    shrink_h = (changed_h && (directions & MAX_HORIZONTAL)==0);
-    shrink_v = (changed_v && (directions & MAX_VERTICAL)==0);
+    directions &= (MAX_HORIZONTAL|MAX_VERTICAL|MAX_LEFTHALF|MAX_RIGHTHALF);
 
     if (wwin->flags.maximized) {
         /* if already maximized in some direction, we only update the
@@ -413,7 +407,7 @@
          * allow succesive maximizations in different directions without
          * the need to first do an un-maximize (to avoid flicker).
          */
-        if (!(wwin->flags.maximized & MAX_HORIZONTAL)) {
+        if (!(wwin->flags.maximized & 
(MAX_HORIZONTAL|MAX_LEFTHALF|MAX_RIGHTHALF))) {
             wwin->old_geometry.x = wwin->frame_x;
         }
         if (!(wwin->flags.maximized & MAX_VERTICAL)) {
@@ -432,12 +426,19 @@
         if (HAS_BORDER(wwin))
                 new_width -= FRAME_BORDER_WIDTH * 2;
         new_x = usableArea.x1;
-    } else if (shrink_h) {
+    } else if (directions & MAX_LEFTHALF) {
+        new_width = (usableArea.x2 - usableArea.x1)/2;
+        if (HAS_BORDER(wwin))
+                new_width -= FRAME_BORDER_WIDTH * 2;
+        new_x = usableArea.x1;
+    } else if (directions & MAX_RIGHTHALF) {
+        new_width = (usableArea.x2 - usableArea.x1)/2;
+        if (HAS_BORDER(wwin))
+                new_width -= FRAME_BORDER_WIDTH * 2;
+        new_x = usableArea.x1+((usableArea.x2 - usableArea.x1)/2);
+    } else {
         new_x = wwin->old_geometry.x;
         new_width = wwin->old_geometry.width;
-    } else {
-        new_x = wwin->frame_x;
-        new_width = wwin->frame->core->width;
     }
 
     if (directions & MAX_VERTICAL) {
@@ -449,12 +450,9 @@
             new_y -= wwin->frame->top_width;
             new_height += wwin->frame->bottom_width - 1;
         }
-    } else if (shrink_v) {
+    } else {
         new_y = wwin->old_geometry.y;
         new_height = wwin->old_geometry.height;
-    } else {
-        new_y = wwin->frame_y;
-        new_height = wwin->frame->core->height;
     }
 
     if (!WFLAGP(wwin, full_maximize)) {
@@ -488,7 +486,7 @@
         wwin->flags.skip_next_animation = 1;
         wUnshadeWindow(wwin);
     }
-    x = ((wwin->flags.maximized & MAX_HORIZONTAL) && wwin->old_geometry.x) ?
+    x = ((wwin->flags.maximized & (MAX_HORIZONTAL|MAX_LEFTHALF|MAX_RIGHTHALF)) 
&& wwin->old_geometry.x) ?
         wwin->old_geometry.x : wwin->frame_x;
     y = ((wwin->flags.maximized & MAX_VERTICAL) && wwin->old_geometry.y) ?
         wwin->old_geometry.y : wwin->frame_y;
diff -r 5a2507602c48 -r 647a234dc2c9 src/actions.h
--- a/src/actions.h     Sun Dec 14 19:59:05 2008 -0800
+++ b/src/actions.h     Tue Feb 03 00:41:17 2009 +0200
@@ -26,8 +26,10 @@
 
 #define MAX_HORIZONTAL         1
 #define MAX_VERTICAL   2
-#define MAX_IGNORE_XINERAMA 4
-#define MAX_KEYBOARD 8
+#define MAX_LEFTHALF   4
+#define MAX_RIGHTHALF  8
+#define MAX_IGNORE_XINERAMA 16
+#define MAX_KEYBOARD 32
 
 void wSetFocusTo(WScreen *scr, WWindow *wwin);
 
diff -r 5a2507602c48 -r 647a234dc2c9 src/defaults.c
--- a/src/defaults.c    Sun Dec 14 19:59:05 2008 -0800
+++ b/src/defaults.c    Tue Feb 03 00:41:17 2009 +0200
@@ -711,6 +711,12 @@
     {"HMaximizeKey", "None",                   (void*)WKBD_HMAXIMIZE,
     NULL,                              getKeybind,     setKeyGrab
     },
+    {"LHMaximizeKey", "None",                  (void*)WKBD_LHMAXIMIZE,
+    NULL,                              getKeybind,     setKeyGrab
+    },
+    {"RHMaximizeKey", "None",                  (void*)WKBD_RHMAXIMIZE,
+    NULL,                              getKeybind,     setKeyGrab
+    },
     {"RaiseKey", "\"Meta+Up\"",                        (void*)WKBD_RAISE,
     NULL,                              getKeybind,     setKeyGrab
     },
diff -r 5a2507602c48 -r 647a234dc2c9 src/event.c
--- a/src/event.c       Sun Dec 14 19:59:05 2008 -0800
+++ b/src/event.c       Tue Feb 03 00:41:17 2009 +0200
@@ -1483,6 +1483,32 @@
             }
         }
         break;
+    case WKBD_LHMAXIMIZE:
+        if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) {
+            int newdir = (MAX_VERTICAL|MAX_LEFTHALF);
+
+            CloseWindowMenu(scr);
+
+            if (wwin->flags.maximized == newdir) {
+                wUnmaximizeWindow(wwin);
+            } else {
+                wMaximizeWindow(wwin, newdir|MAX_KEYBOARD);
+            }
+        }
+        break;
+    case WKBD_RHMAXIMIZE:
+        if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) {
+            int newdir = (MAX_VERTICAL|MAX_RIGHTHALF);
+
+            CloseWindowMenu(scr);
+
+            if (wwin->flags.maximized == newdir) {
+                wUnmaximizeWindow(wwin);
+            } else {
+                wMaximizeWindow(wwin, newdir|MAX_KEYBOARD);
+            }
+        }
+        break;
     case WKBD_RAISE:
         if (ISMAPPED(wwin) && ISFOCUSED(wwin)) {
             CloseWindowMenu(scr);
diff -r 5a2507602c48 -r 647a234dc2c9 src/keybind.h
--- a/src/keybind.h     Sun Dec 14 19:59:05 2008 -0800
+++ b/src/keybind.h     Tue Feb 03 00:41:17 2009 +0200
@@ -32,57 +32,59 @@
 #define WKBD_MAXIMIZE           6
 #define WKBD_VMAXIMIZE          7
 #define WKBD_HMAXIMIZE          8
-#define WKBD_SELECT             9
+#define WKBD_LHMAXIMIZE                9
+#define WKBD_RHMAXIMIZE                10
+#define WKBD_SELECT             11
 /* Clip */
-#define WKBD_CLIPLOWER          10
-#define WKBD_CLIPRAISE         11
-#define WKBD_CLIPRAISELOWER    12
+#define WKBD_CLIPLOWER          12
+#define WKBD_CLIPRAISE         13
+#define WKBD_CLIPRAISELOWER    14
 /* window */
-#define WKBD_RAISE             13
-#define WKBD_LOWER             14
-#define WKBD_RAISELOWER                15
-#define WKBD_MOVERESIZE                16
-#define WKBD_SHADE             17
+#define WKBD_RAISE             15
+#define WKBD_LOWER             16
+#define WKBD_RAISELOWER                17
+#define WKBD_MOVERESIZE                18
+#define WKBD_SHADE             19
 /* window, menu */
-#define WKBD_CLOSE             18
+#define WKBD_CLOSE             20
 /* window */
-#define WKBD_FOCUSNEXT         19
-#define WKBD_FOCUSPREV          20
+#define WKBD_FOCUSNEXT         21
+#define WKBD_FOCUSPREV          22
 
-#define WKBD_WORKSPACE1                21
-#define WKBD_WORKSPACE2                22
-#define WKBD_WORKSPACE3                23
-#define WKBD_WORKSPACE4                24
-#define WKBD_WORKSPACE5                25
-#define WKBD_WORKSPACE6                26
-#define WKBD_WORKSPACE7                27
-#define WKBD_WORKSPACE8                28
-#define WKBD_WORKSPACE9                29
-#define WKBD_WORKSPACE10       30
-#define WKBD_NEXTWORKSPACE     31
-#define WKBD_PREVWORKSPACE     32
-#define WKBD_NEXTWSLAYER       33
-#define WKBD_PREVWSLAYER       34
+#define WKBD_WORKSPACE1                23
+#define WKBD_WORKSPACE2                24
+#define WKBD_WORKSPACE3                25
+#define WKBD_WORKSPACE4                26
+#define WKBD_WORKSPACE5                27
+#define WKBD_WORKSPACE6                28
+#define WKBD_WORKSPACE7                29
+#define WKBD_WORKSPACE8                30
+#define WKBD_WORKSPACE9                31
+#define WKBD_WORKSPACE10       32
+#define WKBD_NEXTWORKSPACE     33
+#define WKBD_PREVWORKSPACE     34
+#define WKBD_NEXTWSLAYER       35
+#define WKBD_PREVWSLAYER       36
 
 /* window shortcuts */
-#define WKBD_WINDOW1           35
-#define WKBD_WINDOW2           36
-#define WKBD_WINDOW3           37
-#define WKBD_WINDOW4           38
-#define WKBD_WINDOW5           39
-#define WKBD_WINDOW6           40
-#define WKBD_WINDOW7           41
-#define WKBD_WINDOW8           42
-#define WKBD_WINDOW9           43
-#define WKBD_WINDOW10          44
+#define WKBD_WINDOW1           37
+#define WKBD_WINDOW2           38
+#define WKBD_WINDOW3           39
+#define WKBD_WINDOW4           40
+#define WKBD_WINDOW5           41
+#define WKBD_WINDOW6           42
+#define WKBD_WINDOW7           43
+#define WKBD_WINDOW8           44
+#define WKBD_WINDOW9           45
+#define WKBD_WINDOW10          46
 
-#define WKBD_SWITCH_SCREEN      45
+#define WKBD_SWITCH_SCREEN      47
 
 #ifdef KEEP_XKB_LOCK_STATUS
-# define WKBD_TOGGLE           46
-# define WKBD_TMP              47
+# define WKBD_TOGGLE           48
+# define WKBD_TMP              49
 #else
-# define WKBD_TMP              46
+# define WKBD_TMP              48
 #endif
 
 #ifdef VIRTUAL_DESKTOP
diff -r 5a2507602c48 -r 647a234dc2c9 src/window.c
--- a/src/window.c      Sun Dec 14 19:59:05 2008 -0800
+++ b/src/window.c      Tue Feb 03 00:41:17 2009 +0200
@@ -1552,6 +1552,7 @@
     /*
      *--------------------------------------------------
      *
+     *  
      *  Cleanup temporary stuff
      *
      *--------------------------------------------------
@@ -1699,8 +1700,8 @@
         wwin->prev = NULL;
     }
 
-    if (wwin->flags.is_gnustep == 0)
-        wFrameWindowChangeState(wwin->frame, WS_UNFOCUSED);
+//    if (wwin->flags.is_gnustep == 0)
+  //      wFrameWindowChangeState(wwin->frame, WS_UNFOCUSED);
 
     /*    if (wPreferences.auto_focus)*/
     wSetFocusTo(scr, wwin);
diff -r 5a2507602c48 -r 647a234dc2c9 src/window.h
--- a/src/window.h      Sun Dec 14 19:59:05 2008 -0800
+++ b/src/window.h      Tue Feb 03 00:41:17 2009 +0200
@@ -256,7 +256,7 @@
         unsigned int miniaturized:1;
         unsigned int hidden:1;
         unsigned int shaded:1;
-        unsigned int maximized:2;
+        unsigned int maximized:4;
         unsigned int fullscreen:1;
         unsigned int omnipresent:1;
 

Reply via email to