]> Dogcows Code - chaz/openbox/blob - openbox/actions/activate.c
c3f3f98e2b62b75a0e4b715b2b4606bb917ffcc4
[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 if (data->button == 0 || client_mouse_focusable(data->client) ||
57 data->context != OB_FRAME_CONTEXT_CLIENT ||
58 data->context != OB_FRAME_CONTEXT_FRAME)
59 {
60 client_activate(data->client, o->here, o->raise, o->unshade, TRUE);
61 }
62 } else {
63 /* focus action on something other than a client, make keybindings
64 work for this openbox instance, but don't focus any specific client
65 */
66 focus_nothing();
67 }
68
69 return FALSE;
70 }
This page took 0.037268 seconds and 4 git commands to generate.