X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Faction.c;h=8c8064f89a21ab86acc5f145efbcdb6f981e9558;hb=6171dbf970c2c4f8d9736a8ae5184eb9ac38d7ce;hp=c106ead97b6c81a254a7e7ec74acd11569a844fc;hpb=a3f8c5c45a1ff323fc088cc5af49ab48d5679e54;p=chaz%2Fopenbox diff --git a/openbox/action.c b/openbox/action.c index c106ead9..8c8064f8 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -48,8 +48,21 @@ inline void client_action_start(union ActionData *data) inline void client_action_end(union ActionData *data) { if (config_focus_follow) - if (data->any.context != OB_FRAME_CONTEXT_CLIENT && !data->any.button) - grab_pointer(FALSE, FALSE, OB_CURSOR_NONE); + if (data->any.context != OB_FRAME_CONTEXT_CLIENT) { + if (!data->any.button) { + grab_pointer(FALSE, FALSE, OB_CURSOR_NONE); + } else { + ObClient *c; + + /* usually this is sorta redundant, but with a press action + that moves windows our from under the cursor, the enter + event will come as a GrabNotify which is ignored, so this + makes a fake enter event + */ + if ((c = client_under_pointer())) + event_enter_client(c); + } + } } typedef struct @@ -109,6 +122,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 +131,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 +140,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 +149,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 +158,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 +167,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 +176,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 +185,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 +314,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 +325,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; } @@ -407,21 +430,21 @@ void setup_action_bottom_layer(ObAction **a, ObUserAction uact) void setup_action_move(ObAction **a, ObUserAction uact) { (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS; - (*a)->data.moveresize.move = TRUE; (*a)->data.moveresize.keyboard = (uact == OB_USER_ACTION_NONE || uact == OB_USER_ACTION_KEYBOARD_KEY || uact == OB_USER_ACTION_MENU_SELECTION); + (*a)->data.moveresize.corner = 0; } void setup_action_resize(ObAction **a, ObUserAction uact) { (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS; - (*a)->data.moveresize.move = FALSE; (*a)->data.moveresize.keyboard = (uact == OB_USER_ACTION_NONE || uact == OB_USER_ACTION_KEYBOARD_KEY || uact == OB_USER_ACTION_MENU_SELECTION); + (*a)->data.moveresize.corner = 0; } void setup_action_showmenu(ObAction **a, ObUserAction uact) @@ -735,12 +758,12 @@ ActionString actionstrings[] = }, { "move", - action_moveresize, + action_move, setup_action_move }, { "resize", - action_moveresize, + action_resize, setup_action_resize }, { @@ -1011,6 +1034,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 +1044,38 @@ 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_resize) { + if ((n = parse_find_node("edge", node->xmlChildrenNode))) { + gchar *s = parse_string(doc, n); + if (!g_ascii_strcasecmp(s, "top")) + act->data.moveresize.corner = + prop_atoms.net_wm_moveresize_size_top; + else if (!g_ascii_strcasecmp(s, "bottom")) + act->data.moveresize.corner = + prop_atoms.net_wm_moveresize_size_bottom; + else if (!g_ascii_strcasecmp(s, "left")) + act->data.moveresize.corner = + prop_atoms.net_wm_moveresize_size_left; + else if (!g_ascii_strcasecmp(s, "right")) + act->data.moveresize.corner = + prop_atoms.net_wm_moveresize_size_right; + else if (!g_ascii_strcasecmp(s, "topleft")) + act->data.moveresize.corner = + prop_atoms.net_wm_moveresize_size_topleft; + else if (!g_ascii_strcasecmp(s, "topright")) + act->data.moveresize.corner = + prop_atoms.net_wm_moveresize_size_topright; + else if (!g_ascii_strcasecmp(s, "bottomleft")) + act->data.moveresize.corner = + prop_atoms.net_wm_moveresize_size_bottomleft; + else if (!g_ascii_strcasecmp(s, "bottomright")) + act->data.moveresize.corner = + prop_atoms.net_wm_moveresize_size_bottomright; + g_free(s); + } } else if (act->func == action_raise || act->func == action_lower || act->func == action_raiselower || @@ -1057,12 +1114,20 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context, } } - if (!inter) { - /* sometimes when we execute another app as an action, - it won't work right unless we XUngrabKeyboard first, - even though we grabbed the key/button Asychronously. - e.g. "gnome-panel-control --main-menu" */ - grab_keyboard(FALSE); + if (!inter && button == 0) { + /* Ungrab the keyboard before running the action, if it was + not from a mouse event. + + We have to do this because a key press causes a passive + grab on the keyboard, and so if the action we are running + wants to grab the keyboard, it will fail if the button is still + held down (which is likely). + + Use the X function not out own, because we're not considering + a grab to be in place at all so our function won't try ungrab + anything. + */ + XUngrabKeyboard(ob_display, time); } for (it = acts; it; it = g_slist_next(it)) { @@ -1089,11 +1154,14 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context, /* XXX UGLY HACK race with motion event starting a move and the button release gettnig processed first. answer: don't queue moveresize starts. UGLY HACK XXX */ - if (a->data.any.interactive || a->func == action_moveresize) { + if (a->data.any.interactive || a->func == action_move || + a->func == action_resize) + { /* interactive actions are not queued */ a->func(&a->data); - } else if ((context == OB_FRAME_CONTEXT_CLIENT || - (c && c->type == OB_CLIENT_TYPE_DESKTOP && + } else if (c && + (context == OB_FRAME_CONTEXT_CLIENT || + (c->type == OB_CLIENT_TYPE_DESKTOP && context == OB_FRAME_CONTEXT_DESKTOP)) && (a->func == action_focus || a->func == action_activate || @@ -1200,7 +1268,8 @@ void action_activate(union ActionData *data) { if (data->client.any.c) { if (!data->any.button || client_mouse_focusable(data->client.any.c) || - data->any.context != OB_FRAME_CONTEXT_CLIENT) + (data->any.context != OB_FRAME_CONTEXT_CLIENT && + data->any.context != OB_FRAME_CONTEXT_FRAME)) { /* if using focus_delay, stop the timer now so that focus doesn't go moving on us */ @@ -1220,7 +1289,8 @@ void action_focus(union ActionData *data) { if (data->client.any.c) { if (!data->any.button || client_mouse_focusable(data->client.any.c) || - data->any.context != OB_FRAME_CONTEXT_CLIENT) + (data->any.context != OB_FRAME_CONTEXT_CLIENT && + data->any.context != OB_FRAME_CONTEXT_FRAME)) { /* if using focus_delay, stop the timer now so that focus doesn't go moving on us */ @@ -1239,13 +1309,13 @@ void action_focus(union ActionData *data) void action_unfocus (union ActionData *data) { if (data->client.any.c == focus_client) - focus_fallback(FALSE); + focus_fallback(TRUE); } void action_iconify(union ActionData *data) { client_action_start(data); - client_iconify(data->client.any.c, TRUE, TRUE); + client_iconify(data->client.any.c, TRUE, TRUE, FALSE); client_action_end(data); } @@ -1531,9 +1601,7 @@ void action_desktop(union ActionData *data) if (data->inter.any.interactive) screen_desktop_popup(data->desktop.desk, TRUE); } - } - - if (!data->inter.any.interactive || data->inter.final) + } else screen_desktop_popup(0, FALSE); } @@ -1547,11 +1615,13 @@ void action_desktop_dir(union ActionData *data) data->desktopdir.inter.any.interactive, data->desktopdir.inter.final, data->desktopdir.inter.cancel); + /* only move the desktop when the action is complete. if we switch + desktops during the interactive action, focus will move but with + NotifyWhileGrabbed and applications don't like that. */ if (!data->sendtodir.inter.any.interactive || - !data->sendtodir.inter.final || - data->sendtodir.inter.cancel) + (data->sendtodir.inter.final && !data->sendtodir.inter.cancel)) { - screen_set_desktop(d, TRUE); + if (d != screen_desktop) screen_set_desktop(d, TRUE); } } @@ -1567,12 +1637,14 @@ void action_send_to_desktop_dir(union ActionData *data) data->sendtodir.inter.any.interactive, data->sendtodir.inter.final, data->sendtodir.inter.cancel); + /* only move the desktop when the action is complete. if we switch + desktops during the interactive action, focus will move but with + NotifyWhileGrabbed and applications don't like that. */ if (!data->sendtodir.inter.any.interactive || - !data->sendtodir.inter.final || - data->sendtodir.inter.cancel) + (data->sendtodir.inter.final && !data->sendtodir.inter.cancel)) { client_set_desktop(c, d, data->sendtodir.follow); - if (data->sendtodir.follow) + if (data->sendtodir.follow && d != screen_desktop) screen_set_desktop(d, TRUE); } } @@ -1591,7 +1663,8 @@ void action_toggle_decorations(union ActionData *data) client_action_end(data); } -static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch) +static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch, + gboolean shaded) { /* let's make x and y client relative instead of screen relative */ x = x - cx; @@ -1631,11 +1704,11 @@ static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch) |CCCCCCC | A B | DDDDDDD| | CCCCCCCC | A | | B | DDDDDDDD | | CCCCCCC A B DDDDDDD | - - - - - - - - - - - - +CCCCCCC+aaaaaaa+DDDDDDD+ - - - - - - - - - - - - | | b c | | - | west | b move c | east | - | | b c | | - - - - - - - - - - - - +EEEEEEE+ddddddd+FFFFFFF+- - - - - - - - - - - + - - - - - - - - - - - +CCCCCCC+aaaaaaa+DDDDDDD+ - - - - - - - - - - - - + | | b c | | sh + | west | b move c | east | ad + | | b c | | ed + - - - - - - - - - - - +EEEEEEE+ddddddd+FFFFFFF+- - - - - - - - - - - - | EEEEEEE G H FFFFFFF | | EEEEEEEE | G | | H | FFFFFFFF | |EEEEEEE | G H | FFFFFFF| @@ -1652,6 +1725,15 @@ static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch) +---------------------G-------|-------|-------H---------------------+ */ + if (shaded) { + /* for shaded windows, you can only resize west/east and move */ + if (b) + return prop_atoms.net_wm_moveresize_size_left; + if (c) + return prop_atoms.net_wm_moveresize_size_right; + return prop_atoms.net_wm_moveresize_move; + } + if (y < A && y >= C) return prop_atoms.net_wm_moveresize_size_topleft; else if (y >= A && y >= B && a) @@ -1686,31 +1768,39 @@ static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch) #undef d } -void action_moveresize(union ActionData *data) +void action_move(union ActionData *data) { ObClient *c = data->moveresize.any.c; guint32 corner; - if (!client_normal(c)) return; + if (data->moveresize.keyboard) + corner = prop_atoms.net_wm_moveresize_move_keyboard; + else + corner = prop_atoms.net_wm_moveresize_move; - if (data->moveresize.keyboard) { - corner = (data->moveresize.move ? - prop_atoms.net_wm_moveresize_move_keyboard : - prop_atoms.net_wm_moveresize_size_keyboard); - } else { - corner = (data->moveresize.move ? - prop_atoms.net_wm_moveresize_move : - pick_corner(data->any.x, data->any.y, - c->frame->area.x, c->frame->area.y, - /* use the client size because the frame - can be differently sized (shaded - windows) and we want this based on the - clients size */ - c->area.width + c->frame->size.left + - c->frame->size.right, - c->area.height + c->frame->size.top + - c->frame->size.bottom)); - } + moveresize_start(c, data->any.x, data->any.y, data->any.button, corner); +} + +void action_resize(union ActionData *data) +{ + ObClient *c = data->moveresize.any.c; + guint32 corner; + + if (data->moveresize.keyboard) + corner = prop_atoms.net_wm_moveresize_size_keyboard; + else if (data->moveresize.corner) + corner = data->moveresize.corner; /* it was specified in the binding */ + else + corner = pick_corner(data->any.x, data->any.y, + c->frame->area.x, c->frame->area.y, + /* use the client size because the frame + can be differently sized (shaded + windows) and we want this based on the + clients size */ + c->area.width + c->frame->size.left + + c->frame->size.right, + c->area.height + c->frame->size.top + + c->frame->size.bottom, c->shaded); moveresize_start(c, data->any.x, data->any.y, data->any.button, corner); } @@ -1747,6 +1837,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); @@ -1760,6 +1851,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, @@ -1896,17 +1988,17 @@ void action_toggle_dockautohide(union ActionData *data) void action_toggle_show_desktop(union ActionData *data) { - screen_show_desktop(!screen_showing_desktop, TRUE); + screen_show_desktop(!screen_showing_desktop, NULL); } void action_show_desktop(union ActionData *data) { - screen_show_desktop(TRUE, TRUE); + screen_show_desktop(TRUE, NULL); } void action_unshow_desktop(union ActionData *data) { - screen_show_desktop(FALSE, TRUE); + screen_show_desktop(FALSE, NULL); } void action_break_chroot(union ActionData *data)