let the frame hold a focus state so that it can lie.
dont focus windows while cycling, just highlight them as if they are focused
This commit is contained in:
parent
11b7764e5f
commit
16a9ac018e
5 changed files with 44 additions and 28 deletions
|
@ -498,7 +498,7 @@ static void event_handle_client(Client *client, XEvent *e)
|
|||
#endif
|
||||
/* focus state can affect the stacking layer */
|
||||
client_calc_layer(client);
|
||||
frame_adjust_focus(client->frame);
|
||||
frame_adjust_focus(client->frame, e->type == FocusIn);
|
||||
break;
|
||||
case EnterNotify:
|
||||
if (client_normal(client)) {
|
||||
|
|
|
@ -20,7 +20,7 @@ GList **focus_order = NULL; /* these lists are created when screen_startup
|
|||
|
||||
Window focus_backup = None;
|
||||
|
||||
static gboolean noreorder = 0;
|
||||
static Client *focus_cycle_target = NULL;
|
||||
|
||||
void focus_startup()
|
||||
{
|
||||
|
@ -85,13 +85,15 @@ void focus_set_client(Client *client)
|
|||
XSync(ob_display, FALSE);
|
||||
}
|
||||
|
||||
/* in the middle of cycling..? kill it. */
|
||||
if (focus_cycle_target)
|
||||
focus_cycle(TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
old = focus_client;
|
||||
focus_client = client;
|
||||
|
||||
/* move to the top of the list */
|
||||
if (noreorder)
|
||||
--noreorder;
|
||||
else if (client != NULL)
|
||||
if (client != NULL)
|
||||
push_to_top(client);
|
||||
|
||||
/* set the NET_ACTIVE_WINDOW hint */
|
||||
|
@ -221,21 +223,26 @@ Client *focus_cycle(gboolean forward, gboolean linear, gboolean done,
|
|||
Client *ft;
|
||||
|
||||
if (cancel) {
|
||||
if (first) client_focus(first);
|
||||
/*if (first) client_focus(first); XXX*/
|
||||
if (focus_cycle_target)
|
||||
frame_adjust_focus(focus_cycle_target->frame, FALSE);
|
||||
if (focus_client)
|
||||
frame_adjust_focus(focus_client->frame, TRUE);
|
||||
goto done_cycle;
|
||||
} else if (done) {
|
||||
if (focus_client) {
|
||||
push_to_top(focus_client); /* move to top of focus_order */
|
||||
stacking_raise(focus_client);
|
||||
if (focus_cycle_target) {
|
||||
client_focus(focus_cycle_target);
|
||||
stacking_raise(focus_cycle_target);
|
||||
}
|
||||
goto done_cycle;
|
||||
}
|
||||
if (!first) first = focus_client;
|
||||
if (!focus_cycle_target) focus_cycle_target = focus_client;
|
||||
|
||||
if (linear) list = client_list;
|
||||
else list = focus_order[screen_desktop];
|
||||
|
||||
start = it = g_list_find(list, focus_client);
|
||||
start = it = g_list_find(list, focus_cycle_target);
|
||||
if (!start) /* switched desktops or something? */
|
||||
start = it = forward ? g_list_last(list) : g_list_first(list);
|
||||
if (!start) goto done_cycle;
|
||||
|
@ -249,9 +256,13 @@ Client *focus_cycle(gboolean forward, gboolean linear, gboolean done,
|
|||
if (it == NULL) it = g_list_last(list);
|
||||
}
|
||||
ft = client_focus_target(it->data);
|
||||
if (ft == it->data && focus_client != ft && client_normal(ft) &&
|
||||
client_focus(ft)) {
|
||||
noreorder++; /* avoid reordering the focus_order */
|
||||
if (ft == it->data && client_normal(ft) && client_focusable(ft)) {
|
||||
if (focus_cycle_target)
|
||||
frame_adjust_focus(focus_cycle_target->frame, FALSE);
|
||||
else if (focus_client)
|
||||
frame_adjust_focus(focus_client->frame, FALSE);
|
||||
focus_cycle_target = ft;
|
||||
frame_adjust_focus(focus_cycle_target->frame, TRUE);
|
||||
return ft;
|
||||
}
|
||||
} while (it != start);
|
||||
|
@ -260,6 +271,7 @@ Client *focus_cycle(gboolean forward, gboolean linear, gboolean done,
|
|||
done_cycle:
|
||||
t = NULL;
|
||||
first = NULL;
|
||||
focus_cycle_target = NULL;
|
||||
g_list_free(order);
|
||||
order = NULL;
|
||||
return NULL;
|
||||
|
|
|
@ -124,6 +124,8 @@ Frame *frame_new()
|
|||
attrib.cursor = ob_cursors.br;
|
||||
self->rgrip = createWindow(self->handle, mask, &attrib);
|
||||
|
||||
self->focused = FALSE;
|
||||
|
||||
/* the other stuff is shown based on decor settings */
|
||||
XMapWindow(ob_display, self->plate);
|
||||
XMapWindow(ob_display, self->lgrip);
|
||||
|
@ -386,8 +388,9 @@ void frame_adjust_state(Frame *self)
|
|||
framerender_frame(self);
|
||||
}
|
||||
|
||||
void frame_adjust_focus(Frame *self)
|
||||
void frame_adjust_focus(Frame *self, gboolean hilite)
|
||||
{
|
||||
self->focused = hilite;
|
||||
framerender_frame(self);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,8 @@ typedef struct Frame {
|
|||
gboolean desk_press;
|
||||
gboolean shade_press;
|
||||
gboolean iconify_press;
|
||||
|
||||
gboolean focused;
|
||||
} Frame;
|
||||
|
||||
void frame_startup();
|
||||
|
@ -90,7 +92,7 @@ void frame_hide(Frame *self);
|
|||
void frame_adjust_shape(Frame *self);
|
||||
void frame_adjust_area(Frame *self, gboolean moved, gboolean resized);
|
||||
void frame_adjust_state(Frame *self);
|
||||
void frame_adjust_focus(Frame *self);
|
||||
void frame_adjust_focus(Frame *self, gboolean hilite);
|
||||
void frame_adjust_title(Frame *self);
|
||||
void frame_adjust_icon(Frame *self);
|
||||
void frame_grab_client(Frame *self, Client *client);
|
||||
|
|
|
@ -14,22 +14,21 @@ static void framerender_close(Frame *self, Appearance *a);
|
|||
|
||||
void framerender_frame(Frame *self)
|
||||
{
|
||||
if (client_focused(self->client)) {
|
||||
if (self->focused)
|
||||
XSetWindowBorder(ob_display, self->plate,
|
||||
theme_cb_focused_color->pixel);
|
||||
} else {
|
||||
else
|
||||
XSetWindowBorder(ob_display, self->plate,
|
||||
theme_cb_unfocused_color->pixel);
|
||||
}
|
||||
|
||||
if (self->client->decorations & Decor_Titlebar) {
|
||||
Appearance *t, *l, *m, *n, *i, *d, *s, *c;
|
||||
|
||||
t = (client_focused(self->client) ?
|
||||
t = (self->focused ?
|
||||
self->a_focused_title : self->a_unfocused_title);
|
||||
l = (client_focused(self->client) ?
|
||||
l = (self->focused ?
|
||||
self->a_focused_label : self->a_unfocused_label);
|
||||
m = (client_focused(self->client) ?
|
||||
m = (self->focused ?
|
||||
(self->client->max_vert || self->client->max_horz ?
|
||||
theme_a_focused_pressed_set_max :
|
||||
(self->max_press ?
|
||||
|
@ -40,14 +39,14 @@ void framerender_frame(Frame *self)
|
|||
theme_a_unfocused_pressed_max :
|
||||
theme_a_unfocused_unpressed_max)));
|
||||
n = self->a_icon;
|
||||
i = (client_focused(self->client) ?
|
||||
i = (self->focused ?
|
||||
(self->iconify_press ?
|
||||
theme_a_focused_pressed_iconify :
|
||||
theme_a_focused_unpressed_iconify) :
|
||||
(self->iconify_press ?
|
||||
theme_a_unfocused_pressed_iconify :
|
||||
theme_a_unfocused_unpressed_iconify));
|
||||
d = (client_focused(self->client) ?
|
||||
d = (self->focused ?
|
||||
(self->client->desktop == DESKTOP_ALL ?
|
||||
theme_a_focused_pressed_set_desk :
|
||||
(self->desk_press ?
|
||||
|
@ -58,7 +57,7 @@ void framerender_frame(Frame *self)
|
|||
(self->desk_press ?
|
||||
theme_a_unfocused_pressed_desk :
|
||||
theme_a_unfocused_unpressed_desk)));
|
||||
s = (client_focused(self->client) ?
|
||||
s = (self->focused ?
|
||||
(self->client->shaded ?
|
||||
theme_a_focused_pressed_set_shade :
|
||||
(self->shade_press ?
|
||||
|
@ -69,7 +68,7 @@ void framerender_frame(Frame *self)
|
|||
(self->shade_press ?
|
||||
theme_a_unfocused_pressed_shade :
|
||||
theme_a_unfocused_unpressed_shade)));
|
||||
c = (client_focused(self->client) ?
|
||||
c = (self->focused ?
|
||||
(self->close_press ?
|
||||
theme_a_focused_pressed_close :
|
||||
theme_a_focused_unpressed_close) :
|
||||
|
@ -120,9 +119,9 @@ void framerender_frame(Frame *self)
|
|||
if (self->client->decorations & Decor_Handle) {
|
||||
Appearance *h, *g;
|
||||
|
||||
h = (client_focused(self->client) ?
|
||||
h = (self->focused ?
|
||||
self->a_focused_handle : self->a_unfocused_handle);
|
||||
g = (client_focused(self->client) ?
|
||||
g = (self->focused ?
|
||||
theme_a_focused_grip : theme_a_unfocused_grip);
|
||||
|
||||
if (g->surface.data.planar.grad == Background_ParentRelative) {
|
||||
|
|
Loading…
Reference in a new issue