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
|
if (!focus_cycle_target) {
|
||||||
focus an iconic window, but we want to be able to, so we just check
|
XUnmapWindow(ob_display, focus_indicator.top.win);
|
||||||
if the focus flags on the window allow it, and its on the current
|
XUnmapWindow(ob_display, focus_indicator.left.win);
|
||||||
desktop */
|
XUnmapWindow(ob_display, focus_indicator.right.win);
|
||||||
return (!ft->transients && client_normal(ft) &&
|
XUnmapWindow(ob_display, focus_indicator.bottom.win);
|
||||||
((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 {
|
} 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)
|
if (focus_cycle_target)
|
||||||
frame_adjust_focus(focus_cycle_target->frame, FALSE);
|
frame_adjust_focus(focus_cycle_target->frame, FALSE);
|
||||||
*/
|
|
||||||
focus_cycle_target = ft;
|
|
||||||
/*
|
|
||||||
frame_adjust_focus(focus_cycle_target->frame, TRUE);
|
frame_adjust_focus(focus_cycle_target->frame, TRUE);
|
||||||
*/
|
*/
|
||||||
{
|
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
int wt, wl, wr, wb;
|
int wt, wl, wr, wb;
|
||||||
|
|
||||||
|
@ -541,12 +486,71 @@ void focus_cycle(gboolean forward, gboolean linear,
|
||||||
RrPaint(a_focus_indicator, focus_indicator.bottom.win,
|
RrPaint(a_focus_indicator, focus_indicator.bottom.win,
|
||||||
w, h);
|
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);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
} while (it != start);
|
} while (it != start);
|
||||||
|
@ -555,17 +559,13 @@ done_cycle:
|
||||||
if (done && focus_cycle_target)
|
if (done && focus_cycle_target)
|
||||||
client_activate(focus_cycle_target, FALSE);
|
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;
|
t = NULL;
|
||||||
first = NULL;
|
first = NULL;
|
||||||
focus_cycle_target = NULL;
|
focus_cycle_target = NULL;
|
||||||
g_list_free(order);
|
g_list_free(order);
|
||||||
order = NULL;
|
order = NULL;
|
||||||
|
|
||||||
|
focus_cycle_draw_indicator();
|
||||||
popup_cycle(ft, FALSE);
|
popup_cycle(ft, FALSE);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -61,6 +61,7 @@ void focus_cycle(gboolean forward, gboolean linear,
|
||||||
gboolean dialog, gboolean done, gboolean cancel);
|
gboolean dialog, gboolean done, gboolean cancel);
|
||||||
void focus_directional_cycle(ObDirection dir,
|
void focus_directional_cycle(ObDirection dir,
|
||||||
gboolean dialog, gboolean done, gboolean cancel);
|
gboolean dialog, gboolean done, gboolean cancel);
|
||||||
|
void focus_cycle_draw_indicator();
|
||||||
|
|
||||||
/*! Add a new client into the focus order */
|
/*! Add a new client into the focus order */
|
||||||
void focus_order_add_new(struct _ObClient *c);
|
void focus_order_add_new(struct _ObClient *c);
|
||||||
|
|
Loading…
Reference in a new issue