1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/action_value.h"
4 #include "openbox/event.h"
5 #include "openbox/client.h"
6 #include "openbox/focus.h"
7 #include "openbox/screen.h"
14 static gpointer setup_func(GHashTable *config);
15 static void free_func(gpointer o);
16 static gboolean run_func(const ObActionListRun *data, gpointer options);
18 void action_focus_startup(void)
20 action_register("Focus", OB_ACTION_DEFAULT_FILTER_SINGLE,
21 setup_func, free_func, run_func);
24 static gpointer setup_func(GHashTable *config)
29 o = g_slice_new0(Options);
32 v = g_hash_table_lookup(config, "here");
33 if (v && action_value_is_string(v))
34 o->here = action_value_bool(v);
35 v = g_hash_table_lookup(config, "stopInteractive");
36 if (v && action_value_is_string(v))
37 o->stop_int = action_value_bool(v);
41 static void free_func(gpointer o)
43 g_slice_free(Options, o);
46 /* Always return FALSE because its not interactive */
47 static gboolean run_func(const ObActionListRun *data, gpointer options)
53 ob_debug("button %d focusable %d context %d %d %d\n",
54 data->button, client_mouse_focusable(data->client),
56 OB_FRAME_CONTEXT_CLIENT, OB_FRAME_CONTEXT_FRAME);
58 if (data->button == 0 || client_mouse_focusable(data->client) ||
59 (data->context != OB_FRAME_CONTEXT_CLIENT &&
60 data->context != OB_FRAME_CONTEXT_FRAME))
63 action_interactive_cancel_act();
65 action_client_move(data, TRUE);
66 client_activate(data->client, TRUE, o->here, FALSE, FALSE, TRUE);
67 action_client_move(data, FALSE);
69 } else if (data->context == OB_FRAME_CONTEXT_DESKTOP) {
71 action_interactive_cancel_act();
73 /* focus action on the root window. make keybindings work for this
74 openbox instance, but don't focus any specific client */