From 8f2b071e3dcd274803a7c65503d11411530b3895 Mon Sep 17 00:00:00 2001 From: Reginald Kennedy Date: Fri, 9 May 2014 14:09:27 +0800 Subject: [PATCH] Add new quirk IGNOREPID. Ignore the PID when determining the initial workspace for a new window. Especially useful for terminal windows that share a process. closes #49 --- spectrwm.1 | 3 +++ spectrwm.c | 55 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/spectrwm.1 b/spectrwm.1 index 2859e34..d3623c2 100644 --- a/spectrwm.1 +++ b/spectrwm.1 @@ -948,6 +948,9 @@ When an application requests focus on the window via a _NET_ACTIVE_WINDOW client message (source indication of 1), comply with the request. Note that a source indication of 0 (unspecified) or 2 (pager) are always obeyed. +.It IGNOREPID +Ignore the PID when determining the initial workspace for a new window. +Especially useful for terminal windows that share a process. .El .Pp Custom quirks in the configuration file are specified as follows: diff --git a/spectrwm.c b/spectrwm.c index 317d4b7..136077e 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -671,6 +671,7 @@ struct quirk { #define SWM_Q_NOFOCUSONMAP (1<<6) /* Don't focus on window when mapped. */ #define SWM_Q_FOCUSONMAP_SINGLE (1<<7) /* Only focus if single win of type. */ #define SWM_Q_OBEYAPPFOCUSREQ (1<<8) /* Focus when applications ask. */ +#define SWM_Q_IGNOREPID (1<<9) /* Ignore PID when determining ws. */ }; TAILQ_HEAD(quirk_list, quirk); struct quirk_list quirks = TAILQ_HEAD_INITIALIZER(quirks); @@ -7550,6 +7551,7 @@ const char *quirkname[] = { "NOFOCUSONMAP", "FOCUSONMAP_SINGLE", "OBEYAPPFOCUSREQ", + "IGNOREPID", }; /* SWM_Q_WS: retain '|' for back compat for now (2009-08-11) */ @@ -8793,32 +8795,6 @@ manage_window(xcb_window_t id, int mapped) /* Get WM_PROTOCOLS. */ get_wm_protocols(win); - /* Figure out which workspace the window belongs to. */ - if ((p = find_pid(window_get_pid(win->id))) != NULL) { - win->ws = &r->s->ws[p->ws]; - TAILQ_REMOVE(&pidlist, p, entry); - free(p); - p = NULL; - } else if ((ws_idx = get_ws_idx(win->id)) != -1 && - !TRANS(win)) { - /* _SWM_WS is set; use that. */ - win->ws = &r->s->ws[ws_idx]; - } else if (trans && (ww = find_window(trans)) != NULL) { - /* Launch transients in the same ws as parent. */ - win->ws = ww->ws; - } else { - win->ws = r->ws; - } - - /* Set the _NET_WM_DESKTOP atom. */ - DNPRINTF(SWM_D_PROP, "manage_window: set _NET_WM_DESKTOP: %d\n", - win->ws->idx); - xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win->id, - ewmh[_NET_WM_DESKTOP].atom, XCB_ATOM_CARDINAL, 32, 1, &win->ws->idx); - - /* WS must already be set for this to work. */ - store_float_geom(win); - /* Set initial quirks based on EWMH. */ ewmh_autoquirk(win); @@ -8861,6 +8837,33 @@ manage_window(xcb_window_t id, int mapped) fake_keypress(win, XK_KP_Add, XCB_MOD_MASK_SHIFT); } + /* Figure out which workspace the window belongs to. */ + if (!(win->quirks & SWM_Q_IGNOREPID) && + (p = find_pid(window_get_pid(win->id))) != NULL) { + win->ws = &r->s->ws[p->ws]; + TAILQ_REMOVE(&pidlist, p, entry); + free(p); + p = NULL; + } else if ((ws_idx = get_ws_idx(win->id)) != -1 && + !TRANS(win)) { + /* _SWM_WS is set; use that. */ + win->ws = &r->s->ws[ws_idx]; + } else if (trans && (ww = find_window(trans)) != NULL) { + /* Launch transients in the same ws as parent. */ + win->ws = ww->ws; + } else { + win->ws = r->ws; + } + + /* Set the _NET_WM_DESKTOP atom. */ + DNPRINTF(SWM_D_PROP, "manage_window: set _NET_WM_DESKTOP: %d\n", + win->ws->idx); + xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win->id, + ewmh[_NET_WM_DESKTOP].atom, XCB_ATOM_CARDINAL, 32, 1, &win->ws->idx); + + /* WS must already be set for this to work. */ + store_float_geom(win); + /* Make sure window is positioned inside its region, if its active. */ if (win->ws->r) { region_containment(win, r, SWM_CW_ALLSIDES | -- 1.7.10.4