summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Houston <stephen@localhost.localdomain>2016-09-21 11:34:43 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-09-23 10:17:54 -0400
commit5b2f952c85dde4572cae4bdb1b054e76500f3065 (patch)
tree551d38dedd6a91d096d9e788bbc4de4e6d59a1f5
parent900517b80f1521d7d98c90195b87b612a36539fa (diff)
Introduce pager gadget using new gadget api.
-rw-r--r--src/modules/Makefile_pager.mk7
-rw-r--r--src/modules/pager/e_mod_config.c8
-rw-r--r--src/modules/pager/e_mod_main.c44
-rw-r--r--src/modules/pager/e_mod_main.h30
-rw-r--r--src/modules/pager/gadget/config.c601
-rw-r--r--src/modules/pager/gadget/mod.c104
-rw-r--r--src/modules/pager/gadget/pager.c1950
-rw-r--r--src/modules/pager/gadget/pager.h50
8 files changed, 2744 insertions, 50 deletions
diff --git a/src/modules/Makefile_pager.mk b/src/modules/Makefile_pager.mk
index a77198e84..3799e8952 100644
--- a/src/modules/Makefile_pager.mk
+++ b/src/modules/Makefile_pager.mk
@@ -5,7 +5,6 @@ pagerdir = $(MDIR)/pager
5pager_DATA = src/modules/pager/e-module-pager.edj \ 5pager_DATA = src/modules/pager/e-module-pager.edj \
6 src/modules/pager/module.desktop 6 src/modules/pager/module.desktop
7 7
8
9pagerpkgdir = $(MDIR)/pager/$(MODULE_ARCH) 8pagerpkgdir = $(MDIR)/pager/$(MODULE_ARCH)
10pagerpkg_LTLIBRARIES = src/modules/pager/module.la 9pagerpkg_LTLIBRARIES = src/modules/pager/module.la
11 10
@@ -14,7 +13,11 @@ src_modules_pager_module_la_CPPFLAGS = $(MOD_CPPFLAGS)
14src_modules_pager_module_la_LDFLAGS = $(MOD_LDFLAGS) 13src_modules_pager_module_la_LDFLAGS = $(MOD_LDFLAGS)
15src_modules_pager_module_la_SOURCES = src/modules/pager/e_mod_main.h \ 14src_modules_pager_module_la_SOURCES = src/modules/pager/e_mod_main.h \
16 src/modules/pager/e_mod_main.c \ 15 src/modules/pager/e_mod_main.c \
17 src/modules/pager/e_mod_config.c 16 src/modules/pager/e_mod_config.c \
17 src/modules/pager/gadget/pager.h \
18 src/modules/pager/gadget/pager.c \
19 src/modules/pager/gadget/mod.c \
20 src/modules/pager/gadget/config.c
18 21
19PHONIES += pager install-pager 22PHONIES += pager install-pager
20pager: $(pagerpkg_LTLIBRARIES) $(pager_DATA) 23pager: $(pagerpkg_LTLIBRARIES) $(pager_DATA)
diff --git a/src/modules/pager/e_mod_config.c b/src/modules/pager/e_mod_config.c
index 391c0ca4b..5d57051a2 100644
--- a/src/modules/pager/e_mod_config.c
+++ b/src/modules/pager/e_mod_config.c
@@ -70,10 +70,10 @@ _config_pager_module(Config_Item *ci)
70 v->advanced.check_changed = _adv_check_changed; 70 v->advanced.check_changed = _adv_check_changed;
71 71
72 snprintf(buff, sizeof(buff), "%s/e-module-pager.edj", 72 snprintf(buff, sizeof(buff), "%s/e-module-pager.edj",
73 pager_config->module->dir); 73 module->dir);
74 cfd = e_config_dialog_new(NULL, _("Pager Settings"), "E", 74 cfd = e_config_dialog_new(NULL, _("Pager Settings"), "E",
75 "_e_mod_pager_config_dialog", buff, 0, v, ci); 75 "_e_mod_pager_config_dialog", buff, 0, v, ci);
76 pager_config->config_dialog = cfd; 76 config_dialog = cfd;
77} 77}
78 78
79/* local function prototypes */ 79/* local function prototypes */
@@ -111,7 +111,7 @@ _free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
111{ 111{
112 cfdata->gui.popup_list = eina_list_free(cfdata->gui.popup_list); 112 cfdata->gui.popup_list = eina_list_free(cfdata->gui.popup_list);
113 cfdata->gui.urgent_list = eina_list_free(cfdata->gui.urgent_list); 113 cfdata->gui.urgent_list = eina_list_free(cfdata->gui.urgent_list);
114 pager_config->config_dialog = NULL; 114 config_dialog = NULL;
115 E_FREE(cfdata); 115 E_FREE(cfdata);
116} 116}
117 117
@@ -153,6 +153,7 @@ _basic_apply(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
153 pager_config->show_desk_names = cfdata->show_desk_names; 153 pager_config->show_desk_names = cfdata->show_desk_names;
154 pager_config->popup_urgent = cfdata->popup.urgent_show; 154 pager_config->popup_urgent = cfdata->popup.urgent_show;
155 _pager_cb_config_updated(); 155 _pager_cb_config_updated();
156 _pager_cb_config_gadget_updated();
156 e_config_save_queue(); 157 e_config_save_queue();
157 return 1; 158 return 1;
158} 159}
@@ -306,6 +307,7 @@ _adv_apply(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
306 pager_config->btn_noplace = cfdata->btn.noplace; 307 pager_config->btn_noplace = cfdata->btn.noplace;
307 pager_config->btn_desk = cfdata->btn.desk; 308 pager_config->btn_desk = cfdata->btn.desk;
308 _pager_cb_config_updated(); 309 _pager_cb_config_updated();
310 _pager_cb_config_gadget_updated();
309 e_config_save_queue(); 311 e_config_save_queue();
310 return 1; 312 return 1;
311} 313}
diff --git a/src/modules/pager/e_mod_main.c b/src/modules/pager/e_mod_main.c
index 3bde8977b..4e4b21d67 100644
--- a/src/modules/pager/e_mod_main.c
+++ b/src/modules/pager/e_mod_main.c
@@ -167,8 +167,9 @@ static E_Desk *current_desk = NULL;
167static E_Config_DD *conf_edd = NULL; 167static E_Config_DD *conf_edd = NULL;
168static Eina_List *pagers = NULL; 168static Eina_List *pagers = NULL;
169 169
170Config *pager_config = NULL; 170EINTERN E_Module *module;
171 171EINTERN E_Config_Dialog *config_dialog;
172EINTERN Eina_List *instances, *shandlers;
172 173
173static Pager_Win * 174static Pager_Win *
174_pager_desk_window_find(Pager_Desk *pd, E_Client *client) 175_pager_desk_window_find(Pager_Desk *pd, E_Client *client)
@@ -240,7 +241,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
240 _pager_cb_obj_show, inst); 241 _pager_cb_obj_show, inst);
241 evas_object_event_callback_add(o, EVAS_CALLBACK_HIDE, 242 evas_object_event_callback_add(o, EVAS_CALLBACK_HIDE,
242 _pager_cb_obj_hide, inst); 243 _pager_cb_obj_hide, inst);
243 pager_config->instances = eina_list_append(pager_config->instances, inst); 244 instances = eina_list_append(instances, inst);
244 return gcc; 245 return gcc;
245} 246}
246 247
@@ -251,7 +252,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
251 252
252 inst = gcc->data; 253 inst = gcc->data;
253 if (pager_config) 254 if (pager_config)
254 pager_config->instances = eina_list_remove(pager_config->instances, inst); 255 instances = eina_list_remove(instances, inst);
255 e_drop_handler_del(inst->pager->drop_handler); 256 e_drop_handler_del(inst->pager->drop_handler);
256 _pager_free(inst->pager); 257 _pager_free(inst->pager);
257 free(inst); 258 free(inst);
@@ -299,7 +300,7 @@ _gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas)
299 300
300 o = edje_object_add(evas); 301 o = edje_object_add(evas);
301 snprintf(buf, sizeof(buf), "%s/e-module-pager.edj", 302 snprintf(buf, sizeof(buf), "%s/e-module-pager.edj",
302 e_module_dir_get(pager_config->module)); 303 e_module_dir_get(module));
303 edje_object_file_set(o, buf, "icon"); 304 edje_object_file_set(o, buf, "icon");
304 return o; 305 return o;
305} 306}
@@ -310,7 +311,7 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class)
310 static char buf[4096]; 311 static char buf[4096];
311 312
312 snprintf(buf, sizeof(buf), "%s.%d", client_class->name, 313 snprintf(buf, sizeof(buf), "%s.%d", client_class->name,
313 eina_list_count(pager_config->instances) + 1); 314 eina_list_count(instances) + 1);
314 return buf; 315 return buf;
315} 316}
316 317
@@ -908,7 +909,7 @@ static void
908_pager_inst_cb_menu_configure(void *data EINA_UNUSED, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED) 909_pager_inst_cb_menu_configure(void *data EINA_UNUSED, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
909{ 910{
910 if (!pager_config) return; 911 if (!pager_config) return;
911 if (pager_config->config_dialog) return; 912 if (config_dialog) return;
912 /* FIXME: pass zone config item */ 913 /* FIXME: pass zone config item */
913 _config_pager_module(NULL); 914 _config_pager_module(NULL);
914} 915}
@@ -917,10 +918,10 @@ static E_Config_Dialog *
917_pager_config_dialog(Evas_Object *parent EINA_UNUSED, const char *params EINA_UNUSED) 918_pager_config_dialog(Evas_Object *parent EINA_UNUSED, const char *params EINA_UNUSED)
918{ 919{
919 if (!pager_config) return NULL; 920 if (!pager_config) return NULL;
920 if (pager_config->config_dialog) return NULL; 921 if (config_dialog) return NULL;
921 /* FIXME: pass zone config item */ 922 /* FIXME: pass zone config item */
922 _config_pager_module(NULL); 923 _config_pager_module(NULL);
923 return pager_config->config_dialog; 924 return config_dialog;
924} 925}
925 926
926static void 927static void
@@ -2040,6 +2041,7 @@ e_modapi_init(E_Module *m)
2040{ 2041{
2041 E_Module *p; 2042 E_Module *p;
2042 2043
2044 e_modapi_gadget_init(m);
2043 p = e_module_find("pager_plain"); 2045 p = e_module_find("pager_plain");
2044 if (p && p->enabled) 2046 if (p && p->enabled)
2045 { 2047 {
@@ -2098,13 +2100,13 @@ e_modapi_init(E_Module *m)
2098 E_CONFIG_LIMIT(pager_config->btn_noplace, 0, 32); 2100 E_CONFIG_LIMIT(pager_config->btn_noplace, 0, 32);
2099 E_CONFIG_LIMIT(pager_config->btn_desk, 0, 32); 2101 E_CONFIG_LIMIT(pager_config->btn_desk, 0, 32);
2100 2102
2101 E_LIST_HANDLER_APPEND(pager_config->handlers, E_EVENT_ZONE_DESK_COUNT_SET, _pager_cb_event_zone_desk_count_set, NULL); 2103 E_LIST_HANDLER_APPEND(shandlers, E_EVENT_ZONE_DESK_COUNT_SET, _pager_cb_event_zone_desk_count_set, NULL);
2102 E_LIST_HANDLER_APPEND(pager_config->handlers, E_EVENT_DESK_SHOW, _pager_cb_event_desk_show, NULL); 2104 E_LIST_HANDLER_APPEND(shandlers, E_EVENT_DESK_SHOW, _pager_cb_event_desk_show, NULL);
2103 E_LIST_HANDLER_APPEND(pager_config->handlers, E_EVENT_DESK_NAME_CHANGE, _pager_cb_event_desk_name_change, NULL); 2105 E_LIST_HANDLER_APPEND(shandlers, E_EVENT_DESK_NAME_CHANGE, _pager_cb_event_desk_name_change, NULL);
2104 E_LIST_HANDLER_APPEND(pager_config->handlers, E_EVENT_COMPOSITOR_RESIZE, _pager_cb_event_compositor_resize, NULL); 2106 E_LIST_HANDLER_APPEND(shandlers, E_EVENT_COMPOSITOR_RESIZE, _pager_cb_event_compositor_resize, NULL);
2105 E_LIST_HANDLER_APPEND(pager_config->handlers, E_EVENT_CLIENT_PROPERTY, _pager_cb_event_client_urgent_change, NULL); 2107 E_LIST_HANDLER_APPEND(shandlers, E_EVENT_CLIENT_PROPERTY, _pager_cb_event_client_urgent_change, NULL);
2106 2108
2107 pager_config->module = m; 2109 module = m;
2108 2110
2109 e_gadcon_provider_register(&_gadcon_class); 2111 e_gadcon_provider_register(&_gadcon_class);
2110 2112
@@ -2140,13 +2142,14 @@ e_modapi_init(E_Module *m)
2140} 2142}
2141 2143
2142E_API int 2144E_API int
2143e_modapi_shutdown(E_Module *m EINA_UNUSED) 2145e_modapi_shutdown(E_Module *m)
2144{ 2146{
2147 e_modapi_gadget_shutdown(m);
2145 e_gadcon_provider_unregister(&_gadcon_class); 2148 e_gadcon_provider_unregister(&_gadcon_class);
2146 2149
2147 if (pager_config->config_dialog) 2150 if (config_dialog)
2148 e_object_del(E_OBJECT(pager_config->config_dialog)); 2151 e_object_del(E_OBJECT(config_dialog));
2149 E_FREE_LIST(pager_config->handlers, ecore_event_handler_del); 2152 E_FREE_LIST(shandlers, ecore_event_handler_del);
2150 2153
2151 e_configure_registry_item_del("extensions/pager"); 2154 e_configure_registry_item_del("extensions/pager");
2152 2155
@@ -2166,8 +2169,9 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
2166} 2169}
2167 2170
2168E_API int 2171E_API int
2169e_modapi_save(E_Module *m EINA_UNUSED) 2172e_modapi_save(E_Module *m)
2170{ 2173{
2174 e_modapi_gadget_save(m);
2171 e_config_domain_save("module.pager", conf_edd, pager_config); 2175 e_config_domain_save("module.pager", conf_edd, pager_config);
2172 return 1; 2176 return 1;
2173} 2177}
diff --git a/src/modules/pager/e_mod_main.h b/src/modules/pager/e_mod_main.h
index 746e73343..90409952e 100644
--- a/src/modules/pager/e_mod_main.h
+++ b/src/modules/pager/e_mod_main.h
@@ -1,5 +1,6 @@
1#ifndef E_MOD_MAIN_H 1#ifndef E_MOD_MAIN_H
2#define E_MOD_MAIN_H 2#define E_MOD_MAIN_H
3#include "gadget/pager.h"
3 4
4typedef struct _Config Config; 5typedef struct _Config Config;
5typedef struct _Config_Item Config_Item; 6typedef struct _Config_Item Config_Item;
@@ -15,38 +16,17 @@ typedef struct _Config_Item Config_Item;
15#define PAGER_DESKNAME_LEFT 3 16#define PAGER_DESKNAME_LEFT 3
16#define PAGER_DESKNAME_RIGHT 4 17#define PAGER_DESKNAME_RIGHT 4
17 18
18struct _Config
19{
20 unsigned int popup;
21 double popup_speed;
22 unsigned int popup_urgent;
23 unsigned int popup_urgent_stick;
24 unsigned int popup_urgent_focus;
25 double popup_urgent_speed;
26 unsigned int show_desk_names;
27 int popup_act_height; /*keyaction popup */
28 int popup_height; /* urgent/on-deskswitch popup*/
29 unsigned int drag_resist;
30 unsigned int btn_drag;
31 unsigned int btn_noplace;
32 unsigned int btn_desk;
33 unsigned int flip_desk;
34
35 /* just config state */
36 E_Module *module;
37 E_Config_Dialog *config_dialog;
38 Eina_List *instances, *handlers;
39};
40
41E_API extern E_Module_Api e_modapi; 19E_API extern E_Module_Api e_modapi;
42 20
43E_API void *e_modapi_init(E_Module *m); 21E_API void *e_modapi_init(E_Module *m);
44E_API int e_modapi_shutdown(E_Module *m); 22E_API int e_modapi_shutdown(E_Module *m);
45E_API int e_modapi_save(E_Module *m); 23E_API int e_modapi_save(E_Module *m);
46 24
47EINTERN void _pager_cb_config_updated(void);
48EINTERN void _config_pager_module(Config_Item *ci); 25EINTERN void _config_pager_module(Config_Item *ci);
49extern Config *pager_config; 26
27extern E_Module *module;
28extern E_Config_Dialog *config_dialog;
29extern Eina_List *instances, *shandlers;
50 30
51/** 31/**
52 * @addtogroup Optional_Gadgets 32 * @addtogroup Optional_Gadgets
diff --git a/src/modules/pager/gadget/config.c b/src/modules/pager/gadget/config.c
new file mode 100644
index 000000000..cb06e4260
--- /dev/null
+++ b/src/modules/pager/gadget/config.c
@@ -0,0 +1,601 @@
1#include "pager.h"
2
3#define BUTTON_DRAG 0
4#define BUTTON_NOPLACE 1
5#define BUTTON_DESK 2
6
7typedef struct _Config_Objects Config_Objects;
8struct _Config_Objects
9{
10 Evas_Object *general_page;
11 Evas_Object *popup_page;
12 Evas_Object *urgent_page;
13 Evas_Object *o_popup;
14 Evas_Object *o_popup_speed;
15 Evas_Object *o_popup_urgent;
16 Evas_Object *o_popup_urgent_stick;
17 Evas_Object *o_popup_urgent_focus;
18 Evas_Object *o_popup_urgent_speed;
19 Evas_Object *o_show_desk_names;
20 Evas_Object *o_popup_act_height;
21 Evas_Object *o_popup_height;
22 Evas_Object *o_drag_resist;
23 Evas_Object *o_btn_drag;
24 Evas_Object *o_btn_noplace;
25 Evas_Object *o_btn_desk;
26 Evas_Object *o_flip_desk;
27 E_Grab_Dialog *grab_dia;
28 int grab_btn;
29 int w, h;
30};
31Config_Objects *pager_gadget_config_objects = NULL;
32
33static void
34_config_close(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
35{
36 cfg_dialog = NULL;
37 E_FREE(pager_gadget_config_objects);
38}
39
40static void
41_config_show_general(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
42{
43 evas_object_hide(pager_gadget_config_objects->popup_page);
44 evas_object_hide(pager_gadget_config_objects->urgent_page);
45 evas_object_show(pager_gadget_config_objects->general_page);
46}
47
48static void
49_config_show_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
50{
51 evas_object_hide(pager_gadget_config_objects->general_page);
52 evas_object_hide(pager_gadget_config_objects->urgent_page);
53 evas_object_show(pager_gadget_config_objects->popup_page);
54}
55
56static void
57_config_show_urgent(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
58{
59 evas_object_hide(pager_gadget_config_objects->general_page);
60 evas_object_hide(pager_gadget_config_objects->popup_page);
61 evas_object_show(pager_gadget_config_objects->urgent_page);
62}
63
64static void
65_config_value_changed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
66{
67 pager_config->popup =
68 elm_check_state_get(pager_gadget_config_objects->o_popup);
69 pager_config->popup_speed =
70 elm_slider_value_get(pager_gadget_config_objects->o_popup_speed);
71 pager_config->flip_desk =
72 elm_check_state_get(pager_gadget_config_objects->o_flip_desk);
73 pager_config->popup_urgent =
74 elm_check_state_get(pager_gadget_config_objects->o_popup_urgent);
75 pager_config->popup_urgent_stick =
76 elm_check_state_get(pager_gadget_config_objects->o_popup_urgent_stick);
77 pager_config->popup_urgent_focus =
78 elm_check_state_get(pager_gadget_config_objects->o_popup_urgent_focus);
79 pager_config->popup_urgent_speed =
80 elm_slider_value_get(pager_gadget_config_objects->o_popup_urgent_speed);
81 pager_config->show_desk_names =
82 elm_check_state_get(pager_gadget_config_objects->o_show_desk_names);
83 pager_config->popup_height =
84 elm_slider_value_get(pager_gadget_config_objects->o_popup_height);
85 pager_config->popup_act_height =
86 elm_slider_value_get(pager_gadget_config_objects->o_popup_act_height);
87 pager_config->drag_resist =
88 elm_slider_value_get(pager_gadget_config_objects->o_drag_resist);
89 _pager_cb_config_gadget_updated();
90 _pager_cb_config_updated();
91 e_config_save_queue();
92
93 elm_object_disabled_set(pager_gadget_config_objects->o_popup_speed,
94 !pager_config->popup);
95 elm_object_disabled_set(pager_gadget_config_objects->o_popup_act_height,
96 !pager_config->popup);
97 elm_object_disabled_set(pager_gadget_config_objects->o_popup_height,
98 !pager_config->popup);
99 elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_stick,
100 !pager_config->popup_urgent);
101 elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_focus,
102 !pager_config->popup_urgent);
103 elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_speed,
104 !pager_config->popup_urgent);
105}
106
107static void
108_config_update_btn(Evas_Object *button, const int mouse_button)
109{
110 char lbl[256];
111 char *icon = NULL;
112 Evas_Object *ic = NULL;
113
114 switch (mouse_button)
115 {
116 case 0:
117 snprintf(lbl, sizeof(lbl), _("Click to set"));
118 break;
119 case 1:
120 if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT)
121 {
122 snprintf(lbl, sizeof(lbl), _("Left button"));
123 icon = "preferences-desktop-mouse-left";
124 }
125 else if (e_config->mouse_hand == E_MOUSE_HAND_LEFT)
126 {
127 snprintf(lbl, sizeof(lbl), _("Right button"));
128 icon = "preferences-desktop-mouse-right";
129 }
130 else
131 {
132 snprintf(lbl, sizeof(lbl), _("Button %i"), mouse_button);
133 icon = "preferences-desktop-mouse-extra";
134 }
135 break;
136 case 2:
137 snprintf(lbl, sizeof(lbl), _("Middle button"));
138 icon = "preferences-desktop-mouse-middle";
139 break;
140 case 3:
141 if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT)
142 {
143 snprintf(lbl, sizeof(lbl), _("Right button"));
144 icon = "preferences-desktop-mouse-right";
145 }
146 else if (e_config->mouse_hand == E_MOUSE_HAND_LEFT)
147 {
148 snprintf(lbl, sizeof(lbl), _("Left button"));
149 icon = "preferences-desktop-mouse-left";
150 }
151 else
152 {
153 snprintf(lbl, sizeof(lbl), _("Button %i"), mouse_button);
154 icon = "preferences-desktop-mouse-extra";
155 }
156 break;
157 default:
158 snprintf(lbl, sizeof(lbl), _("Button %i"), mouse_button);
159 icon = "preferences-desktop-mouse-extra";
160 break;
161 }
162 elm_object_text_set(button, lbl);
163 if (icon)
164 {
165 ic = elm_icon_add(evas_object_evas_get(button));
166 elm_icon_standard_set(ic, icon);
167 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
168 }
169 elm_object_part_content_set(button, "icon", ic);
170}
171
172static void
173_config_update_btns(void)
174{
175#if 0
176 _config_update_btn(pager_gadget_config_objects->o_btn_drag, pager_config->btn_drag);
177#endif
178
179 _config_update_btn(pager_gadget_config_objects->o_btn_noplace, pager_config->btn_noplace);
180 _config_update_btn(pager_gadget_config_objects->o_btn_desk, pager_config->btn_desk);
181}
182
183static void
184_config_grab_window_del(void *data EINA_UNUSED)
185{
186 evas_object_show(cfg_dialog);
187 _config_update_btns();
188}
189
190static Eina_Bool
191_config_grab_cb_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
192{
193 Ecore_Event_Mouse_Button *ev;
194
195 ev = event;
196
197 if (ev->buttons == 3)
198 {
199 e_util_dialog_show(_("Attention"),
200 _("You cannot use the right mouse button in the<br>"
201 "gadget for this as it is already taken by internal<br>"
202 "code for context menus.<br>"
203 "This button only works in the popup."));
204 }
205 else
206 {
207 if (ev->buttons == pager_config->btn_drag)
208 pager_config->btn_drag = 0;
209 else if (ev->buttons == pager_config->btn_noplace)
210 pager_config->btn_noplace = 0;
211 else if (ev->buttons == pager_config->btn_desk)
212 pager_config->btn_desk = 0;
213
214 if (pager_gadget_config_objects->grab_btn == 1)
215 pager_config->btn_drag = ev->buttons;
216 else if (pager_gadget_config_objects->grab_btn == 2)
217 pager_config->btn_noplace = ev->buttons;
218 else
219 pager_config->btn_desk = ev->buttons;
220 }
221
222 e_object_del(E_OBJECT(pager_gadget_config_objects->grab_dia));
223 return ECORE_CALLBACK_PASS_ON;
224}
225
226static Eina_Bool
227_config_grab_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
228{
229 Ecore_Event_Key *ev;
230
231 ev = event;
232 if (!strcmp(ev->key, "Delete"))
233 {
234 if (pager_gadget_config_objects->grab_btn == 1)
235 pager_config->btn_drag = 0;
236 else if (pager_gadget_config_objects->grab_btn == 2)
237 pager_config->btn_noplace = 0;
238 else
239 pager_config->btn_desk = 0;
240 }
241 e_object_del(E_OBJECT(pager_gadget_config_objects->grab_dia));
242 return ECORE_CALLBACK_PASS_ON;
243}
244
245static void
246_config_grab_window_show(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
247{
248
249 evas_object_hide(cfg_dialog);
250 pager_gadget_config_objects->grab_btn = 0;
251 if ((long)data == BUTTON_DRAG)
252 pager_gadget_config_objects->grab_btn = 1;
253 else if ((long)data == BUTTON_NOPLACE)
254 pager_gadget_config_objects->grab_btn = 2;
255
256 pager_gadget_config_objects->grab_dia = e_grab_dialog_show(NULL, EINA_TRUE,
257 _config_grab_cb_key_down, _config_grab_cb_mouse_down, NULL, NULL);
258 e_object_del_attach_func_set(E_OBJECT(pager_gadget_config_objects->grab_dia), _config_grab_window_del);
259}
260
261static Evas_Object *
262_config_create_pages(Evas_Object *parent)
263{
264 Evas_Object *m, *tb, *ow;
265 int row = 4;
266
267 m = elm_table_add(parent);
268 E_EXPAND(m);
269 evas_object_show(m);
270
271 /* General Page */
272 tb = elm_table_add(m);
273 E_EXPAND(tb);
274 evas_object_show(tb);
275
276 ow = elm_check_add(tb);
277 elm_object_text_set(ow, _("Flip desktop on mouse wheel"));
278 evas_object_size_hint_align_set(ow, 0.0, EVAS_HINT_FILL);
279 elm_check_state_set(ow, pager_config->flip_desk);
280 elm_table_pack(tb, ow, 0, 0, 1, 1);
281 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
282 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
283 evas_object_smart_callback_add(ow, "changed",
284 _config_value_changed, NULL);
285 evas_object_show(ow);
286 pager_gadget_config_objects->o_flip_desk = ow;
287
288 ow = elm_check_add(tb);
289 elm_object_text_set(ow, _("Always show desktop names"));
290 evas_object_size_hint_align_set(ow, 0.0, EVAS_HINT_FILL);
291 elm_check_state_set(ow, pager_config->show_desk_names);
292 elm_table_pack(tb, ow, 0, 1, 1, 1);
293 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
294 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
295 evas_object_smart_callback_add(ow, "changed",
296 _config_value_changed, NULL);
297 evas_object_show(ow);
298 pager_gadget_config_objects->o_show_desk_names = ow;
299
300 ow = elm_label_add(tb);
301 elm_object_text_set(ow, _("Resistance to dragging"));
302 elm_table_pack(tb, ow, 0, 2, 1, 1);
303 E_ALIGN(ow, 0.5, 0.5);
304 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
305 evas_object_show(ow);
306
307 ow = elm_slider_add(tb);
308 elm_slider_min_max_set(ow, 0, 10);
309 elm_slider_step_set(ow, 1);
310 elm_slider_value_set(ow, pager_config->drag_resist);
311 elm_slider_unit_format_set(ow, _("%.0f pixels"));
312 elm_table_pack(tb, ow, 0, 3, 1, 1);
313 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
314 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
315 evas_object_smart_callback_add(ow, "delay,changed",
316 _config_value_changed, NULL);
317 evas_object_show(ow);
318 pager_gadget_config_objects->o_drag_resist = ow;
319
320#if 0
321 ow = elm_label_add(tb);
322 elm_object_text_set(ow, _("Select and Slide button"));
323 elm_table_pack(tb, ow, 0, row, 1, 1);
324 E_ALIGN(ow, 0.5, 0.5);
325 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
326 evas_object_show(ow);
327 row++;
328
329 ow = elm_button_add(tb);
330 elm_object_text_set(ow, _("Click to set"));
331 evas_object_smart_callback_add(ow, "clicked",
332 _config_grab_window_show, (void *)BUTTON_DRAG);
333 elm_table_pack(tb, ow, 0, row, 1, 1);
334 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
335 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
336 evas_object_show(ow);
337 pager_gadget_config_objects->o_btn_drag = ow;
338 row++;
339#endif
340
341 ow = elm_label_add(tb);
342 elm_object_text_set(ow, _("Drag and Drop button"));
343 elm_table_pack(tb, ow, 0, row, 1, 1);
344 E_ALIGN(ow, 0.5, 0.5);
345 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
346 evas_object_show(ow);
347 row++;
348
349 ow = elm_button_add(tb);
350 elm_object_text_set(ow, _("Click to set"));
351 evas_object_smart_callback_add(ow, "clicked",
352 _config_grab_window_show, (void *)BUTTON_NOPLACE);
353 elm_table_pack(tb, ow, 0, row, 1, 1);
354 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
355 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
356 evas_object_show(ow);
357 pager_gadget_config_objects->o_btn_noplace = ow;
358 row++;
359
360 ow = elm_label_add(tb);
361 elm_object_text_set(ow, _("Drag whole desktop"));
362 elm_table_pack(tb, ow, 0, row, 1, 1);
363 E_ALIGN(ow, 0.5, 0.5);
364 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
365 evas_object_show(ow);
366 row++;
367
368 ow = elm_button_add(tb);
369 elm_object_text_set(ow, _("Click to set"));
370 evas_object_smart_callback_add(ow, "clicked",
371 _config_grab_window_show, (void *)BUTTON_DESK);
372 elm_table_pack(tb, ow, 0, row, 1, 1);
373 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
374 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
375 evas_object_show(ow);
376 pager_gadget_config_objects->o_btn_desk = ow;
377
378 _config_update_btns();
379
380 elm_table_pack(m, tb, 0, 0, 1, 1);
381 pager_gadget_config_objects->general_page = tb;
382
383 /* Popup Page */
384 tb = elm_table_add(m);
385 E_EXPAND(tb);
386 evas_object_show(tb);
387
388 ow = elm_check_add(tb);
389 elm_object_text_set(ow, _("Show popup on desktop change"));
390 evas_object_size_hint_align_set(ow, 0.0, EVAS_HINT_FILL);
391 elm_check_state_set(ow, pager_config->show_desk_names);
392 elm_table_pack(tb, ow, 0, 0, 1, 1);
393 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
394 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
395 evas_object_smart_callback_add(ow, "changed",
396 _config_value_changed, NULL);
397 evas_object_show(ow);
398 pager_gadget_config_objects->o_popup = ow;
399
400 ow = elm_label_add(tb);
401 elm_object_text_set(ow, _("Popup pager height"));
402 elm_object_disabled_set(ow, !pager_config->popup);
403 elm_table_pack(tb, ow, 0, 1, 1, 1);
404 E_ALIGN(ow, 0.5, 0.5);
405 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
406 evas_object_show(ow);
407
408 ow = elm_slider_add(tb);
409 elm_object_disabled_set(ow, !pager_config->popup);
410 elm_slider_min_max_set(ow, 20, 200);
411 elm_slider_step_set(ow, 1);
412 elm_slider_value_set(ow, pager_config->popup_height);
413 elm_slider_unit_format_set(ow, _("%.0f pixels"));
414 elm_table_pack(tb, ow, 0, 2, 1, 1);
415 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
416 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
417 evas_object_smart_callback_add(ow, "delay,changed",
418 _config_value_changed, NULL);
419 evas_object_show(ow);
420 pager_gadget_config_objects->o_popup_height = ow;
421
422 ow = elm_label_add(tb);
423 elm_object_text_set(ow, _("Popup duration"));
424 elm_object_disabled_set(ow, !pager_config->popup);
425 elm_table_pack(tb, ow, 0, 3, 1, 1);
426 E_ALIGN(ow, 0.5, 0.5);
427 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
428 evas_object_show(ow);
429
430 ow = elm_slider_add(tb);
431 elm_object_disabled_set(ow, !pager_config->popup);
432 elm_slider_min_max_set(ow, 0.1, 10);
433 elm_slider_step_set(ow, 0.1);
434 elm_slider_value_set(ow, pager_config->popup_speed);
435 elm_slider_unit_format_set(ow, _("%1.1f seconds"));
436 elm_table_pack(tb, ow, 0, 4, 1, 1);
437 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
438 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
439 evas_object_smart_callback_add(ow, "delay,changed",
440 _config_value_changed, NULL);
441 evas_object_show(ow);
442 pager_gadget_config_objects->o_popup_speed = ow;
443
444 ow = elm_label_add(tb);
445 elm_object_text_set(ow, _("Pager action popup height"));
446 elm_object_disabled_set(ow, !pager_config->popup);
447 elm_table_pack(tb, ow, 0, 5, 1, 1);
448 E_ALIGN(ow, 0.5, 0.5);
449 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
450 evas_object_show(ow);
451
452 ow = elm_slider_add(tb);
453 elm_object_disabled_set(ow, !pager_config->popup);
454 elm_slider_min_max_set(ow, 20, 200);
455 elm_slider_step_set(ow, 1);
456 elm_slider_value_set(ow, pager_config->popup_act_height);
457 elm_slider_unit_format_set(ow, _("%.0f pixels"));
458 elm_table_pack(tb, ow, 0, 6, 1, 1);
459 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
460 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
461 evas_object_smart_callback_add(ow, "delay,changed",
462 _config_value_changed, NULL);
463 evas_object_show(ow);
464 pager_gadget_config_objects->o_popup_act_height = ow;
465
466 elm_table_pack(m, tb, 0, 0, 1, 1);
467 pager_gadget_config_objects->popup_page = tb;
468
469 /* Urgent Page */
470 tb = elm_table_add(m);
471 E_EXPAND(tb);
472 evas_object_show(tb);
473
474 ow = elm_check_add(tb);
475 elm_object_text_set(ow, _("Show popup for urgent window"));
476 evas_object_size_hint_align_set(ow, 0.0, EVAS_HINT_FILL);
477 elm_check_state_set(ow, pager_config->popup_urgent);
478 elm_table_pack(tb, ow, 0, 0, 1, 1);
479 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
480 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
481 evas_object_smart_callback_add(ow, "changed",
482 _config_value_changed, NULL);
483 evas_object_show(ow);
484 pager_gadget_config_objects->o_popup_urgent = ow;
485
486 ow = elm_check_add(tb);
487 elm_object_disabled_set(ow, !pager_config->popup_urgent);
488 elm_object_text_set(ow, _("Urgent popup sticks on screen"));
489 evas_object_size_hint_align_set(ow, 0.0, EVAS_HINT_FILL);
490 elm_check_state_set(ow, pager_config->popup_urgent_stick);
491 elm_table_pack(tb, ow, 0, 1, 1, 1);
492 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
493 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
494 evas_object_smart_callback_add(ow, "changed",
495 _config_value_changed, NULL);
496 evas_object_show(ow);
497 pager_gadget_config_objects->o_popup_urgent_stick = ow;
498
499 ow = elm_check_add(tb);
500 elm_object_disabled_set(ow, !pager_config->popup_urgent);
501 elm_object_text_set(ow, _("Show popup for focused windows"));
502 evas_object_size_hint_align_set(ow, 0.0, EVAS_HINT_FILL);
503 elm_check_state_set(ow, pager_config->popup_urgent_focus);
504 elm_table_pack(tb, ow, 0, 2, 1, 1);
505 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
506 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
507 evas_object_smart_callback_add(ow, "changed",
508 _config_value_changed, NULL);
509 evas_object_show(ow);
510 pager_gadget_config_objects->o_popup_urgent_focus = ow;
511
512 ow = elm_label_add(tb);
513 elm_object_text_set(ow, _("Urgent Popup Duration"));
514 elm_object_disabled_set(ow, !pager_config->popup_urgent);
515 elm_table_pack(tb, ow, 0, 3, 1, 1);
516 E_ALIGN(ow, 0.5, 0.5);
517 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
518 evas_object_show(ow);
519
520 ow = elm_slider_add(tb);
521 elm_object_disabled_set(ow, !pager_config->popup_urgent);
522 elm_slider_min_max_set(ow, 0.1, 10);
523 elm_slider_step_set(ow, 0.1);
524 elm_slider_value_set(ow, pager_config->popup_urgent_speed);
525 elm_slider_unit_format_set(ow, _("%1.1f seconds"));
526 elm_table_pack(tb, ow, 0, 4, 1, 1);
527 E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
528 E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
529 evas_object_smart_callback_add(ow, "delay,changed",
530 _config_value_changed, NULL);
531 evas_object_show(ow);
532 pager_gadget_config_objects->o_popup_urgent_speed = ow;
533
534 elm_table_pack(m, tb, 0, 0, 1, 1);
535 pager_gadget_config_objects->urgent_page = tb;
536
537 return m;
538}
539
540EINTERN Evas_Object *
541config_pager(E_Zone *zone)
542{
543 Evas_Object *popup, *tb, *lbl, *list, *fr;
544 Elm_Object_Item *it;
545
546 pager_gadget_config_objects = E_NEW(Config_Objects, 1);
547 pager_gadget_config_objects->w = 0;
548 pager_gadget_config_objects->h = 0;
549
550 popup = elm_popup_add(e_comp->elm);
551 E_EXPAND(popup);
552 elm_popup_allow_events_set(popup, 1);
553 elm_popup_scrollable_set(popup, 1);
554
555 tb = elm_table_add(popup);
556 E_EXPAND(tb);
557 evas_object_show(tb);
558 elm_object_content_set(popup, tb);
559
560 lbl = elm_label_add(tb);
561 elm_object_style_set(lbl, "marker");
562 evas_object_show(lbl);
563 elm_object_text_set(lbl, _("Pager Configuration"));
564 elm_table_pack(tb, lbl, 0, 0, 2, 1);
565
566 list = elm_list_add(tb);
567 E_ALIGN(list, 0, EVAS_HINT_FILL);
568 E_WEIGHT(list, 0, EVAS_HINT_EXPAND);
569 elm_table_pack(tb, list, 0, 1, 1, 1);
570 elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
571 elm_scroller_content_min_limit(list, 1, 1);
572 it = elm_list_item_append(list, _("General"), NULL, NULL,
573 _config_show_general, NULL);
574 elm_list_item_selected_set(it, 1);
575 it = elm_list_item_append(list, _("Popup"), NULL, NULL,
576 _config_show_popup, NULL);
577 it = elm_list_item_append(list, _("Urgent"), NULL, NULL,
578 _config_show_urgent, NULL);
579 elm_list_go(list);
580 evas_object_show(list);
581
582 fr = elm_frame_add(tb);
583 E_EXPAND(fr);
584 elm_table_pack(tb, fr, 1, 1, 1, 1);
585 evas_object_show(fr);
586
587 elm_object_content_set(fr,
588 _config_create_pages(fr));
589 _config_show_general(NULL, NULL, NULL);
590
591 popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);
592 evas_object_layer_set(popup, E_LAYER_POPUP);
593 evas_object_resize(popup, zone->w / 4, zone->h / 3);
594 e_comp_object_util_center(popup);
595 evas_object_show(popup);
596 e_comp_object_util_autoclose(popup, NULL, e_comp_object_util_autoclose_on_escape, NULL);
597 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _config_close, NULL);
598
599 return cfg_dialog = popup;
600}
601
diff --git a/src/modules/pager/gadget/mod.c b/src/modules/pager/gadget/mod.c
new file mode 100644
index 000000000..af4c370fe
--- /dev/null
+++ b/src/modules/pager/gadget/mod.c
@@ -0,0 +1,104 @@
1#include "pager.h"
2static E_Config_DD *conf_edd = NULL;
3Config *pager_config;
4E_Module *gmodule;
5Evas_Object *cfg_dialog;
6Eina_List *ginstances, *ghandlers;
7
8E_API void *
9e_modapi_gadget_init(E_Module *m)
10{
11 conf_edd = E_CONFIG_DD_NEW("Pager_Config", Config);
12#undef T
13#undef D
14#define T Config
15#define D conf_edd
16 E_CONFIG_VAL(D, T, popup, UINT);
17 E_CONFIG_VAL(D, T, popup_speed, DOUBLE);
18 E_CONFIG_VAL(D, T, popup_urgent, UINT);
19 E_CONFIG_VAL(D, T, popup_urgent_stick, UINT);
20 E_CONFIG_VAL(D, T, popup_urgent_speed, DOUBLE);
21 E_CONFIG_VAL(D, T, show_desk_names, UINT);
22 E_CONFIG_VAL(D, T, popup_height, INT);
23 E_CONFIG_VAL(D, T, popup_act_height, INT);
24 E_CONFIG_VAL(D, T, drag_resist, UINT);
25 E_CONFIG_VAL(D, T, btn_drag, UCHAR);
26 E_CONFIG_VAL(D, T, btn_noplace, UCHAR);
27 E_CONFIG_VAL(D, T, btn_desk, UCHAR);
28 E_CONFIG_VAL(D, T, flip_desk, UCHAR);
29
30 pager_config = e_config_domain_load("module.pager", conf_edd);
31
32 if (!pager_config)
33 {
34 pager_config = E_NEW(Config, 1);
35 pager_config->popup = 1;
36 pager_config->popup_speed = 1.0;
37 pager_config->popup_urgent = 0;
38 pager_config->popup_urgent_stick = 0;
39 pager_config->popup_urgent_speed = 1.5;
40 pager_config->show_desk_names = 0;
41 pager_config->popup_height = 60;
42 pager_config->popup_act_height = 60;
43 pager_config->drag_resist = 3;
44 pager_config->btn_drag = 1;
45 pager_config->btn_noplace = 2;
46 pager_config->btn_desk = 2;
47 pager_config->flip_desk = 0;
48 }
49 E_CONFIG_LIMIT(pager_config->popup, 0, 1);
50 E_CONFIG_LIMIT(pager_config->popup_speed, 0.1, 10.0);
51 E_CONFIG_LIMIT(pager_config->popup_urgent, 0, 1);
52 E_CONFIG_LIMIT(pager_config->popup_urgent_stick, 0, 1);
53 E_CONFIG_LIMIT(pager_config->popup_urgent_speed, 0.1, 10.0);
54 E_CONFIG_LIMIT(pager_config->show_desk_names, 0, 1);
55 E_CONFIG_LIMIT(pager_config->popup_height, 20, 200);
56 E_CONFIG_LIMIT(pager_config->popup_act_height, 20, 200);
57 E_CONFIG_LIMIT(pager_config->drag_resist, 0, 50);
58 E_CONFIG_LIMIT(pager_config->flip_desk, 0, 1);
59 E_CONFIG_LIMIT(pager_config->btn_drag, 0, 32);
60 E_CONFIG_LIMIT(pager_config->btn_noplace, 0, 32);
61 E_CONFIG_LIMIT(pager_config->btn_desk, 0, 32);
62
63 gmodule = m;
64
65 pager_init();
66
67 e_gadget_type_add("Pager Gadget", pager_create, NULL);
68
69 return m;
70}
71
72E_API int
73e_modapi_gadget_shutdown(E_Module *m EINA_UNUSED)
74{
75 if (cfg_dialog)
76 e_object_del(E_OBJECT(cfg_dialog));
77
78 if (pager_config && ghandlers)
79 E_FREE_LIST(ghandlers, ecore_event_handler_del);
80
81 e_action_del("pager_gadget_show");
82 e_action_del("pager_gadget_switch");
83
84 e_action_predef_name_del("Pager Gadget", "Show Pager Popup");
85 e_action_predef_name_del("Pager Gadget", "Popup Desk Right");
86 e_action_predef_name_del("Pager Gadget", "Popup Desk Left");
87 e_action_predef_name_del("Pager Gadget", "Popup Desk Up");
88 e_action_predef_name_del("Pager Gadget", "Popup Desk Down");
89 e_action_predef_name_del("Pager Gadget", "Popup Desk Next");
90 e_action_predef_name_del("Pager Gadget", "Popup Desk Previous");
91
92 e_gadget_type_del("Pager Gadget");
93
94 E_FREE(pager_config);
95 E_CONFIG_DD_FREE(conf_edd);
96 return 1;
97}
98
99E_API int
100e_modapi_gadget_save(E_Module *m EINA_UNUSED)
101{
102 e_config_domain_save("module.pager", conf_edd, pager_config);
103 return 1;
104}
diff --git a/src/modules/pager/gadget/pager.c b/src/modules/pager/gadget/pager.c
new file mode 100644
index 000000000..588659233
--- /dev/null
+++ b/src/modules/pager/gadget/pager.c
@@ -0,0 +1,1950 @@
1#include "pager.h"
2
3/* actual module specifics */
4typedef struct _Instance Instance;
5typedef struct _Pager Pager;
6typedef struct _Pager_Desk Pager_Desk;
7typedef struct _Pager_Win Pager_Win;
8typedef struct _Pager_Popup Pager_Popup;
9
10struct _Instance
11{
12 Evas_Object *o_pager; /* table */
13 Pager *pager;
14 Pager_Popup *popup;
15 Eina_Bool destroyed;
16};
17
18struct _Pager
19{
20 Instance *inst;
21 Pager_Popup *popup;
22 Evas_Object *o_table;
23 E_Zone *zone;
24 int xnum, ynum;
25 Eina_List *desks;
26 Pager_Desk *active_pd;
27 unsigned char dragging : 1;
28 unsigned char just_dragged : 1;
29 E_Client *active_drag_client;
30 Ecore_Job *recalc;
31 Eina_Bool invert : 1;
32};
33
34struct _Pager_Desk
35{
36 Pager *pager;
37 E_Desk *desk;
38 Eina_List *wins;
39 Evas_Object *o_desk;
40 Evas_Object *o_layout;
41 Evas_Object *drop_handler;
42 int xpos, ypos, urgent;
43 int current : 1;
44 struct
45 {
46 Pager *from_pager;
47 unsigned char in_pager : 1;
48 unsigned char start : 1;
49 int x, y, dx, dy, button;
50 } drag;
51};
52
53struct _Pager_Win
54{
55 E_Client *client;
56 Pager_Desk *desk;
57 Evas_Object *o_window;
58 Evas_Object *o_mirror;
59 unsigned char skip_winlist : 1;
60 struct
61 {
62 Pager *from_pager;
63 unsigned char start : 1;
64 unsigned char in_pager : 1;
65 unsigned char desktop : 1;
66 int x, y, dx, dy, button;
67 } drag;
68};
69
70struct _Pager_Popup
71{
72 Evas_Object *popup;
73 Evas_Object *o_bg;
74 Pager *pager;
75 Ecore_Timer *timer;
76 unsigned char urgent : 1;
77};
78
79static void _pager_cb_mirror_add(Pager_Desk *pd, Evas_Object *obj, Evas_Object *mirror);
80
81static void _pager_cb_obj_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
82static void _pager_cb_obj_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
83static void _button_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
84static Evas_Object *_pager_gadget_configure(Evas_Object *g);
85static Eina_Bool _pager_cb_event_desk_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
86static Eina_Bool _pager_cb_event_desk_name_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
87static Eina_Bool _pager_cb_event_compositor_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
88static void _pager_window_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
89static void _pager_window_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
90static void _pager_window_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
91static void _pager_window_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
92static void *_pager_window_cb_drag_convert(E_Drag *drag, const char *type);
93static void _pager_window_cb_drag_finished(E_Drag *drag, int dropped);
94static void _pager_drop_cb_enter(void *data, const char *type EINA_UNUSED, void *event_info);
95static void _pager_drop_cb_move(void *data, const char *type EINA_UNUSED, void *event_info);
96static void _pager_drop_cb_leave(void *data, const char *type EINA_UNUSED, void *event_info EINA_UNUSED);
97static void _pager_drop_cb_drop(void *data, const char *type, void *event_info);
98static void _pager_update_drop_position(Pager *p, Pager_Desk *pd, Evas_Coord x, Evas_Coord y);
99static void _pager_desk_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
100static void _pager_desk_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
101static void _pager_desk_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
102static void _pager_desk_cb_drag_finished(E_Drag *drag, int dropped);
103static void _pager_desk_cb_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
104static Eina_Bool _pager_popup_cb_timeout(void *data);
105static Pager *_pager_new(Evas *evas);
106static void _pager_free(Pager *p);
107static void _pager_fill(Pager *p);
108static void _pager_orient(Instance *inst, E_Gadget_Site_Orient orient);
109static void _pager_empty(Pager *p);
110static Pager_Desk *_pager_desk_new(Pager *p, E_Desk *desk, int xpos, int ypos, Eina_Bool invert);
111static void _pager_desk_free(Pager_Desk *pd);
112static void _pager_desk_select(Pager_Desk *pd);
113static Pager_Desk *_pager_desk_find(Pager *p, E_Desk *desk);
114static void _pager_desk_switch(Pager_Desk *pd1, Pager_Desk *pd2);
115static Pager_Win *_pager_window_new(Pager_Desk *pd, Evas_Object *mirror, E_Client *client);
116static void _pager_window_free(Pager_Win *pw);
117static Pager_Popup *pager_popup_new(int keyaction);
118static void _pager_popup_free(Pager_Popup *pp);
119static Pager_Popup *_pager_popup_find(E_Zone *zone);
120
121/* functions for pager popup on key actions */
122static int _pager_popup_show(void);
123static void _pager_popup_hide(int switch_desk);
124static Eina_Bool _pager_popup_cb_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
125static void _pager_popup_desk_switch(int x, int y);
126static void _pager_popup_modifiers_set(int mod);
127static Eina_Bool _pager_popup_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
128static Eina_Bool _pager_popup_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
129static void _pager_popup_cb_action_show(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED, Ecore_Event_Key *ev EINA_UNUSED);
130static void _pager_popup_cb_action_switch(E_Object *obj EINA_UNUSED, const char *params, Ecore_Event_Key *ev);
131
132/* variables for pager popup on key actions */
133static Ecore_Window input_window = 0;
134static Eina_List *handlers = NULL;
135static Pager_Popup *act_popup = NULL; /* active popup */
136static int hold_count = 0;
137static int hold_mod = 0;
138static E_Desk *current_desk = NULL;
139static Eina_List *pagers = NULL;
140
141static E_Action *act_popup_show = NULL;
142static E_Action *act_popup_switch = NULL;
143
144static Pager_Win *
145_pager_desk_window_find(Pager_Desk *pd, E_Client *client)
146{
147 Eina_List *l;
148 Pager_Win *pw;
149
150 EINA_LIST_FOREACH(pd->wins, l, pw)
151 {
152 if (pw)
153 {
154 if (pw->client == client) return pw;
155 }
156 }
157 return NULL;
158}
159
160static Pager_Win *
161_pager_window_find(Pager *p, E_Client *client)
162{
163 Eina_List *l;
164 Pager_Desk *pd;
165
166 EINA_LIST_FOREACH(p->desks, l, pd)
167 {
168 Pager_Win *pw;
169
170 pw = _pager_desk_window_find(pd, client);
171 if (pw) return pw;
172 }
173 return NULL;
174}
175
176static void
177_pager_gadget_anchor_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
178{
179 Instance *inst = data;
180
181 _pager_orient(inst, e_gadget_site_orient_get(obj));
182 if (inst->pager && inst->o_pager)
183 {
184 _pager_empty(inst->pager);
185 _pager_fill(inst->pager);
186 }
187}
188
189
190static void
191_pager_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
192{
193 Instance *inst = data;
194 Eina_List *l;
195 Pager_Desk *pd;
196
197 e_gadget_configure_cb_set(inst->o_pager, _pager_gadget_configure);
198 _pager_orient(inst, e_gadget_site_orient_get(obj));
199 if (inst->pager && inst->o_pager)
200 {
201 _pager_empty(inst->pager);
202 _pager_fill(inst->pager);
203
204 EINA_LIST_FOREACH(inst->pager->desks, l, pd)
205 {
206 if (!pd->drop_handler)
207 {
208 const char *drop[] =
209 {
210 "enlightenment/pager_win", "enlightenment/border",
211 "enlightenment/vdesktop"
212 };
213 pd->drop_handler =
214 e_gadget_drop_handler_add(inst->o_pager, pd,
215 _pager_drop_cb_enter, _pager_drop_cb_move,
216 _pager_drop_cb_leave, _pager_drop_cb_drop,
217 drop, 3);
218 //edje_object_part_swallow(pd->o_desk, "e.swallow.drop", pd->drop_handler);
219 evas_object_show(pd->drop_handler);
220 }
221 }
222 }
223 evas_object_smart_callback_del_full(obj, "gadget_created", _pager_gadget_created_cb, data);
224}
225
226static void
227_pager_gadget_destroyed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
228{
229 Instance *inst = data;
230
231 inst->destroyed = EINA_TRUE;
232}
233
234static void
235_pager_orient(Instance *inst, E_Gadget_Site_Orient orient)
236{
237 int aspect_w, aspect_h;
238 double aspect_ratio;
239
240 if (inst->o_pager)
241 {
242 switch (orient)
243 {
244
245 case E_GADGET_SITE_ORIENT_HORIZONTAL:
246 inst->pager->invert = EINA_FALSE;
247 break;
248 case E_GADGET_SITE_ORIENT_VERTICAL:
249 inst->pager->invert = EINA_TRUE;
250 break;
251 case E_GADGET_SITE_ORIENT_NONE:
252 inst->pager->invert = EINA_TRUE;
253 break;
254 default:
255 inst->pager->invert = EINA_FALSE;
256 }
257 }
258 if (inst->pager->invert)
259 {
260 aspect_w = inst->pager->ynum * inst->pager->zone->w;
261 aspect_h = inst->pager->xnum * inst->pager->zone->h;
262 evas_object_size_hint_aspect_set(inst->o_pager, EVAS_ASPECT_CONTROL_HORIZONTAL, aspect_w, aspect_h);
263 }
264 else
265 {
266 aspect_w = inst->pager->xnum * inst->pager->zone->w;
267 aspect_h = inst->pager->ynum * inst->pager->zone->h;
268 evas_object_size_hint_aspect_set(inst->o_pager, EVAS_ASPECT_CONTROL_VERTICAL, aspect_w, aspect_h);
269 }
270 aspect_ratio = (double)aspect_w / (double)aspect_h;
271
272 if (aspect_ratio > 1.0)
273 evas_object_size_hint_min_set(inst->o_pager, 4 * aspect_ratio, 4);
274 else
275 evas_object_size_hint_min_set(inst->o_pager, 4, 4 * aspect_ratio);
276}
277
278static void
279_pager_recalc(void *data)
280{
281 Pager *p = data;
282 Pager_Desk *pd;
283 Evas_Coord mw = 0, mh = 0;
284 int w, h, zw, zh, w2, h2;
285
286 p->recalc = NULL;
287 zw = p->zone->w; zh = p->zone->h;
288 pd = eina_list_data_get(p->desks);
289 if (!pd) return;
290
291 edje_object_size_min_calc(pd->o_desk, &mw, &mh);
292 evas_object_geometry_get(pd->o_desk, NULL, NULL, &w, &h);
293 w -= mw; h -= mh;
294 w2 = w; h2 = (zh * w) / zw;
295 if (h2 > h)
296 {
297 h2 = h; w2 = (zw * h) / zh;
298 }
299 w = w2; h = h2;
300 w += mw; h += mh;
301 if ((p->inst) && (p->inst->o_pager))
302 {
303 _pager_orient(p->inst, e_gadget_site_orient_get(e_gadget_site_get(p->inst->o_pager)));
304 if (p->invert)
305 evas_object_size_hint_min_set(p->inst->o_pager, p->ynum * w, p->xnum * h);
306 else
307 evas_object_size_hint_min_set(p->inst->o_pager, p->xnum * w, p->ynum * h);
308 }
309}
310
311static void
312_pager_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
313{
314 Pager *p = data;
315
316 if (!p->recalc)
317 p->recalc = ecore_job_add(_pager_recalc, p);
318}
319
320static Pager *
321_pager_new(Evas *evas)
322{
323 Pager *p;
324
325 p = E_NEW(Pager, 1);
326 p->inst = NULL;
327 p->popup = NULL;
328 p->o_table = elm_table_add(e_win_evas_win_get(evas));
329 evas_object_event_callback_add(p->o_table, EVAS_CALLBACK_RESIZE, _pager_resize, p);
330 elm_table_homogeneous_set(p->o_table, 1);
331 p->zone = e_comp_object_util_zone_get(p->o_table);
332 _pager_fill(p);
333 pagers = eina_list_append(pagers, p);
334 return p;
335}
336
337static void
338_pager_free(Pager *p)
339{
340 _pager_empty(p);
341 evas_object_del(p->o_table);
342 ecore_job_del(p->recalc);
343 pagers = eina_list_remove(pagers, p);
344 free(p);
345}
346
347static void
348_pager_fill(Pager *p)
349{
350 int x, y;
351 E_Gadget_Site_Orient orient;
352
353 if (p->inst && p->inst->o_pager)
354 {
355 orient = e_gadget_site_orient_get(e_gadget_site_get(p->inst->o_pager));
356 switch (orient)
357 {
358
359 case E_GADGET_SITE_ORIENT_HORIZONTAL:
360 p->invert = EINA_FALSE;
361 break;
362 case E_GADGET_SITE_ORIENT_VERTICAL:
363 p->invert = EINA_TRUE;
364 break;
365 case E_GADGET_SITE_ORIENT_NONE:
366 p->invert = EINA_TRUE;
367 break;
368 default:
369 p->invert = EINA_FALSE;
370 }
371 }
372 e_zone_desk_count_get(p->zone, &(p->xnum), &(p->ynum));
373 if (p->ynum != 1) p->invert = EINA_FALSE;
374 for (x = 0; x < p->xnum; x++)
375 {
376 for (y = 0; y < p->ynum; y++)
377 {
378 Pager_Desk *pd;
379 E_Desk *desk;
380
381 desk = e_desk_at_xy_get(p->zone, x, y);
382 if (desk)
383 {
384 pd = _pager_desk_new(p, desk, x, y, p->invert);
385 if (pd)
386 {
387 p->desks = eina_list_append(p->desks, pd);
388 if (desk == e_desk_current_get(desk->zone))
389 _pager_desk_select(pd);
390 }
391 }
392 }
393 }
394}
395
396static void
397_pager_empty(Pager *p)
398{
399 p->active_pd = NULL;
400 E_FREE_LIST(p->desks, _pager_desk_free);
401}
402
403static Pager_Desk *
404_pager_desk_new(Pager *p, E_Desk *desk, int xpos, int ypos, Eina_Bool invert)
405{
406 Pager_Desk *pd;
407 Evas_Object *o, *evo;
408 E_Client *ec;
409 Eina_List *l;
410 int w, h;
411 Evas *e;
412 const char *drop[] =
413 {
414 "enlightenment/pager_win", "enlightenment/border",
415 "enlightenment/vdesktop"
416 };
417
418 if (!desk) return NULL;
419 pd = E_NEW(Pager_Desk, 1);
420 if (!pd) return NULL;
421
422 pd->xpos = xpos;
423 pd->ypos = ypos;
424 pd->urgent = 0;
425 pd->desk = desk;
426 e_object_ref(E_OBJECT(desk));
427 pd->pager = p;
428 pd->drop_handler = NULL;
429
430 e = evas_object_evas_get(p->o_table);
431 o = edje_object_add(e);
432 pd->o_desk = o;
433 e_theme_edje_object_set(o, "base/theme/modules/pager",
434 "e/modules/pager16/desk");
435 edje_object_part_text_set(o, "e.text.label", desk->name);
436 if (pager_config->show_desk_names)
437 edje_object_signal_emit(o, "e,name,show", "e");
438
439 edje_object_size_min_calc(o, &w, &h);
440 evas_object_size_hint_min_set(o, w, h);
441
442 E_EXPAND(o);
443 E_FILL(o);
444 if (invert)
445 elm_table_pack(p->o_table, o, ypos, xpos, 1, 1);
446 else
447 elm_table_pack(p->o_table, o, xpos, ypos, 1, 1);
448
449 evo = (Evas_Object *)edje_object_part_object_get(o, "e.eventarea");
450 if (!evo) evo = o;
451
452 evas_object_event_callback_add(evo, EVAS_CALLBACK_MOUSE_DOWN,
453 _pager_desk_cb_mouse_down, pd);
454 evas_object_event_callback_add(evo, EVAS_CALLBACK_MOUSE_UP,
455 _pager_desk_cb_mouse_up, pd);
456 evas_object_event_callback_add(evo, EVAS_CALLBACK_MOUSE_MOVE,
457 _pager_desk_cb_mouse_move, pd);
458 evas_object_event_callback_add(evo, EVAS_CALLBACK_MOUSE_WHEEL,
459 _pager_desk_cb_mouse_wheel, pd);
460 evas_object_show(o);
461
462 pd->o_layout = e_deskmirror_add(desk, 1, 0);
463 evas_object_smart_callback_add(pd->o_layout, "mirror_add", (Evas_Smart_Cb)_pager_cb_mirror_add, pd);
464
465 l = e_deskmirror_mirror_list(pd->o_layout);
466 EINA_LIST_FREE(l, o)
467 {
468 ec = evas_object_data_get(o, "E_Client");
469 if (ec)
470 {
471 Pager_Win *pw;
472
473 pw = _pager_window_new(pd, o, ec);
474 if (pw) pd->wins = eina_list_append(pd->wins, pw);
475 }
476 }
477 edje_object_part_swallow(pd->o_desk, "e.swallow.content", pd->o_layout);
478 evas_object_show(pd->o_layout);
479
480 if (pd->pager->inst)
481 {
482 pd->drop_handler =
483 e_gadget_drop_handler_add(p->inst->o_pager, pd,
484 _pager_drop_cb_enter, _pager_drop_cb_move,
485 _pager_drop_cb_leave, _pager_drop_cb_drop,
486 drop, 3);
487 edje_object_part_swallow(pd->o_desk, "e.swallow.drop", pd->drop_handler);
488 evas_object_show(pd->drop_handler);
489 }
490
491 return pd;
492}
493
494static void
495_pager_desk_free(Pager_Desk *pd)
496{
497 Pager_Win *w;
498
499 if (pd->drop_handler)
500 evas_object_del(pd->drop_handler);
501 pd->drop_handler = NULL;
502 evas_object_del(pd->o_desk);
503 evas_object_del(pd->o_layout);
504 EINA_LIST_FREE(pd->wins, w)
505 _pager_window_free(w);
506 e_object_unref(E_OBJECT(pd->desk));
507 free(pd);
508}
509
510static void
511_pager_desk_select(Pager_Desk *pd)
512{
513 if (pd->current) return;
514 if (pd->pager->active_pd)
515 {
516 pd->pager->active_pd->current = 0;
517 edje_object_signal_emit(pd->pager->active_pd->o_desk, "e,state,unselected", "e");
518 }
519 pd->current = 1;
520 evas_object_raise(pd->o_desk);
521 edje_object_signal_emit(pd->o_desk, "e,state,selected", "e");
522 pd->pager->active_pd = pd;
523}
524
525static Pager_Desk *
526_pager_desk_find(Pager *p, E_Desk *desk)
527{
528 Eina_List *l;
529 Pager_Desk *pd;
530
531 EINA_LIST_FOREACH(p->desks, l, pd)
532 if (pd->desk == desk) return pd;
533
534 return NULL;
535}
536
537static void
538_pager_desk_switch(Pager_Desk *pd1, Pager_Desk *pd2)
539{
540 int c;
541 E_Zone *zone1, *zone2;
542 E_Desk *desk1, *desk2;
543 Pager_Win *pw;
544 Eina_List *l;
545
546 if ((!pd1) || (!pd2) || (!pd1->desk) || (!pd2->desk)) return;
547 if (pd1 == pd2) return;
548
549 desk1 = pd1->desk;
550 desk2 = pd2->desk;
551 zone1 = pd1->desk->zone;
552 zone2 = pd2->desk->zone;
553
554 /* Move opened windows from on desk to the other */
555 EINA_LIST_FOREACH(pd1->wins, l, pw)
556 {
557 if ((!pw) || (!pw->client) || (pw->client->iconic)) continue;
558 pw->client->hidden = 0;
559 e_client_desk_set(pw->client, desk2);
560 }
561 EINA_LIST_FOREACH(pd2->wins, l, pw)
562 {
563 if ((!pw) || (!pw->client) || (pw->client->iconic)) continue;
564 pw->client->hidden = 0;
565 e_client_desk_set(pw->client, desk1);
566 }
567
568 /* Modify desktop names in the config */
569 for (l = e_config->desktop_names, c = 0; l && c < 2; l = l->next)
570 {
571 E_Config_Desktop_Name *tmp_dn;
572
573 tmp_dn = l->data;
574 if (!tmp_dn) continue;
575 if ((tmp_dn->desk_x == desk1->x) &&
576 (tmp_dn->desk_y == desk1->y) &&
577 (tmp_dn->zone == (int)desk1->zone->num))
578 {
579 tmp_dn->desk_x = desk2->x;
580 tmp_dn->desk_y = desk2->y;
581 tmp_dn->zone = desk2->zone->num;
582 c++;
583 }
584 else if ((tmp_dn->desk_x == desk2->x) &&
585 (tmp_dn->desk_y == desk2->y) &&
586 (tmp_dn->zone == (int)desk2->zone->num))
587 {
588 tmp_dn->desk_x = desk1->x;
589 tmp_dn->desk_y = desk1->y;
590 tmp_dn->zone = desk1->zone->num;
591 c++;
592 }
593 }
594 if (c > 0) e_config_save();
595 e_desk_name_update();
596
597 /* Modify desktop backgrounds in the config */
598 for (l = e_config->desktop_backgrounds, c = 0; l && c < 2; l = l->next)
599 {
600 E_Config_Desktop_Background *tmp_db;
601
602 tmp_db = l->data;
603 if (!tmp_db) continue;
604 if ((tmp_db->desk_x == desk1->x) &&
605 (tmp_db->desk_y == desk1->y) &&
606 (tmp_db->zone == (int)desk1->zone->num))
607 {
608 tmp_db->desk_x = desk2->x;
609 tmp_db->desk_y = desk2->y;
610 tmp_db->zone = desk2->zone->num;
611 c++;
612 }
613 else if ((tmp_db->desk_x == desk2->x) &&
614 (tmp_db->desk_y == desk2->y) &&
615 (tmp_db->zone == (int)desk2->zone->num))
616 {
617 tmp_db->desk_x = desk1->x;
618 tmp_db->desk_y = desk1->y;
619 tmp_db->zone = desk1->zone->num;
620 c++;
621 }
622 }
623 if (c > 0) e_config_save();
624
625 /* If the current desktop has been switched, force to update of the screen */
626 if (desk2 == e_desk_current_get(zone2))
627 {
628 desk2->visible = 0;
629 e_desk_show(desk2);
630 }
631 if (desk1 == e_desk_current_get(zone1))
632 {
633 desk1->visible = 0;
634 e_desk_show(desk1);
635 }
636}
637
638static Pager_Win *
639_pager_window_new(Pager_Desk *pd, Evas_Object *mirror, E_Client *client)
640{
641 Pager_Win *pw;
642 //Evas_Object *o;
643 //int visible;
644
645 if (!client) return NULL;
646 pw = E_NEW(Pager_Win, 1);
647 if (!pw) return NULL;
648
649 pw->client = client;
650 pw->o_mirror = mirror;
651
652 //visible = evas_object_visible_get(mirror);
653 //pw->skip_winlist = client->netwm.state.skip_pager;
654 pw->desk = pd;
655
656 //o = edje_object_add(evas_object_evas_get(pd->pager->o_table));
657 //pw->o_window = o;
658 //e_theme_edje_object_set(o, "base/theme/modules/pager",
659 //"e/modules/pager16/window");
660 //if (visible) evas_object_show(o);
661
662
663 evas_object_event_callback_add(mirror, EVAS_CALLBACK_MOUSE_DOWN,
664 _pager_window_cb_mouse_down, pw);
665 evas_object_event_callback_add(mirror, EVAS_CALLBACK_MOUSE_UP,
666 _pager_window_cb_mouse_up, pw);
667 evas_object_event_callback_add(mirror, EVAS_CALLBACK_MOUSE_MOVE,
668 _pager_window_cb_mouse_move, pw);
669 evas_object_event_callback_add(mirror, EVAS_CALLBACK_DEL,
670 _pager_window_cb_del, pw);
671
672 if (client->urgent)
673 {
674 if (!(client->iconic))
675 edje_object_signal_emit(pd->o_desk, "e,state,urgent", "e");
676 //edje_object_signal_emit(pw->o_window, "e,state,urgent", "e");
677 }
678
679 //evas_object_show(o);
680 return pw;
681}
682
683static void
684_pager_window_free(Pager_Win *pw)
685{
686 if ((pw->drag.from_pager) && (pw->desk->pager->dragging))
687 pw->desk->pager->dragging = 0;
688 if (pw->o_mirror)
689 evas_object_event_callback_del_full(pw->o_mirror, EVAS_CALLBACK_DEL,
690 _pager_window_cb_del, pw);
691 if (pw->o_window) evas_object_del(pw->o_window);
692 free(pw);
693}
694
695static void
696_pager_popup_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
697{
698 Pager_Popup *pp = data;
699 E_FREE_FUNC(pp->timer, ecore_timer_del);
700 _pager_free(pp->pager);
701 free(pp);
702}
703
704static Pager_Popup *
705pager_popup_new(int keyaction)
706{
707 Pager_Popup *pp;
708 Evas_Coord w, h, zx, zy, zw, zh;
709 int x, y, height, width;
710 E_Desk *desk;
711 Pager_Desk *pd;
712 E_Zone *zone = e_zone_current_get();
713
714 pp = E_NEW(Pager_Popup, 1);
715 if (!pp) return NULL;
716
717 /* Show popup */
718
719 pp->pager = _pager_new(e_comp->evas);
720
721 pp->pager->popup = pp;
722 pp->urgent = 0;
723
724 e_zone_desk_count_get(zone, &x, &y);
725
726 if (keyaction)
727 height = pager_config->popup_act_height;
728 else
729 height = pager_config->popup_height;
730
731 pd = eina_list_data_get(pp->pager->desks);
732 if (!pd)
733 {
734 height *= y;
735 width = height * (zone->w * x) / (zone->h * y);
736 }
737 else
738 {
739 Evas_Coord mw = 0, mh = 0;
740
741 edje_object_size_min_calc(pd->o_desk, &mw, &mh);
742 height -= mh;
743 width = (height * zone->w) / zone->h;
744 height *= y;
745 height += (y * mh);
746 width *= x;
747 width += (x * mw);
748 }
749
750 evas_object_move(pp->pager->o_table, 0, 0);
751 evas_object_resize(pp->pager->o_table, width, height);
752
753 pp->o_bg = edje_object_add(e_comp->evas);
754 evas_object_name_set(pp->o_bg, "pager_gadget_popup");
755 e_theme_edje_object_set(pp->o_bg, "base/theme/modules/pager",
756 "e/modules/pager16/popup");
757 desk = e_desk_current_get(zone);
758 if (desk)
759 edje_object_part_text_set(pp->o_bg, "e.text.label", desk->name);
760
761 evas_object_size_hint_min_set(pp->pager->o_table, width, height);
762 edje_object_part_swallow(pp->o_bg, "e.swallow.content", pp->pager->o_table);
763 edje_object_size_min_calc(pp->o_bg, &w, &h);
764
765 pp->popup = e_comp_object_util_add(pp->o_bg, E_COMP_OBJECT_TYPE_POPUP);
766 evas_object_layer_set(pp->popup, E_LAYER_CLIENT_POPUP);
767 evas_object_pass_events_set(pp->popup, 1);
768 e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh);
769 evas_object_geometry_set(pp->popup, zx, zy, w, h);
770 e_comp_object_util_center(pp->popup);
771 evas_object_event_callback_add(pp->popup, EVAS_CALLBACK_DEL, _pager_popup_cb_del, pp);
772 evas_object_show(pp->popup);
773
774 pp->timer = NULL;
775
776 return pp;
777}
778
779static void
780_pager_popup_free(Pager_Popup *pp)
781{
782 E_FREE_FUNC(pp->timer, ecore_timer_del);
783 evas_object_hide(pp->popup);
784 evas_object_del(pp->popup);
785}
786
787static Pager_Popup *
788_pager_popup_find(E_Zone *zone)
789{
790 Eina_List *l;
791 Pager *p;
792
793 EINA_LIST_FOREACH(pagers, l, p)
794 if ((p->popup) && (p->zone == zone))
795 return p->popup;
796
797 return NULL;
798}
799
800static void
801_pager_cb_obj_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
802{
803 Instance *inst = data;
804 Eina_List *l;
805 Pager_Desk *pd;
806
807 EINA_LIST_FOREACH(inst->pager->desks, l, pd)
808 edje_object_signal_emit(pd->o_desk, "e,state,hidden", "e");
809}
810
811static void
812_pager_cb_obj_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
813{
814 Instance *inst = data;
815 Eina_List *l;
816 Pager_Desk *pd;
817
818 EINA_LIST_FOREACH(inst->pager->desks, l, pd)
819 edje_object_signal_emit(pd->o_desk, "e,state,visible", "e");
820}
821
822static Evas_Object *
823_pager_gadget_configure(Evas_Object *g)
824{
825 if (!pager_config) return NULL;
826 if (cfg_dialog) return NULL;
827 return config_pager(e_comp_object_util_zone_get(g));
828}
829
830static void
831_button_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
832{
833 Instance *inst = data;
834 Evas_Event_Mouse_Down *ev = event_info;
835
836 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
837 if (ev->button != 3) return;
838 if(!pager_config) return;
839 if (cfg_dialog) return;
840 e_gadget_configure(inst->o_pager);
841}
842
843EINTERN void
844_pager_cb_config_gadget_updated(void)
845{
846 Pager *p;
847 Pager_Desk *pd;
848 Eina_List *l, *ll;
849 if (!pager_config) return;
850 EINA_LIST_FOREACH(pagers, l, p)
851 EINA_LIST_FOREACH(p->desks, ll, pd)
852 {
853 if (pd->current)
854 edje_object_signal_emit(pd->o_desk, "e,state,selected", "e");
855 else
856 edje_object_signal_emit(pd->o_desk, "e,state,unselected", "e");
857 if (pager_config->show_desk_names)
858 edje_object_signal_emit(pd->o_desk, "e,name,show", "e");
859 else
860 edje_object_signal_emit(pd->o_desk, "e,name,hide", "e");
861 }
862}
863
864static void
865_pager_cb_mirror_add(Pager_Desk *pd, Evas_Object *obj EINA_UNUSED, Evas_Object *mirror)
866{
867 Pager_Win *pw;
868
869 pw = _pager_window_new(pd, mirror, evas_object_data_get(mirror, "E_Client"));
870 if (pw) pd->wins = eina_list_append(pd->wins, pw);
871}
872
873static Eina_Bool
874_pager_cb_event_zone_desk_count_set(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Zone_Desk_Count_Set *ev)
875{
876 Eina_List *l;
877 Pager *p;
878
879 EINA_LIST_FOREACH(pagers, l, p)
880 {
881 if ((ev->zone->desk_x_count == p->xnum) &&
882 (ev->zone->desk_y_count == p->ynum)) continue;
883 _pager_empty(p);
884 _pager_fill(p);
885 if (p->inst) _pager_orient(p->inst, e_gadget_site_orient_get(e_gadget_site_get(p->inst->o_pager)));
886 }
887
888 return ECORE_CALLBACK_PASS_ON;
889}
890
891static Eina_Bool
892_pager_cb_event_desk_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
893{
894 E_Event_Desk_Show *ev = event;
895 Eina_List *l;
896 Pager *p;
897 Pager_Popup *pp;
898 Pager_Desk *pd;
899
900 EINA_LIST_FOREACH(pagers, l, p)
901 {
902 if (p->zone != ev->desk->zone) continue;
903 pd = _pager_desk_find(p, ev->desk);
904 if (pd) _pager_desk_select(pd);
905
906 if (p->popup)
907 edje_object_part_text_set(p->popup->o_bg, "e.text.label", ev->desk->name);
908 }
909
910 if ((pager_config->popup) && (!act_popup))
911 {
912 if ((pp = _pager_popup_find(ev->desk->zone)))
913 evas_object_show(pp->popup);
914 else
915 pp = pager_popup_new(0);
916 if (pp->timer)
917 ecore_timer_reset(pp->timer);
918 else
919 pp->timer = ecore_timer_add(pager_config->popup_speed,
920 _pager_popup_cb_timeout, pp);
921 }
922
923 return ECORE_CALLBACK_PASS_ON;
924}
925
926static Eina_Bool
927_pager_cb_event_desk_name_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
928{
929 E_Event_Desk_Name_Change *ev = event;
930 Eina_List *l;
931 Pager *p;
932
933 EINA_LIST_FOREACH(pagers, l, p)
934 {
935 Pager_Desk *pd;
936
937 if (p->zone != ev->desk->zone) continue;
938 pd = _pager_desk_find(p, ev->desk);
939 if (pager_config->show_desk_names)
940 {
941 if (pd)
942 edje_object_part_text_set(pd->o_desk, "e.text.label",
943 ev->desk->name);
944 }
945 else
946 {
947 if (pd)
948 edje_object_part_text_set(pd->o_desk, "e.text.label", "");
949 }
950 }
951
952 return ECORE_CALLBACK_PASS_ON;
953}
954
955static Eina_Bool
956_pager_cb_event_client_urgent_change(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client_Property *ev)
957{
958 if (!(ev->property & E_CLIENT_PROPERTY_URGENCY)) return ECORE_CALLBACK_RENEW;
959
960 if (pager_config->popup_urgent && (!e_client_util_desk_visible(ev->ec, e_desk_current_get(ev->ec->zone))) &&
961 (pager_config->popup_urgent_focus ||
962 (!pager_config->popup_urgent_focus && (!ev->ec->focused) && (!ev->ec->want_focus))))
963 {
964 Pager_Popup *pp;
965
966 pp = _pager_popup_find(ev->ec->zone);
967
968 if ((!pp) && (ev->ec->urgent || ev->ec->icccm.urgent) && (!ev->ec->iconic))
969 {
970 pp = pager_popup_new(0);
971 if (!pp) return ECORE_CALLBACK_RENEW;
972
973 if (!pager_config->popup_urgent_stick)
974 pp->timer = ecore_timer_add(pager_config->popup_urgent_speed,
975 _pager_popup_cb_timeout, pp);
976 pp->urgent = 1;
977 }
978 }
979 return ECORE_CALLBACK_RENEW;
980}
981
982static Eina_Bool
983_pager_cb_event_compositor_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
984{
985 Eina_List *l;
986 Pager *p;
987
988 EINA_LIST_FOREACH(pagers, l, p)
989 {
990 Eina_List *l2;
991 Pager_Desk *pd;
992
993 EINA_LIST_FOREACH(p->desks, l2, pd)
994 e_layout_virtual_size_set(pd->o_layout, pd->desk->zone->w,
995 pd->desk->zone->h);
996
997 if (p->inst) _pager_orient(p->inst, e_gadget_site_orient_get(e_gadget_site_get(p->inst->o_pager)));
998 /* TODO if (p->popup) */
999 }
1000
1001 return ECORE_CALLBACK_PASS_ON;
1002}
1003
1004static void
1005_pager_window_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1006{
1007 Pager_Win *pw = data;
1008
1009 pw->desk->wins = eina_list_remove(pw->desk->wins, pw);
1010 _pager_window_free(data);
1011}
1012
1013static void
1014_pager_window_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1015{
1016 Pager_Win *pw = data;
1017
1018 pw->drag.button = 0;
1019}
1020
1021static void
1022_pager_window_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1023{
1024 Evas_Event_Mouse_Down *ev;
1025 Pager_Win *pw;
1026
1027 ev = event_info;
1028 pw = data;
1029
1030 if (!pw) return;
1031 pw->desk->pager->active_drag_client = NULL;
1032 if (pw->desk->pager->popup && !act_popup) return;
1033 if (!pw->desk->pager->popup && ev->button == 3) return;
1034 if (e_client_util_ignored_get(pw->client) || e_client_util_is_popup(pw->client)) return;
1035 if (ev->button == (int)pager_config->btn_desk) return;
1036 if ((ev->button == (int)pager_config->btn_drag) ||
1037 (ev->button == (int)pager_config->btn_noplace))
1038 {
1039 Evas_Coord ox, oy;
1040
1041 evas_object_geometry_get(pw->o_mirror, &ox, &oy, NULL, NULL);
1042 pw->drag.in_pager = 1;
1043 pw->drag.x = ev->canvas.x;
1044 pw->drag.y = ev->canvas.y;
1045 pw->drag.dx = ox - ev->canvas.x;
1046 pw->drag.dy = oy - ev->canvas.y;
1047 pw->drag.start = 1;
1048 pw->drag.button = ev->button;
1049 pw->desk->pager->active_drag_client = pw->client;
1050 }
1051}
1052
1053static void
1054_pager_window_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1055{
1056 Evas_Event_Mouse_Move *ev;
1057 Pager_Win *pw;
1058 E_Drag *drag;
1059 Evas_Object *o;
1060 Evas_Coord x, y, w, h;
1061 const char *drag_types[] =
1062 { "enlightenment/pager_win", "enlightenment/border" };
1063 Evas_Coord dx, dy;
1064 unsigned int resist = 0;
1065
1066 ev = event_info;
1067 pw = data;
1068
1069 if (!pw) return;
1070 if (pw->client->lock_user_location) return;
1071 if ((pw->desk->pager->popup) && (!act_popup)) return;
1072 if (!pw->drag.button) return;
1073
1074 /* prevent drag for a few pixels */
1075 if (!pw->drag.start) return;
1076
1077 dx = pw->drag.x - ev->cur.output.x;
1078 dy = pw->drag.y - ev->cur.output.y;
1079 if (pw->desk->pager)
1080 resist = pager_config->drag_resist;
1081
1082 if (((unsigned int)(dx * dx) + (unsigned int)(dy * dy)) <=
1083 (resist * resist)) return;
1084
1085 pw->desk->pager->dragging = 1;
1086 pw->drag.start = 0;
1087 e_comp_object_effect_clip(pw->client->frame);
1088 edje_object_signal_emit(pw->desk->o_desk, "e,action,drag,in", "e");
1089
1090 evas_object_geometry_get(pw->o_mirror, &x, &y, &w, &h);
1091 evas_object_hide(pw->o_mirror);
1092
1093 drag = e_drag_new(x, y, drag_types, 2, pw->desk->pager, -1,
1094 _pager_window_cb_drag_convert,
1095 _pager_window_cb_drag_finished);
1096 drag->button_mask = evas_pointer_button_down_mask_get(e_comp->evas);
1097
1098 /* this is independent of the original mirror */
1099 o = e_deskmirror_mirror_copy(pw->o_mirror);
1100 evas_object_show(o);
1101
1102 e_drag_object_set(drag, o);
1103 e_drag_resize(drag, w, h);
1104 e_drag_show(drag);
1105 e_drag_start(drag, x - pw->drag.dx, y - pw->drag.dy);
1106}
1107
1108static void *
1109_pager_window_cb_drag_convert(E_Drag *drag, const char *type)
1110{
1111 Pager *p;
1112
1113 p = drag->data;
1114 if (!strcmp(type, "enlightenment/pager_win")) return _pager_window_find(p, p->active_drag_client);
1115 if (!strcmp(type, "enlightenment/border")) return p->active_drag_client;
1116 return NULL;
1117}
1118
1119static void
1120_pager_window_cb_drag_finished(E_Drag *drag, int dropped)
1121{
1122 Pager_Win *pw;
1123 Pager *p;
1124
1125 p = drag->data;
1126 if (!p) return;
1127 pw = _pager_window_find(p, p->active_drag_client);
1128 if (!pw) return;
1129 p->active_drag_client = NULL;
1130 evas_object_show(pw->o_mirror);
1131 if (dropped)
1132 {
1133 /* be helpful */
1134 if (pw->client->desk->visible && (!e_client_focused_get()))
1135 evas_object_focus_set(pw->client->frame, 1);
1136 }
1137 else
1138 {
1139 int dx, dy, x, y, zx, zy, zw, zh;
1140 pw->client->hidden = !p->active_pd->desk->visible;
1141 e_client_desk_set(pw->client, p->active_pd->desk);
1142
1143 dx = (pw->client->w / 2);
1144 dy = (pw->client->h / 2);
1145
1146 evas_pointer_canvas_xy_get(evas_object_evas_get(p->o_table), &x, &y);
1147 e_zone_useful_geometry_get(p->zone, &zx, &zy, &zw, &zh);
1148
1149 /* offset so that center of window is on mouse, but keep within desk bounds */
1150 if (dx < x)
1151 {
1152 x -= dx;
1153 if ((pw->client->w < zw) &&
1154 (x + pw->client->w > zx + zw))
1155 x -= x + pw->client->w - (zx + zw);
1156 }
1157 else x = 0;
1158
1159 if (dy < y)
1160 {
1161 y -= dy;
1162 if ((pw->client->h < zh) &&
1163 (y + pw->client->h > zy + zh))
1164 y -= y + pw->client->h - (zy + zh);
1165 }
1166 else y = 0;
1167 evas_object_move(pw->client->frame, x, y);
1168
1169
1170 if (!(pw->client->lock_user_stacking))
1171 evas_object_raise(pw->client->frame);
1172 evas_object_focus_set(pw->client->frame, 1);
1173 }
1174 edje_object_signal_emit(pw->desk->o_desk, "e,action,drag,out", "e");
1175 if (!pw->drag.from_pager)
1176 {
1177 if (!pw->drag.start) p->just_dragged = 1;
1178 pw->drag.in_pager = 0;
1179 pw->drag.button = pw->drag.start = 0;
1180 p->dragging = 0;
1181 }
1182 if (pw->drag.from_pager) pw->drag.from_pager->dragging = 0;
1183 pw->drag.from_pager = NULL;
1184 e_comp_object_effect_unclip(pw->client->frame);
1185 if (act_popup)
1186 {
1187 if (e_comp->comp_type == E_PIXMAP_TYPE_X)
1188 e_grabinput_get(input_window, 0, input_window);
1189 else
1190 e_comp_grab_input(1, 1);
1191 if (!hold_count) _pager_popup_hide(1);
1192 }
1193}
1194
1195static void
1196_pager_update_drop_position(Pager *p, Pager_Desk *pd, Evas_Coord x, Evas_Coord y)
1197{
1198 Pager_Win *pw = NULL;
1199
1200 if (pd)
1201 pw = _pager_desk_window_find(pd, p->active_drag_client);
1202 else
1203 pw = _pager_window_find(p, p->active_drag_client);
1204 if (!pw) return;
1205 if (pd)
1206 {
1207 int zx, zy, zw, zh, vx, vy;
1208
1209 pw->drag.in_pager = 1;
1210 //makes drags look weird
1211 //e_zone_useful_geometry_get(pd->desk->zone, &zx, &zy, &zw, &zh);
1212 zx = pd->desk->zone->x, zy = pd->desk->zone->y;
1213 zw = pd->desk->zone->w, zh = pd->desk->zone->h;
1214 e_deskmirror_coord_canvas_to_virtual(pd->o_layout,
1215 x + pw->drag.dx,
1216 y + pw->drag.dy, &vx, &vy);
1217 pw->client->hidden = !pd->desk->visible;
1218 e_client_desk_set(pw->client, pd->desk);
1219 x = E_CLAMP(vx + zx, zx, zx + zw - pw->client->w);
1220 y = E_CLAMP(vy + zy, zy, zy + zh - pw->client->h);
1221 evas_object_move(pw->client->frame, x, y);
1222 }
1223 else
1224 {
1225 /* this prevents the desk from switching on drags */
1226 pw->drag.from_pager = pw->desk->pager;
1227 pw->drag.from_pager->dragging = 1;
1228 pw->drag.in_pager = 0;
1229 }
1230}
1231
1232static void
1233_pager_drop_cb_enter(void *data, const char *type EINA_UNUSED, void *event_info EINA_UNUSED)
1234{
1235 Pager_Desk *pd = data;
1236
1237 /* FIXME this fixes a segv, but the case is not easy
1238 * reproduceable. this makes no sense either since
1239 * the same 'pager' is passed to e_drop_handler_add
1240 * and it works without this almost all the time.
1241 * so this must be an issue with e_dnd code... i guess */
1242 if (act_popup) return;
1243 edje_object_signal_emit(pd->o_desk, "e,action,drag,in", "e");
1244}
1245
1246static void
1247_pager_drop_cb_move(void *data, const char *type EINA_UNUSED, void *event_info)
1248{
1249 E_Event_Dnd_Move *ev;
1250 Pager_Desk *pd;
1251
1252 ev = event_info;
1253 pd = data;
1254
1255 if (act_popup) return;
1256 _pager_update_drop_position(pd->pager, pd, ev->x, ev->y);
1257}
1258
1259static void
1260_pager_drop_cb_leave(void *data, const char *type EINA_UNUSED, void *event_info EINA_UNUSED)
1261{
1262 Pager_Desk *pd = data;
1263
1264 if (act_popup) return;
1265 edje_object_signal_emit(pd->o_desk, "e,action,drag,out", "e");
1266}
1267
1268static void
1269_pager_drop_cb_drop(void *data, const char *type, void *event_info)
1270{
1271 E_Event_Dnd_Drop *ev;
1272 Eina_List *l;
1273 Pager_Desk *pd;
1274 Pager_Desk *pd2 = NULL;
1275 E_Client *ec = NULL;
1276 int dx = 0, dy = 0;
1277 Pager_Win *pw = NULL;
1278 Evas_Coord wx, wy, wx2, wy2;
1279 Evas_Coord nx, ny;
1280 ev = event_info;
1281 pd = data;
1282
1283 if (act_popup) return;
1284
1285 if (pd)
1286 {
1287 if (!strcmp(type, "enlightenment/pager_win"))
1288 {
1289 pw = (Pager_Win *)(ev->data);
1290 if (pw)
1291 {
1292 ec = pw->client;
1293 dx = pw->drag.dx;
1294 dy = pw->drag.dy;
1295 }
1296 }
1297 else if (!strcmp(type, "enlightenment/border"))
1298 {
1299 ec = ev->data;
1300 e_deskmirror_coord_virtual_to_canvas(pd->o_layout, ec->x, ec->y,
1301 &wx, &wy);
1302 e_deskmirror_coord_virtual_to_canvas(pd->o_layout, ec->x + ec->w,
1303 ec->y + ec->h, &wx2, &wy2);
1304 dx = (wx - wx2) / 2;
1305 dy = (wy - wy2) / 2;
1306 }
1307 else if (!strcmp(type, "enlightenment/vdesktop"))
1308 {
1309 pd2 = ev->data;
1310 if (!pd2) return;
1311 _pager_desk_switch(pd, pd2);
1312 }
1313 else
1314 return;
1315
1316 if (ec)
1317 {
1318 E_Maximize max = ec->maximized;
1319 E_Fullscreen fs = ec->fullscreen_policy;
1320 Eina_Bool fullscreen = ec->fullscreen;
1321
1322 if (ec->iconic) e_client_uniconify(ec);
1323 if (ec->maximized)
1324 e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
1325 if (fullscreen) e_client_unfullscreen(ec);
1326 ec->hidden = 0;
1327 e_client_desk_set(ec, pd->desk);
1328 evas_object_raise(ec->frame);
1329
1330 if ((!max) && (!fullscreen))
1331 {
1332 int zx, zy, zw, zh, mx, my;
1333
1334 e_deskmirror_coord_canvas_to_virtual(pd->o_layout,
1335 ev->x + dx,
1336 ev->y + dy,
1337 &nx, &ny);
1338 e_zone_useful_geometry_get(pd->desk->zone,
1339 &zx, &zy, &zw, &zh);
1340
1341 mx = E_CLAMP(nx + zx, zx, zx + zw - ec->w);
1342 my = E_CLAMP(ny + zy, zy, zy + zh - ec->h);
1343 evas_object_move(ec->frame, mx, my);
1344 }
1345 if (max) e_client_maximize(ec, max);
1346 if (fullscreen) e_client_fullscreen(ec, fs);
1347 }
1348 }
1349 EINA_LIST_FOREACH(pd->pager->desks, l, pd)
1350 {
1351 edje_object_signal_emit(pd->o_desk, "e,action,drag,out", "e");
1352 }
1353}
1354
1355static void
1356_pager_desk_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1357{
1358 Evas_Event_Mouse_Down *ev;
1359 Pager_Desk *pd;
1360 Evas_Coord ox, oy;
1361
1362 ev = event_info;
1363 pd = data;
1364 if (!pd) return;
1365 if ((!pd->pager->popup) && (ev->button == 3)) return;
1366 if (ev->button == (int)pager_config->btn_desk)
1367 {
1368 evas_object_geometry_get(pd->o_desk, &ox, &oy, NULL, NULL);
1369 pd->drag.start = 1;
1370 pd->drag.in_pager = 1;
1371 pd->drag.dx = ox - ev->canvas.x;
1372 pd->drag.dy = oy - ev->canvas.y;
1373 pd->drag.x = ev->canvas.x;
1374 pd->drag.y = ev->canvas.y;
1375 pd->drag.button = ev->button;
1376 }
1377 else
1378 {
1379 pd->drag.dx = pd->drag.dy = pd->drag.x = pd->drag.y = 0;
1380 }
1381 pd->pager->just_dragged = 0;
1382}
1383
1384static void
1385_pager_desk_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1386{
1387 Evas_Event_Mouse_Up *ev;
1388 Pager_Desk *pd;
1389 Pager *p;
1390
1391 ev = event_info;
1392 pd = data;
1393
1394 if (!pd) return;
1395 p = pd->pager;
1396
1397 /* FIXME: pd->pager->dragging is 0 when finishing a drag from desk to desk */
1398 if ((ev->button == 1) && (!pd->pager->dragging) &&
1399 (!pd->pager->just_dragged))
1400 {
1401 current_desk = pd->desk;
1402 e_desk_show(pd->desk);
1403 pd->drag.start = 0;
1404 pd->drag.in_pager = 0;
1405 }
1406 else if (ev->button == (int)pager_config->btn_desk)
1407 {
1408 if (pd->pager->dragging) pd->pager->dragging = 0;
1409 pd->drag.start = 0;
1410 pd->drag.in_pager = 0;
1411 }
1412
1413 if ((p->popup) && (p->popup->urgent)) _pager_popup_free(p->popup);
1414}
1415
1416static void
1417_pager_desk_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1418{
1419 Evas_Event_Mouse_Move *ev;
1420 Pager_Desk *pd;
1421 Evas_Coord dx, dy;
1422 unsigned int resist = 0;
1423 E_Drag *drag;
1424 Evas_Object *o;
1425 Evas_Coord x, y, w, h;
1426 const char *drag_types[] = { "enlightenment/vdesktop" };
1427
1428 ev = event_info;
1429
1430 pd = data;
1431 if (!pd) return;
1432 /* prevent drag for a few pixels */
1433 if (pd->drag.start)
1434 {
1435 dx = pd->drag.x - ev->cur.output.x;
1436 dy = pd->drag.y - ev->cur.output.y;
1437 if ((pd->pager) && (pd->pager->inst))
1438 resist = pager_config->drag_resist;
1439
1440 if (((unsigned int)(dx * dx) + (unsigned int)(dy * dy)) <=
1441 (resist * resist)) return;
1442
1443 if (pd->pager) pd->pager->dragging = 1;
1444 pd->drag.start = 0;
1445 }
1446
1447 if (pd->drag.in_pager && pd->pager)
1448 {
1449 evas_object_geometry_get(pd->o_desk, &x, &y, &w, &h);
1450 drag = e_drag_new(x, y, drag_types, 1, pd, -1,
1451 NULL, _pager_desk_cb_drag_finished);
1452 drag->button_mask = evas_pointer_button_down_mask_get(e_comp->evas);
1453
1454 /* redraw the desktop theme above */
1455 o = e_comp_object_util_mirror_add(pd->o_layout);
1456 e_drag_object_set(drag, o);
1457
1458 e_drag_resize(drag, w, h);
1459 e_drag_start(drag, x - pd->drag.dx, y - pd->drag.dy);
1460
1461 pd->drag.from_pager = pd->pager;
1462 pd->drag.from_pager->dragging = 1;
1463 pd->drag.in_pager = 0;
1464 }
1465}
1466
1467static void
1468_pager_desk_cb_drag_finished(E_Drag *drag, int dropped)
1469{
1470 Pager_Desk *pd;
1471 Pager_Desk *pd2 = NULL;
1472 Eina_List *l;
1473 E_Desk *desk;
1474 E_Zone *zone;
1475 Pager *p;
1476
1477 pd = drag->data;
1478 if (!pd) return;
1479 if (!dropped)
1480 {
1481 /* wasn't dropped on pager, switch with current desktop */
1482 if (!pd->desk) return;
1483 zone = e_zone_current_get();
1484 desk = e_desk_current_get(zone);
1485 EINA_LIST_FOREACH(pagers, l, p)
1486 {
1487 pd2 = _pager_desk_find(p, desk);
1488 if (pd2) break;
1489 }
1490 _pager_desk_switch(pd, pd2);
1491 }
1492 if (pd->drag.from_pager)
1493 {
1494 pd->drag.from_pager->dragging = 0;
1495 pd->drag.from_pager->just_dragged = 0;
1496 }
1497 edje_object_signal_emit(pd->o_desk, "e,action,drag,out", "e");
1498 pd->drag.from_pager = NULL;
1499
1500 if (act_popup)
1501 {
1502 if (e_comp->comp_type == E_PIXMAP_TYPE_X)
1503 e_grabinput_get(input_window, 0, input_window);
1504 else
1505 e_comp_grab_input(1, 1);
1506 if (!hold_count) _pager_popup_hide(1);
1507 }
1508}
1509
1510static void
1511_pager_desk_cb_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1512{
1513 Evas_Event_Mouse_Wheel *ev;
1514 Pager_Desk *pd;
1515
1516 ev = event_info;
1517 pd = data;
1518
1519 if (pd->pager->popup) return;
1520
1521 if (pager_config->flip_desk)
1522 e_zone_desk_linear_flip_by(pd->desk->zone, ev->z);
1523}
1524
1525static Eina_Bool
1526_pager_popup_cb_timeout(void *data)
1527{
1528 Pager_Popup *pp;
1529
1530 pp = data;
1531 pp->timer = NULL;
1532 _pager_popup_free(pp);
1533
1534#ifndef HAVE_WAYLAND_ONLY
1535 if (e_comp->comp_type == E_PIXMAP_TYPE_X)
1536 {
1537 if (input_window)
1538 {
1539 e_grabinput_release(input_window, input_window);
1540 ecore_x_window_free(input_window);
1541 input_window = 0;
1542 }
1543 }
1544#endif
1545 if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
1546 {
1547 e_comp_ungrab_input(1, 1);
1548 input_window = 0;
1549 }
1550
1551 return ECORE_CALLBACK_CANCEL;
1552}
1553
1554/************************************************************************/
1555/* popup-on-keyaction functions */
1556static int
1557_pager_popup_show(void)
1558{
1559 E_Zone *zone;
1560 int x, y, w, h;
1561 Pager_Popup *pp;
1562 //const char *drop[] =
1563 //{
1564 //"enlightenment/pager_win", "enlightenment/border",
1565 //"enlightenment/vdesktop"
1566 //};
1567
1568 if ((act_popup) || (input_window)) return 0;
1569
1570 zone = e_zone_current_get();
1571
1572 pp = _pager_popup_find(zone);
1573 if (pp) _pager_popup_free(pp);
1574
1575#ifndef HAVE_WAYLAND_ONLY
1576 if (e_comp->comp_type == E_PIXMAP_TYPE_X)
1577 {
1578 input_window = ecore_x_window_input_new(e_comp->win, 0, 0, 1, 1);
1579 ecore_x_window_show(input_window);
1580 if (!e_grabinput_get(input_window, 0, input_window))
1581 {
1582 ecore_x_window_free(input_window);
1583 input_window = 0;
1584 return 0;
1585 }
1586 }
1587#endif
1588 if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
1589 {
1590 input_window = e_comp->ee_win;
1591 e_comp_grab_input(1, 1);
1592 }
1593
1594 handlers = eina_list_append
1595 (handlers, ecore_event_handler_add
1596 (ECORE_EVENT_KEY_DOWN, _pager_popup_cb_key_down, NULL));
1597 handlers = eina_list_append
1598 (handlers, ecore_event_handler_add
1599 (ECORE_EVENT_KEY_UP, _pager_popup_cb_key_up, NULL));
1600 handlers = eina_list_append
1601 (handlers, ecore_event_handler_add
1602 (ECORE_EVENT_MOUSE_WHEEL, _pager_popup_cb_mouse_wheel, NULL));
1603
1604 act_popup = pager_popup_new(0);
1605
1606 evas_object_geometry_get(act_popup->pager->o_table, &x, &y, &w, &h);
1607
1608 current_desk = e_desk_current_get(zone);
1609
1610 return 1;
1611}
1612
1613static void
1614_pager_popup_hide(int switch_desk)
1615{
1616 hold_count = 0;
1617 hold_mod = 0;
1618 while (handlers)
1619 {
1620 ecore_event_handler_del(handlers->data);
1621 handlers = eina_list_remove_list(handlers, handlers);
1622 }
1623
1624 act_popup->timer = ecore_timer_add(0.1, _pager_popup_cb_timeout, act_popup);
1625
1626 if ((switch_desk) && (current_desk)) e_desk_show(current_desk);
1627
1628 act_popup = NULL;
1629}
1630
1631static void
1632_pager_popup_modifiers_set(int mod)
1633{
1634 if (!act_popup) return;
1635 hold_mod = mod;
1636 hold_count = 0;
1637 if (hold_mod & ECORE_EVENT_MODIFIER_SHIFT) hold_count++;
1638 if (hold_mod & ECORE_EVENT_MODIFIER_CTRL) hold_count++;
1639 if (hold_mod & ECORE_EVENT_MODIFIER_ALT) hold_count++;
1640 if (hold_mod & ECORE_EVENT_MODIFIER_WIN) hold_count++;
1641}
1642
1643static void
1644_pager_popup_desk_switch(int x, int y)
1645{
1646 int max_x, max_y, desk_x, desk_y;
1647 Pager_Desk *pd;
1648 Pager_Popup *pp = act_popup;
1649
1650 e_zone_desk_count_get(pp->pager->zone, &max_x, &max_y);
1651
1652 desk_x = current_desk->x + x;
1653 desk_y = current_desk->y + y;
1654
1655 if (desk_x < 0)
1656 desk_x = max_x - 1;
1657 else if (desk_x >= max_x)
1658 desk_x = 0;
1659
1660 if (desk_y < 0)
1661 desk_y = max_y - 1;
1662 else if (desk_y >= max_y)
1663 desk_y = 0;
1664
1665 current_desk = e_desk_at_xy_get(pp->pager->zone, desk_x, desk_y);
1666
1667 pd = _pager_desk_find(pp->pager, current_desk);
1668 if (pd) _pager_desk_select(pd);
1669
1670 edje_object_part_text_set(pp->o_bg, "e.text.label", current_desk->name);
1671}
1672
1673static void
1674_pager_popup_cb_action_show(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED, Ecore_Event_Key *ev EINA_UNUSED)
1675{
1676 if (_pager_popup_show())
1677 _pager_popup_modifiers_set(ev->modifiers);
1678}
1679
1680static void
1681_pager_popup_cb_action_switch(E_Object *obj EINA_UNUSED, const char *params, Ecore_Event_Key *ev)
1682{
1683 int max_x, max_y, desk_x;
1684 int x = 0, y = 0;
1685
1686 if (!act_popup)
1687 {
1688 if (_pager_popup_show())
1689 _pager_popup_modifiers_set(ev->modifiers);
1690 else
1691 return;
1692 }
1693
1694 e_zone_desk_count_get(act_popup->pager->zone, &max_x, &max_y);
1695 desk_x = current_desk->x /* + x <=this is always 0 */;
1696
1697 if (!strcmp(params, "left"))
1698 x = -1;
1699 else if (!strcmp(params, "right"))
1700 x = 1;
1701 else if (!strcmp(params, "up"))
1702 y = -1;
1703 else if (!strcmp(params, "down"))
1704 y = 1;
1705 else if (!strcmp(params, "next"))
1706 {
1707 x = 1;
1708 if (desk_x == max_x - 1)
1709 y = 1;
1710 }
1711 else if (!strcmp(params, "prev"))
1712 {
1713 x = -1;
1714 if (desk_x == 0)
1715 y = -1;
1716 }
1717
1718 _pager_popup_desk_switch(x, y);
1719}
1720
1721static Eina_Bool
1722_pager_popup_cb_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
1723{
1724 Ecore_Event_Mouse_Wheel *ev = event;
1725 Pager_Popup *pp = act_popup;
1726 int max_x;
1727
1728 e_zone_desk_count_get(pp->pager->zone, &max_x, NULL);
1729
1730 if (current_desk->x + ev->z >= max_x)
1731 _pager_popup_desk_switch(1, 1);
1732 else if (current_desk->x + ev->z < 0)
1733 _pager_popup_desk_switch(-1, -1);
1734 else
1735 _pager_popup_desk_switch(ev->z, 0);
1736
1737 return ECORE_CALLBACK_PASS_ON;
1738}
1739
1740static Eina_Bool
1741_pager_popup_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
1742{
1743 Ecore_Event_Key *ev;
1744
1745 ev = event;
1746 if (ev->window != input_window) return ECORE_CALLBACK_PASS_ON;
1747 if (!strcmp(ev->key, "Up"))
1748 _pager_popup_desk_switch(0, -1);
1749 else if (!strcmp(ev->key, "Down"))
1750 _pager_popup_desk_switch(0, 1);
1751 else if (!strcmp(ev->key, "Left"))
1752 _pager_popup_desk_switch(-1, 0);
1753 else if (!strcmp(ev->key, "Right"))
1754 _pager_popup_desk_switch(1, 0);
1755 else if (!strcmp(ev->key, "Escape"))
1756 _pager_popup_hide(0);
1757 else if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")) ||
1758 (!strcmp(ev->key, "space")))
1759 {
1760 Pager_Popup *pp = act_popup;
1761
1762 if (pp)
1763 {
1764 E_Desk *desk;
1765
1766 desk = e_desk_at_xy_get(pp->pager->zone,
1767 current_desk->x, current_desk->y);
1768 if (desk) e_desk_show(desk);
1769 }
1770 _pager_popup_hide(0);
1771 }
1772 else
1773 {
1774 E_Config_Binding_Key *binding;
1775 Eina_List *l;
1776
1777 EINA_LIST_FOREACH(e_bindings->key_bindings, l, binding)
1778 {
1779 E_Binding_Modifier mod = 0;
1780
1781 if ((binding->action) && (strcmp(binding->action, "pager_gadget_switch")))
1782 continue;
1783
1784 if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
1785 mod |= E_BINDING_MODIFIER_SHIFT;
1786 if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)
1787 mod |= E_BINDING_MODIFIER_CTRL;
1788 if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)
1789 mod |= E_BINDING_MODIFIER_ALT;
1790 if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN)
1791 mod |= E_BINDING_MODIFIER_WIN;
1792
1793 if (binding->key && (!strcmp(binding->key, ev->key)) &&
1794 ((binding->modifiers == mod)))
1795 {
1796 E_Action *act;
1797
1798 act = e_action_find(binding->action);
1799
1800 if (act)
1801 {
1802 if (act->func.go_key)
1803 act->func.go_key(NULL, binding->params, ev);
1804 }
1805 }
1806 }
1807 }
1808 return ECORE_CALLBACK_PASS_ON;
1809}
1810
1811static Eina_Bool
1812_pager_popup_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
1813{
1814 Ecore_Event_Key *ev;
1815
1816 ev = event;
1817 if (!(act_popup)) return ECORE_CALLBACK_PASS_ON;
1818
1819 if (hold_mod)
1820 {
1821 if ((hold_mod & ECORE_EVENT_MODIFIER_SHIFT) &&
1822 (!strcmp(ev->key, "Shift_L"))) hold_count--;
1823 else if ((hold_mod & ECORE_EVENT_MODIFIER_SHIFT) &&
1824 (!strcmp(ev->key, "Shift_R")))
1825 hold_count--;
1826 else if ((hold_mod & ECORE_EVENT_MODIFIER_CTRL) &&
1827 (!strcmp(ev->key, "Control_L")))
1828 hold_count--;
1829 else if ((hold_mod & ECORE_EVENT_MODIFIER_CTRL) &&
1830 (!strcmp(ev->key, "Control_R")))
1831 hold_count--;
1832 else if ((hold_mod & ECORE_EVENT_MODIFIER_ALT) &&
1833 (!strcmp(ev->key, "Alt_L")))
1834 hold_count--;
1835 else if ((hold_mod & ECORE_EVENT_MODIFIER_ALT) &&
1836 (!strcmp(ev->key, "Alt_R")))
1837 hold_count--;
1838 else if ((hold_mod & ECORE_EVENT_MODIFIER_ALT) &&
1839 (!strcmp(ev->key, "Meta_L")))
1840 hold_count--;
1841 else if ((hold_mod & ECORE_EVENT_MODIFIER_ALT) &&
1842 (!strcmp(ev->key, "Meta_R")))
1843 hold_count--;
1844 else if ((hold_mod & ECORE_EVENT_MODIFIER_ALT) &&
1845 (!strcmp(ev->key, "Super_L")))
1846 hold_count--;
1847 else if ((hold_mod & ECORE_EVENT_MODIFIER_ALT) &&
1848 (!strcmp(ev->key, "Super_R")))
1849 hold_count--;
1850 else if ((hold_mod & ECORE_EVENT_MODIFIER_WIN) &&
1851 (!strcmp(ev->key, "Super_L")))
1852 hold_count--;
1853 else if ((hold_mod & ECORE_EVENT_MODIFIER_WIN) &&
1854 (!strcmp(ev->key, "Super_R")))
1855 hold_count--;
1856 else if ((hold_mod & ECORE_EVENT_MODIFIER_WIN) &&
1857 (!strcmp(ev->key, "Mode_switch")))
1858 hold_count--;
1859 else if ((hold_mod & ECORE_EVENT_MODIFIER_WIN) &&
1860 (!strcmp(ev->key, "Meta_L")))
1861 hold_count--;
1862 else if ((hold_mod & ECORE_EVENT_MODIFIER_WIN) &&
1863 (!strcmp(ev->key, "Meta_R")))
1864 hold_count--;
1865 if ((hold_count <= 0) && (!act_popup->pager->dragging))
1866 {
1867 _pager_popup_hide(1);
1868 return ECORE_CALLBACK_PASS_ON;
1869 }
1870 }
1871
1872 return ECORE_CALLBACK_PASS_ON;
1873}
1874
1875static void
1876pager_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1877{
1878 Instance *inst = data;
1879
1880 _pager_free(inst->pager);
1881 ginstances = eina_list_remove(ginstances, inst);
1882 free(inst);
1883}
1884
1885EINTERN Evas_Object *
1886pager_create(Evas_Object *parent, int *id EINA_UNUSED, E_Gadget_Site_Orient orient EINA_UNUSED)
1887{
1888 Pager *p;
1889 Evas_Object *o;
1890 Instance *inst;
1891
1892 inst = E_NEW(Instance, 1);
1893 p = _pager_new(evas_object_evas_get(parent));
1894 p->inst = inst;
1895 inst->pager = p;
1896 o = p->o_table;
1897 inst->o_pager = o;
1898 inst->destroyed = EINA_FALSE;
1899 _pager_orient(inst, e_gadget_site_orient_get(parent));
1900
1901 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, pager_del, inst);
1902 evas_object_smart_callback_add(parent, "gadget_created", _pager_gadget_created_cb, inst);
1903 evas_object_smart_callback_add(parent, "gadget_site_anchor", _pager_gadget_anchor_change_cb, inst);
1904 evas_object_smart_callback_add(parent, "gadget_destroyed", _pager_gadget_destroyed_cb, inst);
1905
1906 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
1907 _button_cb_mouse_down, inst);
1908 evas_object_event_callback_add(o, EVAS_CALLBACK_SHOW,
1909 _pager_cb_obj_show, inst);
1910 evas_object_event_callback_add(o, EVAS_CALLBACK_HIDE,
1911 _pager_cb_obj_hide, inst);
1912 ginstances = eina_list_append(ginstances, inst);
1913 return inst->o_pager;
1914}
1915
1916EINTERN void
1917pager_init(void)
1918{
1919 E_LIST_HANDLER_APPEND(ghandlers, E_EVENT_ZONE_DESK_COUNT_SET, _pager_cb_event_zone_desk_count_set, NULL);
1920 E_LIST_HANDLER_APPEND(ghandlers, E_EVENT_DESK_SHOW, _pager_cb_event_desk_show, NULL);
1921 E_LIST_HANDLER_APPEND(ghandlers, E_EVENT_DESK_NAME_CHANGE, _pager_cb_event_desk_name_change, NULL);
1922 E_LIST_HANDLER_APPEND(ghandlers, E_EVENT_COMPOSITOR_RESIZE, _pager_cb_event_compositor_resize, NULL);
1923 E_LIST_HANDLER_APPEND(ghandlers, E_EVENT_CLIENT_PROPERTY, _pager_cb_event_client_urgent_change, NULL);
1924
1925 act_popup_show = e_action_add("pager_gadget_show");
1926 if (act_popup_show)
1927 {
1928 act_popup_show->func.go_key = _pager_popup_cb_action_show;
1929 e_action_predef_name_set(N_("Pager Gadget"), N_("Show Pager Popup"),
1930 "pager_gadget_show", "<none>", NULL, 0);
1931 }
1932 act_popup_switch = e_action_add("pager_gadget_switch");
1933 if (act_popup_switch)
1934 {
1935 act_popup_switch->func.go_key = _pager_popup_cb_action_switch;
1936 e_action_predef_name_set(N_("Pager Gadget"), N_("Popup Desk Right"),
1937 "pager_gadget_switch", "right", NULL, 0);
1938 e_action_predef_name_set(N_("Pager Gadget"), N_("Popup Desk Left"),
1939 "pager_gadget_switch", "left", NULL, 0);
1940 e_action_predef_name_set(N_("Pager Gadget"), N_("Popup Desk Up"),
1941 "pager_gadget_switch", "up", NULL, 0);
1942 e_action_predef_name_set(N_("Pager Gadget"), N_("Popup Desk Down"),
1943 "pager_gadget_switch", "down", NULL, 0);
1944 e_action_predef_name_set(N_("Pager Gadget"), N_("Popup Desk Next"),
1945 "pager_gadget_switch", "next", NULL, 0);
1946 e_action_predef_name_set(N_("Pager Gadget"), N_("Popup Desk Previous"),
1947 "pager_gadget_switch", "prev", NULL, 0);
1948 }
1949}
1950
diff --git a/src/modules/pager/gadget/pager.h b/src/modules/pager/gadget/pager.h
new file mode 100644
index 000000000..b75c53bb7
--- /dev/null
+++ b/src/modules/pager/gadget/pager.h
@@ -0,0 +1,50 @@
1#ifndef PAGER_H
2#define PAGER_H
3
4#include "e.h"
5
6E_API void *e_modapi_gadget_init(E_Module *m);
7E_API int e_modapi_gadget_shutdown(E_Module *m);
8E_API int e_modapi_gadget_save(E_Module *m);
9
10typedef struct _Config Config;
11struct _Config
12{
13 unsigned int popup;
14 double popup_speed;
15 unsigned int popup_urgent;
16 unsigned int popup_urgent_stick;
17 unsigned int popup_urgent_focus;
18 double popup_urgent_speed;
19 unsigned int show_desk_names;
20 int popup_act_height;
21 int popup_height;
22 unsigned int drag_resist;
23 unsigned int btn_drag;
24 unsigned int btn_noplace;
25 unsigned int btn_desk;
26 unsigned int flip_desk;
27};
28
29EINTERN Evas_Object *pager_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
30EINTERN Evas_Object *config_pager(E_Zone *zone);
31EINTERN void pager_init(void);
32EINTERN void _pager_cb_config_gadget_updated(void);
33EINTERN void _pager_cb_config_updated(void);
34
35extern Config *pager_config;
36extern E_Module *gmodule;
37extern Evas_Object *cfg_dialog;
38extern Eina_List *ginstances, *ghandlers;
39/**
40 * @addtogroup Optional_Gadgets
41 * @{
42 *
43 * @defgroup Module_Pager Virtual Desktop Pager
44 *
45 * Shows the grid of virtual desktops and allows changing between
46 * them.
47 *
48 * @}
49 */
50#endif