X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=f11cda865b02cb894b0dcc2730c3df6323ef2c27;hb=e00144a6bf3cd90c57c865caa8076d2602f04223;hp=fbb41b3ca5ccaa934ae2b3bb8d0786fc042d3d74;hpb=cb242b5abd4026b38291906eec6b2306b7c197bf;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index fbb41b3..f11cda8 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -158,6 +158,8 @@ double dialog_ratio = .6; char *bar_argv[] = { NULL, NULL }; int bar_pipe[2]; char bar_ext[SWM_BAR_MAX]; +char bar_vertext[SWM_BAR_MAX]; +int bar_version = 0; sig_atomic_t bar_alarm = 0; int bar_delay = 30; int bar_enabled = 1; @@ -310,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; }; @@ -599,8 +603,8 @@ bar_update(void) for (i = 0; i < ScreenCount(display); i++) { x = 1; TAILQ_FOREACH(r, &screens[i].rl, entry) { - snprintf(loc, sizeof loc, "%s %d:%d %s", - s, x++, r->ws->idx + 1, bar_ext); + snprintf(loc, sizeof loc, "%s %d:%d %s %s", + s, x++, r->ws->idx + 1, bar_ext, bar_vertext); bar_print(r, loc); } } @@ -726,6 +730,17 @@ bar_setup(struct swm_region *r) } void +version(struct swm_region *r, union arg *args) +{ + bar_version = !bar_version; + if (bar_version) + strlcpy(bar_vertext, cvstag, sizeof bar_vertext); + else + strlcpy(bar_vertext, "", sizeof bar_vertext); + bar_update(); +} + +void config_win(struct ws_win *win) { XConfigureEvent ce; @@ -1515,6 +1530,9 @@ send_to_ws(struct swm_region *r, union arg *args) Atom ws_idx_atom = 0; unsigned char ws_idx_str[SWM_PROPLEN]; + if (win == NULL) + return; + DNPRINTF(SWM_D_MOVE, "send_to_ws: win: %lu\n", win->id); ws = win->ws; @@ -1638,10 +1656,11 @@ struct key { { MODKEY | ShiftMask, XK_x, wkill, {0} }, { MODKEY, XK_s, screenshot, {.id = SWM_ARG_ID_SS_ALL} }, { MODKEY | ShiftMask, XK_s, screenshot, {.id = SWM_ARG_ID_SS_WINDOW} }, + { MODKEY | ShiftMask, XK_v, version, {0} }, }; void -resize_window(struct ws_win *win) +resize_window(struct ws_win *win, int center) { unsigned int mask; XWindowChanges wc; @@ -1649,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); @@ -1695,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); @@ -1776,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} }, };