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