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
234
235
236
237
|
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
/* E_Desk is a child object of E_Zone. A desk is essentially a background
* and an associated set of client windows. Each zone can have an arbitrary
* number of desktops.
*/
static void _e_desk_free(E_Desk *desk);
int _e_desk_current_changing;
static int desk_count;
int
e_desk_init(void)
{
_e_desk_current_changing = 0;
desk_count = 0;
return 1;
}
int
e_desk_shutdown(void)
{
return 1;
}
E_Desk *
e_desk_new(E_Zone *zone, int x, int y)
{
E_Desk *desk;
char name[40];
E_OBJECT_CHECK_RETURN(zone, NULL);
E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, NULL);
desk = E_OBJECT_ALLOC(E_Desk, E_DESK_TYPE, _e_desk_free);
if (!desk) return NULL;
desk->clients = NULL;
desk->zone = zone;
desk->num = ++desk_count;
snprintf(name, sizeof(name), "Desktop %d, %d", x, y);
desk->name = strdup(name);
return desk;
}
void
e_desk_name_set(E_Desk *desk, const char *name)
{
E_OBJECT_CHECK(desk);
E_OBJECT_TYPE_CHECK(desk, E_DESK_TYPE);
if (desk->name)
free(desk->name);
desk->name = strdup(name);
}
void
e_desk_show(E_Desk *desk)
{
Evas_List *l;
int x, y;
E_OBJECT_CHECK(desk);
E_OBJECT_TYPE_CHECK(desk, E_DESK_TYPE);
if (desk->visible) return;
_e_desk_current_changing = 1;
for (l = desk->zone->container->clients; l; l = l->next)
{
E_Border *bd = l->data;
if (bd->desk->zone == desk->zone && !bd->iconic)
{
if (bd->desk == desk || bd->sticky)
{
e_border_show(bd);
}
else
{
e_border_hide(bd);
}
}
}
for (x = 0; x < desk->zone->desk_x_count; x++)
{
for (y = 0; y < desk->zone->desk_y_count; y++)
{
E_Desk *next;
next = e_desk_at_xy_get(desk->zone,x, y);
next->visible = 0;
if (next == desk)
{
desk->zone->desk_x_current = x;
desk->zone->desk_y_current = y;
}
}
}
desk->visible = 1;
_e_desk_current_changing = 0;
}
void
e_desk_row_add(E_Zone *zone)
{
e_zone_desk_count_set(zone, zone->desk_x_count, zone->desk_y_count + 1);
}
void
e_desk_row_remove(E_Zone *zone)
{
e_zone_desk_count_set(zone, zone->desk_x_count, zone->desk_y_count - 1);
}
void
e_desk_col_add(E_Zone *zone)
{
e_zone_desk_count_set(zone, zone->desk_x_count + 1, zone->desk_y_count);
}
void
e_desk_col_remove(E_Zone *zone)
{
e_zone_desk_count_set(zone, zone->desk_x_count - 1, zone->desk_y_count);
}
E_Desk *
e_desk_current_get(E_Zone *zone)
{
E_OBJECT_CHECK_RETURN(zone, NULL);
E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, NULL);
return e_desk_at_xy_get(zone, zone->desk_x_current, zone->desk_y_current);
}
E_Desk *
e_desk_at_xy_get(E_Zone *zone, int x, int y)
{
E_OBJECT_CHECK_RETURN(zone, NULL);
E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, NULL);
if (x >= zone->desk_x_count || y >= zone->desk_y_count)
return NULL;
return (E_Desk *) zone->desks[x + (y * zone->desk_x_count)];
}
void
e_desk_xy_get(E_Desk *desk, int *x, int *y)
{
int xx, yy;
E_OBJECT_CHECK(desk);
E_OBJECT_TYPE_CHECK(desk, E_DESK_TYPE);
for (xx = 0; xx < desk->zone->desk_x_count; xx++)
{
for (yy = 0; yy < desk->zone->desk_y_count; yy++)
{
E_Desk *next;
next = e_desk_at_xy_get(desk->zone, xx, yy);
if (next == desk)
{
*x = xx;
*y = yy;
return;
}
}
}
}
void
e_desk_next(E_Zone *zone)
{
int x, y;
E_OBJECT_CHECK(zone);
E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE);
if (zone->desk_x_count < 2 && zone->desk_y_count < 2)
return;
x = zone->desk_x_current;
y = zone->desk_y_current;
x++;
if (x == zone->desk_x_count)
{
x = 0;
y++;
if (y == zone->desk_y_count)
y = 0;
}
e_desk_show(e_desk_at_xy_get(zone, x, y));
}
void
e_desk_prev(E_Zone *zone)
{
int x, y;
E_OBJECT_CHECK(zone);
E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE);
if (zone->desk_x_count < 2 && zone->desk_y_count < 2)
return;
x = zone->desk_x_current;
y = zone->desk_y_current;
x--;
if (x < 0)
{
x = zone->desk_x_count - 1;
y--;
if (y < 0)
y = zone->desk_y_count - 1;
}
e_desk_show(e_desk_at_xy_get(zone, x, y));
}
static void
_e_desk_free(E_Desk *desk)
{
E_Zone *zone = desk->zone;
if (desk->name)
free(desk->name);
// zone->desks = evas_list_remove(zone->desks, desk);
free(desk);
}
|