]> icculus.org git repositories - dana/openbox.git/blob - openbox/actions/omnipresent.c
Use ObConfigValue to parse gravity coords, remove parse special functions from config...
[dana/openbox.git] / openbox / actions / omnipresent.c
1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/client.h"
4 #include "openbox/client_set.h"
5 #include "openbox/screen.h"
6
7 static gboolean run_func_on(const ObClientSet *set,
8                             const ObActionListRun *data, gpointer options);
9 static gboolean run_func_off(const ObClientSet *set,
10                              const ObActionListRun *data, gpointer options);
11 static gboolean run_func_toggle(const ObClientSet *set,
12                                 const ObActionListRun *data, gpointer options);
13
14 void action_omnipresent_startup(void)
15 {
16     action_register("Omnipresent", OB_ACTION_DEFAULT_FILTER_SINGLE,
17                     NULL, NULL, run_func_on);
18     action_register("Unomnipresent", OB_ACTION_DEFAULT_FILTER_SINGLE,
19                     NULL, NULL, run_func_off);
20     action_register("ToggleOmnipresent", OB_ACTION_DEFAULT_FILTER_SINGLE,
21                     NULL, NULL, run_func_toggle);
22 }
23
24 static gboolean each_off(ObClient *c, const ObActionListRun *data,
25                          gpointer options)
26 {
27     client_set_desktop(c, FALSE, FALSE, TRUE);
28     return TRUE;
29 }
30
31 /* Always return FALSE because its not interactive */
32 static gboolean run_func_off(const ObClientSet *set,
33                              const ObActionListRun *data, gpointer options)
34 {
35     if (!client_set_is_empty(set)) {
36         action_client_move(data, TRUE);
37         client_set_run(set, data, each_off, options);
38         action_client_move(data, FALSE);
39     }
40     return FALSE;
41 }
42
43 static gboolean each_on(ObClient *c, const ObActionListRun *data,
44                          gpointer options)
45 {
46     client_set_desktop(c, TRUE, FALSE, TRUE);
47     return TRUE;
48 }
49
50 /* Always return FALSE because its not interactive */
51 static gboolean run_func_on(const ObClientSet *set,
52                             const ObActionListRun *data, gpointer options)
53 {
54     if (!client_set_is_empty(set)) {
55         action_client_move(data, TRUE);
56         client_set_run(set, data, each_on, options);
57         action_client_move(data, FALSE);
58     }
59     return FALSE;
60 }
61
62 static gboolean each_toggle(ObClient *c, const ObActionListRun *data,
63                          gpointer options)
64 {
65     gboolean omni = c->desktop == DESKTOP_ALL ? screen_desktop : DESKTOP_ALL;
66     client_set_desktop(c, omni, FALSE, TRUE);
67     return TRUE;
68 }
69
70 /* Always return FALSE because its not interactive */
71 static gboolean run_func_toggle(const ObClientSet *set,
72                                 const ObActionListRun *data, gpointer options)
73 {
74     if (!client_set_is_empty(set)) {
75         action_client_move(data, TRUE);
76         client_set_run(set, data, each_toggle, options);
77         action_client_move(data, FALSE);
78     }
79     return FALSE;
80 }