]> Dogcows Code - chaz/openbox/blob - openbox/actions/activate.c
a431bafd027c49774cafcd740b409e7e3d100a62
[chaz/openbox] / openbox / actions / activate.c
1 #include "openbox/actions.h"
2 #include "openbox/event.h"
3 #include "openbox/client.h"
4 #include "openbox/focus.h"
5
6 typedef struct {
7 gboolean here;
8 gboolean raise;
9 gboolean unshade;
10 } Options;
11
12 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
13 static void free_func(gpointer options);
14 static gboolean run_func(ObActionsData *data, gpointer options);
15
16 void action_activate_startup()
17 {
18 actions_register("Activate",
19 setup_func,
20 free_func,
21 run_func,
22 NULL, NULL);
23 }
24
25 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
26 {
27 xmlNodePtr n;
28 Options *o;
29
30 o = g_new0(Options, 1);
31 o->raise = TRUE;
32 o->unshade = TRUE;
33
34 if ((n = parse_find_node("here", node)))
35 o->here = parse_bool(doc, n);
36 if ((n = parse_find_node("raise", node)))
37 o->raise = parse_bool(doc, n);
38 if ((n = parse_find_node("unshade", node)))
39 o->unshade = parse_bool(doc, n);
40 return o;
41 }
42
43 static void free_func(gpointer options)
44 {
45 Options *o = options;
46
47 g_free(o);
48 }
49
50 /* Always return FALSE because its not interactive */
51 static gboolean run_func(ObActionsData *data, gpointer options)
52 {
53 Options *o = options;
54
55 if (data->client) {
56 gboolean mouse = (data->uact == OB_USER_ACTION_MOUSE_PRESS ||
57 data->uact == OB_USER_ACTION_MOUSE_RELEASE ||
58 data->uact == OB_USER_ACTION_MOUSE_CLICK ||
59 data->uact == OB_USER_ACTION_MOUSE_DOUBLE_CLICK ||
60 data->uact == OB_USER_ACTION_MOUSE_MOTION);
61 if (!mouse || client_mouse_focusable(data->client) ||
62 data->context != OB_FRAME_CONTEXT_CLIENT ||
63 data->context != OB_FRAME_CONTEXT_FRAME)
64 {
65 client_activate(data->client, o->here, o->raise, o->unshade, TRUE);
66 }
67 } else {
68 /* focus action on something other than a client, make keybindings
69 work for this openbox instance, but don't focus any specific client
70 */
71 focus_nothing();
72 }
73
74 return FALSE;
75 }
This page took 0.036666 seconds and 3 git commands to generate.