all repos — openbox @ 29c4cf4a15bc5fa97ba746b03a5e334f989c645e

openbox fork - make it a bit more like ryudo

add the activate action. it will replace the focus action, as it can just focus without raising now (or without unshading)
Dana Jansens danakj@orodu.net
commit

29c4cf4a15bc5fa97ba746b03a5e334f989c645e

parent

fbc7607fbd1a380428a53094e727ac7631871bd4

M Makefile.amMakefile.am

@@ -156,6 +156,7 @@ openbox_openbox_SOURCES = \

gettext.h \ openbox/actions/all.c \ openbox/actions/all.h \ + openbox/actions/activate.c \ openbox/actions/cyclewindows.c \ openbox/actions/debug.c \ openbox/actions/execute.c \
M openbox/action.copenbox/action.c

@@ -499,11 +499,6 @@ action_directional_focus,

setup_action_directional_focus_northwest }, { - "activate", - action_activate, - setup_action_focus - }, - { "focus", action_focus, setup_action_focus

@@ -965,9 +960,6 @@ act->data.sendtodir.follow = parse_bool(doc, n);

if ((n = parse_find_node("dialog", node->xmlChildrenNode))) act->data.sendtodir.inter.any.interactive = parse_bool(doc, n); - } else if (act->func == action_activate) { - if ((n = parse_find_node("here", node->xmlChildrenNode))) - act->data.activate.here = parse_bool(doc, n); } else if (act->func == action_directional_focus) { if ((n = parse_find_node("dialog", node->xmlChildrenNode))) act->data.interdiraction.dialog = parse_bool(doc, n);

@@ -1116,27 +1108,6 @@

l = g_slist_append(NULL, a); action_run(l, c, 0, time); -} - -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_FRAME)) - { - /* if using focus_delay, stop the timer now so that focus doesn't - go moving on us */ - event_halt_focus_delay(); - - client_activate(data->activate.any.c, data->activate.here, TRUE); - } - } else { - /* focus action on something other than a client, make keybindings - work for this openbox instance, but don't focus any specific client - */ - focus_nothing(); - } } void action_focus(union ActionData *data)
A openbox/actions/activate.c

@@ -0,0 +1,79 @@

+#include "openbox/actions.h" +#include "openbox/event.h" +#include "openbox/client.h" +#include "openbox/focus.h" + +typedef struct { + gboolean here; + gboolean raise; + gboolean unshade; +} Options; + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static void free_func(gpointer options); +static gboolean run_func(ObActionsData *data, gpointer options); + +void action_activate_startup() +{ + actions_register("Activate", + setup_func, + free_func, + run_func, + NULL, NULL); +} + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +{ + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + o->raise = TRUE; + o->unshade = TRUE; + + if ((n = parse_find_node("here", node))) + o->here = parse_bool(doc, n); + if ((n = parse_find_node("raise", node))) + o->raise = parse_bool(doc, n); + if ((n = parse_find_node("unshade", node))) + o->unshade = parse_bool(doc, n); + return o; +} + +static void free_func(gpointer options) +{ + Options *o = options; + + g_free(o); +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func(ObActionsData *data, gpointer options) +{ + Options *o = options; + + if (data->client) { + gboolean mouse = (data->uact == OB_USER_ACTION_MOUSE_PRESS || + data->uact == OB_USER_ACTION_MOUSE_RELEASE || + data->uact == OB_USER_ACTION_MOUSE_CLICK || + data->uact == OB_USER_ACTION_MOUSE_DOUBLE_CLICK || + data->uact == OB_USER_ACTION_MOUSE_MOTION); + if (!mouse || client_mouse_focusable(data->client) || + data->context != OB_FRAME_CONTEXT_CLIENT || + data->context != OB_FRAME_CONTEXT_FRAME) + { + /* if using focus_delay, stop the timer now so that focus doesn't + go moving on us */ + event_halt_focus_delay(); + + client_activate(data->client, o->here, o->raise, o->unshade, TRUE); + } + } else { + /* focus action on something other than a client, make keybindings + work for this openbox instance, but don't focus any specific client + */ + focus_nothing(); + } + + return FALSE; +}
M openbox/actions/all.copenbox/actions/all.c

@@ -10,4 +10,5 @@ action_reconfigure_startup();

action_exit_startup(); action_restart_startup(); action_cyclewindows_startup(); + action_activate_startup(); }
M openbox/actions/all.hopenbox/actions/all.h

@@ -11,5 +11,6 @@ void action_reconfigure_startup();

void action_exit_startup(); void action_restart_startup(); void action_cyclewindows_startup(); +void action_activate_startup(); #endif
M openbox/client.copenbox/client.c

@@ -88,7 +88,8 @@ ObGroup *oldgroup, ObGroup *newgroup,

gboolean oldgtran, gboolean newgtran, ObClient* oldparent, ObClient *newparent); -static void client_present(ObClient *self, gboolean here, gboolean raise); +static void client_present(ObClient *self, gboolean here, gboolean raise, + gboolean unshade); static GSList *client_search_all_top_parents_internal(ObClient *self, gboolean bylayer, ObStackingLayer layer);

@@ -544,7 +545,7 @@ }

if (activate) { gboolean stacked = client_restore_session_stacking(self); - client_present(self, FALSE, !stacked); + client_present(self, FALSE, !stacked, TRUE); } /* add to client list/map */

@@ -3561,6 +3562,10 @@ ob_debug_type(OB_DEBUG_FOCUS,

"Focusing client \"%s\" (0x%x) at time %u\n", self->title, self->window, event_curtime); + /* if using focus_delay, stop the timer now so that focus doesn't + go moving on us */ + event_halt_focus_delay(); + /* if there is a grab going on, then we need to cancel it. if we move focus during the grab, applications will get NotifyWhileGrabbed events and ignore them !

@@ -3601,17 +3606,9 @@ ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n", xerror_occured);

return !xerror_occured; } -/*! Present the client to the user. - @param raise If the client should be raised or not. You should only set - raise to false if you don't care if the window is completely - hidden. -*/ -static void client_present(ObClient *self, gboolean here, gboolean raise) +static void client_present(ObClient *self, gboolean here, gboolean raise, + gboolean unshade) { - /* if using focus_delay, stop the timer now so that focus doesn't - go moving on us */ - event_halt_focus_delay(); - if (client_normal(self) && screen_showing_desktop) screen_show_desktop(FALSE, self); if (self->iconic)

@@ -3627,7 +3624,7 @@ } else if (!self->frame->visible)

/* if its not visible for other reasons, then don't mess with it */ return; - if (self->shaded) + if (self->shaded && unshade) client_shade(self, FALSE); if (raise) stacking_raise(CLIENT_AS_WINDOW(self));

@@ -3635,7 +3632,8 @@

client_focus(self); } -void client_activate(ObClient *self, gboolean here, gboolean user) +void client_activate(ObClient *self, gboolean here, gboolean raise, + gboolean unshade, gboolean user) { guint32 last_time = focus_client ? focus_client->user_time : CurrentTime; gboolean allow = FALSE;

@@ -3661,7 +3659,7 @@ self->window, event_curtime, last_time,

(user ? "user" : "application"), allow); if (allow) - client_present(self, here, TRUE); + client_present(self, here, raise, unshade); else /* don't focus it but tell the user it wants attention */ client_hilite(self, TRUE);
M openbox/client.hopenbox/client.h

@@ -550,10 +550,13 @@ /*! Activates the client for use, focusing, uniconifying it, etc. To be used

when the user deliberately selects a window for use. @param here If true, then the client is brought to the current desktop; otherwise, the desktop is changed to where the client lives. + @param raise If true, the client is brought to the front. + @param unshade If true, the client is unshaded (if it is shaded) @param user If true, then a user action is what requested the activation; otherwise, it means an application requested it on its own */ -void client_activate(ObClient *self, gboolean here, gboolean user); +void client_activate(ObClient *self, gboolean here, gboolean raise, + gboolean unshade, gboolean user); /*! Bring all of its helper windows to its desktop. These are the utility and stuff windows. */
M openbox/client_list_combined_menu.copenbox/client_list_combined_menu.c

@@ -98,7 +98,7 @@ ObClient *c, guint state, gpointer data)

{ if (self->id == -1) { if (self->data.normal.data) /* it's set to NULL if its destroyed */ - client_activate(self->data.normal.data, FALSE, TRUE); + client_activate(self->data.normal.data, FALSE, TRUE, TRUE, TRUE); } else screen_set_desktop(self->id, TRUE);
M openbox/client_list_menu.copenbox/client_list_menu.c

@@ -98,7 +98,7 @@ ObClient *c, guint state, gpointer data)

{ if (self->id == -1) { if (self->data.normal.data) /* it's set to NULL if its destroyed */ - client_activate(self->data.normal.data, FALSE, TRUE); + client_activate(self->data.normal.data, FALSE, TRUE, TRUE, TRUE); } else screen_set_desktop(self->id, TRUE);
M openbox/event.copenbox/event.c

@@ -1219,7 +1219,7 @@ does, we don't want it!

it can happen now when the window is on another desktop, but we still don't want it! */ - client_activate(client, FALSE, TRUE); + client_activate(client, FALSE, TRUE, TRUE, TRUE); break; case ClientMessage: /* validate cuz we query stuff off the client here */

@@ -1297,7 +1297,7 @@ } else

ob_debug_type(OB_DEBUG_APP_BUGS, "_NET_ACTIVE_WINDOW message for window %s is " "missing source indication\n"); - client_activate(client, FALSE, + client_activate(client, FALSE, TRUE, TRUE, (e->xclient.data.l[0] == 0 || e->xclient.data.l[0] == 2)); } else if (msgtype == prop_atoms.net_wm_moveresize) {
M openbox/focus_cycle.copenbox/focus_cycle.c

@@ -137,7 +137,7 @@ focus_cycle_iconic_windows,

focus_cycle_all_desktops, focus_cycle_dock_windows, focus_cycle_desktop_windows); - return; + return NULL; } else if (ft != focus_cycle_target) { focus_cycle_target = ft; done = TRUE;

@@ -258,12 +258,15 @@

return best_client; } -void focus_directional_cycle(ObDirection dir, gboolean dock_windows, - gboolean desktop_windows, gboolean interactive, - gboolean dialog, gboolean done, gboolean cancel) +ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, + gboolean desktop_windows, + gboolean interactive, + gboolean dialog, + gboolean done, gboolean cancel) { static ObClient *first = NULL; ObClient *ft = NULL; + ObClient *ret = NULL; if (cancel) { focus_cycle_target = NULL;

@@ -313,11 +316,10 @@ focus_cycle_iconic_windows,

focus_cycle_all_desktops, focus_cycle_dock_windows, focus_cycle_desktop_windows); - return; + return NULL; done_cycle: - if (done && focus_cycle_target) - client_activate(focus_cycle_target, FALSE, TRUE); + if (done && !cancel) ret = focus_cycle_target; first = NULL; focus_cycle_target = NULL;

@@ -325,5 +327,5 @@

focus_cycle_draw_indicator(NULL); focus_cycle_popup_single_hide(); - return; + return ret; }
M openbox/focus_cycle.hopenbox/focus_cycle.h

@@ -38,9 +38,12 @@ struct _ObClient* focus_cycle(gboolean forward, gboolean all_desktops,

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 desktop_windows, gboolean interactive, - gboolean dialog, gboolean done, gboolean cancel); +struct _ObClient* focus_directional_cycle(ObDirection dir, + gboolean dock_windows, + gboolean desktop_windows, + gboolean interactive, + gboolean dialog, + gboolean done, gboolean cancel); void focus_cycle_stop(struct _ObClient *ifclient);