]> Dogcows Code - chaz/openbox/blob - openbox/actions/focus.c
Merge branch 'backport' into work
[chaz/openbox] / 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(xmlNodePtr node);
12 static gboolean run_func(ObActionsData *data, gpointer options);
13
14 void action_focus_startup(void)
15 {
16 actions_register("Focus", setup_func, g_free, run_func, NULL, NULL);
17 }
18
19 static gpointer setup_func(xmlNodePtr node)
20 {
21 xmlNodePtr n;
22 Options *o;
23
24 o = g_new0(Options, 1);
25
26 if ((n = obt_parse_find_node(node, "here")))
27 o->here = obt_parse_node_bool(n);
28 return o;
29 }
30
31 /* Always return FALSE because its not interactive */
32 static gboolean run_func(ObActionsData *data, gpointer options)
33 {
34 Options *o = options;
35
36 if (data->client) {
37 /*
38 ob_debug("button %d focusable %d context %d %d %d\n",
39 data->button, client_mouse_focusable(data->client),
40 data->context,
41 OB_FRAME_CONTEXT_CLIENT, OB_FRAME_CONTEXT_FRAME);
42 */
43 if (data->button == 0 || client_mouse_focusable(data->client) ||
44 (data->context != OB_FRAME_CONTEXT_CLIENT &&
45 data->context != OB_FRAME_CONTEXT_FRAME))
46 {
47 actions_client_move(data, TRUE);
48 client_activate(data->client, TRUE, o->here, FALSE, FALSE, TRUE);
49 actions_client_move(data, FALSE);
50 }
51 } else if (data->context == OB_FRAME_CONTEXT_DESKTOP) {
52 /* focus action on the root window. make keybindings work for this
53 openbox instance, but don't focus any specific client */
54 focus_nothing();
55 }
56
57 return FALSE;
58 }
This page took 0.03534 seconds and 4 git commands to generate.