From: Dana Jansens Date: Sun, 21 Sep 2003 19:38:57 +0000 (+0000) Subject: grab the pointer before doing client actions more intelligently, i.e. only when using... X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=904327a0c8ef2e1ee6cb3053d786c30f4693d8f3;p=chaz%2Fopenbox grab the pointer before doing client actions more intelligently, i.e. only when using sloppy focus. fallback focus after the action if the action was fired via a mouse binding, otherwise do not. this makes keyboard bindings not fuck with sloppy focus. --- diff --git a/openbox/action.c b/openbox/action.c index 441b9395..0e4d570f 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -29,9 +29,20 @@ #include "grab.h" #include "keyboard.h" #include "event.h" +#include "config.h" #include +#define ACT_START(d) \ + ((d->any.context != OB_FRAME_CONTEXT_CLIENT && config_focus_follow) ? \ + grab_pointer(TRUE, OB_CURSOR_NONE), 0 : 0) + +#define ACT_END(d) \ + ((d->any.context != OB_FRAME_CONTEXT_CLIENT && config_focus_follow) ? \ + grab_pointer(FALSE, OB_CURSOR_NONE), \ + (d->any.button ? focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS), 1 : 0) : \ + 0) + typedef struct ActionString { const gchar *name; void (*func)(union ActionData *); @@ -785,7 +796,7 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, return act; } -void action_run_list(GSList *acts, ObClient *c, +void action_run_list(GSList *acts, ObClient *c, ObFrameContext context, guint state, guint button, gint x, gint y, gboolean cancel, gboolean done) { @@ -822,6 +833,7 @@ void action_run_list(GSList *acts, ObClient *c, a = it->data; a->data.any.c = c; + a->data.any.context = context; a->data.any.x = x; a->data.any.y = y; @@ -903,27 +915,38 @@ void action_raiselower(union ActionData *data) } } - if (raise) + if (raise) { + ACT_START(data); stacking_raise(CLIENT_AS_WINDOW(c)); - else + ACT_END(data); + } else { + ACT_START(data); stacking_lower(CLIENT_AS_WINDOW(c)); + ACT_END(data); + } } void action_raise(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); stacking_raise(CLIENT_AS_WINDOW(data->client.any.c)); + ACT_END(data); + } } void action_unshaderaise(union ActionData *data) { if (data->client.any.c) { if (data->client.any.c->shaded) { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_shade(data->client.any.c, FALSE); - grab_pointer(FALSE, OB_CURSOR_NONE); - } else + ACT_END(data); + } else { + ACT_START(data); stacking_raise(CLIENT_AS_WINDOW(data->client.any.c)); + ACT_END(data); + } } } @@ -933,17 +956,20 @@ void action_shadelower(union ActionData *data) if (data->client.any.c->shaded) stacking_lower(CLIENT_AS_WINDOW(data->client.any.c)); else { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_shade(data->client.any.c, TRUE); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } } } void action_lower(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); stacking_lower(CLIENT_AS_WINDOW(data->client.any.c)); + ACT_END(data); + } } void action_close(union ActionData *data) @@ -961,27 +987,27 @@ void action_kill(union ActionData *data) void action_shade(union ActionData *data) { if (data->client.any.c) { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_shade(data->client.any.c, TRUE); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } } void action_unshade(union ActionData *data) { if (data->client.any.c) { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_shade(data->client.any.c, FALSE); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } } void action_toggle_shade(union ActionData *data) { if (data->client.any.c) { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_shade(data->client.any.c, !data->client.any.c->shaded); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } } @@ -997,9 +1023,9 @@ void action_move_relative_horz(union ActionData *data) { ObClient *c = data->relative.any.c; if (c) { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_move(c, c->area.x + data->relative.delta, c->area.y); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } } @@ -1007,9 +1033,9 @@ void action_move_relative_vert(union ActionData *data) { ObClient *c = data->relative.any.c; if (c) { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_move(c, c->area.x, c->area.y + data->relative.delta); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } } @@ -1017,11 +1043,11 @@ void action_resize_relative_horz(union ActionData *data) { ObClient *c = data->relative.any.c; if (c) { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_resize(c, c->area.width + data->relative.delta * c->size_inc.width, c->area.height); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } } @@ -1029,69 +1055,97 @@ void action_resize_relative_vert(union ActionData *data) { ObClient *c = data->relative.any.c; if (c && !c->shaded) { - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_resize(c, c->area.width, c->area.height + data->relative.delta * c->size_inc.height); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } } void action_maximize_full(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); client_maximize(data->client.any.c, TRUE, 0, TRUE); + ACT_END(data); + } } void action_unmaximize_full(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); client_maximize(data->client.any.c, FALSE, 0, TRUE); + ACT_END(data); + } } void action_toggle_maximize_full(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); client_maximize(data->client.any.c, !(data->client.any.c->max_horz || data->client.any.c->max_vert), 0, TRUE); + ACT_END(data); + } } void action_maximize_horz(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); client_maximize(data->client.any.c, TRUE, 1, TRUE); + ACT_END(data); + } } void action_unmaximize_horz(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); client_maximize(data->client.any.c, FALSE, 1, TRUE); + ACT_END(data); + } } void action_toggle_maximize_horz(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); client_maximize(data->client.any.c, !data->client.any.c->max_horz, 1, TRUE); + ACT_END(data); + } } void action_maximize_vert(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); client_maximize(data->client.any.c, TRUE, 2, TRUE); + ACT_END(data); + } } void action_unmaximize_vert(union ActionData *data) { - if (data->client.any.c) + if (data->client.any.c) { + ACT_START(data); client_maximize(data->client.any.c, FALSE, 2, TRUE); + ACT_END(data); + } } void action_toggle_maximize_vert(union ActionData *data) { - if (data->client.any.c) - client_maximize(data->client.any.c, !data->client.any.c->max_vert, 2, TRUE); + if (data->client.any.c) { + ACT_START(data); + client_maximize(data->client.any.c, + !data->client.any.c->max_vert, 2, TRUE); + ACT_END(data); + } } void action_send_to_desktop(union ActionData *data) @@ -1154,10 +1208,12 @@ void action_toggle_decorations(union ActionData *data) { ObClient *c = data->client.any.c; - if (!c) return; - - c->decorate = !c->decorate; - client_setup_decor_and_functions(c); + if (c) { + ACT_START(data); + c->decorate = !c->decorate; + client_setup_decor_and_functions(c); + ACT_END(data); + } } static guint32 pick_corner(int x, int y, int cx, int cy, int cw, int ch) @@ -1271,9 +1327,9 @@ void action_movetoedge(union ActionData *data) g_assert_not_reached(); } frame_frame_gravity(c->frame, &x, &y); - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_move(c, x, y); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } @@ -1337,9 +1393,9 @@ void action_growtoedge(union ActionData *data) frame_frame_gravity(c->frame, &x, &y); width -= c->frame->size.left + c->frame->size.right; height -= c->frame->size.top + c->frame->size.bottom; - grab_pointer(TRUE, OB_CURSOR_NONE); + ACT_START(data); client_move_resize(c, x, y, width, height); - grab_pointer(FALSE, OB_CURSOR_NONE); + ACT_END(data); } void action_send_to_layer(union ActionData *data) @@ -1353,10 +1409,12 @@ void action_toggle_layer(union ActionData *data) ObClient *c = data->layer.any.c; if (c) { + ACT_START(data); if (data->layer.layer < 0) client_set_layer(c, c->below ? 0 : -1); else if (data->layer.layer > 0) client_set_layer(c, c->above ? 0 : 1); + ACT_END(data); } } diff --git a/openbox/action.h b/openbox/action.h index 1cd8f42f..bfe0dc9a 100644 --- a/openbox/action.h +++ b/openbox/action.h @@ -34,6 +34,7 @@ typedef struct _ObAction ObAction; struct AnyAction { struct _ObClient *c; + ObFrameContext context; gboolean interactive; gint x; gint y; @@ -180,21 +181,21 @@ void action_free(ObAction *a); @param done If the action is completing an interactive action. This only affects interactive actions, but should generally always be FALSE. */ -void action_run_list(GSList *acts, struct _ObClient *c, +void action_run_list(GSList *acts, struct _ObClient *c, ObFrameContext context, guint state, guint button, gint x, gint y, gboolean cancel, gboolean done); -#define action_run_mouse(a, c, s, b, x, y) \ - action_run_list(a, c, s, b, x, y, FALSE, FALSE) +#define action_run_mouse(a, c, n, s, b, x, y) \ + action_run_list(a, c, n, s, b, x, y, FALSE, FALSE) #define action_run_interactive(a, c, s, n, d) \ - action_run_list(a, c, s, 0, -1, -1, n, d) + action_run_list(a, c, OB_FRAME_CONTEXT_NONE, s, 0, -1, -1, n, d) #define action_run_key(a, c, s, x, y) \ - action_run_list(a, c, s, 0, x, y, FALSE, FALSE) + action_run_list(a, c, OB_FRAME_CONTEXT_NONE, s, 0, x, y, FALSE, FALSE) #define action_run(a, c, s) \ - action_run_list(a, c, s, 0, -1, -1, FALSE, FALSE) + action_run_list(a, c, OB_FRAME_CONTEXT_NONE, s, 0, -1, -1, FALSE, FALSE) /* Execute */ void action_execute(union ActionData *data);