]>
Dogcows Code - chaz/openbox/blob - openbox/actions/addremovedesktop.c
1 #include "openbox/actions.h"
2 #include "openbox/screen.h"
3 #include "openbox/client.h"
4 #include "openbox/debug.h"
12 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
);
13 static gpointer
setup_add_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
);
14 static gpointer
setup_remove_func(ObParseInst
*i
,
15 xmlDocPtr doc
, xmlNodePtr node
);
16 static void free_func(gpointer options
);
17 static gboolean
run_func(ObActionsData
*data
, gpointer options
);
19 void action_addremovedesktop_startup()
21 actions_register("AddDesktop",
26 actions_register("RemoveDesktop",
33 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
38 o
= g_new0(Options
, 1);
40 if ((n
= parse_find_node("where", node
))) {
41 gchar
*s
= parse_string(doc
, n
);
42 if (!g_ascii_strcasecmp(s
, "last"))
44 else if (!g_ascii_strcasecmp(s
, "current"))
52 static gpointer
setup_add_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
54 Options
*o
= setup_func(i
, doc
, node
);
59 static gpointer
setup_remove_func(ObParseInst
*i
,
60 xmlDocPtr doc
, xmlNodePtr node
)
62 Options
*o
= setup_func(i
, doc
, node
);
67 static void free_func(gpointer options
)
74 /* Always return FALSE because its not interactive */
75 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
79 actions_client_move(data
, FALSE
);
82 screen_set_num_desktops(screen_num_desktops
+1);
84 /* move all the clients over */
88 for (it
= client_list
; it
; it
= g_list_next(it
)) {
89 ObClient
*c
= it
->data
;
90 if (c
->desktop
!= DESKTOP_ALL
&& c
->desktop
>= screen_desktop
)
91 client_set_desktop(c
, c
->desktop
+1, FALSE
, TRUE
);
95 else if (screen_num_desktops
> 1) {
96 guint rmdesktop
, movedesktop
;
97 GList
*it
, *stacking_copy
;
99 /* what desktop are we removing and moving to? */
101 rmdesktop
= screen_desktop
;
103 rmdesktop
= screen_num_desktops
- 1;
104 if (rmdesktop
< screen_num_desktops
- 1)
105 movedesktop
= rmdesktop
+ 1;
107 movedesktop
= rmdesktop
;
109 /* make a copy of the list cuz we're changing it */
110 stacking_copy
= g_list_copy(stacking_list
);
111 for (it
= g_list_last(stacking_copy
); it
; it
= g_list_previous(it
)) {
112 if (WINDOW_IS_CLIENT(it
->data
)) {
113 ObClient
*c
= it
->data
;
114 guint d
= c
->desktop
;
115 if (d
!= DESKTOP_ALL
&& d
>= movedesktop
) {
116 client_set_desktop(c
, c
->desktop
- 1, TRUE
, TRUE
);
117 ob_debug("moving window %s\n", c
->title
);
119 /* raise all the windows that are on the current desktop which
121 if ((screen_desktop
== rmdesktop
- 1 ||
122 screen_desktop
== rmdesktop
) &&
123 (d
== DESKTOP_ALL
|| d
== screen_desktop
))
125 stacking_raise(CLIENT_AS_WINDOW(c
));
126 ob_debug("raising window %s\n", c
->title
);
131 /* act like we're changing desktops */
132 if (screen_desktop
< screen_num_desktops
- 1) {
133 gint d
= screen_desktop
;
134 screen_desktop
= screen_last_desktop
;
135 screen_set_desktop(d
, TRUE
);
136 ob_debug("fake desktop change\n");
139 screen_set_num_desktops(screen_num_desktops
-1);
142 actions_client_move(data
, TRUE
);
This page took 0.042927 seconds and 5 git commands to generate.