1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
#include "openbox/actions.h"
#include "openbox/client.h"
typedef struct {
gint layer; /*!< -1 for below, 0 for normal, and 1 for above */
gboolean toggle;
} Options;
static gpointer setup_func_top(xmlNodePtr node);
static gpointer setup_func_bottom(xmlNodePtr node);
static gpointer setup_func_send(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
/* 3.4-compatibility */
static gpointer setup_sendtop_func(xmlNodePtr node);
static gpointer setup_sendbottom_func(xmlNodePtr node);
static gpointer setup_sendnormal_func(xmlNodePtr node);
void action_layer_startup(void)
{
actions_register("ToggleAlwaysOnTop", setup_func_top, g_free,
run_func);
actions_register("ToggleAlwaysOnBottom", setup_func_bottom, g_free,
run_func);
actions_register("SendToLayer", setup_func_send, g_free,
run_func);
/* 3.4-compatibility */
actions_register("SendToTopLayer", setup_sendtop_func, g_free,
run_func);
actions_register("SendToBottomLayer", setup_sendbottom_func, g_free,
run_func);
actions_register("SendToNormalLayer", setup_sendnormal_func, g_free,
run_func);
}
static gpointer setup_func_top(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = 1;
o->toggle = TRUE;
return o;
}
static gpointer setup_func_bottom(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = -1;
o->toggle = TRUE;
return o;
}
static gpointer setup_func_send(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
if ((n = obt_xml_find_node(node, "layer"))) {
gchar *s = obt_xml_node_string(n);
if (!g_ascii_strcasecmp(s, "above") ||
!g_ascii_strcasecmp(s, "top"))
o->layer = 1;
else if (!g_ascii_strcasecmp(s, "below") ||
!g_ascii_strcasecmp(s, "bottom"))
o->layer = -1;
else if (!g_ascii_strcasecmp(s, "normal") ||
!g_ascii_strcasecmp(s, "middle"))
o->layer = 0;
g_free(s);
}
return o;
}
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
Options *o = options;
if (data->client) {
ObClient *c = data->client;
actions_client_move(data, TRUE);
if (o->layer < 0) {
if (o->toggle || !c->below)
client_set_layer(c, c->below ? 0 : -1);
}
else if (o->layer > 0) {
if (o->toggle || !c->above)
client_set_layer(c, c->above ? 0 : 1);
}
else if (c->above || c->below)
client_set_layer(c, 0);
actions_client_move(data, FALSE);
}
return FALSE;
}
/* 3.4-compatibility */
static gpointer setup_sendtop_func(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = 1;
o->toggle = FALSE;
return o;
}
static gpointer setup_sendbottom_func(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = -1;
o->toggle = FALSE;
return o;
}
static gpointer setup_sendnormal_func(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = 0;
o->toggle = FALSE;
return o;
}
|