mirror of
https://github.com/vale981/spectrwm
synced 2025-03-05 18:01:37 -05:00
Fix follow_cursor focus mode and rename option value to 'focus'.
Note that previous value of 'focus_cursor' is still valid.
This commit is contained in:
parent
b019e45389
commit
152d9a5bbe
2 changed files with 67 additions and 36 deletions
|
@ -240,11 +240,11 @@ and
|
||||||
.It Ic focus_mode
|
.It Ic focus_mode
|
||||||
Window focus behavior with respect to the mouse cursor. Possible values:
|
Window focus behavior with respect to the mouse cursor. Possible values:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag -width "follow_cursor" -offset indent -compact
|
.Bl -tag -width "default" -offset indent -compact
|
||||||
.It Cm default
|
.It Cm default
|
||||||
Set window focus on border crossings caused by cursor motion and
|
Set window focus on border crossings caused by cursor motion and
|
||||||
window interaction.
|
window interaction.
|
||||||
.It Cm follow_cursor
|
.It Cm follow
|
||||||
Set window focus on all cursor border crossings, including workspace switches
|
Set window focus on all cursor border crossings, including workspace switches
|
||||||
and changes to layout.
|
and changes to layout.
|
||||||
.It Cm manual
|
.It Cm manual
|
||||||
|
|
51
spectrwm.c
51
spectrwm.c
|
@ -2872,9 +2872,10 @@ switchws(struct swm_region *r, union arg *args)
|
||||||
TAILQ_FOREACH(win, &old_ws->winlist, entry)
|
TAILQ_FOREACH(win, &old_ws->winlist, entry)
|
||||||
unmap_window(win);
|
unmap_window(win);
|
||||||
|
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
new_ws->focus_pending = get_region_focus(new_ws->r);
|
new_ws->focus_pending = get_region_focus(new_ws->r);
|
||||||
|
|
||||||
if (new_ws->focus_pending) {
|
if (new_ws->focus_pending && focus_mode != SWM_FOCUS_FOLLOW) {
|
||||||
/* if workspaces were swapped, then don't wait to set focus */
|
/* if workspaces were swapped, then don't wait to set focus */
|
||||||
if (old_ws->r)
|
if (old_ws->r)
|
||||||
focus_win(new_ws->focus_pending);
|
focus_win(new_ws->focus_pending);
|
||||||
|
@ -3883,7 +3884,7 @@ send_to_ws(struct swm_region *r, union arg *args)
|
||||||
{
|
{
|
||||||
int wsid = args->id;
|
int wsid = args->id;
|
||||||
struct ws_win *win = NULL, *parent;
|
struct ws_win *win = NULL, *parent;
|
||||||
struct workspace *ws, *nws;
|
struct workspace *ws, *nws, *pws;
|
||||||
char ws_idx_str[SWM_PROPLEN];
|
char ws_idx_str[SWM_PROPLEN];
|
||||||
|
|
||||||
if (wsid >= workspace_limit)
|
if (wsid >= workspace_limit)
|
||||||
|
@ -3905,20 +3906,27 @@ send_to_ws(struct swm_region *r, union arg *args)
|
||||||
|
|
||||||
/* Update the window's workspace property: _SWM_WS */
|
/* Update the window's workspace property: _SWM_WS */
|
||||||
if (snprintf(ws_idx_str, SWM_PROPLEN, "%d", nws->idx) < SWM_PROPLEN) {
|
if (snprintf(ws_idx_str, SWM_PROPLEN, "%d", nws->idx) < SWM_PROPLEN) {
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
ws->focus_pending = get_focus_prev(win);
|
ws->focus_pending = get_focus_prev(win);
|
||||||
|
|
||||||
/* Move the parent if this is a transient window. */
|
/* Move the parent if this is a transient window. */
|
||||||
if (win->transient) {
|
if (win->transient) {
|
||||||
parent = find_window(win->transient);
|
parent = find_window(win->transient);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
|
pws = parent->ws;
|
||||||
/* Set new focus in parent's ws if needed. */
|
/* Set new focus in parent's ws if needed. */
|
||||||
if (parent->ws->focus == parent) {
|
if (pws->focus == parent) {
|
||||||
parent->ws->focus_pending =
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
|
pws->focus_pending =
|
||||||
get_focus_prev(parent);
|
get_focus_prev(parent);
|
||||||
|
|
||||||
unfocus_win(parent);
|
unfocus_win(parent);
|
||||||
parent->ws->focus =
|
|
||||||
parent->ws->focus_pending;
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
parent->ws->focus_pending = NULL;
|
pws->focus = pws->focus_pending;
|
||||||
|
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
|
pws->focus_pending = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't unmap parent if new ws is visible */
|
/* Don't unmap parent if new ws is visible */
|
||||||
|
@ -3961,8 +3969,11 @@ send_to_ws(struct swm_region *r, union arg *args)
|
||||||
|
|
||||||
/* Restack and set new focus. */
|
/* Restack and set new focus. */
|
||||||
stack();
|
stack();
|
||||||
|
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW) {
|
||||||
focus_win(ws->focus_pending);
|
focus_win(ws->focus_pending);
|
||||||
ws->focus_pending = NULL;
|
ws->focus_pending = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
focus_flush();
|
focus_flush();
|
||||||
}
|
}
|
||||||
|
@ -6221,7 +6232,8 @@ setconfvalue(char *selector, char *value, int flags)
|
||||||
case SWM_S_FOCUS_MODE:
|
case SWM_S_FOCUS_MODE:
|
||||||
if (!strcmp(value, "default"))
|
if (!strcmp(value, "default"))
|
||||||
focus_mode = SWM_FOCUS_DEFAULT;
|
focus_mode = SWM_FOCUS_DEFAULT;
|
||||||
else if (!strcmp(value, "follow_cursor"))
|
else if (!strcmp(value, "follow") ||
|
||||||
|
!strcmp(value, "follow_cursor"))
|
||||||
focus_mode = SWM_FOCUS_FOLLOW;
|
focus_mode = SWM_FOCUS_FOLLOW;
|
||||||
else if (!strcmp(value, "manual"))
|
else if (!strcmp(value, "manual"))
|
||||||
focus_mode = SWM_FOCUS_MANUAL;
|
focus_mode = SWM_FOCUS_MANUAL;
|
||||||
|
@ -7333,17 +7345,21 @@ destroynotify(xcb_destroy_notify_event_t *e)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW) {
|
||||||
/* If we were focused, make sure we focus on something else. */
|
/* If we were focused, make sure we focus on something else. */
|
||||||
if (win == win->ws->focus)
|
if (win == win->ws->focus)
|
||||||
win->ws->focus_pending = get_focus_prev(win);
|
win->ws->focus_pending = get_focus_prev(win);
|
||||||
|
}
|
||||||
|
|
||||||
unmanage_window(win);
|
unmanage_window(win);
|
||||||
stack();
|
stack();
|
||||||
|
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW) {
|
||||||
if (win->ws->focus_pending) {
|
if (win->ws->focus_pending) {
|
||||||
focus_win(win->ws->focus_pending);
|
focus_win(win->ws->focus_pending);
|
||||||
win->ws->focus_pending = NULL;
|
win->ws->focus_pending = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free_window(win);
|
free_window(win);
|
||||||
|
|
||||||
|
@ -7477,10 +7493,12 @@ mapnotify(xcb_map_notify_event_t *e)
|
||||||
win->mapped = 1;
|
win->mapped = 1;
|
||||||
set_win_state(win, XCB_ICCCM_WM_STATE_NORMAL);
|
set_win_state(win, XCB_ICCCM_WM_STATE_NORMAL);
|
||||||
|
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW) {
|
||||||
if (win->ws->focus_pending == win) {
|
if (win->ws->focus_pending == win) {
|
||||||
focus_win(win);
|
focus_win(win);
|
||||||
win->ws->focus_pending = NULL;
|
win->ws->focus_pending = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xcb_flush(conn);
|
xcb_flush(conn);
|
||||||
}
|
}
|
||||||
|
@ -7525,6 +7543,7 @@ maprequest(xcb_map_request_event_t *e)
|
||||||
stack();
|
stack();
|
||||||
|
|
||||||
/* The new window should get focus. */
|
/* The new window should get focus. */
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
win->ws->focus_pending = get_focus_magic(win);
|
win->ws->focus_pending = get_focus_magic(win);
|
||||||
|
|
||||||
/* Ignore EnterNotify to handle the mapnotify without interference. */
|
/* Ignore EnterNotify to handle the mapnotify without interference. */
|
||||||
|
@ -7589,19 +7608,25 @@ propertynotify(xcb_property_notify_event_t *e)
|
||||||
|
|
||||||
if (e->atom == a_swm_iconic) {
|
if (e->atom == a_swm_iconic) {
|
||||||
if (e->state == XCB_PROPERTY_NEW_VALUE) {
|
if (e->state == XCB_PROPERTY_NEW_VALUE) {
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
win->ws->focus_pending = get_focus_prev(win);
|
win->ws->focus_pending = get_focus_prev(win);
|
||||||
|
|
||||||
unfocus_win(win);
|
unfocus_win(win);
|
||||||
unmap_window(win);
|
unmap_window(win);
|
||||||
|
|
||||||
if (win->ws->r) {
|
if (win->ws->r) {
|
||||||
stack();
|
stack();
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW) {
|
||||||
focus_win(win->ws->focus_pending);
|
focus_win(win->ws->focus_pending);
|
||||||
win->ws->focus_pending = NULL;
|
win->ws->focus_pending = NULL;
|
||||||
|
}
|
||||||
focus_flush();
|
focus_flush();
|
||||||
}
|
}
|
||||||
} else if (e->state == XCB_PROPERTY_DELETE) {
|
} else if (e->state == XCB_PROPERTY_DELETE) {
|
||||||
/* The window is no longer iconic, restack ws. */
|
/* The window is no longer iconic, restack ws. */
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
win->ws->focus_pending = get_focus_magic(win);
|
win->ws->focus_pending = get_focus_magic(win);
|
||||||
|
|
||||||
stack();
|
stack();
|
||||||
|
|
||||||
/* Flush EnterNotify for mapnotify, if needed. */
|
/* Flush EnterNotify for mapnotify, if needed. */
|
||||||
|
@ -7610,9 +7635,12 @@ propertynotify(xcb_property_notify_event_t *e)
|
||||||
} else if (e->atom == a_state) {
|
} else if (e->atom == a_state) {
|
||||||
/* State just changed, make sure it gets focused if mapped. */
|
/* State just changed, make sure it gets focused if mapped. */
|
||||||
if (e->state == XCB_PROPERTY_NEW_VALUE) {
|
if (e->state == XCB_PROPERTY_NEW_VALUE) {
|
||||||
if (win->mapped && win->ws->focus_pending == win) {
|
if (focus_mode != SWM_FOCUS_FOLLOW) {
|
||||||
|
if (win->mapped &&
|
||||||
|
win->ws->focus_pending == win) {
|
||||||
|
focus_win(win->ws->focus_pending);
|
||||||
win->ws->focus_pending = NULL;
|
win->ws->focus_pending = NULL;
|
||||||
focus_win(win);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e->atom == XCB_ATOM_WM_CLASS ||
|
} else if (e->atom == XCB_ATOM_WM_CLASS ||
|
||||||
|
@ -7638,6 +7666,7 @@ unmapnotify(xcb_unmap_notify_event_t *e)
|
||||||
if (getstate(e->window) == XCB_ICCCM_WM_STATE_NORMAL) {
|
if (getstate(e->window) == XCB_ICCCM_WM_STATE_NORMAL) {
|
||||||
/* If we were focused, make sure we focus on something else. */
|
/* If we were focused, make sure we focus on something else. */
|
||||||
if (win == win->ws->focus)
|
if (win == win->ws->focus)
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW)
|
||||||
win->ws->focus_pending = get_focus_prev(win);
|
win->ws->focus_pending = get_focus_prev(win);
|
||||||
|
|
||||||
win->mapped = 0;
|
win->mapped = 0;
|
||||||
|
@ -7646,10 +7675,12 @@ unmapnotify(xcb_unmap_notify_event_t *e)
|
||||||
unmanage_window(win);
|
unmanage_window(win);
|
||||||
stack();
|
stack();
|
||||||
|
|
||||||
|
if (focus_mode != SWM_FOCUS_FOLLOW) {
|
||||||
if (win->ws->focus_pending) {
|
if (win->ws->focus_pending) {
|
||||||
focus_win(win->ws->focus_pending);
|
focus_win(win->ws->focus_pending);
|
||||||
win->ws->focus_pending = NULL;
|
win->ws->focus_pending = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
focus_flush();
|
focus_flush();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue