]> Dogcows Code - chaz/openbox/blob - openbox/actions/addremovedesktop.c
freeze onscreen stacking order changes while a temp raise for focus cycling is occuring
[chaz/openbox] / openbox / actions / addremovedesktop.c
1 #include "openbox/actions.h"
2 #include "openbox/screen.h"
3 #include <glib.h>
4
5 typedef struct {
6 gboolean current;
7 gboolean add;
8 } Options;
9
10 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
11 static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
12 static gpointer setup_remove_func(ObParseInst *i,
13 xmlDocPtr doc, xmlNodePtr node);
14 static void free_func(gpointer options);
15 static gboolean run_func(ObActionsData *data, gpointer options);
16
17 void action_addremovedesktop_startup(void)
18 {
19 actions_register("AddDesktop",
20 setup_add_func,
21 free_func,
22 run_func,
23 NULL, NULL);
24 actions_register("RemoveDesktop",
25 setup_remove_func,
26 free_func,
27 run_func,
28 NULL, NULL);
29 }
30
31 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
32 {
33 xmlNodePtr n;
34 Options *o;
35
36 o = g_new0(Options, 1);
37
38 if ((n = parse_find_node("where", node))) {
39 gchar *s = parse_string(doc, n);
40 if (!g_ascii_strcasecmp(s, "last"))
41 o->current = FALSE;
42 else if (!g_ascii_strcasecmp(s, "current"))
43 o->current = TRUE;
44 g_free(s);
45 }
46
47 return o;
48 }
49
50 static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
51 {
52 Options *o = setup_func(i, doc, node);
53 o->add = TRUE;
54 return o;
55 }
56
57 static gpointer setup_remove_func(ObParseInst *i,
58 xmlDocPtr doc, xmlNodePtr node)
59 {
60 Options *o = setup_func(i, doc, node);
61 o->add = FALSE;
62 return o;
63 }
64
65 static void free_func(gpointer options)
66 {
67 Options *o = options;
68
69 g_free(o);
70 }
71
72 /* Always return FALSE because its not interactive */
73 static gboolean run_func(ObActionsData *data, gpointer options)
74 {
75 Options *o = options;
76
77 actions_client_move(data, TRUE);
78
79 if (o->add)
80 screen_add_desktop(o->current);
81 else
82 screen_remove_desktop(o->current);
83
84 actions_client_move(data, FALSE);
85
86 return FALSE;
87 }
This page took 0.037292 seconds and 4 git commands to generate.