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