add <desktop>yes</desktop> option for Next/Previous window and directional focus actions

This commit is contained in:
Dana Jansens 2007-05-12 17:16:01 +00:00
parent d3ecb7c127
commit 1d1aef75a0
4 changed files with 56 additions and 23 deletions

View file

@ -109,6 +109,7 @@ void setup_action_directional_focus_north(ObAction **a, ObUserAction uact)
(*a)->data.interdiraction.direction = OB_DIRECTION_NORTH;
(*a)->data.interdiraction.dialog = TRUE;
(*a)->data.interdiraction.dock_windows = FALSE;
(*a)->data.interdiraction.desktop_windows = FALSE;
}
void setup_action_directional_focus_east(ObAction **a, ObUserAction uact)
@ -117,6 +118,7 @@ void setup_action_directional_focus_east(ObAction **a, ObUserAction uact)
(*a)->data.interdiraction.direction = OB_DIRECTION_EAST;
(*a)->data.interdiraction.dialog = TRUE;
(*a)->data.interdiraction.dock_windows = FALSE;
(*a)->data.interdiraction.desktop_windows = FALSE;
}
void setup_action_directional_focus_south(ObAction **a, ObUserAction uact)
@ -125,6 +127,7 @@ void setup_action_directional_focus_south(ObAction **a, ObUserAction uact)
(*a)->data.interdiraction.direction = OB_DIRECTION_SOUTH;
(*a)->data.interdiraction.dialog = TRUE;
(*a)->data.interdiraction.dock_windows = FALSE;
(*a)->data.interdiraction.desktop_windows = FALSE;
}
void setup_action_directional_focus_west(ObAction **a, ObUserAction uact)
@ -133,6 +136,7 @@ void setup_action_directional_focus_west(ObAction **a, ObUserAction uact)
(*a)->data.interdiraction.direction = OB_DIRECTION_WEST;
(*a)->data.interdiraction.dialog = TRUE;
(*a)->data.interdiraction.dock_windows = FALSE;
(*a)->data.interdiraction.desktop_windows = FALSE;
}
void setup_action_directional_focus_northeast(ObAction **a, ObUserAction uact)
@ -141,6 +145,7 @@ void setup_action_directional_focus_northeast(ObAction **a, ObUserAction uact)
(*a)->data.interdiraction.direction = OB_DIRECTION_NORTHEAST;
(*a)->data.interdiraction.dialog = TRUE;
(*a)->data.interdiraction.dock_windows = FALSE;
(*a)->data.interdiraction.desktop_windows = FALSE;
}
void setup_action_directional_focus_southeast(ObAction **a, ObUserAction uact)
@ -149,6 +154,7 @@ void setup_action_directional_focus_southeast(ObAction **a, ObUserAction uact)
(*a)->data.interdiraction.direction = OB_DIRECTION_SOUTHEAST;
(*a)->data.interdiraction.dialog = TRUE;
(*a)->data.interdiraction.dock_windows = FALSE;
(*a)->data.interdiraction.desktop_windows = FALSE;
}
void setup_action_directional_focus_southwest(ObAction **a, ObUserAction uact)
@ -157,6 +163,7 @@ void setup_action_directional_focus_southwest(ObAction **a, ObUserAction uact)
(*a)->data.interdiraction.direction = OB_DIRECTION_SOUTHWEST;
(*a)->data.interdiraction.dialog = TRUE;
(*a)->data.interdiraction.dock_windows = FALSE;
(*a)->data.interdiraction.desktop_windows = FALSE;
}
void setup_action_directional_focus_northwest(ObAction **a, ObUserAction uact)
@ -165,6 +172,7 @@ void setup_action_directional_focus_northwest(ObAction **a, ObUserAction uact)
(*a)->data.interdiraction.direction = OB_DIRECTION_NORTHWEST;
(*a)->data.interdiraction.dialog = TRUE;
(*a)->data.interdiraction.dock_windows = FALSE;
(*a)->data.interdiraction.desktop_windows = FALSE;
}
void setup_action_send_to_desktop(ObAction **a, ObUserAction uact)
@ -293,6 +301,7 @@ void setup_action_cycle_windows_next(ObAction **a, ObUserAction uact)
(*a)->data.cycle.forward = TRUE;
(*a)->data.cycle.dialog = TRUE;
(*a)->data.cycle.dock_windows = FALSE;
(*a)->data.cycle.desktop_windows = FALSE;
(*a)->data.cycle.all_desktops = FALSE;
}
@ -303,6 +312,7 @@ void setup_action_cycle_windows_previous(ObAction **a, ObUserAction uact)
(*a)->data.cycle.forward = FALSE;
(*a)->data.cycle.dialog = TRUE;
(*a)->data.cycle.dock_windows = FALSE;
(*a)->data.cycle.desktop_windows = FALSE;
(*a)->data.cycle.all_desktops = FALSE;
}
@ -1011,6 +1021,8 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
act->data.cycle.dialog = parse_bool(doc, n);
if ((n = parse_find_node("panels", node->xmlChildrenNode)))
act->data.cycle.dock_windows = parse_bool(doc, n);
if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
act->data.cycle.desktop_windows = parse_bool(doc, n);
if ((n = parse_find_node("allDesktops",
node->xmlChildrenNode)))
act->data.cycle.all_desktops = parse_bool(doc, n);
@ -1019,6 +1031,9 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
act->data.interdiraction.dialog = parse_bool(doc, n);
if ((n = parse_find_node("panels", node->xmlChildrenNode)))
act->data.interdiraction.dock_windows = parse_bool(doc, n);
if ((n = parse_find_node("desktop", node->xmlChildrenNode)))
act->data.interdiraction.desktop_windows =
parse_bool(doc, n);
} else if (act->func == action_raise ||
act->func == action_lower ||
act->func == action_raiselower ||
@ -1757,6 +1772,7 @@ void action_cycle_windows(union ActionData *data)
focus_cycle(data->cycle.forward,
data->cycle.all_desktops,
data->cycle.dock_windows,
data->cycle.desktop_windows,
data->cycle.linear, data->any.interactive,
data->cycle.dialog,
data->cycle.inter.final, data->cycle.inter.cancel);
@ -1770,6 +1786,7 @@ void action_directional_focus(union ActionData *data)
focus_directional_cycle(data->interdiraction.direction,
data->interdiraction.dock_windows,
data->interdiraction.desktop_windows,
data->any.interactive,
data->interdiraction.dialog,
data->interdiraction.inter.final,

View file

@ -62,6 +62,7 @@ struct InterDirectionalAction{
ObDirection direction;
gboolean dialog;
gboolean dock_windows;
gboolean desktop_windows;
};
struct DirectionalAction{
@ -143,6 +144,7 @@ struct CycleWindows {
gboolean forward;
gboolean dialog;
gboolean dock_windows;
gboolean desktop_windows;
gboolean all_desktops;
};

View file

@ -57,7 +57,8 @@ static ObIconPopup *focus_cycle_popup;
static gboolean valid_focus_target(ObClient *ft,
gboolean all_desktops,
gboolean dock_windows);
gboolean dock_windows,
gboolean desktop_windows);
static void focus_cycle_destructor(ObClient *client, gpointer data);
static Window createWindow(Window parent, gulong mask,
@ -166,7 +167,7 @@ void focus_set_client(ObClient *client)
be used.
*/
if (focus_cycle_target)
focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
focus_client = client;
@ -323,7 +324,8 @@ static gchar *popup_get_name(ObClient *c, ObClient **nametarget)
}
static void popup_cycle(ObClient *c, gboolean show,
gboolean all_desktops, gboolean dock_windows)
gboolean all_desktops, gboolean dock_windows,
gboolean desktop_windows)
{
gchar *showtext = NULL;
ObClient *showtarget;
@ -357,7 +359,9 @@ static void popup_cycle(ObClient *c, gboolean show,
/* build a list of all the valid focus targets */
for (it = focus_order; it; it = g_list_next(it)) {
ObClient *ft = it->data;
if (valid_focus_target(ft, all_desktops, dock_windows)) {
if (valid_focus_target(ft, all_desktops, dock_windows
, desktop_windows))
{
targets = g_list_prepend(targets, ft);
++n;
}
@ -394,7 +398,7 @@ static void focus_cycle_destructor(ObClient *client, gpointer data)
be used
*/
if (focus_cycle_target == client)
focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
}
void focus_cycle_draw_indicator()
@ -543,7 +547,7 @@ static gboolean has_valid_group_siblings_on_desktop(ObClient *ft,
ObClient *c = it->data;
/* check that it's not a helper window to avoid infinite recursion */
if (c != ft && !client_helper(c) &&
valid_focus_target(c, all_desktops, FALSE))
valid_focus_target(c, all_desktops, FALSE, FALSE))
{
return TRUE;
}
@ -555,7 +559,8 @@ static gboolean has_valid_group_siblings_on_desktop(ObClient *ft,
checking helper windows. */
static gboolean valid_focus_target(ObClient *ft,
gboolean all_desktops,
gboolean dock_windows)
gboolean dock_windows,
gboolean desktop_windows)
{
gboolean ok = FALSE;
@ -570,8 +575,9 @@ static gboolean valid_focus_target(ObClient *ft,
ok = ok && (ft->can_focus || ft->focus_notify);
/* it's the right type of window */
if (dock_windows)
ok = ok && ft->type == OB_CLIENT_TYPE_DOCK;
if (dock_windows || desktop_windows)
ok = ok && ((dock_windows && ft->type == OB_CLIENT_TYPE_DOCK) ||
(desktop_windows && ft->type == OB_CLIENT_TYPE_DESKTOP));
else
/* normal non-helper windows are valid targets */
ok = ok &&
@ -600,7 +606,7 @@ static gboolean valid_focus_target(ObClient *ft,
}
void focus_cycle(gboolean forward, gboolean all_desktops,
gboolean dock_windows,
gboolean dock_windows, gboolean desktop_windows,
gboolean linear, gboolean interactive,
gboolean dialog, gboolean done, gboolean cancel)
{
@ -645,14 +651,17 @@ void focus_cycle(gboolean forward, gboolean all_desktops,
if (it == NULL) it = g_list_last(list);
}
ft = it->data;
if (valid_focus_target(ft, all_desktops, dock_windows)) {
if (valid_focus_target(ft, all_desktops, dock_windows,
desktop_windows))
{
if (interactive) {
if (ft != focus_cycle_target) { /* prevents flicker */
focus_cycle_target = ft;
focus_cycle_draw_indicator();
}
/* same arguments as valid_focus_target */
popup_cycle(ft, dialog, all_desktops, dock_windows);
popup_cycle(ft, dialog, all_desktops, dock_windows,
desktop_windows);
return;
} else if (ft != focus_cycle_target) {
focus_cycle_target = ft;
@ -674,7 +683,7 @@ done_cycle:
if (interactive) {
focus_cycle_draw_indicator();
popup_cycle(ft, FALSE, FALSE, FALSE);
popup_cycle(ft, FALSE, FALSE, FALSE, FALSE);
}
return;
@ -682,7 +691,8 @@ done_cycle:
/* this be mostly ripped from fvwm */
static ObClient *focus_find_directional(ObClient *c, ObDirection dir,
gboolean dock_windows)
gboolean dock_windows,
gboolean desktop_windows)
{
gint my_cx, my_cy, his_cx, his_cy;
gint offset = 0;
@ -707,9 +717,10 @@ static ObClient *focus_find_directional(ObClient *c, ObDirection dir,
/* the currently selected window isn't interesting */
if(cur == c)
continue;
if (!dock_windows && !client_normal(cur))
if (!dock_windows && !desktop_windows && !client_normal(cur))
continue;
if (dock_windows && cur->type != OB_CLIENT_TYPE_DOCK)
if (!(dock_windows && cur->type == OB_CLIENT_TYPE_DOCK) ||
(desktop_windows && cur->type == OB_CLIENT_TYPE_DESKTOP))
continue;
/* using c->desktop instead of screen_desktop doesn't work if the
* current window was omnipresent, hope this doesn't have any other
@ -785,7 +796,7 @@ static ObClient *focus_find_directional(ObClient *c, ObDirection dir,
}
void focus_directional_cycle(ObDirection dir, gboolean dock_windows,
gboolean interactive,
gboolean desktop_windows, gboolean interactive,
gboolean dialog, gboolean done, gboolean cancel)
{
static ObClient *first = NULL;
@ -807,12 +818,14 @@ void focus_directional_cycle(ObDirection dir, gboolean dock_windows,
if (!focus_cycle_target) focus_cycle_target = focus_client;
if (focus_cycle_target)
ft = focus_find_directional(focus_cycle_target, dir, dock_windows);
ft = focus_find_directional(focus_cycle_target, dir, dock_windows,
desktop_windows);
else {
GList *it;
for (it = focus_order; it; it = g_list_next(it))
if (valid_focus_target(it->data, FALSE, dock_windows))
if (valid_focus_target(it->data, FALSE, dock_windows,
desktop_windows))
ft = it->data;
}
@ -824,7 +837,8 @@ void focus_directional_cycle(ObDirection dir, gboolean dock_windows,
}
if (focus_cycle_target) {
/* same arguments as valid_focus_target */
popup_cycle(focus_cycle_target, dialog, FALSE, dock_windows);
popup_cycle(focus_cycle_target, dialog, FALSE, dock_windows,
desktop_windows);
if (dialog)
return;
}
@ -838,7 +852,7 @@ done_cycle:
focus_cycle_target = NULL;
focus_cycle_draw_indicator();
popup_cycle(ft, FALSE, FALSE, FALSE);
popup_cycle(ft, FALSE, FALSE, FALSE, FALSE);
return;
}

View file

@ -53,11 +53,11 @@ struct _ObClient* focus_fallback(gboolean allow_refocus);
/*! Cycle focus amongst windows. */
void focus_cycle(gboolean forward, gboolean all_desktops,
gboolean dock_windows,
gboolean dock_windows, gboolean desktop_windows,
gboolean linear, gboolean interactive,
gboolean dialog, gboolean done, gboolean cancel);
void focus_directional_cycle(ObDirection dir, gboolean dock_windows,
gboolean interactive,
gboolean desktop_windows, gboolean interactive,
gboolean dialog, gboolean done, gboolean cancel);
void focus_cycle_draw_indicator();