summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosé Roberto de Souza <jose.souza@intel.com>2013-12-18 18:51:08 -0200
committerMike Blumenkrantz <zmike@samsung.com>2013-12-18 16:25:23 -0500
commitdc74938241d9bac0fa36e3153b3fd09cf6407f49 (patch)
treed2a0dbfade6536a04d15de64b29e47be371f03c3 /src
parentf2e20b205289e3deed64337a3e9190e736be9ef0 (diff)
Refactor systray to have only one box
This is simpler and avoid some edje erros. This patch depends on a patch on elementary to update systray edj.
Diffstat (limited to 'src')
-rw-r--r--src/modules/systray/e-module-systray.edjbin13065 -> 10045 bytes
-rw-r--r--src/modules/systray/e_mod_main.c35
-rw-r--r--src/modules/systray/e_mod_main.h7
-rw-r--r--src/modules/systray/e_mod_notifier_host.c10
-rw-r--r--src/modules/systray/e_mod_xembed.c137
5 files changed, 82 insertions, 107 deletions
diff --git a/src/modules/systray/e-module-systray.edj b/src/modules/systray/e-module-systray.edj
index f2dd5d4bb..f7fd8fd55 100644
--- a/src/modules/systray/e-module-systray.edj
+++ b/src/modules/systray/e-module-systray.edj
Binary files differ
diff --git a/src/modules/systray/e_mod_main.c b/src/modules/systray/e_mod_main.c
index 1550f855d..321196720 100644
--- a/src/modules/systray/e_mod_main.c
+++ b/src/modules/systray/e_mod_main.c
@@ -96,6 +96,7 @@ _cfg_data_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
96 systray_xembed_shutdown(); 96 systray_xembed_shutdown();
97 inst->xembed = NULL; 97 inst->xembed = NULL;
98 } 98 }
99
99 systray_size_updated(inst); 100 systray_size_updated(inst);
100 101
101 ctx->config->use_xembed = cfdata->use_xembed; 102 ctx->config->use_xembed = cfdata->use_xembed;
@@ -514,31 +515,29 @@ systray_edje_get(const Instance *inst)
514 return inst->ui.gadget; 515 return inst->ui.gadget;
515} 516}
516 517
518const Evas_Object *
519systray_box_get(const Instance *inst)
520{
521 EINA_SAFETY_ON_NULL_RETURN_VAL(inst, NULL);
522 return edje_object_part_object_get(inst->ui.gadget, "box");
523}
524
517void 525void
518systray_edje_emit(const Instance *inst, const char *sig) 526systray_edje_box_append(const Instance *inst, Evas_Object *child)
519{ 527{
520 EINA_SAFETY_ON_NULL_RETURN(inst); 528 edje_object_part_box_append(inst->ui.gadget, "box", child);
521 edje_object_signal_emit(inst->ui.gadget, sig, _sig_source);
522} 529}
523 530
524void 531void
525systray_edje_box_append(const Instance *inst, const char *part, 532systray_edje_box_prepend(const Instance *inst, Evas_Object *child)
526 Evas_Object *child)
527{ 533{
528 EINA_SAFETY_ON_NULL_RETURN(inst); 534 edje_object_part_box_prepend(inst->ui.gadget, "box", child);
529 EINA_SAFETY_ON_NULL_RETURN(part);
530 EINA_SAFETY_ON_NULL_RETURN(child);
531 edje_object_part_box_append(inst->ui.gadget, part, child);
532} 535}
533 536
534void 537void
535systray_edje_box_remove(const Instance *inst, const char *part, 538systray_edje_box_remove(const Instance *inst, Evas_Object *child)
536 Evas_Object *child)
537{ 539{
538 EINA_SAFETY_ON_NULL_RETURN(inst); 540 edje_object_part_box_remove(inst->ui.gadget, "box", child);
539 EINA_SAFETY_ON_NULL_RETURN(part);
540 EINA_SAFETY_ON_NULL_RETURN(child);
541 edje_object_part_box_remove(inst->ui.gadget, part, child);
542} 541}
543 542
544int 543int
@@ -560,12 +559,12 @@ _systray_size_apply_do(Instance *inst)
560{ 559{
561 Evas_Coord w, h; 560 Evas_Coord w, h;
562 561
563 if (inst->xembed)
564 systray_xembed_size_updated(inst->xembed);
565
566 edje_object_message_signal_process(inst->ui.gadget); 562 edje_object_message_signal_process(inst->ui.gadget);
567 edje_object_size_min_calc(inst->ui.gadget, &w, &h); 563 edje_object_size_min_calc(inst->ui.gadget, &w, &h);
568 e_gadcon_client_min_size_set(inst->gcc, MAX(w, SYSTRAY_MIN_W), MAX(h, SYSTRAY_MIN_H)); 564 e_gadcon_client_min_size_set(inst->gcc, MAX(w, SYSTRAY_MIN_W), MAX(h, SYSTRAY_MIN_H));
565
566 if (inst->xembed)
567 systray_xembed_size_updated(inst->xembed);
569} 568}
570 569
571static void 570static void
diff --git a/src/modules/systray/e_mod_main.h b/src/modules/systray/e_mod_main.h
index 4055fb9cf..700f5b8f8 100644
--- a/src/modules/systray/e_mod_main.h
+++ b/src/modules/systray/e_mod_main.h
@@ -42,9 +42,10 @@ const char *systray_style_get(const Instance *inst);
42void systray_size_updated(Instance *inst); 42void systray_size_updated(Instance *inst);
43Evas *systray_evas_get(const Instance *inst); 43Evas *systray_evas_get(const Instance *inst);
44Evas_Object *systray_edje_get(const Instance *inst); 44Evas_Object *systray_edje_get(const Instance *inst);
45void systray_edje_emit(const Instance *inst, const char *sig); 45const Evas_Object *systray_box_get(const Instance *inst);
46void systray_edje_box_append(const Instance *inst, const char *part, Evas_Object *child); 46void systray_edje_box_append(const Instance *inst, Evas_Object *child);
47void systray_edje_box_remove(const Instance *inst, const char *part, Evas_Object *child); 47void systray_edje_box_remove(const Instance *inst, Evas_Object *child);
48void systray_edje_box_prepend(const Instance *inst, Evas_Object *child);
48 49
49int systray_manager_number_get(const Instance *inst); 50int systray_manager_number_get(const Instance *inst);
50Ecore_X_Window systray_root_get(const Instance *inst); 51Ecore_X_Window systray_root_get(const Instance *inst);
diff --git a/src/modules/systray/e_mod_notifier_host.c b/src/modules/systray/e_mod_notifier_host.c
index 5331b1985..7141a2738 100644
--- a/src/modules/systray/e_mod_notifier_host.c
+++ b/src/modules/systray/e_mod_notifier_host.c
@@ -14,7 +14,6 @@ const char *Status_Names[] = {
14 "unknown", "Active", "Passive", "NeedsAttention", NULL 14 "unknown", "Active", "Passive", "NeedsAttention", NULL
15}; 15};
16 16
17static const char *box_part_name = "e.dbus_notifier.box";
18static Context_Notifier_Host *ctx = NULL; 17static Context_Notifier_Host *ctx = NULL;
19 18
20void 19void
@@ -247,8 +246,7 @@ jump_search:
247 image_load(item->icon_name, item->icon_path, ii->icon); 246 image_load(item->icon_name, item->icon_path, ii->icon);
248 if (!evas_object_visible_get(ii->icon)) 247 if (!evas_object_visible_get(ii->icon))
249 { 248 {
250 systray_edje_box_append(host_inst->inst, box_part_name, 249 systray_edje_box_append(host_inst->inst, ii->icon);
251 ii->icon);
252 evas_object_show(ii->icon); 250 evas_object_show(ii->icon);
253 } 251 }
254 break; 252 break;
@@ -257,8 +255,7 @@ jump_search:
257 { 255 {
258 if (evas_object_visible_get(ii->icon)) 256 if (evas_object_visible_get(ii->icon))
259 { 257 {
260 systray_edje_box_remove(host_inst->inst, box_part_name, 258 systray_edje_box_remove(host_inst->inst, ii->icon);
261 ii->icon);
262 evas_object_hide(ii->icon); 259 evas_object_hide(ii->icon);
263 } 260 }
264 break; 261 break;
@@ -268,8 +265,7 @@ jump_search:
268 image_load(item->attention_icon_name, item->icon_path, ii->icon); 265 image_load(item->attention_icon_name, item->icon_path, ii->icon);
269 if (!evas_object_visible_get(ii->icon)) 266 if (!evas_object_visible_get(ii->icon))
270 { 267 {
271 systray_edje_box_append(host_inst->inst, box_part_name, 268 systray_edje_box_append(host_inst->inst, ii->icon);
272 ii->icon);
273 evas_object_show(ii->icon); 269 evas_object_show(ii->icon);
274 } 270 }
275 break; 271 break;
diff --git a/src/modules/systray/e_mod_xembed.c b/src/modules/systray/e_mod_xembed.c
index ff7a20c24..c50692972 100644
--- a/src/modules/systray/e_mod_xembed.c
+++ b/src/modules/systray/e_mod_xembed.c
@@ -44,7 +44,7 @@ typedef struct _Icon Icon;
44struct _Icon 44struct _Icon
45{ 45{
46 Ecore_X_Window win; 46 Ecore_X_Window win;
47 Evas_Object *o; 47 Evas_Object *rect;
48 Instance_Xembed *xembed; 48 Instance_Xembed *xembed;
49}; 49};
50 50
@@ -83,39 +83,39 @@ static Ecore_X_Atom _atom_xembed_info = 0;
83static Ecore_X_Atom _atom_st_num = 0; 83static Ecore_X_Atom _atom_st_num = 0;
84static int _last_st_num = -1; 84static int _last_st_num = -1;
85 85
86/* TODO: remove me later: */ 86static void
87static const char _part_box[] = "e.xembed.box"; 87_xembed_win_resize(Instance_Xembed *xembed)
88static const char _part_size[] = "e.xembed.size";
89static const char _sig_enable[] = "e,action,xembed,enable";
90static const char _sig_disable[] = "e,action,xembed,disable";
91/* END TODO: remove me later */
92
93void
94systray_xembed_size_updated(Instance_Xembed *xembed)
95{ 88{
96 const Evas_Object *o; 89 Evas_Coord first_x, first_y, first_w, first_h, last_x, last_y;
97 Evas_Object *ui = systray_edje_get(xembed->inst); 90 Icon *icon;
98 Evas_Coord x, y, w, h, mw = 1, mh = 1;
99 91
100 /* this hack is required so we resize the base xwindow */ 92 if (!xembed->icons)
93 return;
101 94
102 edje_object_message_signal_process(ui); 95 icon = eina_list_data_get(xembed->icons);
103 o = edje_object_part_object_get(ui, _part_box); 96 evas_object_geometry_get(icon->rect, &first_x,
104 if (!o) return; 97 &first_y, &first_w, &first_h);
105 evas_object_size_hint_min_get(o, &w, &h);
106 98
107 if (w < 1) w = 1; 99 icon = eina_list_last_data_get(xembed->icons);
108 if (h < 1) h = 1; 100 evas_object_geometry_get(icon->rect, &last_x,
101 &last_y, NULL, NULL);
109 102
110 if (eina_list_count(xembed->icons) == 0) 103 //because we always prepend xembed icons
111 ecore_x_window_hide(xembed->win.base); 104 ecore_x_window_move_resize(xembed->win.base, last_x, last_y,
112 else 105 (first_x+first_w) - last_x,
113 ecore_x_window_show(xembed->win.base); 106 (first_y+first_h) - last_y);
114 edje_object_size_min_calc(systray_edje_get(xembed->inst), &mw, &mh); 107}
115 e_gadcon_client_min_size_set(systray_gadcon_client_get(xembed->inst), mw, mh);
116 108
117 evas_object_geometry_get(o, &x, &y, &w, &h); 109void
118 ecore_x_window_move_resize(xembed->win.base, x, y, w, h); 110systray_xembed_size_updated(Instance_Xembed *xembed)
111{
112 if (eina_list_count(xembed->icons) == 0)
113 {
114 ecore_x_window_hide(xembed->win.base);
115 return;
116 }
117 ecore_x_window_show(xembed->win.base);
118 _xembed_win_resize(xembed);
119} 119}
120 120
121static void 121static void
@@ -135,15 +135,15 @@ _systray_xembed_cb_resize(void *data, Evas *evas __UNUSED__, Evas_Object *o __UN
135static void 135static void
136_systray_xembed_icon_geometry_apply(Icon *icon) 136_systray_xembed_icon_geometry_apply(Icon *icon)
137{ 137{
138 const Evas_Object *o, *ui = systray_edje_get(icon->xembed->inst); 138 const Evas_Object *box;
139 Evas_Coord x, y, w, h, wx, wy; 139 Evas_Coord x, y, w, h, wx, wy;
140 140
141 /* hack required so we reposition x window inside parent */ 141 /* hack required so we reposition x window inside parent */
142 o = edje_object_part_object_get(ui, _part_size); 142 box = systray_box_get(icon->xembed->inst);
143 if (!o) return; 143 if (!box) return;
144 144
145 evas_object_geometry_get(icon->o, &x, &y, &w, &h); 145 evas_object_geometry_get(icon->rect, &x, &y, &w, &h);
146 evas_object_geometry_get(o, &wx, &wy, NULL, NULL); 146 evas_object_geometry_get(box, &wx, &wy, NULL, NULL);
147 ecore_x_window_move_resize(icon->win, x - wx, y - wy, w, h); 147 ecore_x_window_move_resize(icon->win, x - wx, y - wy, w, h);
148} 148}
149 149
@@ -220,17 +220,10 @@ static Icon *
220_systray_xembed_icon_add(Instance_Xembed *xembed, const Ecore_X_Window win) 220_systray_xembed_icon_add(Instance_Xembed *xembed, const Ecore_X_Window win)
221{ 221{
222 Ecore_X_Gravity gravity; 222 Ecore_X_Gravity gravity;
223 Evas_Object *o; 223 Evas_Object *rect;
224 Evas_Coord w, h, sz = 48; 224 Evas_Coord w, h, sz = 48;
225 Icon *icon; 225 Icon *icon;
226 226
227 edje_object_part_geometry_get(systray_edje_get(xembed->inst), _part_size,
228 NULL, NULL, &w, &h);
229 if (w > h)
230 w = h;
231 else
232 h = w;
233
234 /* assuming systray must be on a shelf here */ 227 /* assuming systray must be on a shelf here */
235 switch (systray_gadcon_get(xembed->inst)->orient) 228 switch (systray_gadcon_get(xembed->inst)->orient)
236 { 229 {
@@ -252,32 +245,31 @@ _systray_xembed_icon_add(Instance_Xembed *xembed, const Ecore_X_Window win)
252 case E_GADCON_ORIENT_CORNER_LB: 245 case E_GADCON_ORIENT_CORNER_LB:
253 case E_GADCON_ORIENT_CORNER_RB: 246 case E_GADCON_ORIENT_CORNER_RB:
254 sz = systray_gadcon_get(xembed->inst)->shelf->w; 247 sz = systray_gadcon_get(xembed->inst)->shelf->w;
248 break;
249
255 default: 250 default:
256 break; 251 break;
257 } 252 }
258 if ((w < 16) && (sz > 16))
259 w = h = sz - 5;
260 253
261 w = h = e_util_icon_size_normalize(w); 254 sz = sz - 5;
262 if (w > sz - 5) 255 w = h = e_util_icon_size_normalize(sz);
263 w = h = e_util_icon_size_normalize(sz - 5);
264 256
265 o = evas_object_rectangle_add(systray_evas_get(xembed->inst)); 257 rect = evas_object_rectangle_add(systray_evas_get(xembed->inst));
266 if (!o) 258 if (!rect)
267 return NULL; 259 return NULL;
268 evas_object_color_set(o, 0, 0, 0, 0); 260 evas_object_color_set(rect, 0, 0, 0, 0);
269 evas_object_resize(o, w, h); 261 evas_object_resize(rect, w, h);
270 evas_object_show(o); 262 evas_object_show(rect);
271 263
272 icon = malloc(sizeof(*icon)); 264 icon = malloc(sizeof(Icon));
273 if (!icon) 265 if (!icon)
274 { 266 {
275 evas_object_del(o); 267 evas_object_del(rect);
276 return NULL; 268 return NULL;
277 } 269 }
278 icon->win = win; 270 icon->win = win;
279 icon->xembed = xembed; 271 icon->xembed = xembed;
280 icon->o = o; 272 icon->rect = rect;
281 273
282 gravity = _systray_xembed_gravity(xembed); 274 gravity = _systray_xembed_gravity(xembed);
283 ecore_x_icccm_size_pos_hints_set(win, 1, gravity, 275 ecore_x_icccm_size_pos_hints_set(win, 1, gravity,
@@ -290,15 +282,13 @@ _systray_xembed_icon_add(Instance_Xembed *xembed, const Ecore_X_Window win)
290 ecore_x_window_save_set_add(win); 282 ecore_x_window_save_set_add(win);
291 ecore_x_window_shape_events_select(win, 1); 283 ecore_x_window_shape_events_select(win, 1);
292 284
293 //ecore_x_window_geometry_get(win, NULL, NULL, &w, &h);
294
295 evas_object_event_callback_add 285 evas_object_event_callback_add
296 (o, EVAS_CALLBACK_MOVE, _systray_xembed_icon_cb_move, icon); 286 (rect, EVAS_CALLBACK_MOVE, _systray_xembed_icon_cb_move, icon);
297 evas_object_event_callback_add 287 evas_object_event_callback_add
298 (o, EVAS_CALLBACK_RESIZE, _systray_xembed_icon_cb_resize, icon); 288 (rect, EVAS_CALLBACK_RESIZE, _systray_xembed_icon_cb_resize, icon);
299 289
300 xembed->icons = eina_list_append(xembed->icons, icon); 290 xembed->icons = eina_list_append(xembed->icons, icon);
301 systray_edje_box_append(xembed->inst, _part_box, o); 291 systray_edje_box_prepend(xembed->inst, rect);
302 systray_size_updated(xembed->inst); 292 systray_size_updated(xembed->inst);
303 _systray_xembed_icon_geometry_apply(icon); 293 _systray_xembed_icon_geometry_apply(icon);
304 294
@@ -314,7 +304,7 @@ _systray_xembed_icon_del_list(Instance_Xembed *xembed, Eina_List *l, Icon *icon)
314 304
315 ecore_x_window_save_set_del(icon->win); 305 ecore_x_window_save_set_del(icon->win);
316 ecore_x_window_reparent(icon->win, 0, 0, 0); 306 ecore_x_window_reparent(icon->win, 0, 0, 0);
317 evas_object_del(icon->o); 307 evas_object_del(icon->rect);
318 free(icon); 308 free(icon);
319 309
320 systray_size_updated(xembed->inst); 310 systray_size_updated(xembed->inst);
@@ -366,8 +356,6 @@ _systray_xembed_deactivate(Instance_Xembed *xembed)
366{ 356{
367 if (xembed->win.selection == 0) return; 357 if (xembed->win.selection == 0) return;
368 358
369 systray_edje_emit(xembed->inst, _sig_disable);
370
371 while (xembed->icons) 359 while (xembed->icons)
372 _systray_xembed_icon_del_list(xembed, xembed->icons, xembed->icons->data); 360 _systray_xembed_icon_del_list(xembed, xembed->icons, xembed->icons->data);
373 361
@@ -381,8 +369,8 @@ _systray_xembed_deactivate(Instance_Xembed *xembed)
381static Eina_Bool 369static Eina_Bool
382_systray_xembed_base_create(Instance_Xembed *xembed) 370_systray_xembed_base_create(Instance_Xembed *xembed)
383{ 371{
384 const Evas_Object *o, *ui = systray_edje_get(xembed->inst); 372 const Evas_Object *box;
385 Evas_Coord x, y, w, h; 373 Evas_Coord x, y;
386 unsigned short r, g, b; 374 unsigned short r, g, b;
387 const char *color; 375 const char *color;
388 Eina_Bool invis = EINA_FALSE; 376 Eina_Bool invis = EINA_FALSE;
@@ -392,7 +380,8 @@ _systray_xembed_base_create(Instance_Xembed *xembed)
392 invis = EINA_TRUE; 380 invis = EINA_TRUE;
393 else 381 else
394 { 382 {
395 color = edje_object_data_get(ui, systray_style_get(xembed->inst)); 383 color = edje_object_data_get(systray_edje_get(xembed->inst),
384 systray_style_get(xembed->inst));
396 385
397 if (color && (sscanf(color, "%hu %hu %hu", &r, &g, &b) == 3)) 386 if (color && (sscanf(color, "%hu %hu %hu", &r, &g, &b) == 3))
398 { 387 {
@@ -404,14 +393,12 @@ _systray_xembed_base_create(Instance_Xembed *xembed)
404 r = g = b = (unsigned short)65535; 393 r = g = b = (unsigned short)65535;
405 } 394 }
406 395
407 o = edje_object_part_object_get(ui, _part_size); 396 box = systray_box_get(xembed->inst);
408 if (!o) 397 if (!box)
409 return EINA_FALSE; 398 return EINA_FALSE;
410 399
411 evas_object_geometry_get(o, &x, &y, &w, &h); 400 evas_object_geometry_get(box, &x, &y, NULL, NULL);
412 if (w < 1) w = 1; 401 xembed->win.base = ecore_x_window_new(0, x, y, 1, 1);
413 if (h < 1) h = 1;
414 xembed->win.base = ecore_x_window_new(0, x, y, w, h);
415 ecore_x_icccm_title_set(xembed->win.base, "noshadow_systray_base"); 402 ecore_x_icccm_title_set(xembed->win.base, "noshadow_systray_base");
416 ecore_x_icccm_name_class_set(xembed->win.base, "systray", "holder"); 403 ecore_x_icccm_name_class_set(xembed->win.base, "systray", "holder");
417 ecore_x_netwm_name_set(xembed->win.base, "noshadow_systray_base"); 404 ecore_x_netwm_name_set(xembed->win.base, "noshadow_systray_base");
@@ -480,8 +467,6 @@ _systray_xembed_activate(Instance_Xembed *xembed)
480 ecore_x_current_time_get(), atom, 467 ecore_x_current_time_get(), atom,
481 xembed->win.selection, 0, 0); 468 xembed->win.selection, 0, 0);
482 469
483 systray_edje_emit(xembed->inst, _sig_enable);
484
485 return 1; 470 return 1;
486} 471}
487 472
@@ -529,8 +514,6 @@ _systray_xembed_activate_retry_first(void *data)
529 return ECORE_CALLBACK_CANCEL; 514 return ECORE_CALLBACK_CANCEL;
530 } 515 }
531 516
532 systray_edje_emit(xembed->inst, _sig_disable);
533
534 fprintf(stderr, "SYSTRAY: activate failure! retrying in %0.1f seconds\n", 517 fprintf(stderr, "SYSTRAY: activate failure! retrying in %0.1f seconds\n",
535 RETRY_TIMEOUT); 518 RETRY_TIMEOUT);
536 519
@@ -737,8 +720,6 @@ _systray_xembed_cb_selection_clear(void *data, int type __UNUSED__, void *event)
737 (ev->atom == _systray_xembed_atom_st_get(manager)) && 720 (ev->atom == _systray_xembed_atom_st_get(manager)) &&
738 (ecore_x_selection_owner_get(ev->atom) != xembed->win.selection)) 721 (ecore_x_selection_owner_get(ev->atom) != xembed->win.selection))
739 { 722 {
740 systray_edje_emit(xembed->inst, _sig_disable);
741
742 while (xembed->icons) 723 while (xembed->icons)
743 _systray_xembed_icon_del_list(xembed, xembed->icons, 724 _systray_xembed_icon_del_list(xembed, xembed->icons,
744 xembed->icons->data); 725 xembed->icons->data);
@@ -850,8 +831,6 @@ systray_xembed_new(Instance *inst)
850 if (!xembed->timer.retry) 831 if (!xembed->timer.retry)
851 xembed->timer.retry = ecore_timer_add 832 xembed->timer.retry = ecore_timer_add
852 (0.1, _systray_xembed_activate_retry_first, xembed); 833 (0.1, _systray_xembed_activate_retry_first, xembed);
853 else
854 systray_edje_emit(xembed->inst, _sig_disable);
855 } 834 }
856 835
857 evas_object_event_callback_add(ui, EVAS_CALLBACK_MOVE, 836 evas_object_event_callback_add(ui, EVAS_CALLBACK_MOVE,