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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
#include "e_mod_main.h"
static int _log_dom = -1;
#undef DBG
#undef WARN
#undef INF
#undef ERR
#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
#define WARN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__)
#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
static Eldbus_Message *
cb_virtual_desktops(const Eldbus_Service_Interface *iface __UNUSED__,
const Eldbus_Message *msg)
{
Eldbus_Message *reply = eldbus_message_method_return_new(msg);
eldbus_message_arguments_append(reply, "ii", e_config->zone_desks_x_count,
e_config->zone_desks_y_count);
DBG("GetVirtualCount: %d %d",
e_config->zone_desks_x_count, e_config->zone_desks_y_count);
return reply;
}
static Eldbus_Message *
cb_desktop_show(const Eldbus_Service_Interface *iface __UNUSED__,
const Eldbus_Message *msg)
{
int x, y;
Eldbus_Message *reply = eldbus_message_method_return_new(msg);
E_Zone *zone;
if (!eldbus_message_arguments_get(msg, "ii", &x, &y))
{
ERR("could not get Show arguments");
return reply;
}
zone = e_util_zone_current_get(e_manager_current_get());
DBG("show desktop %d,%d from zone %p.", x, y, zone);
e_zone_desk_flip_to(zone, x, y);
return reply;
}
static Eldbus_Message *
cb_desktop_show_by_name(const Eldbus_Service_Interface *iface __UNUSED__,
const Eldbus_Message *msg)
{
Eldbus_Message *reply = eldbus_message_method_return_new(msg);
const char *name;
E_Zone *zone;
unsigned int i, count;
if (!eldbus_message_arguments_get(msg, "s", &name))
{
ERR("could not get Show arguments");
return reply;
}
zone = e_util_zone_current_get(e_manager_current_get());
DBG("show desktop %s from zone %p.", name, zone);
count = zone->desk_x_count * zone->desk_y_count;
for (i = 0; i < count; i++)
{
E_Desk *desk = zone->desks[i];
if ((desk->name) && (strcmp(desk->name, name) == 0))
{
DBG("show desktop %s (%d,%d) from zone %p.", name, desk->x,
desk->y, zone);
e_zone_desk_flip_to(zone, desk->x, desk->y);
break;
}
}
return reply;
}
static Eldbus_Message *
cb_desktop_lock(const Eldbus_Service_Interface *iface __UNUSED__,
const Eldbus_Message *msg)
{
DBG("desklock requested");
e_desklock_show(EINA_FALSE);
return eldbus_message_method_return_new(msg);
}
static Eldbus_Message *
cb_desktop_unlock(const Eldbus_Service_Interface *iface __UNUSED__,
const Eldbus_Message *msg)
{
DBG("deskunlock requested");
e_desklock_hide();
return eldbus_message_method_return_new(msg);
}
static Eldbus_Message *
cb_desktop_bgadd(const Eldbus_Service_Interface *iface __UNUSED__,
const Eldbus_Message *msg)
{
int container, zone, desk_x, desk_y;
const char *path;
Eldbus_Message *reply = eldbus_message_method_return_new(msg);
if (!eldbus_message_arguments_get(msg, "iiiis", &container, &zone, &desk_x,
&desk_y, &path))
{
ERR("could not get Add arguments");
return reply;
}
DBG("add bg container=%d, zone=%d, pos=%d,%d path=%s",
container, zone, desk_x, desk_y, path);
e_bg_add(container, zone, desk_x, desk_y, path);
e_bg_update();
e_config_save_queue();
return reply;
}
static Eldbus_Message *
cb_desktop_bgdel(const Eldbus_Service_Interface *iface __UNUSED__,
const Eldbus_Message *msg)
{
int container, zone, desk_x, desk_y;
Eldbus_Message *reply = eldbus_message_method_return_new(msg);
if (!eldbus_message_arguments_get(msg, "iiii", &container, &zone, &desk_x,
&desk_y))
{
ERR("could not get Del arguments");
return reply;
}
DBG("del bg container=%d, zone=%d, pos=%d,%d",
container, zone, desk_x, desk_y);
e_bg_del(container, zone, desk_x, desk_y);
e_bg_update();
e_config_save_queue();
return reply;
}
static Eldbus_Message *
cb_desktop_bglist(const Eldbus_Service_Interface *iface __UNUSED__,
const Eldbus_Message *msg)
{
Eina_List *list;
E_Config_Desktop_Background *bg;
Eldbus_Message *reply = eldbus_message_method_return_new(msg);
Eldbus_Message_Iter *main_iter, *array;
if (!reply)
return NULL;
main_iter = eldbus_message_iter_get(reply);
if (!main_iter)
return reply;
if (!eldbus_message_iter_arguments_append(main_iter, "a(iiiis)", &array))
return reply;
EINA_LIST_FOREACH(e_config->desktop_backgrounds, list, bg)
{
Eldbus_Message_Iter *s;
if (!bg || !bg->file)
{
continue;
}
DBG("Background container=%d zone=%d pos=%d,%d path=%s",
bg->container, bg->zone, bg->desk_x, bg->desk_y, bg->file);
eldbus_message_iter_arguments_append(array, "(iiiis)", &s);
if (!s) continue;
eldbus_message_iter_arguments_append(s, "iiiis", bg->container, bg->zone,
bg->desk_x, bg->desk_y, bg->file);
eldbus_message_iter_container_close(array, s);
}
eldbus_message_iter_container_close(main_iter, array);
return reply;
}
static const Eldbus_Method desktop_methods[] = {
{ "GetVirtualCount", NULL, ELDBUS_ARGS({"i", "desk_x"}, {"i", "desk_y"}),
cb_virtual_desktops },
{ "Show", ELDBUS_ARGS({"i", "desk_x"}, {"i", "desk_y"}), NULL,
cb_desktop_show },
{ "ShowByName", ELDBUS_ARGS({"s", "desk_name"}), NULL,
cb_desktop_show_by_name },
{ "Lock", NULL, NULL, cb_desktop_lock },
{ "Unlock", NULL, NULL, cb_desktop_unlock },
{ }
};
static const Eldbus_Method background_methods[] = {
{ "Add",
ELDBUS_ARGS({"i", "container"}, {"i", "zone"}, {"i", "desk_x"}, {"i", "desk_y"}, {"s", "path"}),
NULL, cb_desktop_bgadd },
{ "Del", ELDBUS_ARGS({"i", "container"}, {"i", "zone"}, {"i", "desk_x"}, {"i", "desk_y"}),
NULL, cb_desktop_bgdel },
{ "List", ELDBUS_ARGS({"a(iiiis)", "array_of_bg"}), NULL, cb_desktop_bglist },
{ }
};
static const Eldbus_Service_Interface_Desc desktop = {
"org.enlightenment.wm.Desktop", desktop_methods
};
static const Eldbus_Service_Interface_Desc bg = {
"org.enlightenment.wm.Desktop.Background", background_methods
};
void msgbus_desktop_init(Eina_Array *ifaces)
{
Eldbus_Service_Interface *iface;
if (_log_dom == -1)
{
_log_dom = eina_log_domain_register("msgbus_desktop", EINA_COLOR_BLUE);
if (_log_dom < 0)
EINA_LOG_ERR("could not register msgbus_desktop log domain!");
}
iface = e_msgbus_interface_attach(&desktop);
if (iface)
eina_array_push(ifaces, iface);
iface = NULL;
iface = e_msgbus_interface_attach(&bg);
if (iface)
eina_array_push(ifaces, iface);
}
|