From e00144a6bf3cd90c57c865caa8076d2602f04223 Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Fri, 30 Jan 2009 20:59:20 +0000 Subject: [PATCH] Make resize smarter so that M-M3 resizes the window without centering it and M-S-M3 keeps the old behavior. --- scrotwm.1 | 2 ++ scrotwm.c | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scrotwm.1 b/scrotwm.1 index 22edc2a..dddcb2a 100644 --- 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 diff --git a/scrotwm.c b/scrotwm.c index d6f4d23..f11cda8 100644 --- 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} }, }; -- 1.7.10.4