]> icculus.org git repositories - dana/openbox.git/blob - openbox/actions/focus.c
Allow the user to bind more than one keycode to a keysym for Ob Menus/Move/Resize
[dana/openbox.git] / openbox / actions / focus.c
1 #include "openbox/actions.h"
2 #include "openbox/event.h"
3 #include "openbox/client.h"
4 #include "openbox/focus.h"
5 #include "openbox/screen.h"
6
7 typedef struct {
8     gboolean here;
9 } Options;
10
11 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
12 static void     free_func(gpointer options);
13 static gboolean run_func(ObActionsData *data, gpointer options);
14
15 void action_focus_startup(void)
16 {
17     actions_register("Focus",
18                      setup_func,
19                      free_func,
20                      run_func,
21                      NULL, NULL);
22 }
23
24 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
25 {
26     xmlNodePtr n;
27     Options *o;
28
29     o = g_new0(Options, 1);
30
31     if ((n = parse_find_node("here", node)))
32         o->here = parse_bool(doc, n);
33     return o;
34 }
35
36 static void free_func(gpointer options)
37 {
38     Options *o = options;
39
40     g_free(o);
41 }
42
43 /* Always return FALSE because its not interactive */
44 static gboolean run_func(ObActionsData *data, gpointer options)
45 {
46     Options *o = options;
47
48     if (data->client) {
49 /*
50         ob_debug("button %d focusable %d context %d %d %d\n",
51                  data->button, client_mouse_focusable(data->client),
52                  data->context,
53                  OB_FRAME_CONTEXT_CLIENT, OB_FRAME_CONTEXT_FRAME);
54 */
55         if (data->button == 0 || client_mouse_focusable(data->client) ||
56             (data->context != OB_FRAME_CONTEXT_CLIENT &&
57              data->context != OB_FRAME_CONTEXT_FRAME))
58         {
59             actions_client_move(data, TRUE);
60             client_activate(data->client, TRUE, o->here, FALSE, FALSE, TRUE);
61             actions_client_move(data, FALSE);
62         }
63     } else if (data->context == OB_FRAME_CONTEXT_DESKTOP) {
64         /* focus action on the root window. make keybindings work for this
65            openbox instance, but don't focus any specific client */
66         focus_nothing();
67     }
68
69     return FALSE;
70 }