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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
static void _e_resize_begin(void *data, void *bd);
static void _e_resize_update(void *data, void *bd);
static void _e_resize_end(void *data, void *bd);
static void _e_resize_border_extents(E_Border *bd, int *w, int *h);
static void _e_move_begin(void *data, void *bd);
static void _e_move_update(void *data, void *bd);
static void _e_move_end(void *data, void *bd);
static void _e_move_resize_object_coords_set(int x, int y, int w, int h);
static E_Popup *_disp_pop = NULL;
static Evas_Object *_obj = NULL;
static Eina_List *hooks = NULL;
static int visible = 0;
static int obj_x = 0;
static int obj_y = 0;
static int obj_w = 0;
static int obj_h = 0;
EAPI int
e_moveresize_init(void)
{
E_Border_Hook *h;
h = e_border_hook_add(E_BORDER_HOOK_RESIZE_BEGIN, _e_resize_begin, NULL);
if (h) hooks = eina_list_append(hooks, h);
h = e_border_hook_add(E_BORDER_HOOK_RESIZE_UPDATE, _e_resize_update, NULL);
if (h) hooks = eina_list_append(hooks, h);
h = e_border_hook_add(E_BORDER_HOOK_RESIZE_END, _e_resize_end, NULL);
if (h) hooks = eina_list_append(hooks, h);
h = e_border_hook_add(E_BORDER_HOOK_MOVE_BEGIN, _e_move_begin, NULL);
if (h) hooks = eina_list_append(hooks, h);
h = e_border_hook_add(E_BORDER_HOOK_MOVE_UPDATE, _e_move_update, NULL);
if (h) hooks = eina_list_append(hooks, h);
h = e_border_hook_add(E_BORDER_HOOK_MOVE_END, _e_move_end, NULL);
if (h) hooks = eina_list_append(hooks, h);
return 1;
}
EAPI int
e_moveresize_shutdown(void)
{
E_Border_Hook *h;
EINA_LIST_FREE(hooks, h)
e_border_hook_del(h);
return 1;
}
static void
_e_resize_begin(void *data, void *border)
{
E_Border *bd = border;
Evas_Coord ew, eh;
char buf[40];
int w, h;
if (_disp_pop) e_object_del(E_OBJECT(_disp_pop));
_disp_pop = NULL;
_obj = NULL;
if (!e_config->resize_info_visible)
return;
if (e_config->resize_info_follows)
_e_move_resize_object_coords_set(bd->x + bd->fx.x, bd->y + bd->fx.y, bd->w, bd->h);
else
_e_move_resize_object_coords_set(bd->zone->x, bd->zone->y, bd->zone->w, bd->zone->h);
_e_resize_border_extents(bd, &w, &h);
_disp_pop = e_popup_new(bd->zone, 0, 0, 1, 1);
if (!_disp_pop) return;
e_popup_layer_set(_disp_pop, 255);
_obj = edje_object_add(_disp_pop->evas);
e_theme_edje_object_set(_obj, "base/theme/borders",
"e/widgets/border/default/resize");
snprintf(buf, sizeof(buf), "9999x9999");
edje_object_part_text_set(_obj, "e.text.label", buf);
edje_object_size_min_calc(_obj, &ew, &eh);
evas_object_move(_obj, 0, 0);
evas_object_resize(_obj, ew, eh);
evas_object_show(_obj);
e_popup_edje_bg_object_set(_disp_pop, _obj);
if (!visible)
{
evas_object_show(_obj);
e_popup_show(_disp_pop);
visible = 1;
}
snprintf(buf, sizeof(buf), "%ix%i", w, h);
edje_object_part_text_set(_obj, "e.text.label", buf);
e_popup_move_resize(_disp_pop,
(obj_x - _disp_pop->zone->x) +
((obj_w - ew) / 2),
(obj_y - _disp_pop->zone->y) +
((obj_h - eh) / 2),
ew, eh);
e_popup_show(_disp_pop);
visible = 1;
}
static void
_e_resize_end(void *data, void *border)
{
if (e_config->resize_info_visible)
{
if (_obj)
{
evas_object_del(_obj);
_obj = NULL;
}
if (_disp_pop)
{
e_object_del(E_OBJECT(_disp_pop));
_disp_pop = NULL;
}
}
visible = 0;
}
static void
_e_resize_update(void *data, void *border)
{
E_Border *bd = border;
char buf[40];
int w, h;
if (!_disp_pop) return;
if (e_config->resize_info_follows)
_e_move_resize_object_coords_set(bd->x + bd->fx.x, bd->y + bd->fx.y, bd->w, bd->h);
else
_e_move_resize_object_coords_set(bd->zone->x, bd->zone->y, bd->zone->w, bd->zone->h);
_e_resize_border_extents(bd, &w, &h);
if (!visible)
{
evas_object_show(_obj);
e_popup_show(_disp_pop);
visible = 1;
}
snprintf(buf, sizeof(buf), "%ix%i", w, h);
edje_object_part_text_set(_obj, "e.text.label", buf);
}
static void
_e_resize_border_extents(E_Border *bd, int *w, int *h)
{
if ((bd->client.icccm.base_w >= 0) &&
(bd->client.icccm.base_h >= 0))
{
if (bd->client.icccm.step_w > 0)
*w = (bd->client.w - bd->client.icccm.base_w) / bd->client.icccm.step_w;
else
*w = bd->client.w;
if (bd->client.icccm.step_h > 0)
*h = (bd->client.h - bd->client.icccm.base_h) / bd->client.icccm.step_h;
else
*h = bd->client.h;
}
else
{
if (bd->client.icccm.step_w > 0)
*w = (bd->client.w - bd->client.icccm.min_w) / bd->client.icccm.step_w;
else
*w = bd->client.w;
if (bd->client.icccm.step_h > 0)
*h = (bd->client.h - bd->client.icccm.min_h) / bd->client.icccm.step_h;
else
*h = bd->client.h;
}
}
static void
_e_move_begin(void *data, void *border)
{
E_Border *bd = border;
Evas_Coord ew, eh;
char buf[40];
if (_disp_pop) e_object_del(E_OBJECT(_disp_pop));
_disp_pop = NULL;
_obj = NULL;
if (!e_config->move_info_visible)
return;
if (e_config->move_info_follows)
_e_move_resize_object_coords_set(bd->x + bd->fx.x, bd->y + bd->fx.y, bd->w, bd->h);
else
_e_move_resize_object_coords_set(bd->zone->x, bd->zone->y, bd->zone->w, bd->zone->h);
_disp_pop = e_popup_new(bd->zone, 0, 0, 1, 1);
_obj = edje_object_add(_disp_pop->evas);
e_theme_edje_object_set(_obj, "base/theme/borders",
"e/widgets/border/default/move");
snprintf(buf, sizeof(buf), "9999 9999");
edje_object_part_text_set(_obj, "e.text.label", buf);
edje_object_size_min_calc(_obj, &ew, &eh);
evas_object_move(_obj, 0, 0);
evas_object_resize(_obj, ew, eh);
evas_object_show(_obj);
e_popup_edje_bg_object_set(_disp_pop, _obj);
e_popup_move_resize(_disp_pop,
(obj_x - _disp_pop->zone->x) +
((obj_w - ew) / 2),
(obj_y - _disp_pop->zone->y) +
((obj_h - eh) / 2),
ew, eh);
}
static void
_e_move_end(void *data, void *border)
{
if (e_config->move_info_visible)
{
if (_obj)
{
evas_object_del(_obj);
_obj = NULL;
}
if (_disp_pop)
{
e_object_del(E_OBJECT(_disp_pop));
_disp_pop = NULL;
}
}
visible = 0;
}
static void
_e_move_update(void *data, void *border)
{
E_Border *bd = border;
char buf[40];
if (!_disp_pop) return;
if (e_config->move_info_follows)
_e_move_resize_object_coords_set(bd->x + bd->fx.x, bd->y + bd->fx.y, bd->w, bd->h);
else
_e_move_resize_object_coords_set(bd->zone->x, bd->zone->y, bd->zone->w, bd->zone->h);
if (!visible)
{
evas_object_show(_obj);
e_popup_show(_disp_pop);
visible = 1;
}
snprintf(buf, sizeof(buf), "%i %i", bd->x, bd->y);
edje_object_part_text_set(_obj, "e.text.label", buf);
}
static void
_e_move_resize_object_coords_set(int x, int y, int w, int h)
{
obj_x = x;
obj_y = y;
obj_w = w;
obj_h = h;
if ((_disp_pop) && (e_config->move_info_visible) && (visible))
{
e_popup_move(_disp_pop,
(obj_x - _disp_pop->zone->x) +
((obj_w - _disp_pop->w) / 2),
(obj_y - _disp_pop->zone->y) +
((obj_h - _disp_pop->h) / 2)
);
}
}
|