]> code.delx.au - spectrwm/commitdiff
Make resize smarter so that M-M3 resizes the window without centering it
authorMarco Peereboom <marco@conformal.com>
Fri, 30 Jan 2009 20:59:20 +0000 (20:59 +0000)
committerMarco Peereboom <marco@conformal.com>
Fri, 30 Jan 2009 20:59:20 +0000 (20:59 +0000)
and M-S-M3 keeps the old behavior.

scrotwm.1
scrotwm.c

index 22edc2a8f4be0fdd2127e219672805808e7ec4f3..dddcb2a70c06d8627dd3badddfb05ccfb32d8e5a 100644 (file)
--- a/scrotwm.1
+++ b/scrotwm.1
@@ -129,6 +129,8 @@ Focus window
 Move window
 .It Cm M-M3
 Resize window
+.It Cm M-S-M3
+Resize window while maintaining it centered
 .El
 .Sh CONFIGURATION FILES
 .Nm
index d6f4d233378c18e69d671195000ee4dae4575137..f11cda865b02cb894b0dcc2730c3df6323ef2c27 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -312,6 +312,8 @@ union arg {
 #define SWM_ARG_ID_CYCLESC_DOWN        (15)
 #define SWM_ARG_ID_SS_ALL      (0)
 #define SWM_ARG_ID_SS_WINDOW   (1)
+#define SWM_ARG_ID_DONTCENTER  (0)
+#define SWM_ARG_ID_CENTER      (1)
        char                    **argv;
 };
 
@@ -1658,7 +1660,7 @@ struct key {
 };
 
 void
-resize_window(struct ws_win *win)
+resize_window(struct ws_win *win, int center)
 {
        unsigned int            mask;
        XWindowChanges          wc;
@@ -1666,12 +1668,15 @@ resize_window(struct ws_win *win)
 
        r = root_to_region(win->wa.root);
        bzero(&wc, sizeof wc);
-       mask = CWX | CWY | CWBorderWidth | CWWidth | CWHeight;
+       mask = CWBorderWidth | CWWidth | CWHeight;
        wc.border_width = 1;
        wc.width = win->g.w;
        wc.height = win->g.h;
-       wc.x = (WIDTH(r) - win->g.w) / 2;
-       wc.y = (HEIGHT(r) - win->g.h) / 2;
+       if (center == SWM_ARG_ID_CENTER) {
+               wc.x = (WIDTH(r) - win->g.w) / 2;
+               wc.y = (HEIGHT(r) - win->g.h) / 2;
+               mask |= CWX | CWY;
+       }
 
        DNPRINTF(SWM_D_STACK, "resize_window: win %lu x %d y %d w %d h %d\n",
            win->id, wc.x, wc.y, wc.width, wc.height);
@@ -1712,7 +1717,7 @@ resize(struct ws_win *win, union arg *args)
                                ev.xmotion.y = 0;
                        win->g.w = ev.xmotion.x;
                        win->g.h = ev.xmotion.y;
-                       resize_window(win);
+                       resize_window(win, args->id);
                        break;
                }
        } while (ev.type != ButtonRelease);
@@ -1793,7 +1798,8 @@ struct button {
        union arg               args;
 } buttons[] = {
          /* action             key             mouse button    func            args */
-       { client_click,         MODKEY,         Button3,        resize,         {0} },
+       { client_click,         MODKEY,         Button3,        resize,         {.id = SWM_ARG_ID_DONTCENTER} },
+       { client_click,         MODKEY | ShiftMask, Button3,    resize,         {.id = SWM_ARG_ID_CENTER} },
        { client_click,         MODKEY,         Button1,        move,           {0} },
 };