added new maximize positions, top and bottom
authorRenan Traba <hellupline@gmail.com>
Sat, 27 Apr 2013 23:33:16 +0000 (27 20:33 -0300)
committerCarlos R. Mafra <crmafra@gmail.com>
Tue, 21 May 2013 10:24:35 +0000 (21 11:24 +0100)
these new positions are equal to left and right,
but they are at top and bottom half of screen

src/actions.c
src/actions.h
src/client.c
src/defaults.c
src/event.c
src/keybind.h
src/moveres.c
src/window.h

index a7cc3ca..8a4a0c1 100644 (file)
@@ -343,7 +343,7 @@ void update_saved_geometry(WWindow *wwin)
 
 void wMaximizeWindow(WWindow *wwin, int directions)
 {
-       unsigned int new_width, new_height, half_scr_width;
+       unsigned int new_width, new_height, half_scr_width, half_scr_height;
        int new_x = 0;
        int new_y = 0;
        int maximus_x = 0;
@@ -386,12 +386,13 @@ void wMaximizeWindow(WWindow *wwin, int directions)
        }
 
        /* Only save directions, not kbd or xinerama hints */
-       directions &= (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_MAXIMUS);
+       directions &= (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
 
        if (WFLAGP(wwin, full_maximize)) {
                usableArea = totalArea;
        }
        half_scr_width = (usableArea.x2 - usableArea.x1)/2;
+       half_scr_height = (usableArea.y2 - usableArea.y1)/2;
 
        if (wwin->flags.shaded) {
                wwin->flags.skip_next_animation = 1;
@@ -420,7 +421,7 @@ void wMaximizeWindow(WWindow *wwin, int directions)
                        new_width = (wwin->old_geometry.width) ? wwin->old_geometry.width : wwin->frame->core->width;
                        new_x = (wwin->old_geometry.x) ? wwin->old_geometry.x : wwin->frame_x;
                }
-               if (!(directions & (MAX_VERTICAL | MAX_MAXIMUS))) {
+               if (!(directions & (MAX_VERTICAL | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS))) {
                        new_height = (wwin->old_geometry.height) ? wwin->old_geometry.height : wwin->frame->core->height;
                        new_y = (wwin->old_geometry.y) ? wwin->old_geometry.y : wwin->frame_y;
                }
@@ -433,6 +434,14 @@ void wMaximizeWindow(WWindow *wwin, int directions)
                        new_width = half_scr_width - adj_size;
                        new_x = usableArea.x1 + half_scr_width;
                }
+               /* top|bottom position */
+               if (directions & MAX_TOPHALF) {
+                       new_height = half_scr_height - adj_size;
+                       new_y = usableArea.y1;
+               } else if (directions & MAX_BOTTOMHALF) {
+                       new_height = half_scr_height - adj_size;
+                       new_y = usableArea.y1 + half_scr_height;
+               }
 
                /* vertical|horizontal position */
                if (directions & MAX_HORIZONTAL) {
@@ -470,7 +479,7 @@ void wMaximizeWindow(WWindow *wwin, int directions)
 void handleMaximize(WWindow *wwin, int directions)
 {
        int current = wwin->flags.maximized;
-       int requested = directions & (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_MAXIMUS);
+       int requested = directions & (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
        int effective = requested ^ current;
        int flags = directions & ~requested;
 
@@ -481,9 +490,11 @@ void handleMaximize(WWindow *wwin, int directions)
                        wMaximizeWindow(wwin, flags);
                else
                        wUnmaximizeWindow(wwin);
-       /* these alone mean vertical toggle */
+       /* these alone mean vertical|horizontal toggle */
        } else if ((effective == MAX_LEFTHALF) ||
-                       (effective == MAX_RIGHTHALF))
+                       (effective == MAX_RIGHTHALF) ||
+                       (effective == MAX_TOPHALF) ||
+                       (effective == MAX_BOTTOMHALF))
                wUnmaximizeWindow(wwin);
        else {
                if ((requested == (MAX_HORIZONTAL | MAX_VERTICAL)) ||
@@ -497,6 +508,17 @@ void handleMaximize(WWindow *wwin, int directions)
                                effective |= MAX_VERTICAL;
                                effective &= ~(MAX_HORIZONTAL | MAX_LEFTHALF);
                        }
+                       if (requested & MAX_TOPHALF) {
+                               effective |= MAX_HORIZONTAL;
+                               effective &= ~(MAX_VERTICAL | MAX_BOTTOMHALF);
+                       } else if (requested & MAX_BOTTOMHALF) {
+                               effective |= MAX_HORIZONTAL;
+                               effective &= ~(MAX_VERTICAL | MAX_TOPHALF);
+                       }
+                       if (requested & MAX_HORIZONTAL)
+                               effective &= ~(MAX_LEFTHALF | MAX_RIGHTHALF);
+                       if (requested & MAX_VERTICAL)
+                               effective &= ~(MAX_TOPHALF | MAX_BOTTOMHALF);
                        effective &= ~MAX_MAXIMUS;
                }
                wMaximizeWindow(wwin, effective | flags);
index 55de740..8390e49 100644 (file)
 #define MAX_VERTICAL           (1 << 1)
 #define MAX_LEFTHALF           (1 << 2)
 #define MAX_RIGHTHALF          (1 << 3)
-#define MAX_MAXIMUS            (1 << 4)
-#define MAX_IGNORE_XINERAMA    (1 << 5)
-#define MAX_KEYBOARD           (1 << 6)
+#define MAX_TOPHALF            (1 << 4)
+#define MAX_BOTTOMHALF         (1 << 5)
+#define MAX_MAXIMUS            (1 << 6)
+#define MAX_IGNORE_XINERAMA    (1 << 7)
+#define MAX_KEYBOARD           (1 << 8)
 
 #define SAVE_GEOMETRY_X        (1 << 0)
 #define SAVE_GEOMETRY_Y        (1 << 1)
index e877229..060ec59 100644 (file)
@@ -252,11 +252,11 @@ void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre)
                        nheight = wwin->frame->core->height - wwin->frame->top_width - wwin->frame->bottom_width;
 
                if (nwidth != wwin->old_geometry.width)
-                       wwin->flags.maximized &= ~(MAX_HORIZONTAL | MAX_MAXIMUS);
-                if (nheight != wwin->old_geometry.height)
+                       wwin->flags.maximized &= ~(MAX_HORIZONTAL | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
+               if (nheight != wwin->old_geometry.height)
                        wwin->flags.maximized &= ~(MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_MAXIMUS);
 
-                wWindowConfigure(wwin, nx, ny, nwidth, nheight);
+               wWindowConfigure(wwin, nx, ny, nwidth, nheight);
                wwin->old_geometry.x = nx;
                wwin->old_geometry.y = ny;
                wwin->old_geometry.width = nwidth;
index 8d2fe22..82202df 100644 (file)
@@ -605,6 +605,10 @@ WDefaultEntry optionList[] = {
            NULL, getKeybind, setKeyGrab, NULL, NULL},
        {"RHMaximizeKey", "None", (void*)WKBD_RHMAXIMIZE,
            NULL, getKeybind, setKeyGrab, NULL, NULL},
+       {"THMaximizeKey", "None", (void*)WKBD_THMAXIMIZE,
+               NULL, getKeybind, setKeyGrab, NULL, NULL},
+       {"BHMaximizeKey", "None", (void*)WKBD_BHMAXIMIZE,
+               NULL, getKeybind, setKeyGrab, NULL, NULL},
        {"MaximusKey", "None", (void*)WKBD_MAXIMUS,
            NULL, getKeybind, setKeyGrab, NULL, NULL},
        {"RaiseKey", "\"Meta+Up\"", (void *)WKBD_RAISE,
index 692fd8a..f169e02 100644 (file)
@@ -1470,6 +1470,20 @@ static void handleKeyPress(XEvent * event)
                        handleMaximize(wwin, MAX_VERTICAL | MAX_RIGHTHALF | MAX_KEYBOARD);
                }
                break;
+       case WKBD_THMAXIMIZE:
+               if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) {
+                       CloseWindowMenu(scr);
+
+                       handleMaximize(wwin, MAX_HORIZONTAL | MAX_TOPHALF | MAX_KEYBOARD);
+               }
+               break;
+       case WKBD_BHMAXIMIZE:
+               if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) {
+                       CloseWindowMenu(scr);
+
+                       handleMaximize(wwin, MAX_HORIZONTAL | MAX_BOTTOMHALF | MAX_KEYBOARD);
+               }
+               break;
        case WKBD_MAXIMUS:
                if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) {
                        CloseWindowMenu(scr);
index 8402b70..0209aed 100644 (file)
@@ -35,8 +35,10 @@ enum {
        WKBD_MAXIMIZE,
        WKBD_VMAXIMIZE,
        WKBD_HMAXIMIZE,
-        WKBD_LHMAXIMIZE,
+       WKBD_LHMAXIMIZE,
        WKBD_RHMAXIMIZE,
+       WKBD_THMAXIMIZE,
+       WKBD_BHMAXIMIZE,
        WKBD_MAXIMUS,
        WKBD_SELECT,
        WKBD_RAISE,
index 23045eb..8f0ecba 100644 (file)
@@ -1521,7 +1521,7 @@ int wKeyboardMoveResizeWindow(WWindow * wwin)
                                        }
                                } else {
                                        if (ww != original_w)
-                                               wwin->flags.maximized &= ~(MAX_HORIZONTAL | MAX_MAXIMUS);
+                                               wwin->flags.maximized &= ~(MAX_HORIZONTAL | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
 
                                        if (wh != original_h)
                                                wwin->flags.maximized &= ~(MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_MAXIMUS);
@@ -2078,7 +2078,7 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev)
                                XUngrabServer(dpy);
 
                                if (fw != original_fw)
-                                       wwin->flags.maximized &= ~(MAX_HORIZONTAL | MAX_MAXIMUS);
+                                       wwin->flags.maximized &= ~(MAX_HORIZONTAL | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
 
                                if (fh != original_fh)
                                        wwin->flags.maximized &= ~(MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_MAXIMUS);
index a95b9f7..ec032c0 100644 (file)
@@ -249,8 +249,8 @@ typedef struct WWindow {
                unsigned int miniaturized:1;
                unsigned int hidden:1;
                unsigned int shaded:1;
-               unsigned int maximized:5;
-               unsigned int old_maximized:5;
+               unsigned int maximized:7;
+               unsigned int old_maximized:7;
                unsigned int fullscreen:1;
                unsigned int omnipresent:1;
                unsigned int semi_focused:1;