From 123a6e786ea9deda09151d05298bf4175dc2e077 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Wed, 16 Dec 2009 02:21:28 +0000 Subject: [PATCH] Add drag_start and drag_end to policy. Remove old dead code. SVN revision: 44493 --- src/modules/illume2/e_mod_dnd.c | 79 +--------------------- src/modules/illume2/e_mod_layout.c | 18 +++++ src/modules/illume2/e_mod_layout.h | 2 + src/modules/illume2/e_mod_layout_illume.c | 81 ++++++++++++++++++++++- src/modules/illume2/e_mod_main.c | 19 ------ 5 files changed, 100 insertions(+), 99 deletions(-) diff --git a/src/modules/illume2/e_mod_dnd.c b/src/modules/illume2/e_mod_dnd.c index 515cae7ad..d96054215 100644 --- a/src/modules/illume2/e_mod_dnd.c +++ b/src/modules/illume2/e_mod_dnd.c @@ -3,16 +3,9 @@ #include "e_mod_dnd.h" /* local function prototypes */ -static void _cb_dnd_enter(void *data, const char *type, void *event); -static void _cb_dnd_move(void *data, const char *type, void *event); -static void _cb_dnd_leave(void *data, const char *type, void *event); -static void _cb_dnd_drop(void *data, const char *type, void *event); -static int _cb_zone_move_resize(void *data, int type, void *event); /* local variables */ -static E_Drop_Handler *drop_handler = NULL; -static const char *drop_types[] = { "illume/indicator" }; -static Ecore_Event_Handler *handler = NULL; +static Eina_List *handlers = NULL; /* public functions */ EAPI int @@ -21,18 +14,6 @@ e_mod_dnd_init(void) E_Zone *z; z = e_util_container_zone_number_get(0, 0); - e_drop_xdnd_register_set(z->container->bg_win, 1); - - handler = - ecore_event_handler_add(E_EVENT_ZONE_MOVE_RESIZE, - _cb_zone_move_resize, z); - - drop_handler = - e_drop_handler_add(E_OBJECT(z), z, - _cb_dnd_enter, _cb_dnd_move, - _cb_dnd_leave, _cb_dnd_drop, - drop_types, 1, z->x, z->y, z->w, z->h); - e_drop_handler_responsive_set(drop_handler); return 1; } @@ -40,65 +21,7 @@ e_mod_dnd_init(void) EAPI int e_mod_dnd_shutdown(void) { - if (handler) ecore_event_handler_del(handler); - handler = NULL; - if (drop_handler) e_drop_handler_del(drop_handler); - drop_handler = NULL; return 1; } /* local functions */ -static void -_cb_dnd_enter(void *data, const char *type, void *event) -{ - E_Event_Dnd_Enter *ev; - - ev = event; - printf("Dnd Enter\n"); - if (strcmp(type, drop_types[0])) return; - e_drop_handler_action_set(ev->action); -} - -static void -_cb_dnd_move(void *data, const char *type, void *event) -{ - E_Event_Dnd_Move *ev; - - ev = event; - printf("Dnd Move\n"); - if (strcmp(type, drop_types[0])) return; - e_drop_handler_action_set(ev->action); -} - -static void -_cb_dnd_leave(void *data, const char *type, void *event) -{ - E_Event_Dnd_Leave *ev; - - ev = event; - printf("Dnd Leave\n"); - if (strcmp(type, drop_types[0])) return; -} - -static void -_cb_dnd_drop(void *data, const char *type, void *event) -{ - E_Event_Dnd_Drop *ev; - - ev = event; - printf("Dnd Drop\n"); - if (strcmp(type, drop_types[0])) return; -} - -static int -_cb_zone_move_resize(void *data, int type, void *event) -{ - E_Event_Zone_Move_Resize *ev; - E_Zone *z; - - if (!(z = data)) return 1; - ev = event; - if ((ev->zone != z)) return 1; - e_drop_handler_geometry_set(drop_handler, z->x, z->y, z->w, z->h); - return 1; -} diff --git a/src/modules/illume2/e_mod_layout.c b/src/modules/illume2/e_mod_layout.c index cf3114025..0685efab7 100644 --- a/src/modules/illume2/e_mod_layout.c +++ b/src/modules/illume2/e_mod_layout.c @@ -723,5 +723,23 @@ _cb_event_client_message(void *data, int type, void *event) if (!(bd = e_border_focused_get())) return 1; e_border_act_close_begin(bd); } + else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_DRAG_START) + { + E_Border *bd; + + bd = e_border_find_by_client_window(ev->win); + if (bd->stolen) return 1; + if ((mode) && (mode->funcs.drag_start)) + mode->funcs.drag_start(bd); + } + else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_DRAG_END) + { + E_Border *bd; + + bd = e_border_find_by_client_window(ev->win); + if (bd->stolen) return 1; + if ((mode) && (mode->funcs.drag_end)) + mode->funcs.drag_end(bd); + } return 1; } diff --git a/src/modules/illume2/e_mod_layout.h b/src/modules/illume2/e_mod_layout.h index 9f53f1bf5..063b8f3cd 100644 --- a/src/modules/illume2/e_mod_layout.h +++ b/src/modules/illume2/e_mod_layout.h @@ -30,6 +30,8 @@ struct _Illume_Layout_Mode void (*zone_move_resize) (E_Zone *zone); // --- add more below (activate callback, and more) void (*border_activate) (E_Border *bd); + void (*drag_start) (E_Border *bd); + void (*drag_end) (E_Border *bd); } funcs; }; diff --git a/src/modules/illume2/e_mod_layout_illume.c b/src/modules/illume2/e_mod_layout_illume.c index ff32778a9..befabf365 100644 --- a/src/modules/illume2/e_mod_layout_illume.c +++ b/src/modules/illume2/e_mod_layout_illume.c @@ -12,17 +12,24 @@ static void _border_del(E_Border *bd); static void _border_focus_in(E_Border *bd); static void _border_focus_out(E_Border *bd); static void _border_activate(E_Border *bd); +static void _drag_start(E_Border *bd); +static void _drag_end(E_Border *bd); static void _zone_layout(E_Zone *z); static void _zone_layout_single(E_Border *bd); static void _zone_layout_dual(E_Border *bd); static void _zone_layout_dual_top(E_Border *bd); static void _zone_layout_dual_left(E_Border *bd); static void _zone_move_resize(E_Zone *z); +static int _cb_mouse_up(void *data, int type, void *event); +static int _cb_mouse_move(void *data, int type, void *event); /* local variables */ static int shelfsize = 0; static int kbdsize = 0; static int panelsize = 0; +static Ecore_X_Window _drag_win = 0; +static Eina_List *handlers = NULL; +static E_Border *_drag_border = NULL; const Illume_Layout_Mode laymode = { @@ -30,7 +37,8 @@ const Illume_Layout_Mode laymode = _border_add, _border_del, _border_focus_in, _border_focus_out, _zone_layout, _zone_move_resize, - _border_activate + _border_activate, + _drag_start, _drag_end }; /* public functions */ @@ -38,11 +46,24 @@ void illume_layout_illume_init(void) { illume_layout_mode_register(&laymode); + handlers = + eina_list_append(handlers, + ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, + _cb_mouse_up, NULL)); + handlers = + eina_list_append(handlers, + ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, + _cb_mouse_move, NULL)); } void illume_layout_illume_shutdown(void) { + Ecore_Event_Handler *handler; + + EINA_LIST_FREE(handlers, handler) + ecore_event_handler_del(handler); + illume_layout_mode_unregister(&laymode); } @@ -196,6 +217,34 @@ _border_activate(E_Border *bd) } } +static void +_drag_start(E_Border *bd) +{ + E_Container *con; + + /* HANDLE A BORDER DRAG BEING STARTED */ + + if (_drag_win) return; + con = bd->zone->container; + _drag_win = + ecore_x_window_input_new(con->win, con->x, con->y, con->w, con->h); + ecore_x_window_show(_drag_win); + if (!e_grabinput_get(_drag_win, 1, _drag_win)) + { + ecore_x_window_free(_drag_win); + return; + } + _drag_border = bd; +} + +static void +_drag_end(E_Border *bd) +{ + /* HANDLE A BORDER DRAG BEING ENDED */ + ecore_x_e_illume_drag_set(bd->client.win, 0); + _drag_border = NULL; +} + static void _zone_layout(E_Zone *z) { @@ -241,7 +290,7 @@ _zone_layout(E_Zone *z) { _border_resize_fx(bd, z->x, z->y, z->w, shelfsize); e_border_stick(bd); - if (bd->layer != 200) e_border_layer_set(bd, 200); + if (bd->layer != 100) e_border_layer_set(bd, 100); } else if (illume_border_is_bottom_panel(bd)) { @@ -481,3 +530,31 @@ _zone_move_resize(E_Zone *z) /* the zone was moved or resized - re-configure all windows in this zone */ _zone_layout(z); } + +static int +_cb_mouse_up(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Button *ev; + + ev = event; + if (ev->window != _drag_win) return 1; + e_grabinput_release(_drag_win, _drag_win); + ecore_x_window_free(_drag_win); + _drag_win = 0; + ecore_x_e_illume_drag_end_send(_drag_border->client.win); + return 1; +} + +static int +_cb_mouse_move(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Move *ev; + + ev = event; + if (ev->window != _drag_win) return 1; + if ((ev->y + _drag_border->h) >= _drag_border->zone->h) return 1; + if ((ev->y + _drag_border->h) >= (_drag_border->zone->h - panelsize)) return 1; + if ((_drag_border->y != ev->y)) + e_border_move(_drag_border, _drag_border->x, ev->y); + return 1; +} diff --git a/src/modules/illume2/e_mod_main.c b/src/modules/illume2/e_mod_main.c index a37e6c9ba..3f10b1599 100644 --- a/src/modules/illume2/e_mod_main.c +++ b/src/modules/illume2/e_mod_main.c @@ -84,22 +84,3 @@ e_modapi_save(E_Module *m) { return il_config_save(); } - -/* local functions */ -static int -_cb_event_dnd_drop(void *data, int type, void *event) -{ - return 1; -} - -static int -_cb_event_dnd_position(void *data, int type, void *event) -{ - return 1; -} - -static int -_cb_event_dnd_selection(void *data, int type, void *event) -{ - return 1; -}