supply focus_cycle_draw_indicator which draws/moves/resizes the focus cycling indicator
This commit is contained in:
parent
e69da364cc
commit
ff08e38027
2 changed files with 129 additions and 128 deletions
140
openbox/focus.c
140
openbox/focus.c
|
@ -362,74 +362,19 @@ static void popup_cycle(ObClient *c, gboolean show)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean valid_focus_target(ObClient *ft)
|
||||
void focus_cycle_draw_indicator()
|
||||
{
|
||||
/* we don't use client_can_focus here, because that doesn't let you
|
||||
focus an iconic window, but we want to be able to, so we just check
|
||||
if the focus flags on the window allow it, and its on the current
|
||||
desktop */
|
||||
return (!ft->transients && client_normal(ft) &&
|
||||
((ft->can_focus || ft->focus_notify) &&
|
||||
!ft->skip_taskbar &&
|
||||
(ft->desktop == screen_desktop || ft->desktop == DESKTOP_ALL)));
|
||||
}
|
||||
|
||||
void focus_cycle(gboolean forward, gboolean linear,
|
||||
gboolean dialog, gboolean done, gboolean cancel)
|
||||
{
|
||||
static ObClient *first = NULL;
|
||||
static ObClient *t = NULL;
|
||||
static GList *order = NULL;
|
||||
GList *it, *start, *list;
|
||||
ObClient *ft = NULL;
|
||||
|
||||
if (cancel) {
|
||||
/*
|
||||
if (focus_cycle_target)
|
||||
frame_adjust_focus(focus_cycle_target->frame, FALSE);
|
||||
if (focus_client)
|
||||
frame_adjust_focus(focus_client->frame, TRUE);
|
||||
*/
|
||||
focus_cycle_target = NULL;
|
||||
goto done_cycle;
|
||||
} else if (done && dialog) {
|
||||
goto done_cycle;
|
||||
}
|
||||
|
||||
if (!focus_order[screen_desktop])
|
||||
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_cycle_target);
|
||||
if (!start) /* switched desktops or something? */
|
||||
start = it = forward ? g_list_last(list) : g_list_first(list);
|
||||
if (!start) goto done_cycle;
|
||||
|
||||
do {
|
||||
if (forward) {
|
||||
it = it->next;
|
||||
if (it == NULL) it = g_list_first(list);
|
||||
if (!focus_cycle_target) {
|
||||
XUnmapWindow(ob_display, focus_indicator.top.win);
|
||||
XUnmapWindow(ob_display, focus_indicator.left.win);
|
||||
XUnmapWindow(ob_display, focus_indicator.right.win);
|
||||
XUnmapWindow(ob_display, focus_indicator.bottom.win);
|
||||
} else {
|
||||
it = it->prev;
|
||||
if (it == NULL) it = g_list_last(list);
|
||||
}
|
||||
ft = it->data;
|
||||
if (valid_focus_target(ft)) {
|
||||
if (ft != focus_cycle_target) { /* prevents flicker */
|
||||
/*
|
||||
if (focus_cycle_target)
|
||||
frame_adjust_focus(focus_cycle_target->frame, FALSE);
|
||||
*/
|
||||
focus_cycle_target = ft;
|
||||
/*
|
||||
frame_adjust_focus(focus_cycle_target->frame, TRUE);
|
||||
*/
|
||||
{
|
||||
int x, y, w, h;
|
||||
int wt, wl, wr, wb;
|
||||
|
||||
|
@ -542,11 +487,70 @@ void focus_cycle(gboolean forward, gboolean linear,
|
|||
w, h);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean valid_focus_target(ObClient *ft)
|
||||
{
|
||||
/* we don't use client_can_focus here, because that doesn't let you
|
||||
focus an iconic window, but we want to be able to, so we just check
|
||||
if the focus flags on the window allow it, and its on the current
|
||||
desktop */
|
||||
return (!ft->transients && client_normal(ft) &&
|
||||
((ft->can_focus || ft->focus_notify) &&
|
||||
!ft->skip_taskbar &&
|
||||
(ft->desktop == screen_desktop || ft->desktop == DESKTOP_ALL)));
|
||||
}
|
||||
|
||||
void focus_cycle(gboolean forward, gboolean linear,
|
||||
gboolean dialog, gboolean done, gboolean cancel)
|
||||
{
|
||||
static ObClient *first = NULL;
|
||||
static ObClient *t = NULL;
|
||||
static GList *order = NULL;
|
||||
GList *it, *start, *list;
|
||||
ObClient *ft = NULL;
|
||||
|
||||
if (cancel) {
|
||||
/*
|
||||
if (focus_cycle_target)
|
||||
frame_adjust_focus(focus_cycle_target->frame, FALSE);
|
||||
if (focus_client)
|
||||
frame_adjust_focus(focus_client->frame, TRUE);
|
||||
*/
|
||||
focus_cycle_target = NULL;
|
||||
goto done_cycle;
|
||||
} else if (done && dialog) {
|
||||
goto done_cycle;
|
||||
}
|
||||
|
||||
if (!focus_order[screen_desktop])
|
||||
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_cycle_target);
|
||||
if (!start) /* switched desktops or something? */
|
||||
start = it = forward ? g_list_last(list) : g_list_first(list);
|
||||
if (!start) goto done_cycle;
|
||||
|
||||
do {
|
||||
if (forward) {
|
||||
it = it->next;
|
||||
if (it == NULL) it = g_list_first(list);
|
||||
} else {
|
||||
it = it->prev;
|
||||
if (it == NULL) it = g_list_last(list);
|
||||
}
|
||||
ft = it->data;
|
||||
if (valid_focus_target(ft)) {
|
||||
if (ft != focus_cycle_target) { /* prevents flicker */
|
||||
focus_cycle_target = ft;
|
||||
focus_cycle_draw_indicator();
|
||||
}
|
||||
popup_cycle(ft, dialog);
|
||||
XMapWindow(ob_display, focus_indicator.top.win);
|
||||
XMapWindow(ob_display, focus_indicator.left.win);
|
||||
XMapWindow(ob_display, focus_indicator.right.win);
|
||||
XMapWindow(ob_display, focus_indicator.bottom.win);
|
||||
return;
|
||||
}
|
||||
} while (it != start);
|
||||
|
@ -555,17 +559,13 @@ done_cycle:
|
|||
if (done && focus_cycle_target)
|
||||
client_activate(focus_cycle_target, FALSE);
|
||||
|
||||
XUnmapWindow(ob_display, focus_indicator.top.win);
|
||||
XUnmapWindow(ob_display, focus_indicator.left.win);
|
||||
XUnmapWindow(ob_display, focus_indicator.right.win);
|
||||
XUnmapWindow(ob_display, focus_indicator.bottom.win);
|
||||
|
||||
t = NULL;
|
||||
first = NULL;
|
||||
focus_cycle_target = NULL;
|
||||
g_list_free(order);
|
||||
order = NULL;
|
||||
|
||||
focus_cycle_draw_indicator();
|
||||
popup_cycle(ft, FALSE);
|
||||
|
||||
return;
|
||||
|
|
|
@ -61,6 +61,7 @@ void focus_cycle(gboolean forward, gboolean linear,
|
|||
gboolean dialog, gboolean done, gboolean cancel);
|
||||
void focus_directional_cycle(ObDirection dir,
|
||||
gboolean dialog, gboolean done, gboolean cancel);
|
||||
void focus_cycle_draw_indicator();
|
||||
|
||||
/*! Add a new client into the focus order */
|
||||
void focus_order_add_new(struct _ObClient *c);
|
||||
|
|
Loading…
Reference in a new issue