1 #include "openbox/action.h"
2 #include "openbox/action_value.h"
3 #include "openbox/event.h"
4 #include "openbox/client.h"
5 #include "openbox/focus.h"
6 #include "openbox/screen.h"
13 static gpointer setup_func(GHashTable *config);
14 static void free_func(gpointer o);
15 static gboolean run_func(ObActionData *data, gpointer options);
17 void action_focus_startup(void)
19 action_register("Focus", setup_func, free_func, run_func);
22 static gpointer setup_func(GHashTable *config)
27 o = g_slice_new0(Options);
30 v = g_hash_table_lookup(config, "here");
31 if (v && action_value_is_string(v))
32 o->here = action_value_bool(v);
33 v = g_hash_table_lookup(config, "stopInteractive");
34 if (v && action_value_is_string(v))
35 o->stop_int = action_value_bool(v);
39 static void free_func(gpointer o)
41 g_slice_free(Options, o);
44 /* Always return FALSE because its not interactive */
45 static gboolean run_func(ObActionData *data, gpointer options)
51 ob_debug("button %d focusable %d context %d %d %d\n",
52 data->button, client_mouse_focusable(data->client),
54 OB_FRAME_CONTEXT_CLIENT, OB_FRAME_CONTEXT_FRAME);
56 if (data->button == 0 || client_mouse_focusable(data->client) ||
57 (data->context != OB_FRAME_CONTEXT_CLIENT &&
58 data->context != OB_FRAME_CONTEXT_FRAME))
61 action_interactive_cancel_act();
63 action_client_move(data, TRUE);
64 client_activate(data->client, TRUE, o->here, FALSE, FALSE, TRUE);
65 action_client_move(data, FALSE);
67 } else if (data->context == OB_FRAME_CONTEXT_DESKTOP) {
69 action_interactive_cancel_act();
71 /* focus action on the root window. make keybindings work for this
72 openbox instance, but don't focus any specific client */