summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2014-09-01 15:28:40 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2014-09-01 15:28:40 -0400
commit19899da34d6f75cc3c9ce7adea1f578ba12031e9 (patch)
tree02d252162245369231a12a9d6786b59bbea6bd37
parent4c83676a7440cc18fc6ef83d88732feda20729be (diff)
allow drags from zoom
-rw-r--r--e-module-desksanity.edc69
-rw-r--r--src/ds_config.c2
-rw-r--r--src/zoom.c119
3 files changed, 178 insertions, 12 deletions
diff --git a/e-module-desksanity.edc b/e-module-desksanity.edc
index 430e654..3ee67ba 100644
--- a/e-module-desksanity.edc
+++ b/e-module-desksanity.edc
@@ -239,6 +239,16 @@ collections {
239 link.base: "mouse,in" "events"; 239 link.base: "mouse,in" "events";
240 link.transition: LINEAR 0.2; 240 link.transition: LINEAR 0.2;
241 } 241 }
242 desc { "hid"; inherit: "default";
243 color: 255 255 255 0;
244 hid;
245 link.base: "e,drag,begin" "e";
246 link.transition: LINEAR 0.2;
247 link.after: "drag_begin";
248 program { "drag_begin";
249 action: SIGNAL_EMIT "e,drag,begun" "e";
250 }
251 }
242 } 252 }
243 proxy { "clone"; 253 proxy { "clone";
244 desc { 254 desc {
@@ -284,6 +294,7 @@ collections {
284 after: "go_hid"; 294 after: "go_hid";
285 } 295 }
286 program { name: "go_hid"; 296 program { name: "go_hid";
297 signal: "e,drag,begin"; source: "e";
287 action: STATE_SET "default" 0.0; 298 action: STATE_SET "default" 0.0;
288 transition: LINEAR 0.5; 299 transition: LINEAR 0.5;
289 target: "clone"; 300 target: "clone";
@@ -335,4 +346,62 @@ collections {
335 } 346 }
336 } 347 }
337 } 348 }
349 group { "e/modules/desksanity/zoom/client/drag";
350 images.image: "win_shadow.png" COMP;
351 script {
352 public message(Msg_Type:type, id, ...) {
353 if (type == MSG_INT_SET) {
354 /* client diff geom[4] */
355 new x, y, w, h;
356
357 x = getarg(2);
358 y = getarg(3);
359 w = getarg(4);
360 h = getarg(5);
361
362 custom_state(PART:"e.swallow.client", "default", 0.0);
363 set_state_val(PART:"e.swallow.client", STATE_REL1_OFFSET, x, y);
364 set_state_val(PART:"e.swallow.client", STATE_REL2_OFFSET, w, h);
365 }
366 }
367 }
368 parts {
369 rect { "clip";
370 desc {}
371 desc { "hid"; hid;
372 color: 255 255 255 0;
373 link.base: "e,drag,release" "e";
374 link.transition: LINEAR 0.1;
375 }
376 }
377 image { "shadow"; clip: "clip";
378 desc {
379 image.normal: "win_shadow.png";
380 image.border: 14 14 14 14;
381 image.middle: 0;
382 rel1.to: "e.swallow.client";
383 rel1.offset: -7 -3;
384 rel2.to: "e.swallow.client";
385 rel2.offset: 6 11;
386 fill.smooth: 0;
387 }
388 }
389 swallow { "e.swallow.client"; }
390 rect { "over"; clip: "clip";
391 desc {
392 rel1.to: "e.swallow.client";
393 rel2.to: "e.swallow.client";
394 color: 255 255 255 90;
395 }
396 }
397 program { signal: "e,drag,release"; source: "e";
398 action: STATE_SET "custom";
399 target: "e.swallow.client";
400 transition: LINEAR 0.1;
401 sequence {
402 action: SIGNAL_EMIT "e,action,done" "e";
403 }
404 }
405 }
406 }
338} 407}
diff --git a/src/ds_config.c b/src/ds_config.c
index b8134d7..d95ec2d 100644
--- a/src/ds_config.c
+++ b/src/ds_config.c
@@ -106,7 +106,7 @@ _ds_menu_add(void *data EINA_UNUSED, E_Menu *m)
106 if (ds_config->disable_transitions) return; 106 if (ds_config->disable_transitions) return;
107 107
108 subm = e_menu_new(); 108 subm = e_menu_new();
109 e_menu_title_set(subm, D_("Transitions")); 109 e_menu_title_set(subm, D_("Disable Transitions"));
110 e_menu_item_submenu_set(mi, subm); 110 e_menu_item_submenu_set(mi, subm);
111 e_object_unref(E_OBJECT(subm)); 111 e_object_unref(E_OBJECT(subm));
112 112
diff --git a/src/zoom.c b/src/zoom.c
index 59cafe3..e4f870e 100644
--- a/src/zoom.c
+++ b/src/zoom.c
@@ -2,10 +2,13 @@
2 2
3#define MAX_COLS 4 3#define MAX_COLS 4
4 4
5#define DRAG_RESIST 10
6
5typedef Eina_Bool (*Zoom_Filter_Cb)(const E_Client *, E_Zone *); 7typedef Eina_Bool (*Zoom_Filter_Cb)(const E_Client *, E_Zone *);
6 8
7static Eina_List *zoom_objs = NULL; 9static Eina_List *zoom_objs = NULL;
8static Eina_List *current = NULL; 10static Eina_List *current = NULL;
11static Eina_List *handlers = NULL;
9static E_Action *act_zoom_desk = NULL; 12static E_Action *act_zoom_desk = NULL;
10static E_Action *act_zoom_desk_all = NULL; 13static E_Action *act_zoom_desk_all = NULL;
11static E_Action *act_zoom_zone = NULL; 14static E_Action *act_zoom_zone = NULL;
@@ -13,10 +16,12 @@ static E_Action *act_zoom_zone_all = NULL;
13 16
14static E_Action *cur_act = NULL; 17static E_Action *cur_act = NULL;
15 18
16static Eina_List *handlers = NULL;
17
18static int zmw, zmh; 19static int zmw, zmh;
19 20
21static Evas_Coord dx = -1;
22static Evas_Coord dy = -1;
23static Evas_Object *dm, *dm_drag;
24
20static inline unsigned int 25static inline unsigned int
21_cols_calc(unsigned int count) 26_cols_calc(unsigned int count)
22{ 27{
@@ -26,12 +31,36 @@ _cols_calc(unsigned int count)
26 return 4; 31 return 4;
27} 32}
28 33
34static inline void
35_drag_reset(void)
36{
37 dx = dy = -1;
38 dm = NULL;
39 E_FREE_FUNC(dm_drag, evas_object_del);
40}
41
42static void
43_edje_custom_setup(Evas_Object *obj, const E_Client *ec, int x, int y, int w, int h)
44{
45 Edje_Message_Int_Set *msg;
46
47 msg = alloca(sizeof(Edje_Message_Int_Set) + ((4 - 1) * sizeof(int)));
48 msg->count = 4;
49 msg->val[0] = ec->client.x - x;
50 msg->val[1] = ec->client.y - y;
51 msg->val[2] = (ec->client.x + ec->client.w) - (x + w);
52 msg->val[3] = (ec->client.y + ec->client.h) - (y + h);
53 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 0, msg);
54 edje_object_message_signal_process(obj);
55}
56
29static void 57static void
30_hid(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED) 58_hid(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
31{ 59{
32 e_comp_shape_queue(e_comp_util_evas_object_comp_get(obj)); 60 e_comp_shape_queue(e_comp_util_evas_object_comp_get(obj));
33 evas_object_hide(obj); 61 evas_object_hide(obj);
34 evas_object_del(obj); 62 evas_object_del(obj);
63 _drag_reset();
35} 64}
36 65
37static void 66static void
@@ -56,6 +85,72 @@ _dismiss()
56} 85}
57 86
58static void 87static void
88_client_mouse_down(E_Client *ec EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, Evas_Event_Mouse_Down *ev)
89{
90 dx = ev->output.x;
91 dy = ev->output.y;
92 dm = edje_object_part_swallow_get(obj, "e.swallow.client");
93}
94
95static void
96_client_mouse_up(E_Client *ec, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Event_Mouse_Up *ev)
97{
98 E_Zone *zone;
99 E_Desk *desk;
100 int x, y, w, h;
101
102 if (!dm_drag)
103 {
104 _drag_reset();
105 return;
106 }
107 zone = e_comp_zone_xy_get(e_comp_get(NULL), ev->output.x, ev->output.y);
108 desk = e_desk_current_get(zone);
109 ec->hidden = 0;
110 e_client_desk_set(ec, desk);
111 e_client_activate(ec, 1);
112
113 evas_object_geometry_get(edje_object_part_swallow_get(dm_drag, "e.swallow.client"), &x, &y, &w, &h);
114 _edje_custom_setup(dm_drag, ec, x, y, w, h);
115
116 edje_object_signal_emit(dm_drag, "e,drag,release", "e");
117}
118
119static Eina_Bool
120_client_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
121{
122 int x, y, w, h;
123
124 if (!dm) return ECORE_CALLBACK_RENEW;
125
126 evas_object_geometry_get(dm, &x, &y, &w, &h);
127 if (!dm_drag)
128 {
129 Evas_Object *m;
130
131 /* no adjust, not X coords */
132 if ((abs(ev->root.x - dx) < DRAG_RESIST) && (abs(ev->root.y - dy) < DRAG_RESIST)) return ECORE_CALLBACK_RENEW;
133 dm_drag = edje_object_add(evas_object_evas_get(dm));
134 evas_object_pass_events_set(dm_drag, 1);
135 evas_object_size_hint_min_get(dm, &w, &h);
136 e_theme_edje_object_set(dm_drag, NULL, "e/modules/desksanity/zoom/client/drag");
137 edje_object_signal_callback_add(dm_drag, "e,action,done", "e", _dismiss, NULL);
138 evas_object_layer_set(dm_drag, E_LAYER_POPUP);
139 evas_object_resize(dm_drag, w, h);
140 m = e_comp_object_util_mirror_add(dm);
141 e_comp_object_util_del_list_append(dm_drag, m);
142 evas_object_size_hint_min_set(m, w, h);
143 edje_object_part_swallow(dm_drag, "e.swallow.client", m);
144 evas_object_show(dm_drag);
145 edje_object_signal_emit(evas_object_smart_parent_get(dm), "e,drag,begin", "e");
146 }
147 evas_object_move(dm_drag,
148 e_comp_canvas_x_root_adjust(e_comp_get(NULL), ev->root.x) - (dx - x),
149 e_comp_canvas_y_root_adjust(e_comp_get(NULL), ev->root.y) - (dy - y));
150 return ECORE_CALLBACK_RENEW;
151}
152
153static void
59_client_activate(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED) 154_client_activate(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
60{ 155{
61 e_client_activate(data, 1); 156 e_client_activate(data, 1);
@@ -96,6 +191,12 @@ _zoomobj_pack_client(const E_Client *ec, const E_Zone *zone, Evas_Object *tb, Ev
96} 191}
97 192
98static void 193static void
194_client_drag_begun(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
195{
196 evas_object_hide(obj);
197}
198
199static void
99_zoomobj_add_client(Evas_Object *zoom_obj, Eina_List *l, Evas_Object *m) 200_zoomobj_add_client(Evas_Object *zoom_obj, Eina_List *l, Evas_Object *m)
100{ 201{
101 E_Client *ec; 202 E_Client *ec;
@@ -107,10 +208,13 @@ _zoomobj_add_client(Evas_Object *zoom_obj, Eina_List *l, Evas_Object *m)
107 e_comp_object_util_del_list_append(zoom_obj, e); 208 e_comp_object_util_del_list_append(zoom_obj, e);
108 e_comp_object_util_del_list_append(zoom_obj, m); 209 e_comp_object_util_del_list_append(zoom_obj, m);
109 e_theme_edje_object_set(e, NULL, "e/modules/desksanity/zoom/client"); 210 e_theme_edje_object_set(e, NULL, "e/modules/desksanity/zoom/client");
211 evas_object_event_callback_add(e, EVAS_CALLBACK_MOUSE_DOWN, (Evas_Object_Event_Cb)_client_mouse_down, ec);
212 evas_object_event_callback_add(e, EVAS_CALLBACK_MOUSE_UP, (Evas_Object_Event_Cb)_client_mouse_up, ec);
110 if ((!zmw) && (!zmh)) 213 if ((!zmw) && (!zmh))
111 edje_object_size_min_calc(e, &zmw, &zmh); 214 edje_object_size_min_calc(e, &zmw, &zmh);
112 edje_object_signal_callback_add(e, "e,action,activate", "e", _client_activate, ec); 215 edje_object_signal_callback_add(e, "e,action,activate", "e", _client_activate, ec);
113 edje_object_signal_callback_add(e, "e,state,active", "e", _client_active, ec); 216 edje_object_signal_callback_add(e, "e,state,active", "e", _client_active, ec);
217 edje_object_signal_callback_add(e, "e,drag,begun", "e", _client_drag_begun, ec);
114 if (e_client_focused_get() == ec) 218 if (e_client_focused_get() == ec)
115 { 219 {
116 edje_object_signal_emit(e, "e,state,focused", "e"); 220 edje_object_signal_emit(e, "e,state,focused", "e");
@@ -135,19 +239,11 @@ _zoomobj_position_client(Evas_Object *m)
135 int x, y, w, h; 239 int x, y, w, h;
136 E_Client *ec; 240 E_Client *ec;
137 Evas_Object *e; 241 Evas_Object *e;
138 Edje_Message_Int_Set *msg;
139 242
140 e = evas_object_smart_parent_get(m); 243 e = evas_object_smart_parent_get(m);
141 ec = evas_object_data_get(m, "E_Client"); 244 ec = evas_object_data_get(m, "E_Client");
142 evas_object_geometry_get(e, &x, &y, &w, &h); 245 evas_object_geometry_get(e, &x, &y, &w, &h);
143 msg = alloca(sizeof(Edje_Message_Int_Set) + ((4 - 1) * sizeof(int))); 246 _edje_custom_setup(e, ec, x, y, w, h);
144 msg->count = 4;
145 msg->val[0] = ec->client.x - x;
146 msg->val[1] = ec->client.y - y;
147 msg->val[2] = (ec->client.x + ec->client.w) - (x + w);
148 msg->val[3] = (ec->client.y + ec->client.h) - (y + h);
149 edje_object_message_send(e, EDJE_MESSAGE_INT_SET, 0, msg);
150 edje_object_message_signal_process(e);
151 edje_object_signal_emit(e, "e,action,show", "e"); 247 edje_object_signal_emit(e, "e,action,show", "e");
152} 248}
153 249
@@ -370,6 +466,7 @@ zoom(Eina_List *clients, E_Zone *zone)
370 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_PROPERTY, _zoom_client_property, NULL); 466 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_PROPERTY, _zoom_client_property, NULL);
371 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ADD, _zoom_client_add, NULL); 467 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ADD, _zoom_client_add, NULL);
372 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_REMOVE, _zoom_client_del, NULL); 468 E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_REMOVE, _zoom_client_del, NULL);
469 E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _client_mouse_move, NULL);
373 } 470 }
374 471
375 zoom_obj = edje_object_add(comp->evas); 472 zoom_obj = edje_object_add(comp->evas);