Hi
I wrote a patch that allows you to maximize a window to the left or
right half of your display. This is useful on widescreen displays where
you want to bring up two windows side-by-side. The shortcut keys are
configurable in WPrefs.
This is my first windowmaker patch and my first using Mercurial, so let
me know if the patch came out wrong.
Regards,
Johann
# HG changeset patch
# User [email protected]
# Date 1233004546 -7200
# Node ID 257ea74be08466e47ba74cb3cb5a11fe37aa09e7
# Parent 5a2507602c48324fba0f07754a442a8cc6ab967c
Added an action that allows you to maximize a window so that it covers the
left or right half of the display. This is useful on widescreen displays
where you want to have two windows opened side by side.
diff -r 5a2507602c48 -r 257ea74be084 WPrefs.app/KeyboardShortcuts.c
--- a/WPrefs.app/KeyboardShortcuts.c Sun Dec 14 19:59:05 2008 -0800
+++ b/WPrefs.app/KeyboardShortcuts.c Mon Jan 26 23:15:46 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 257ea74be084 src/actions.c
--- a/src/actions.c Sun Dec 14 19:59:05 2008 -0800
+++ b/src/actions.c Mon Jan 26 23:15:46 2009 +0200
@@ -400,11 +400,11 @@
wUnshadeWindow(wwin);
}
/* Only save directions, not kbd or xinerama hints */
- directions &= (MAX_HORIZONTAL|MAX_VERTICAL);
+ directions &= (MAX_HORIZONTAL|MAX_VERTICAL|MAX_LEFTHALF|MAX_RIGHTHALF);
- changed_h = ((wwin->flags.maximized ^ directions) & MAX_HORIZONTAL);
+ changed_h = ((wwin->flags.maximized ^ directions) &
(MAX_HORIZONTAL|MAX_LEFTHALF|MAX_RIGHTHALF));
changed_v = ((wwin->flags.maximized ^ directions) & MAX_VERTICAL);
- shrink_h = (changed_h && (directions & MAX_HORIZONTAL)==0);
+ shrink_h = (changed_h && (directions &
(MAX_HORIZONTAL|MAX_LEFTHALF|MAX_RIGHTHALF))==0);
shrink_v = (changed_v && (directions & MAX_VERTICAL)==0);
if (wwin->flags.maximized) {
@@ -457,6 +457,23 @@
new_height = wwin->frame->core->height;
}
+ 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 (shrink_h) {
+ new_x = wwin->old_geometry.x;
+ new_width = wwin->old_geometry.width;
+ }
+
+ 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);
+ }
+
if (!WFLAGP(wwin, full_maximize)) {
new_height -= wwin->frame->top_width+wwin->frame->bottom_width;
}
@@ -488,7 +505,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 257ea74be084 src/actions.h
--- a/src/actions.h Sun Dec 14 19:59:05 2008 -0800
+++ b/src/actions.h Mon Jan 26 23:15:46 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 257ea74be084 src/defaults.c
--- a/src/defaults.c Sun Dec 14 19:59:05 2008 -0800
+++ b/src/defaults.c Mon Jan 26 23:15:46 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 257ea74be084 src/event.c
--- a/src/event.c Sun Dec 14 19:59:05 2008 -0800
+++ b/src/event.c Mon Jan 26 23:15:46 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 257ea74be084 src/keybind.h
--- a/src/keybind.h Sun Dec 14 19:59:05 2008 -0800
+++ b/src/keybind.h Mon Jan 26 23:15:46 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 257ea74be084 src/window.h
--- a/src/window.h Sun Dec 14 19:59:05 2008 -0800
+++ b/src/window.h Mon Jan 26 23:15:46 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;