discomfitor pushed a commit to branch master.

http://git.enlightenment.org/enlightenment/modules/desksanity.git/commit/?id=19899da34d6f75cc3c9ce7adea1f578ba12031e9

commit 19899da34d6f75cc3c9ce7adea1f578ba12031e9
Author: Mike Blumenkrantz <[email protected]>
Date:   Mon Sep 1 15:28:40 2014 -0400

    allow drags from zoom
---
 e-module-desksanity.edc |  69 ++++++++++++++++++++++++++++
 src/ds_config.c         |   2 +-
 src/zoom.c              | 119 +++++++++++++++++++++++++++++++++++++++++++-----
 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 {
                link.base: "mouse,in" "events";
                link.transition: LINEAR 0.2;
             }
+            desc { "hid"; inherit: "default";
+               color: 255 255 255 0;
+               hid;
+               link.base: "e,drag,begin" "e";
+               link.transition: LINEAR 0.2;
+               link.after: "drag_begin";
+               program { "drag_begin";
+                  action: SIGNAL_EMIT "e,drag,begun" "e";
+               }
+            }
          }
          proxy { "clone";
             desc {
@@ -284,6 +294,7 @@ collections {
                after: "go_hid";
             }
             program { name: "go_hid";
+               signal: "e,drag,begin"; source: "e";
                action: STATE_SET "default" 0.0;
                transition: LINEAR 0.5;
                target: "clone";
@@ -335,4 +346,62 @@ collections {
          }
       }
    }
+   group { "e/modules/desksanity/zoom/client/drag";
+      images.image: "win_shadow.png" COMP;
+      script {
+         public message(Msg_Type:type, id, ...) {
+            if (type == MSG_INT_SET) {
+               /* client diff geom[4] */
+               new x, y, w, h;
+
+               x = getarg(2);
+               y = getarg(3);
+               w = getarg(4);
+               h = getarg(5);
+
+               custom_state(PART:"e.swallow.client", "default", 0.0);
+               set_state_val(PART:"e.swallow.client", STATE_REL1_OFFSET, x, y);
+               set_state_val(PART:"e.swallow.client", STATE_REL2_OFFSET, w, h);
+            }
+         }
+      }
+      parts {
+         rect { "clip";
+            desc {}
+            desc { "hid"; hid;
+               color: 255 255 255 0;
+               link.base: "e,drag,release" "e";
+               link.transition: LINEAR 0.1;
+            }
+         }
+         image { "shadow"; clip: "clip";
+            desc {
+               image.normal: "win_shadow.png";
+               image.border: 14 14 14 14;
+               image.middle: 0;
+               rel1.to: "e.swallow.client";
+               rel1.offset: -7  -3;
+               rel2.to: "e.swallow.client";
+               rel2.offset: 6 11;
+               fill.smooth: 0;
+            }
+         }
+         swallow { "e.swallow.client"; }
+         rect { "over"; clip: "clip";
+            desc {
+               rel1.to: "e.swallow.client";
+               rel2.to: "e.swallow.client";
+               color: 255 255 255 90;
+            }
+         }
+         program { signal: "e,drag,release"; source: "e";
+            action: STATE_SET "custom";
+            target: "e.swallow.client";
+            transition: LINEAR 0.1;
+            sequence {
+               action: SIGNAL_EMIT "e,action,done" "e";
+            }
+         }
+      }
+   }
 }
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)
    if (ds_config->disable_transitions) return;
 
    subm = e_menu_new();
-   e_menu_title_set(subm, D_("Transitions"));
+   e_menu_title_set(subm, D_("Disable Transitions"));
    e_menu_item_submenu_set(mi, subm);
    e_object_unref(E_OBJECT(subm));
 
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 @@
 
 #define MAX_COLS 4
 
+#define DRAG_RESIST 10
+
 typedef Eina_Bool (*Zoom_Filter_Cb)(const E_Client *, E_Zone *);
 
 static Eina_List *zoom_objs = NULL;
 static Eina_List *current = NULL;
+static Eina_List *handlers = NULL;
 static E_Action *act_zoom_desk = NULL;
 static E_Action *act_zoom_desk_all = NULL;
 static E_Action *act_zoom_zone = NULL;
@@ -13,10 +16,12 @@ static E_Action *act_zoom_zone_all = NULL;
 
 static E_Action *cur_act = NULL;
 
-static Eina_List *handlers = NULL;
-
 static int zmw, zmh;
 
+static Evas_Coord dx = -1;
+static Evas_Coord dy = -1;
+static Evas_Object *dm, *dm_drag;
+
 static inline unsigned int
 _cols_calc(unsigned int count)
 {
@@ -26,12 +31,36 @@ _cols_calc(unsigned int count)
    return 4;
 }
 
+static inline void
+_drag_reset(void)
+{
+   dx = dy = -1;
+   dm = NULL;
+   E_FREE_FUNC(dm_drag, evas_object_del);
+}
+
+static void
+_edje_custom_setup(Evas_Object *obj, const E_Client *ec, int x, int y, int w, 
int h)
+{
+   Edje_Message_Int_Set *msg;
+
+   msg = alloca(sizeof(Edje_Message_Int_Set) + ((4 - 1) * sizeof(int)));
+   msg->count = 4;
+   msg->val[0] = ec->client.x - x;
+   msg->val[1] = ec->client.y - y;
+   msg->val[2] = (ec->client.x + ec->client.w) - (x + w);
+   msg->val[3] = (ec->client.y + ec->client.h) - (y + h);
+   edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 0, msg);
+   edje_object_message_signal_process(obj);
+}
+
 static void
 _hid(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, 
const char *src EINA_UNUSED)
 {
    e_comp_shape_queue(e_comp_util_evas_object_comp_get(obj));
    evas_object_hide(obj);
    evas_object_del(obj);
+   _drag_reset();
 }
 
 static void
@@ -56,6 +85,72 @@ _dismiss()
 }
 
 static void
+_client_mouse_down(E_Client *ec EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object 
*obj, Evas_Event_Mouse_Down *ev)
+{
+   dx = ev->output.x;
+   dy = ev->output.y;
+   dm = edje_object_part_swallow_get(obj, "e.swallow.client");
+}
+
+static void
+_client_mouse_up(E_Client *ec, Evas *e EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, Evas_Event_Mouse_Up *ev)
+{
+   E_Zone *zone;
+   E_Desk *desk;
+   int x, y, w, h;
+
+   if (!dm_drag)
+     {
+        _drag_reset();
+        return;
+     }
+   zone = e_comp_zone_xy_get(e_comp_get(NULL), ev->output.x, ev->output.y);
+   desk = e_desk_current_get(zone);
+   ec->hidden = 0;
+   e_client_desk_set(ec, desk);
+   e_client_activate(ec, 1);
+
+   evas_object_geometry_get(edje_object_part_swallow_get(dm_drag, 
"e.swallow.client"), &x, &y, &w, &h);
+   _edje_custom_setup(dm_drag, ec, x, y, w, h);
+
+   edje_object_signal_emit(dm_drag, "e,drag,release", "e");
+}
+
+static Eina_Bool
+_client_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, 
Ecore_Event_Mouse_Move *ev)
+{
+   int x, y, w, h;
+
+   if (!dm) return ECORE_CALLBACK_RENEW;
+
+   evas_object_geometry_get(dm, &x, &y, &w, &h);
+   if (!dm_drag)
+     {
+        Evas_Object *m;
+
+        /* no adjust, not X coords */
+        if ((abs(ev->root.x - dx) < DRAG_RESIST) && (abs(ev->root.y - dy) < 
DRAG_RESIST)) return ECORE_CALLBACK_RENEW;
+        dm_drag = edje_object_add(evas_object_evas_get(dm));
+        evas_object_pass_events_set(dm_drag, 1);
+        evas_object_size_hint_min_get(dm, &w, &h);
+        e_theme_edje_object_set(dm_drag, NULL, 
"e/modules/desksanity/zoom/client/drag");
+        edje_object_signal_callback_add(dm_drag, "e,action,done", "e", 
_dismiss, NULL);
+        evas_object_layer_set(dm_drag, E_LAYER_POPUP);
+        evas_object_resize(dm_drag, w, h);
+        m = e_comp_object_util_mirror_add(dm);
+        e_comp_object_util_del_list_append(dm_drag, m);
+        evas_object_size_hint_min_set(m, w, h);
+        edje_object_part_swallow(dm_drag, "e.swallow.client", m);
+        evas_object_show(dm_drag);
+        edje_object_signal_emit(evas_object_smart_parent_get(dm), 
"e,drag,begin", "e");
+     }
+   evas_object_move(dm_drag,
+     e_comp_canvas_x_root_adjust(e_comp_get(NULL), ev->root.x) - (dx - x),
+     e_comp_canvas_y_root_adjust(e_comp_get(NULL), ev->root.y) - (dy - y));
+   return ECORE_CALLBACK_RENEW;
+}
+
+static void
 _client_activate(void *data, Evas_Object *obj EINA_UNUSED, const char *sig 
EINA_UNUSED, const char *src EINA_UNUSED)
 {
    e_client_activate(data, 1);
@@ -96,6 +191,12 @@ _zoomobj_pack_client(const E_Client *ec, const E_Zone 
*zone, Evas_Object *tb, Ev
 }
 
 static void
+_client_drag_begun(void *data EINA_UNUSED, Evas_Object *obj, const char *sig 
EINA_UNUSED, const char *src EINA_UNUSED)
+{
+   evas_object_hide(obj);
+}
+
+static void
 _zoomobj_add_client(Evas_Object *zoom_obj, Eina_List *l, Evas_Object *m)
 {
    E_Client *ec;
@@ -107,10 +208,13 @@ _zoomobj_add_client(Evas_Object *zoom_obj, Eina_List *l, 
Evas_Object *m)
    e_comp_object_util_del_list_append(zoom_obj, e);
    e_comp_object_util_del_list_append(zoom_obj, m);
    e_theme_edje_object_set(e, NULL, "e/modules/desksanity/zoom/client");
+   evas_object_event_callback_add(e, EVAS_CALLBACK_MOUSE_DOWN, 
(Evas_Object_Event_Cb)_client_mouse_down, ec);
+   evas_object_event_callback_add(e, EVAS_CALLBACK_MOUSE_UP, 
(Evas_Object_Event_Cb)_client_mouse_up, ec);
    if ((!zmw) && (!zmh))
      edje_object_size_min_calc(e, &zmw, &zmh);
    edje_object_signal_callback_add(e, "e,action,activate", "e", 
_client_activate, ec);
    edje_object_signal_callback_add(e, "e,state,active", "e", _client_active, 
ec);
+   edje_object_signal_callback_add(e, "e,drag,begun", "e", _client_drag_begun, 
ec);
    if (e_client_focused_get() == ec)
      {
         edje_object_signal_emit(e, "e,state,focused", "e");
@@ -135,19 +239,11 @@ _zoomobj_position_client(Evas_Object *m)
    int x, y, w, h;
    E_Client *ec;
    Evas_Object *e;
-   Edje_Message_Int_Set *msg;
 
    e = evas_object_smart_parent_get(m);
    ec = evas_object_data_get(m, "E_Client");
    evas_object_geometry_get(e, &x, &y, &w, &h);
-   msg = alloca(sizeof(Edje_Message_Int_Set) + ((4 - 1) * sizeof(int)));
-   msg->count = 4;
-   msg->val[0] = ec->client.x - x;
-   msg->val[1] = ec->client.y - y;
-   msg->val[2] = (ec->client.x + ec->client.w) - (x + w);
-   msg->val[3] = (ec->client.y + ec->client.h) - (y + h);
-   edje_object_message_send(e, EDJE_MESSAGE_INT_SET, 0, msg);
-   edje_object_message_signal_process(e);
+   _edje_custom_setup(e, ec, x, y, w, h);
    edje_object_signal_emit(e, "e,action,show", "e");
 }
 
@@ -370,6 +466,7 @@ zoom(Eina_List *clients, E_Zone *zone)
         E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_PROPERTY, 
_zoom_client_property, NULL);
         E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ADD, _zoom_client_add, 
NULL);
         E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_REMOVE, 
_zoom_client_del, NULL);
+        E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE, 
_client_mouse_move, NULL);
      }
 
    zoom_obj = edje_object_add(comp->evas);

-- 


Reply via email to