allow focus_fallback to query if a client can be focused without changing the focus order on it
This commit is contained in:
parent
9232682ad6
commit
e0fa57d21c
3 changed files with 29 additions and 1 deletions
|
@ -2239,10 +2239,30 @@ Client *client_focus_target(Client *self)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean client_can_focus(Client *self)
|
||||||
|
{
|
||||||
|
/* same code as in client_focus */
|
||||||
|
|
||||||
|
/* choose the correct target */
|
||||||
|
self = client_focus_target(self);
|
||||||
|
|
||||||
|
if (!self->frame->visible)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!((self->can_focus || self->focus_notify) &&
|
||||||
|
(self->desktop == screen_desktop ||
|
||||||
|
self->desktop == DESKTOP_ALL) &&
|
||||||
|
!self->iconic))
|
||||||
|
return FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean client_focus(Client *self)
|
gboolean client_focus(Client *self)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
|
/* same code as in client_can_focus */
|
||||||
|
|
||||||
/* choose the correct target */
|
/* choose the correct target */
|
||||||
self = client_focus_target(self);
|
self = client_focus_target(self);
|
||||||
|
|
||||||
|
|
|
@ -430,6 +430,10 @@ void client_set_state(Client *self, Atom action, long data1, long data2);
|
||||||
Client passed to it or another Client if appropriate. */
|
Client passed to it or another Client if appropriate. */
|
||||||
Client *client_focus_target(Client *self);
|
Client *client_focus_target(Client *self);
|
||||||
|
|
||||||
|
/*! Returns what client_focus would return if passed the same client, but
|
||||||
|
without focusing it or modifying the focus order lists. */
|
||||||
|
gboolean client_can_focus(Client *self);
|
||||||
|
|
||||||
/*! Attempt to focus the client window */
|
/*! Attempt to focus the client window */
|
||||||
gboolean client_focus(Client *self);
|
gboolean client_focus(Client *self);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
Client *focus_client = NULL;
|
Client *focus_client = NULL;
|
||||||
GList **focus_order = NULL; /* these lists are created when screen_startup
|
GList **focus_order = NULL; /* these lists are created when screen_startup
|
||||||
|
@ -213,10 +214,13 @@ void focus_fallback(FallbackType type)
|
||||||
for (sit = old->group->members; sit; sit = sit->next)
|
for (sit = old->group->members; sit; sit = sit->next)
|
||||||
if (sit->data == it->data)
|
if (sit->data == it->data)
|
||||||
if (sit->data != old && client_normal(sit->data))
|
if (sit->data != old && client_normal(sit->data))
|
||||||
if (client_focus(sit->data))
|
if (client_can_focus(sit->data)) {
|
||||||
|
gboolean r = client_focus(sit->data);
|
||||||
|
assert(r);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
|
for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
|
||||||
if (type != Fallback_Unfocusing || it->data != old)
|
if (type != Fallback_Unfocusing || it->data != old)
|
||||||
|
|
Loading…
Reference in a new issue