From: Dana Jansens Date: Sun, 3 Jun 2007 17:58:21 +0000 (+0000) Subject: add focus option X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=097d02d9d3d4b2eeea11084c54812de9cd7d14c0;p=chaz%2Fopenbox add focus option --- diff --git a/openbox/action.c b/openbox/action.c index 39c1169b..de5f9a8a 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -43,11 +43,11 @@ static void client_action_start(union ActionData *data) { } -static void client_action_end(union ActionData *data) +static void client_action_end(union ActionData *data, gboolean allow_enters) { if (config_focus_follow) if (data->any.context != OB_FRAME_CONTEXT_CLIENT) { - if (!data->any.button && data->any.c) { + if (!data->any.button && data->any.c && !allow_enters) { event_ignore_all_queued_enters(); } else { ObClient *c; @@ -1318,7 +1318,7 @@ void action_iconify(union ActionData *data) { client_action_start(data); client_iconify(data->client.any.c, TRUE, TRUE, FALSE); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_focus_order_to_bottom(union ActionData *data) @@ -1332,14 +1332,14 @@ void action_raiselower(union ActionData *data) client_action_start(data); stacking_restack_request(c, NULL, Opposite, FALSE); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_raise(union ActionData *data) { client_action_start(data); stacking_raise(CLIENT_AS_WINDOW(data->client.any.c)); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_unshaderaise(union ActionData *data) @@ -1362,7 +1362,7 @@ void action_lower(union ActionData *data) { client_action_start(data); stacking_lower(CLIENT_AS_WINDOW(data->client.any.c)); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_close(union ActionData *data) @@ -1379,21 +1379,21 @@ void action_shade(union ActionData *data) { client_action_start(data); client_shade(data->client.any.c, TRUE); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_unshade(union ActionData *data) { client_action_start(data); client_shade(data->client.any.c, FALSE); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_toggle_shade(union ActionData *data) { client_action_start(data); client_shade(data->client.any.c, !data->client.any.c->shaded); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_toggle_omnipresent(union ActionData *data) @@ -1408,7 +1408,7 @@ void action_move_relative_horz(union ActionData *data) ObClient *c = data->relative.any.c; client_action_start(data); client_move(c, c->area.x + data->relative.deltax, c->area.y); - client_action_end(data); + client_action_end(data, FALSE); } void action_move_relative_vert(union ActionData *data) @@ -1416,7 +1416,7 @@ void action_move_relative_vert(union ActionData *data) ObClient *c = data->relative.any.c; client_action_start(data); client_move(c, c->area.x, c->area.y + data->relative.deltax); - client_action_end(data); + client_action_end(data, FALSE); } void action_move_to_center(union ActionData *data) @@ -1427,7 +1427,7 @@ void action_move_to_center(union ActionData *data) client_action_start(data); client_move(c, area->width / 2 - c->area.width / 2, area->height / 2 - c->area.height / 2); - client_action_end(data); + client_action_end(data, FALSE); } void action_resize_relative_horz(union ActionData *data) @@ -1437,7 +1437,7 @@ void action_resize_relative_horz(union ActionData *data) client_resize(c, c->area.width + data->relative.deltax * c->size_inc.width, c->area.height); - client_action_end(data); + client_action_end(data, FALSE); } void action_resize_relative_vert(union ActionData *data) @@ -1447,7 +1447,7 @@ void action_resize_relative_vert(union ActionData *data) client_action_start(data); client_resize(c, c->area.width, c->area.height + data->relative.deltax * c->size_inc.height); - client_action_end(data); + client_action_end(data, FALSE); } } @@ -1457,7 +1457,7 @@ void action_move_relative(union ActionData *data) client_action_start(data); client_move(c, c->area.x + data->relative.deltax, c->area.y + data->relative.deltay); - client_action_end(data); + client_action_end(data, FALSE); } void action_resize_relative(union ActionData *data) @@ -1478,21 +1478,21 @@ void action_resize_relative(union ActionData *data) client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE); client_move_resize(c, x + (ow - w), y + (oh - h), w, h); - client_action_end(data); + client_action_end(data, FALSE); } void action_maximize_full(union ActionData *data) { client_action_start(data); client_maximize(data->client.any.c, TRUE, 0); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_unmaximize_full(union ActionData *data) { client_action_start(data); client_maximize(data->client.any.c, FALSE, 0); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_toggle_maximize_full(union ActionData *data) @@ -1502,21 +1502,21 @@ void action_toggle_maximize_full(union ActionData *data) !(data->client.any.c->max_horz || data->client.any.c->max_vert), 0); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_maximize_horz(union ActionData *data) { client_action_start(data); client_maximize(data->client.any.c, TRUE, 1); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_unmaximize_horz(union ActionData *data) { client_action_start(data); client_maximize(data->client.any.c, FALSE, 1); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_toggle_maximize_horz(union ActionData *data) @@ -1524,21 +1524,21 @@ void action_toggle_maximize_horz(union ActionData *data) client_action_start(data); client_maximize(data->client.any.c, !data->client.any.c->max_horz, 1); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_maximize_vert(union ActionData *data) { client_action_start(data); client_maximize(data->client.any.c, TRUE, 2); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_unmaximize_vert(union ActionData *data) { client_action_start(data); client_maximize(data->client.any.c, FALSE, 2); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_toggle_maximize_vert(union ActionData *data) @@ -1546,14 +1546,14 @@ void action_toggle_maximize_vert(union ActionData *data) client_action_start(data); client_maximize(data->client.any.c, !data->client.any.c->max_vert, 2); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_toggle_fullscreen(union ActionData *data) { client_action_start(data); client_fullscreen(data->client.any.c, !(data->client.any.c->fullscreen)); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_send_to_desktop(union ActionData *data) @@ -1639,7 +1639,7 @@ void action_toggle_decorations(union ActionData *data) client_action_start(data); client_set_undecorated(c, !c->undecorated); - client_action_end(data); + client_action_end(data, FALSE); } static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch, @@ -1872,7 +1872,7 @@ void action_movetoedge(union ActionData *data) frame_frame_gravity(c->frame, &x, &y, c->area.width, c->area.height); client_action_start(data); client_move(c, x, y); - client_action_end(data); + client_action_end(data, FALSE); } void action_growtoedge(union ActionData *data) @@ -1939,7 +1939,7 @@ void action_growtoedge(union ActionData *data) frame_frame_gravity(c->frame, &x, &y, width, height); client_action_start(data); client_move_resize(c, x, y, width, height); - client_action_end(data); + client_action_end(data, FALSE); } void action_send_to_layer(union ActionData *data) @@ -1956,7 +1956,7 @@ void action_toggle_layer(union ActionData *data) client_set_layer(c, c->below ? 0 : -1); else if (data->layer.layer > 0) client_set_layer(c, c->above ? 0 : 1); - client_action_end(data); + client_action_end(data, config_focus_under_mouse); } void action_toggle_dockautohide(union ActionData *data) diff --git a/openbox/client.c b/openbox/client.c index a338df16..9b4932a0 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -644,9 +644,11 @@ void client_unmanage(ObClient *self) /* flush to send the hide to the server quickly */ XFlush(ob_display); - /* ignore enter events from the unmap so it doesnt mess with the - focus */ - event_ignore_all_queued_enters(); + if (!client_focused(self) || !config_focus_under_mouse) { + /* ignore enter events from the unmap so it doesnt mess with the + focus */ + event_ignore_all_queued_enters(); + } mouse_grab_for_client(self, FALSE); diff --git a/openbox/config.c b/openbox/config.c index 86068d75..133fb4a6 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -33,6 +33,7 @@ gboolean config_focus_follow; guint config_focus_delay; gboolean config_focus_raise; gboolean config_focus_last; +gboolean config_focus_under_mouse; ObPlacePolicy config_place_policy; @@ -468,6 +469,8 @@ static void parse_focus(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, config_focus_raise = parse_bool(doc, n); if ((n = parse_find_node("focusLast", node))) config_focus_last = parse_bool(doc, n); + if ((n = parse_find_node("underMouse", node))) + config_focus_under_mouse = parse_bool(doc, n); } static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, @@ -849,6 +852,7 @@ void config_startup(ObParseInst *i) config_focus_delay = 0; config_focus_raise = FALSE; config_focus_last = FALSE; + config_focus_under_mouse = FALSE; parse_register(i, "focus", parse_focus, NULL); diff --git a/openbox/config.h b/openbox/config.h index 6a064fff..0a4ad090 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -69,6 +69,9 @@ extern guint config_focus_delay; extern gboolean config_focus_raise; /*! Focus the last focused window, not under the mouse, in follow mouse mode */ extern gboolean config_focus_last; +/*! Try keep focus on the window under the mouse when the mouse is not moving + */ +extern gboolean config_focus_under_mouse; extern ObPlacePolicy config_place_policy; diff --git a/openbox/event.c b/openbox/event.c index 6b372a85..a45d070d 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -1031,6 +1031,7 @@ static void event_handle_client(ObClient *client, XEvent *e) gint x, y, w, h; gboolean move = FALSE; gboolean resize = FALSE; + gboolean restack = FALSE; /* get the current area */ RECT_TO_DIMS(client->area, x, y, w, h); @@ -1068,8 +1069,9 @@ static void event_handle_client(ObClient *client, XEvent *e) } /* activate it rather than just focus it */ - stacking_restack_request(client, sibling, - e->xconfigurerequest.detail, TRUE); + restack = stacking_restack_request(client, sibling, + e->xconfigurerequest.detail, + TRUE); /* if a stacking change moves the window without resizing */ move = TRUE; @@ -1169,8 +1171,10 @@ static void event_handle_client(ObClient *client, XEvent *e) client_configure(client, x, y, w, h, FALSE, TRUE); } - /* ignore enter events caused by these like ob actions do */ - event_ignore_all_queued_enters(); + if (!restack || !config_focus_under_mouse) { + /* ignore enter events caused by these like ob actions do */ + event_ignore_all_queued_enters(); + } } break; } @@ -1265,8 +1269,10 @@ static void event_handle_client(ObClient *client, XEvent *e) client_set_state(client, e->xclient.data.l[0], e->xclient.data.l[1], e->xclient.data.l[2]); - /* ignore enter events caused by these like ob actions do */ - event_ignore_all_queued_enters(); + if (!config_focus_under_mouse) { + /* ignore enter events caused by these like ob actions do */ + event_ignore_all_queued_enters(); + } } else if (msgtype == prop_atoms.net_close_window) { ob_debug("net_close_window for 0x%lx\n", client->window); client_close(client);