summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2016-05-05 10:22:04 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-05-05 15:47:55 -0400
commitef1772b8cb992b115411f01e1915fca015eea158 (patch)
tree1d8163853448ed5de75e9745ea733bdaef31082d
parente0d1a572a10303a6313c5efa3915df7489706caa (diff)
implement wl client session recovery
another small feature patch brought to you by insomnia #SamsungFeatures
-rw-r--r--src/bin/Makefile.mk6
-rw-r--r--src/bin/e.h1
-rw-r--r--src/bin/e_client.c9
-rw-r--r--src/bin/e_client.h4
-rw-r--r--src/bin/e_comp_wl.c16
-rw-r--r--src/bin/e_comp_wl_extensions.c65
-rw-r--r--src/bin/e_config.c2
-rw-r--r--src/bin/e_includes.h1
-rw-r--r--src/bin/e_main.c13
-rw-r--r--src/bin/e_remember.c580
-rw-r--r--src/bin/e_remember.h5
-rw-r--r--src/bin/e_uuid_store.c210
-rw-r--r--src/bin/e_uuid_store.h36
-rw-r--r--src/bin/generated/session-recovery-server-protocol.h43
-rw-r--r--src/bin/generated/session-recovery.c (renamed from src/bin/generated/session-recovery-protocol.c)15
-rw-r--r--src/bin/generated/session-recovery.h62
-rw-r--r--src/protocol/session-recovery.xml13
17 files changed, 462 insertions, 619 deletions
diff --git a/src/bin/Makefile.mk b/src/bin/Makefile.mk
index c7d04fc1e..c6930d32b 100644
--- a/src/bin/Makefile.mk
+++ b/src/bin/Makefile.mk
@@ -221,7 +221,6 @@ src/bin/e_zone.h
221 221
222if HAVE_WAYLAND 222if HAVE_WAYLAND
223ENLIGHTENMENTHEADERS += \ 223ENLIGHTENMENTHEADERS += \
224src/bin/e_uuid_store.h \
225src/bin/e_comp_wl_data.h \ 224src/bin/e_comp_wl_data.h \
226src/bin/e_comp_wl_input.h \ 225src/bin/e_comp_wl_input.h \
227src/bin/e_comp_wl.h 226src/bin/e_comp_wl.h
@@ -394,11 +393,10 @@ endif
394 393
395if HAVE_WAYLAND 394if HAVE_WAYLAND
396enlightenment_src += \ 395enlightenment_src += \
397src/bin/e_uuid_store.c \
398src/bin/generated/www-protocol.c \ 396src/bin/generated/www-protocol.c \
399src/bin/generated/www-protocol.h \ 397src/bin/generated/www-protocol.h \
400src/bin/generated/session-recovery-protocol.c \ 398src/bin/generated/session-recovery.c \
401src/bin/generated/session-recovery-server-protocol.h \ 399src/bin/generated/session-recovery.h \
402src/bin/generated/e_comp_wl_screenshooter_server.c \ 400src/bin/generated/e_comp_wl_screenshooter_server.c \
403src/bin/generated/e_comp_wl_screenshooter_server.h \ 401src/bin/generated/e_comp_wl_screenshooter_server.h \
404src/bin/e_comp_wl_data.c \ 402src/bin/e_comp_wl_data.c \
diff --git a/src/bin/e.h b/src/bin/e.h
index 2c2d2037e..b7390afdc 100644
--- a/src/bin/e.h
+++ b/src/bin/e.h
@@ -133,7 +133,6 @@ void *alloca (size_t);
133 133
134# ifdef HAVE_WAYLAND 134# ifdef HAVE_WAYLAND
135# include <Ecore_Wl2.h> 135# include <Ecore_Wl2.h>
136# include <uuid.h>
137# endif 136# endif
138 137
139# ifdef E_API 138# ifdef E_API
diff --git a/src/bin/e_client.c b/src/bin/e_client.c
index be4f52307..d3a00a3e6 100644
--- a/src/bin/e_client.c
+++ b/src/bin/e_client.c
@@ -554,6 +554,7 @@ _e_client_free(E_Client *ec)
554 eina_stringshare_replace(&ec->netwm.icon_name, NULL); 554 eina_stringshare_replace(&ec->netwm.icon_name, NULL);
555 eina_stringshare_replace(&ec->internal_icon, NULL); 555 eina_stringshare_replace(&ec->internal_icon, NULL);
556 eina_stringshare_replace(&ec->internal_icon_key, NULL); 556 eina_stringshare_replace(&ec->internal_icon_key, NULL);
557 eina_stringshare_replace(&ec->uuid, NULL);
557 558
558 focus_stack = eina_list_remove(focus_stack, ec); 559 focus_stack = eina_list_remove(focus_stack, ec);
559 raise_stack = eina_list_remove(raise_stack, ec); 560 raise_stack = eina_list_remove(raise_stack, ec);
@@ -570,10 +571,6 @@ _e_client_free(E_Client *ec)
570 evas_object_del(ec->frame); 571 evas_object_del(ec->frame);
571 E_OBJECT(ec)->references--; 572 E_OBJECT(ec)->references--;
572 573
573#ifdef HAVE_WAYLAND
574 e_uuid_store_entry_del(ec->uuid);
575#endif
576
577 free(ec); 574 free(ec);
578} 575}
579 576
@@ -2346,10 +2343,6 @@ e_client_new(E_Pixmap *cp, int first_map, int internal)
2346 if (!ec) return NULL; 2343 if (!ec) return NULL;
2347 e_object_del_func_set(E_OBJECT(ec), E_OBJECT_CLEANUP_FUNC(_e_client_del)); 2344 e_object_del_func_set(E_OBJECT(ec), E_OBJECT_CLEANUP_FUNC(_e_client_del));
2348 2345
2349#ifdef HAVE_WAYLAND
2350 uuid_generate(ec->uuid);
2351#endif
2352
2353 ec->focus_policy_override = E_FOCUS_LAST; 2346 ec->focus_policy_override = E_FOCUS_LAST;
2354 ec->w = 1; 2347 ec->w = 1;
2355 ec->h = 1; 2348 ec->h = 1;
diff --git a/src/bin/e_client.h b/src/bin/e_client.h
index e2d83fccb..1508e2714 100644
--- a/src/bin/e_client.h
+++ b/src/bin/e_client.h
@@ -686,9 +686,7 @@ struct E_Client
686 686
687 E_Focus_Policy focus_policy_override; 687 E_Focus_Policy focus_policy_override;
688 688
689#ifdef HAVE_WAYLAND 689 Eina_Stringshare *uuid;
690 uuid_t uuid;
691#endif
692 690
693 Eina_Bool override : 1; 691 Eina_Bool override : 1;
694 Eina_Bool input_only : 1; 692 Eina_Bool input_only : 1;
diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index ec571313f..105bad623 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -1603,15 +1603,13 @@ _e_comp_wl_compositor_cb_surface_create(struct wl_client *client, struct wl_reso
1603 1603
1604 ec = e_client_new(ep, 0, 0); 1604 ec = e_client_new(ep, 0, 0);
1605 } 1605 }
1606 if (ec) 1606 if (ec->new_client)
1607 { 1607 e_comp->new_clients--;
1608 if (ec->new_client) 1608 ec->new_client = 0;
1609 e_comp->new_clients--; 1609 if ((!ec->client.w) && (ec->client.h))
1610 ec->new_client = 0; 1610 ec->client.w = ec->client.h = 1;
1611 if ((!ec->client.w) && (ec->client.h)) 1611 ec->comp_data->surface = res;
1612 ec->client.w = ec->client.h = 1; 1612 ec->netwm.pid = pid;
1613 ec->comp_data->surface = res;
1614 }
1615 1613
1616 /* set reference to pixmap so we can fetch it later */ 1614 /* set reference to pixmap so we can fetch it later */
1617 DBG("\tUsing Client: %p", ec); 1615 DBG("\tUsing Client: %p", ec);
diff --git a/src/bin/e_comp_wl_extensions.c b/src/bin/e_comp_wl_extensions.c
index dd15f10d3..4849682f7 100644
--- a/src/bin/e_comp_wl_extensions.c
+++ b/src/bin/e_comp_wl_extensions.c
@@ -1,8 +1,10 @@
1#define E_COMP_WL 1#define E_COMP_WL
2#include "e.h" 2#include "e.h"
3 3
4
5#include <uuid.h>
4#include "e_comp_wl_screenshooter_server.h" 6#include "e_comp_wl_screenshooter_server.h"
5#include "session-recovery-server-protocol.h" 7#include "session-recovery.h"
6#include "www-protocol.h" 8#include "www-protocol.h"
7 9
8static void 10static void
@@ -24,9 +26,62 @@ _e_comp_wl_extensions_client_move_end(void *d EINA_UNUSED, E_Client *ec)
24} 26}
25 27
26static void 28static void
27_e_comp_wl_sr_cb_provide_uuid(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, const char *uuid) 29_e_comp_wl_session_recovery_get_uuid(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *surface)
28{ 30{
29 DBG("Provide UUID callback called for UUID: %s", uuid); 31 E_Client *ec;
32 uuid_t u;
33 char uuid[37];
34
35 ec = wl_resource_get_user_data(surface);
36 if (e_object_is_del(E_OBJECT(ec))) return;
37 if (ec->internal || ec->uuid) return;
38 uuid_generate(u);
39 uuid_unparse_lower(u, uuid);
40 eina_stringshare_replace(&ec->uuid, uuid);
41 zwp_e_session_recovery_send_create_uuid(resource, surface, uuid);
42 if (ec->remember)
43 e_remember_unuse(ec->remember);
44 ec->remember = e_remember_new();
45 e_remember_use(ec->remember);
46 ec->remember->apply = E_REMEMBER_APPLY_POS | E_REMEMBER_APPLY_DESKTOP |
47 E_REMEMBER_APPLY_LAYER | E_REMEMBER_APPLY_ZONE | E_REMEMBER_APPLY_UUID;
48 e_remember_update(ec);
49}
50
51static void
52_e_comp_wl_session_recovery_set_uuid(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, struct wl_resource *surface, const char *uuid)
53{
54 E_Client *ec;
55 E_Remember *rem;
56
57 ec = wl_resource_get_user_data(surface);
58 if (e_object_is_del(E_OBJECT(ec))) return;
59 if (ec->internal || ec->uuid) return; //FIXME: error
60 eina_stringshare_replace(&ec->uuid, uuid);
61 rem = e_remember_find_usable(ec);
62 if ((!rem) || (rem == ec->remember)) return;
63 if (ec->remember)
64 e_remember_unuse(ec->remember);
65 ec->remember = rem;
66 e_remember_use(rem);
67 e_remember_apply(rem, ec);
68 ec->re_manage = 1;
69}
70
71static void
72_e_comp_wl_session_recovery_destroy_uuid(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, struct wl_resource *surface, const char *uuid)
73{
74 E_Client *ec;
75
76 ec = wl_resource_get_user_data(surface);
77 if (!eina_streq(ec->uuid, uuid)) return; //FIXME: error
78 eina_stringshare_replace(&ec->uuid, NULL);
79 e_remember_unuse(ec->remember);
80 e_remember_del(ec->remember);
81 ec->remember = e_remember_find_usable(ec);
82 if (!ec->remember) return;
83 e_remember_use(ec->remember);
84 e_remember_apply(ec->remember, ec);
30} 85}
31 86
32static void 87static void
@@ -145,7 +200,9 @@ _e_comp_wl_www_cb_create(struct wl_client *client, struct wl_resource *resource,
145 200
146static const struct zwp_e_session_recovery_interface _e_session_recovery_interface = 201static const struct zwp_e_session_recovery_interface _e_session_recovery_interface =
147{ 202{
148 _e_comp_wl_sr_cb_provide_uuid, 203 _e_comp_wl_session_recovery_get_uuid,
204 _e_comp_wl_session_recovery_set_uuid,
205 _e_comp_wl_session_recovery_destroy_uuid,
149}; 206};
150 207
151static const struct screenshooter_interface _e_screenshooter_interface = 208static const struct screenshooter_interface _e_screenshooter_interface =
diff --git a/src/bin/e_config.c b/src/bin/e_config.c
index 3ca945653..cb999fc41 100644
--- a/src/bin/e_config.c
+++ b/src/bin/e_config.c
@@ -384,6 +384,8 @@ _e_config_edd_init(Eina_Bool old)
384 E_CONFIG_VAL(D, T, prop.desktop_file, STR); 384 E_CONFIG_VAL(D, T, prop.desktop_file, STR);
385 E_CONFIG_VAL(D, T, prop.offer_resistance, UCHAR); 385 E_CONFIG_VAL(D, T, prop.offer_resistance, UCHAR);
386 E_CONFIG_VAL(D, T, prop.opacity, UCHAR); 386 E_CONFIG_VAL(D, T, prop.opacity, UCHAR);
387 E_CONFIG_VAL(D, T, uuid, STR);
388 E_CONFIG_VAL(D, T, pid, INT);
387 389
388 _e_config_color_class_edd = E_CONFIG_DD_NEW("E_Color_Class", E_Color_Class); 390 _e_config_color_class_edd = E_CONFIG_DD_NEW("E_Color_Class", E_Color_Class);
389#undef T 391#undef T
diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h
index 63133df11..cfc6f530c 100644
--- a/src/bin/e_includes.h
+++ b/src/bin/e_includes.h
@@ -157,5 +157,4 @@
157# include "e_comp_wl.h" 157# include "e_comp_wl.h"
158# include "e_comp_wl_data.h" 158# include "e_comp_wl_data.h"
159# include "e_comp_wl_input.h" 159# include "e_comp_wl_input.h"
160# include "e_uuid_store.h"
161#endif 160#endif
diff --git a/src/bin/e_main.c b/src/bin/e_main.c
index 04ddbb2a4..ef68ab509 100644
--- a/src/bin/e_main.c
+++ b/src/bin/e_main.c
@@ -536,19 +536,6 @@ main(int argc, char **argv)
536 _e_main_shutdown_push(e_alert_shutdown); 536 _e_main_shutdown_push(e_alert_shutdown);
537#endif 537#endif
538 538
539#if 0
540//#ifdef HAVE_WAYLAND
541 /* init uuid store for window/surface properties */
542 TS("E_UUID_Store Init");
543 if (!e_uuid_store_init())
544 {
545 e_error_message_show(_("Enlightenment cannot initialize its UUID store.\n"));
546 _e_main_shutdown(-1);
547 }
548 TS("E_UUID_Store Init Done");
549 _e_main_shutdown_push(e_uuid_store_shutdown);
550#endif
551
552 TS("E Directories Init"); 539 TS("E Directories Init");
553 /* setup directories we will be using for configurations storage etc. */ 540 /* setup directories we will be using for configurations storage etc. */
554 if (!_e_main_dirs_init()) 541 if (!_e_main_dirs_init())
diff --git a/src/bin/e_remember.c b/src/bin/e_remember.c
index 62147f473..e0fec5161 100644
--- a/src/bin/e_remember.c
+++ b/src/bin/e_remember.c
@@ -268,6 +268,289 @@ e_remember_del(E_Remember *rem)
268 _e_remember_free(rem); 268 _e_remember_free(rem);
269} 269}
270 270
271E_API void
272e_remember_apply(E_Remember *rem, E_Client *ec)
273{
274 int temporary = 0;
275 if (ec->internal && remembers && ec->icccm.class && ec->icccm.class[0])
276 {
277 Eina_List *l;
278 EINA_LIST_FOREACH(remembers->list, l, rem)
279 {
280 if (rem->class && !strcmp(rem->class, ec->icccm.class))
281 break;
282 }
283 if (rem)
284 {
285 temporary = 1;
286 remembers->list = eina_list_remove(remembers->list, rem);
287 remember_idler_list = eina_list_remove(remember_idler_list, rem);
288 if (!remembers->list)
289 e_config_domain_save("e_remember_restart",
290 e_remember_list_edd, remembers);
291 }
292 else rem = ec->remember;
293 }
294
295 if (!rem)
296 return;
297
298 if (rem->apply & E_REMEMBER_APPLY_ZONE)
299 {
300 E_Zone *zone;
301
302 zone = e_comp_zone_number_get(rem->prop.zone);
303 if (zone)
304 e_client_zone_set(ec, zone);
305 }
306 if (rem->apply & E_REMEMBER_APPLY_DESKTOP)
307 {
308 E_Desk *desk;
309
310 desk = e_desk_at_xy_get(ec->zone, rem->prop.desk_x, rem->prop.desk_y);
311 if (desk)
312 {
313 if (ec->desk != desk)
314 ec->hidden = 0;
315 e_client_desk_set(ec, desk);
316 if (e_config->desk_auto_switch)
317 e_desk_show(desk);
318 }
319 }
320 if (rem->apply & E_REMEMBER_APPLY_SIZE)
321 {
322 int w, h;
323
324 w = ec->client.w;
325 h = ec->client.h;
326 if (rem->prop.pos_w)
327 ec->client.w = rem->prop.pos_w;
328 if (rem->prop.pos_h)
329 ec->client.h = rem->prop.pos_h;
330 /* we can trust internal windows */
331 if (ec->internal)
332 {
333 if (ec->zone->w != rem->prop.res_x)
334 {
335 if (ec->client.w > (ec->zone->w - 64))
336 ec->client.w = ec->zone->w - 64;
337 }
338 if (ec->zone->h != rem->prop.res_y)
339 {
340 if (ec->client.h > (ec->zone->h - 64))
341 ec->client.h = ec->zone->h - 64;
342 }
343 if (ec->icccm.min_w > ec->client.w)
344 ec->client.w = ec->icccm.min_w;
345 if ((ec->icccm.max_w > 0) && (ec->icccm.max_w < ec->client.w))
346 ec->client.w = ec->icccm.max_w;
347 if (ec->icccm.min_h > ec->client.h)
348 ec->client.h = ec->icccm.min_h;
349 if ((ec->icccm.max_h > 0) && (ec->icccm.max_h < ec->client.h))
350 ec->client.h = ec->icccm.max_h;
351 }
352 e_comp_object_frame_wh_adjust(ec->frame, ec->client.w, ec->client.h, &ec->w, &ec->h);
353 if (rem->prop.maximize)
354 {
355 ec->saved.x = rem->prop.pos_x;
356 ec->saved.y = rem->prop.pos_y;
357 ec->saved.w = ec->client.w;
358 ec->saved.h = ec->client.h;
359 ec->maximized = rem->prop.maximize | e_config->maximize_policy;
360 }
361 if ((w != ec->client.w) || (h != ec->client.h))
362 {
363 ec->changes.size = 1;
364 ec->changes.shape = 1;
365 EC_CHANGED(ec);
366 }
367 }
368 if ((rem->apply & E_REMEMBER_APPLY_POS) && (!ec->re_manage))
369 {
370 ec->x = rem->prop.pos_x;
371 ec->y = rem->prop.pos_y;
372 if (ec->zone->w != rem->prop.res_x)
373 {
374 int px;
375
376 px = ec->x + (ec->w / 2);
377 if (px < ((rem->prop.res_x * 1) / 3))
378 {
379 if (ec->zone->w >= (rem->prop.res_x / 3))
380 ec->x = rem->prop.pos_x;
381 else
382 ec->x = ((rem->prop.pos_x - 0) * ec->zone->w) /
383 (rem->prop.res_x / 3);
384 }
385 else if (px < ((rem->prop.res_x * 2) / 3))
386 {
387 if (ec->zone->w >= (rem->prop.res_x / 3))
388 ec->x = (ec->zone->w / 2) +
389 (px - (rem->prop.res_x / 2)) -
390 (ec->w / 2);
391 else
392 ec->x = (ec->zone->w / 2) +
393 (((px - (rem->prop.res_x / 2)) * ec->zone->w) /
394 (rem->prop.res_x / 3)) -
395 (ec->w / 2);
396 }
397 else
398 {
399 if (ec->zone->w >= (rem->prop.res_x / 3))
400 ec->x = ec->zone->w +
401 rem->prop.pos_x - rem->prop.res_x +
402 (rem->prop.w - ec->client.w);
403 else
404 ec->x = ec->zone->w +
405 (((rem->prop.pos_x - rem->prop.res_x) * ec->zone->w) /
406 (rem->prop.res_x / 3)) +
407 (rem->prop.w - ec->client.w);
408 }
409 if ((rem->prop.pos_x >= 0) && (ec->x < 0))
410 ec->x = 0;
411 else if (((rem->prop.pos_x + rem->prop.w) < rem->prop.res_x) &&
412 ((ec->x + ec->w) > ec->zone->w))
413 ec->x = ec->zone->w - ec->w;
414 }
415 if (ec->zone->h != rem->prop.res_y)
416 {
417 int py;
418
419 py = ec->y + (ec->h / 2);
420 if (py < ((rem->prop.res_y * 1) / 3))
421 {
422 if (ec->zone->h >= (rem->prop.res_y / 3))
423 ec->y = rem->prop.pos_y;
424 else
425 ec->y = ((rem->prop.pos_y - 0) * ec->zone->h) /
426 (rem->prop.res_y / 3);
427 }
428 else if (py < ((rem->prop.res_y * 2) / 3))
429 {
430 if (ec->zone->h >= (rem->prop.res_y / 3))
431 ec->y = (ec->zone->h / 2) +
432 (py - (rem->prop.res_y / 2)) -
433 (ec->h / 2);
434 else
435 ec->y = (ec->zone->h / 2) +
436 (((py - (rem->prop.res_y / 2)) * ec->zone->h) /
437 (rem->prop.res_y / 3)) -
438 (ec->h / 2);
439 }
440 else
441 {
442 if (ec->zone->h >= (rem->prop.res_y / 3))
443 ec->y = ec->zone->h +
444 rem->prop.pos_y - rem->prop.res_y +
445 (rem->prop.h - ec->client.h);
446 else
447 ec->y = ec->zone->h +
448 (((rem->prop.pos_y - rem->prop.res_y) * ec->zone->h) /
449 (rem->prop.res_y / 3)) +
450 (rem->prop.h - ec->client.h);
451 }
452 if ((rem->prop.pos_y >= 0) && (ec->y < 0))
453 ec->y = 0;
454 else if (((rem->prop.pos_y + rem->prop.h) < rem->prop.res_y) &&
455 ((ec->y + ec->h) > ec->zone->h))
456 ec->y = ec->zone->h - ec->h;
457 }
458 // if (ec->zone->w != rem->prop.res_x)
459 // ec->x = (rem->prop.pos_x * ec->zone->w) / rem->prop.res_x;
460 // if (ec->zone->h != rem->prop.res_y)
461 // ec->y = (rem->prop.pos_y * ec->zone->h) / rem->prop.res_y;
462 if (
463 /* upper left */
464 (!E_INSIDE(ec->x, ec->y, 0, 0, ec->zone->w, ec->zone->h)) &&
465 /* upper right */
466 (!E_INSIDE(ec->x + ec->w, ec->y, 0, 0, ec->zone->w, ec->zone->h)) &&
467 /* lower left */
468 (!E_INSIDE(ec->x, ec->y + ec->h, 0, 0, ec->zone->w, ec->zone->h)) &&
469 /* lower right */
470 (!E_INSIDE(ec->x + ec->w, ec->y + ec->h, 0, 0, ec->zone->w, ec->zone->h))
471 )
472 {
473 e_comp_object_util_center_pos_get(ec->frame, &ec->x, &ec->y);
474 rem->prop.pos_x = ec->x, rem->prop.pos_y = ec->y;
475 }
476 ec->x += ec->zone->x;
477 ec->y += ec->zone->y;
478 ec->placed = 1;
479 ec->changes.pos = 1;
480 EC_CHANGED(ec);
481 }
482 if (rem->apply & E_REMEMBER_APPLY_LAYER)
483 {
484 evas_object_layer_set(ec->frame, rem->prop.layer);
485 }
486 if (rem->apply & E_REMEMBER_APPLY_BORDER)
487 {
488 eina_stringshare_replace(&ec->bordername, NULL);
489 ec->bordername = eina_stringshare_ref(rem->prop.border);
490 ec->border.changed = 1;
491 EC_CHANGED(ec);
492 }
493 if (rem->apply & E_REMEMBER_APPLY_FULLSCREEN)
494 {
495 if (rem->prop.fullscreen)
496 e_client_fullscreen(ec, e_config->fullscreen_policy);
497 }
498 if (rem->apply & E_REMEMBER_APPLY_STICKY)
499 {
500 if (rem->prop.sticky) e_client_stick(ec);
501 }
502 if (rem->apply & E_REMEMBER_APPLY_SHADE)
503 {
504 if (rem->prop.shaded >= 100)
505 e_client_shade(ec, rem->prop.shaded - 100);
506 else if (rem->prop.shaded >= 50)
507 e_client_unshade(ec, rem->prop.shaded - 50);
508 }
509 if (rem->apply & E_REMEMBER_APPLY_LOCKS)
510 {
511 ec->lock_user_location = rem->prop.lock_user_location;
512 ec->lock_client_location = rem->prop.lock_client_location;
513 ec->lock_user_size = rem->prop.lock_user_size;
514 ec->lock_client_size = rem->prop.lock_client_size;
515 ec->lock_user_stacking = rem->prop.lock_user_stacking;
516 ec->lock_client_stacking = rem->prop.lock_client_stacking;
517 ec->lock_user_iconify = rem->prop.lock_user_iconify;
518 ec->lock_client_iconify = rem->prop.lock_client_iconify;
519 ec->lock_user_desk = rem->prop.lock_user_desk;
520 ec->lock_client_desk = rem->prop.lock_client_desk;
521 ec->lock_user_sticky = rem->prop.lock_user_sticky;
522 ec->lock_client_sticky = rem->prop.lock_client_sticky;
523 ec->lock_user_shade = rem->prop.lock_user_shade;
524 ec->lock_client_shade = rem->prop.lock_client_shade;
525 ec->lock_user_maximize = rem->prop.lock_user_maximize;
526 ec->lock_client_maximize = rem->prop.lock_client_maximize;
527 ec->lock_user_fullscreen = rem->prop.lock_user_fullscreen;
528 ec->lock_client_fullscreen = rem->prop.lock_client_fullscreen;
529 ec->lock_border = rem->prop.lock_border;
530 ec->lock_close = rem->prop.lock_close;
531 ec->lock_focus_in = rem->prop.lock_focus_in;
532 ec->lock_focus_out = rem->prop.lock_focus_out;
533 ec->lock_life = rem->prop.lock_life;
534 }
535 if (rem->apply & E_REMEMBER_APPLY_SKIP_WINLIST)
536 ec->user_skip_winlist = rem->prop.skip_winlist;
537 if (rem->apply & E_REMEMBER_APPLY_SKIP_PAGER)
538 ec->netwm.state.skip_pager = rem->prop.skip_pager;
539 if (rem->apply & E_REMEMBER_APPLY_SKIP_TASKBAR)
540 ec->netwm.state.skip_taskbar = rem->prop.skip_taskbar;
541 if (rem->apply & E_REMEMBER_APPLY_ICON_PREF)
542 ec->icon_preference = rem->prop.icon_preference;
543 if (rem->apply & E_REMEMBER_APPLY_OFFER_RESISTANCE)
544 ec->offer_resistance = rem->prop.offer_resistance;
545 if (rem->apply & E_REMEMBER_SET_FOCUS_ON_START)
546 ec->want_focus = 1;
547 if (rem->apply & E_REMEMBER_APPLY_OPACITY)
548 ec->netwm.opacity = rem->prop.opacity;
549
550 if (temporary)
551 _e_remember_free(rem);
552}
553
271E_API E_Remember * 554E_API E_Remember *
272e_remember_find_usable(E_Client *ec) 555e_remember_find_usable(E_Client *ec)
273{ 556{
@@ -376,10 +659,6 @@ e_remember_default_match_set(E_Remember *rem, E_Client *ec)
376E_API void 659E_API void
377e_remember_update(E_Client *ec) 660e_remember_update(E_Client *ec)
378{ 661{
379#ifdef HAVE_WAYLAND
380 /* Use this as e_remeber_update is called in all the right places already */
381 e_uuid_store_entry_update(ec->uuid, ec);
382#endif
383 if (ec->new_client) return; 662 if (ec->new_client) return;
384 if (!ec->remember) return; 663 if (!ec->remember) return;
385 if (ec->remember->keep_settings) return; 664 if (ec->remember->keep_settings) return;
@@ -491,6 +770,12 @@ _e_remember_update(E_Client *ec, E_Remember *rem)
491 else 770 else
492 eina_stringshare_replace(&rem->prop.border, ec->bordername); 771 eina_stringshare_replace(&rem->prop.border, ec->bordername);
493 } 772 }
773 if (rem->apply & E_REMEMBER_APPLY_UUID)
774 {
775 eina_stringshare_refplace(&rem->uuid, ec->uuid);
776 rem->pid = ec->netwm.pid;
777 rem->apply_first_only = 1;
778 }
494 rem->no_reopen = ec->internal_no_reopen; 779 rem->no_reopen = ec->internal_no_reopen;
495 { 780 {
496 E_Event_Remember_Update *ev; 781 E_Event_Remember_Update *ev;
@@ -571,6 +856,13 @@ _e_remember_find(E_Client *ec, int check_usable)
571 if ((check_usable) && (!e_remember_usable_get(rem))) 856 if ((check_usable) && (!e_remember_usable_get(rem)))
572 continue; 857 continue;
573 858
859 if (!eina_streq(rem->uuid, ec->uuid)) continue;
860 if (rem->uuid)
861 {
862 if (rem->pid != ec->netwm.pid) continue;
863 return rem;
864 }
865
574 if (ec->netwm.name) title = ec->netwm.name; 866 if (ec->netwm.name) title = ec->netwm.name;
575 else title = ec->icccm.title; 867 else title = ec->icccm.title;
576 868
@@ -616,6 +908,7 @@ _e_remember_free(E_Remember *rem)
616 if (rem->prop.border) eina_stringshare_del(rem->prop.border); 908 if (rem->prop.border) eina_stringshare_del(rem->prop.border);
617 if (rem->prop.command) eina_stringshare_del(rem->prop.command); 909 if (rem->prop.command) eina_stringshare_del(rem->prop.command);
618 if (rem->prop.desktop_file) eina_stringshare_del(rem->prop.desktop_file); 910 if (rem->prop.desktop_file) eina_stringshare_del(rem->prop.desktop_file);
911 eina_stringshare_del(rem->uuid);
619 free(rem); 912 free(rem);
620} 913}
621 914
@@ -659,7 +952,6 @@ static void
659_e_remember_cb_hook_pre_post_fetch(void *data EINA_UNUSED, E_Client *ec) 952_e_remember_cb_hook_pre_post_fetch(void *data EINA_UNUSED, E_Client *ec)
660{ 953{
661 E_Remember *rem = NULL; 954 E_Remember *rem = NULL;
662 int temporary = 0;
663 955
664 if ((!ec->new_client) || ec->internal_no_remember || e_client_util_ignored_get(ec)) return; 956 if ((!ec->new_client) || ec->internal_no_remember || e_client_util_ignored_get(ec)) return;
665 957
@@ -673,283 +965,7 @@ _e_remember_cb_hook_pre_post_fetch(void *data EINA_UNUSED, E_Client *ec)
673 } 965 }
674 } 966 }
675 967
676 if (ec->internal && remembers && ec->icccm.class && ec->icccm.class[0]) 968 e_remember_apply(rem, ec);
677 {
678 Eina_List *l;
679 EINA_LIST_FOREACH(remembers->list, l, rem)
680 {
681 if (rem->class && !strcmp(rem->class, ec->icccm.class))
682 break;
683 }
684 if (rem)
685 {
686 temporary = 1;
687 remembers->list = eina_list_remove(remembers->list, rem);
688 remember_idler_list = eina_list_remove(remember_idler_list, rem);
689 if (!remembers->list)
690 e_config_domain_save("e_remember_restart",
691 e_remember_list_edd, remembers);
692 }
693 else rem = ec->remember;
694 }
695
696 if (!rem)
697 return;
698
699 if (rem->apply & E_REMEMBER_APPLY_ZONE)
700 {
701 E_Zone *zone;
702
703 zone = e_comp_zone_number_get(rem->prop.zone);
704 if (zone)
705 e_client_zone_set(ec, zone);
706 }
707 if (rem->apply & E_REMEMBER_APPLY_DESKTOP)
708 {
709 E_Desk *desk;
710
711 desk = e_desk_at_xy_get(ec->zone, rem->prop.desk_x, rem->prop.desk_y);
712 if (desk)
713 {
714 if (ec->desk != desk)
715 ec->hidden = 0;
716 e_client_desk_set(ec, desk);
717 if (e_config->desk_auto_switch)
718 e_desk_show(desk);
719 }
720 }
721 if (rem->apply & E_REMEMBER_APPLY_SIZE)
722 {
723 int w, h;
724
725 w = ec->client.w;
726 h = ec->client.h;
727 if (rem->prop.pos_w)
728 ec->client.w = rem->prop.pos_w;
729 if (rem->prop.pos_h)
730 ec->client.h = rem->prop.pos_h;
731 /* we can trust internal windows */
732 if (ec->internal)
733 {
734 if (ec->zone->w != rem->prop.res_x)
735 {
736 if (ec->client.w > (ec->zone->w - 64))
737 ec->client.w = ec->zone->w - 64;
738 }
739 if (ec->zone->h != rem->prop.res_y)
740 {
741 if (ec->client.h > (ec->zone->h - 64))
742 ec->client.h = ec->zone->h - 64;
743 }
744 if (ec->icccm.min_w > ec->client.w)
745 ec->client.w = ec->icccm.min_w;
746 if ((ec->icccm.max_w > 0) && (ec->icccm.max_w < ec->client.w))
747 ec->client.w = ec->icccm.max_w;
748 if (ec->icccm.min_h > ec->client.h)
749 ec->client.h = ec->icccm.min_h;
750 if ((ec->icccm.max_h > 0) && (ec->icccm.max_h < ec->client.h))
751 ec->client.h = ec->icccm.max_h;
752 }
753 e_comp_object_frame_wh_adjust(ec->frame, ec->client.w, ec->client.h, &ec->w, &ec->h);
754 if (rem->prop.maximize)
755 {
756 ec->saved.x = rem->prop.pos_x;
757 ec->saved.y = rem->prop.pos_y;
758 ec->saved.w = ec->client.w;
759 ec->saved.h = ec->client.h;
760 ec->maximized = rem->prop.maximize | e_config->maximize_policy;
761 }
762 if ((w != ec->client.w) || (h != ec->client.h))
763 {
764 ec->changes.size = 1;
765 ec->changes.shape = 1;
766 EC_CHANGED(ec);
767 }
768 }
769 if ((rem->apply & E_REMEMBER_APPLY_POS) && (!ec->re_manage))
770 {
771 ec->x = rem->prop.pos_x;
772 ec->y = rem->prop.pos_y;
773 if (ec->zone->w != rem->prop.res_x)
774 {
775 int px;
776
777 px = ec->x + (ec->w / 2);
778 if (px < ((rem->prop.res_x * 1) / 3))
779 {
780 if (ec->zone->w >= (rem->prop.res_x / 3))
781 ec->x = rem->prop.pos_x;
782 else
783 ec->x = ((rem->prop.pos_x - 0) * ec->zone->w) /
784 (rem->prop.res_x / 3);
785 }
786 else if (px < ((rem->prop.res_x * 2) / 3))
787 {
788 if (ec->zone->w >= (rem->prop.res_x / 3))
789 ec->x = (ec->zone->w / 2) +
790 (px - (rem->prop.res_x / 2)) -
791 (ec->w / 2);
792 else
793 ec->x = (ec->zone->w / 2) +
794 (((px - (rem->prop.res_x / 2)) * ec->zone->w) /
795 (rem->prop.res_x / 3)) -
796 (ec->w / 2);
797 }
798 else
799 {
800 if (ec->zone->w >= (rem->prop.res_x / 3))
801 ec->x = ec->zone->w +
802 rem->prop.pos_x - rem->prop.res_x +
803 (rem->prop.w - ec->client.w);
804 else
805 ec->x = ec->zone->w +
806 (((rem->prop.pos_x - rem->prop.res_x) * ec->zone->w) /
807 (rem->prop.res_x / 3)) +
808 (rem->prop.w - ec->client.w);
809 }
810 if ((rem->prop.pos_x >= 0) && (ec->x < 0))
811 ec->x = 0;
812 else if (((rem->prop.pos_x + rem->prop.w) < rem->prop.res_x) &&
813 ((ec->x + ec->w) > ec->zone->w))
814 ec->x = ec->zone->w - ec->w;
815 }
816 if (ec->zone->h != rem->prop.res_y)
817 {
818 int py;
819
820 py = ec->y + (ec->h / 2);
821 if (py < ((rem->prop.res_y * 1) / 3))
822 {
823 if (ec->zone->h >= (rem->prop.res_y / 3))
824 ec->y = rem->prop.pos_y;
825 else
826 ec->y = ((rem->prop.pos_y - 0) * ec->zone->h) /
827 (rem->prop.res_y / 3);
828 }
829 else if (py < ((rem->prop.res_y * 2) / 3))
830 {
831 if (ec->zone->h >= (rem->prop.res_y / 3))
832 ec->y = (ec->zone->h / 2) +
833 (py - (rem->prop.res_y / 2)) -
834 (ec->h / 2);
835 else
836 ec->y = (ec->zone->h / 2) +
837 (((py - (rem->prop.res_y / 2)) * ec->zone->h) /
838 (rem->prop.res_y / 3)) -
839 (ec->h / 2);
840 }
841 else
842 {
843 if (ec->zone->h >= (rem->prop.res_y / 3))
844 ec->y = ec->zone->h +
845 rem->prop.pos_y - rem->prop.res_y +
846 (rem->prop.h - ec->client.h);
847 else
848 ec->y = ec->zone->h +
849 (((rem->prop.pos_y - rem->prop.res_y) * ec->zone->h) /
850 (rem->prop.res_y / 3)) +
851 (rem->prop.h - ec->client.h);
852 }
853 if ((rem->prop.pos_y >= 0) && (ec->y < 0))
854 ec->y = 0;
855 else if (((rem->prop.pos_y + rem->prop.h) < rem->prop.res_y) &&
856 ((ec->y + ec->h) > ec->zone->h))
857 ec->y = ec->zone->h - ec->h;
858 }
859 // if (ec->zone->w != rem->prop.res_x)
860 // ec->x = (rem->prop.pos_x * ec->zone->w) / rem->prop.res_x;
861 // if (ec->zone->h != rem->prop.res_y)
862 // ec->y = (rem->prop.pos_y * ec->zone->h) / rem->prop.res_y;
863 if (
864 /* upper left */
865 (!E_INSIDE(ec->x, ec->y, 0, 0, ec->zone->w, ec->zone->h)) &&
866 /* upper right */
867 (!E_INSIDE(ec->x + ec->w, ec->y, 0, 0, ec->zone->w, ec->zone->h)) &&
868 /* lower left */
869 (!E_INSIDE(ec->x, ec->y + ec->h, 0, 0, ec->zone->w, ec->zone->h)) &&
870 /* lower right */
871 (!E_INSIDE(ec->x + ec->w, ec->y + ec->h, 0, 0, ec->zone->w, ec->zone->h))
872 )
873 {
874 e_comp_object_util_center_pos_get(ec->frame, &ec->x, &ec->y);
875 rem->prop.pos_x = ec->x, rem->prop.pos_y = ec->y;
876 }
877 ec->x += ec->zone->x;
878 ec->y += ec->zone->y;
879 ec->placed = 1;
880 ec->changes.pos = 1;
881 EC_CHANGED(ec);
882 }
883 if (rem->apply & E_REMEMBER_APPLY_LAYER)
884 {
885 evas_object_layer_set(ec->frame, rem->prop.layer);
886 }
887 if (rem->apply & E_REMEMBER_APPLY_BORDER)
888 {
889 eina_stringshare_replace(&ec->bordername, NULL);
890 ec->bordername = eina_stringshare_ref(rem->prop.border);
891 ec->border.changed = 1;
892 EC_CHANGED(ec);
893 }
894 if (rem->apply & E_REMEMBER_APPLY_FULLSCREEN)
895 {
896 if (rem->prop.fullscreen)
897 e_client_fullscreen(ec, e_config->fullscreen_policy);
898 }
899 if (rem->apply & E_REMEMBER_APPLY_STICKY)
900 {
901 if (rem->prop.sticky) e_client_stick(ec);
902 }
903 if (rem->apply & E_REMEMBER_APPLY_SHADE)
904 {
905 if (rem->prop.shaded >= 100)
906 e_client_shade(ec, rem->prop.shaded - 100);
907 else if (rem->prop.shaded >= 50)
908 e_client_unshade(ec, rem->prop.shaded - 50);
909 }
910 if (rem->apply & E_REMEMBER_APPLY_LOCKS)
911 {
912 ec->lock_user_location = rem->prop.lock_user_location;
913 ec->lock_client_location = rem->prop.lock_client_location;
914 ec->lock_user_size = rem->prop.lock_user_size;
915 ec->lock_client_size = rem->prop.lock_client_size;
916 ec->lock_user_stacking = rem->prop.lock_user_stacking;
917 ec->lock_client_stacking = rem->prop.lock_client_stacking;
918 ec->lock_user_iconify = rem->prop.lock_user_iconify;
919 ec->lock_client_iconify = rem->prop.lock_client_iconify;
920 ec->lock_user_desk = rem->prop.lock_user_desk;
921 ec->lock_client_desk = rem->prop.lock_client_desk;
922 ec->lock_user_sticky = rem->prop.lock_user_sticky;
923 ec->lock_client_sticky = rem->prop.lock_client_sticky;
924 ec->lock_user_shade = rem->prop.lock_user_shade;
925 ec->lock_client_shade = rem->prop.lock_client_shade;
926 ec->lock_user_maximize = rem->prop.lock_user_maximize;
927 ec->lock_client_maximize = rem->prop.lock_client_maximize;
928 ec->lock_user_fullscreen = rem->prop.lock_user_fullscreen;
929 ec->lock_client_fullscreen = rem->prop.lock_client_fullscreen;
930 ec->lock_border = rem->prop.lock_border;
931 ec->lock_close = rem->prop.lock_close;
932 ec->lock_focus_in = rem->prop.lock_focus_in;
933 ec->lock_focus_out = rem->prop.lock_focus_out;
934 ec->lock_life = rem->prop.lock_life;
935 }
936 if (rem->apply & E_REMEMBER_APPLY_SKIP_WINLIST)
937 ec->user_skip_winlist = rem->prop.skip_winlist;
938 if (rem->apply & E_REMEMBER_APPLY_SKIP_PAGER)
939 ec->netwm.state.skip_pager = rem->prop.skip_pager;
940 if (rem->apply & E_REMEMBER_APPLY_SKIP_TASKBAR)
941 ec->netwm.state.skip_taskbar = rem->prop.skip_taskbar;
942 if (rem->apply & E_REMEMBER_APPLY_ICON_PREF)
943 ec->icon_preference = rem->prop.icon_preference;
944 if (rem->apply & E_REMEMBER_APPLY_OFFER_RESISTANCE)
945 ec->offer_resistance = rem->prop.offer_resistance;
946 if (rem->apply & E_REMEMBER_SET_FOCUS_ON_START)
947 ec->want_focus = 1;
948 if (rem->apply & E_REMEMBER_APPLY_OPACITY)
949 ec->netwm.opacity = rem->prop.opacity;
950
951 if (temporary)
952 _e_remember_free(rem);
953} 969}
954 970
955static void 971static void
diff --git a/src/bin/e_remember.h b/src/bin/e_remember.h
index 1182cd8e9..5f0bae490 100644
--- a/src/bin/e_remember.h
+++ b/src/bin/e_remember.h
@@ -35,6 +35,7 @@ typedef struct _E_Remember E_Remember;
35#define E_REMEMBER_APPLY_FULLSCREEN (1 << 15) 35#define E_REMEMBER_APPLY_FULLSCREEN (1 << 15)
36#define E_REMEMBER_APPLY_OFFER_RESISTANCE (1 << 16) 36#define E_REMEMBER_APPLY_OFFER_RESISTANCE (1 << 16)
37#define E_REMEMBER_APPLY_OPACITY (1 << 17) 37#define E_REMEMBER_APPLY_OPACITY (1 << 17)
38#define E_REMEMBER_APPLY_UUID (1 << 18)
38 39
39#define E_REMEMBER_INTERNAL_DIALOGS (1 << 0) 40#define E_REMEMBER_INTERNAL_DIALOGS (1 << 0)
40#define E_REMEMBER_INTERNAL_FM_WINS (1 << 1) 41#define E_REMEMBER_INTERNAL_FM_WINS (1 << 1)
@@ -109,6 +110,8 @@ struct _E_Remember
109 const char *desktop_file; 110 const char *desktop_file;
110 unsigned char opacity; 111 unsigned char opacity;
111 } prop; 112 } prop;
113 Eina_Stringshare *uuid;
114 int pid;
112}; 115};
113 116
114EINTERN int e_remember_init(E_Startup_Mode mode); 117EINTERN int e_remember_init(E_Startup_Mode mode);
@@ -124,5 +127,7 @@ E_API void e_remember_match_update(E_Remember *rem);
124E_API void e_remember_update(E_Client *ec); 127E_API void e_remember_update(E_Client *ec);
125E_API int e_remember_default_match_set(E_Remember *rem, E_Client *ec); 128E_API int e_remember_default_match_set(E_Remember *rem, E_Client *ec);
126E_API void e_remember_internal_save(void); 129E_API void e_remember_internal_save(void);
130
131E_API void e_remember_apply(E_Remember *rem, E_Client *ec);
127#endif 132#endif
128#endif 133#endif
diff --git a/src/bin/e_uuid_store.c b/src/bin/e_uuid_store.c
deleted file mode 100644
index d083c3ad0..000000000
--- a/src/bin/e_uuid_store.c
+++ /dev/null
@@ -1,210 +0,0 @@
1/* vim:ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0
2 */
3
4/* 1. Create mmaped memory blob, name the memory object
5 * 2. Fill in table and keep it up-to-date
6 * 3. (optional) Write the whole blob into a file on disk for later use)
7 */
8
9#include <e.h>
10#include <sys/mman.h>
11
12/* Use anonymous mapping if we don't want a persistent file on the disk */
13#define OBJECT_NAME "/e_uuid_store"
14#define TABLE_SIZE 10*eina_cpu_page_size()
15
16struct uuid_store *store;
17
18void
19e_uuid_dump(void)
20 {
21 struct uuid_table *table;
22 int i;
23 char uuid_string[37];
24
25 if (store == NULL) return;
26
27 table = store->table;
28 if (table == NULL) return;
29
30 INF("Dump UUID table:");
31 for (i = 0; i < UUID_STORE_TABLE_SIZE -1; i++)
32 {
33 if (uuid_is_null(table->entries[i].uuid)) continue;
34 uuid_unparse(table->entries[i].uuid, uuid_string);
35 INF("UUID %s, x=%i, y=%i, width=%i, heigth=%i", uuid_string, table->entries[i].x,
36 table->entries[i].y, table->entries[i].width,
37 table->entries[i].heigth);
38 }
39 }
40
41/**
42 * Initialize the UUID store
43 *
44 * @returns 1 if init was successful, 0 on failure
45 */
46EINTERN int
47e_uuid_store_init(void)
48 {
49 /* FIXME think about refcounting here */
50 eina_init();
51
52 store = calloc(1, sizeof(struct uuid_store));
53 if (store == NULL) return 0;
54
55 /* Try to open existing SHM object */
56 store->shmfd = shm_open(OBJECT_NAME, O_RDWR, S_IRWXU | S_IRWXG);
57 if (store->shmfd < 0 && errno == ENOENT)
58 {
59 INF("shm_open failed to open an existing file %s", OBJECT_NAME);
60 if (!e_uuid_store_reload()) return 0;
61 }
62 else if (store->shmfd < 0)
63 {
64 INF("shm_open failed");
65 return 0;
66 }
67
68 /* Adjust in memory blob to our given table size */
69 /* FIXME: How can we make sure we have the right size for our given table? */
70 if (ftruncate(store->shmfd, TABLE_SIZE) < 0)
71 {
72 ERR("ftruncate failed: %s", strerror(errno));
73 return 0;
74 }
75
76 store->table = (struct uuid_table *)mmap(NULL, TABLE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, store->shmfd, 0);
77 if (store->table == NULL)
78 {
79 ERR("mmap failed");
80 return 0;
81 }
82
83 INF("mmaped blob with size %i created", TABLE_SIZE);
84
85 if (store->table->version)
86 INF("UUID table with version %i", store->table->version);
87 else
88 store->table->version = 1;
89
90 INF("UUID table with %i entries", store->table->entry_count);
91
92 return 1;
93 }
94
95EINTERN int
96e_uuid_store_shutdown(void)
97 {
98 /* Cleanup for shutdown */
99 if (shm_unlink(OBJECT_NAME) != 0)
100 {
101 ERR("shm_unlink failed");
102 return 0;
103 }
104
105 close(store->shmfd);
106 free(store);
107 eina_shutdown();
108 return 1;
109 }
110
111Eina_Bool
112e_uuid_store_reload(void)
113 {
114 /* After crash reload the table with its POSIX object name from memory */
115 store->shmfd = shm_open(OBJECT_NAME, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG);
116 if (store->shmfd < 0)
117 {
118 INF("shm_open failed");
119 return EINA_FALSE;
120 }
121 return EINA_TRUE;
122 }
123
124Eina_Bool
125e_uuid_store_entry_del(uuid_t uuid)
126 {
127 struct uuid_table *table;
128 int i;
129 char uuid_string[37];
130
131 if (store == NULL) return EINA_FALSE;
132
133 table = store->table;
134 if (table == NULL) return EINA_FALSE;
135
136 /* Search through uuid list and delete if found */
137 for (i = 0; i < UUID_STORE_TABLE_SIZE -1; i++)
138 {
139 if (!uuid_compare(table->entries[i].uuid, uuid))
140 {
141 uuid_clear(table->entries[i].uuid);
142 table->entries[i].x = 0;
143 table->entries[i].x = 0;
144 table->entries[i].width = 0;
145 table->entries[i].heigth = 0;
146 table->entry_count--;
147 uuid_unparse(uuid, uuid_string);
148 DBG("Removed entry with UUID %s", uuid_string);
149 return EINA_TRUE;
150 }
151 }
152 uuid_unparse(uuid, uuid_string);
153 DBG("NOT removed entry with UUID %s. Entry not found.", uuid_string);
154 return EINA_FALSE;
155 }
156
157/* FIXME: Think about having _add and _update functions instead only update */
158
159Eina_Bool
160e_uuid_store_entry_update(uuid_t uuid, E_Client *ec)
161 {
162 struct uuid_table *table;
163 int i, index = -1;
164 char uuid_string[37];
165
166 if (store == NULL) return EINA_FALSE;
167
168 table = store->table;
169 if (table == NULL) return EINA_FALSE;
170
171 /* Search through uuid list if it already exist if yes update */
172 for (i = 0; i < UUID_STORE_TABLE_SIZE -1; i++)
173 {
174 if (!uuid_compare(table->entries[i].uuid, uuid))
175 {
176 table->entries[i].x = ec->x;
177 table->entries[i].y = ec->y;
178 table->entries[i].width = ec->client.w;
179 table->entries[i].heigth = ec->client.h;
180 uuid_unparse(uuid, uuid_string);
181 DBG("Updated entry with UUID %s", uuid_string);
182 return EINA_TRUE;
183 }
184 }
185
186 /* Find first empty entry */
187 for (i = 0; i < UUID_STORE_TABLE_SIZE -1; i++)
188 {
189 if (uuid_is_null(table->entries[i].uuid))
190 index = i;
191 }
192
193 if (index == -1)
194 {
195 ERR("UUID table full");
196 return EINA_FALSE;
197 }
198
199 /* We do not have this UUID in the table yet. Create it */
200 table->entries[index].x = ec->x;
201 table->entries[index].y = ec->y;
202 table->entries[index].width = ec->client.w;
203 table->entries[index].heigth = ec->client.h;
204 uuid_copy(table->entries[index].uuid, uuid);
205 table->entry_count++;
206 uuid_unparse(table->entries[index].uuid, uuid_string);
207 DBG("Created entry with UUID %s", uuid_string);
208
209 return EINA_TRUE;
210 }
diff --git a/src/bin/e_uuid_store.h b/src/bin/e_uuid_store.h
deleted file mode 100644
index 855c57d91..000000000
--- a/src/bin/e_uuid_store.h
+++ /dev/null
@@ -1,36 +0,0 @@
1#ifndef E_UUID_STORE_H
2#define E_UUID_STORE_H
3
4/* vim:ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0
5 */
6
7#define UUID_STORE_TABLE_SIZE 100
8
9struct table_entry {
10 uuid_t uuid;
11 /* data structure for per application properties */
12 Evas_Coord x, y;
13 Evas_Coord width, heigth;
14 unsigned int virtual_desktop;
15 int flags;
16};
17
18struct uuid_table {
19 int version; /* Version to allow future extensions */
20 unsigned int entry_count; /* Entry counter to allow excat memory consuptions needs? */
21 /* Global settings like current virtual desktop, screen setup, etc */
22 struct table_entry entries[UUID_STORE_TABLE_SIZE]; /* FIXME make this more adjustable */
23};
24
25struct uuid_store {
26 struct uuid_table *table;
27 int shmfd;
28};
29
30EINTERN int e_uuid_store_init(void);
31EINTERN int e_uuid_store_shutdown(void);
32E_API void e_uuid_dump(void);
33E_API Eina_Bool e_uuid_store_reload(void);
34E_API Eina_Bool e_uuid_store_entry_del(uuid_t uuid);
35E_API Eina_Bool e_uuid_store_entry_update(uuid_t uuid, E_Client *ec);
36#endif
diff --git a/src/bin/generated/session-recovery-server-protocol.h b/src/bin/generated/session-recovery-server-protocol.h
deleted file mode 100644
index c08800212..000000000
--- a/src/bin/generated/session-recovery-server-protocol.h
+++ /dev/null
@@ -1,43 +0,0 @@
1#ifndef E_SESSION_RECOVERY_SERVER_PROTOCOL_H
2#define E_SESSION_RECOVERY_SERVER_PROTOCOL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <stddef.h>
10#include "wayland-server.h"
11
12struct wl_client;
13struct wl_resource;
14
15struct zwp_e_session_recovery;
16
17extern const struct wl_interface zwp_e_session_recovery_interface;
18
19struct zwp_e_session_recovery_interface {
20 /**
21 * provide_uuid - (none)
22 * @uuid: (none)
23 */
24 void (*provide_uuid)(struct wl_client *client,
25 struct wl_resource *resource,
26 const char *uuid);
27};
28
29#define ZWP_E_SESSION_RECOVERY_UUID 0
30
31#define ZWP_E_SESSION_RECOVERY_UUID_SINCE_VERSION 1
32
33static inline void
34zwp_e_session_recovery_send_uuid(struct wl_resource *resource_, const char *uuid)
35{
36 wl_resource_post_event(resource_, ZWP_E_SESSION_RECOVERY_UUID, uuid);
37}
38
39#ifdef __cplusplus
40}
41#endif
42
43#endif
diff --git a/src/bin/generated/session-recovery-protocol.c b/src/bin/generated/session-recovery.c
index 32ddbcbef..47ecbb975 100644
--- a/src/bin/generated/session-recovery-protocol.c
+++ b/src/bin/generated/session-recovery.c
@@ -2,22 +2,31 @@
2#include <stdint.h> 2#include <stdint.h>
3#include "wayland-util.h" 3#include "wayland-util.h"
4 4
5extern const struct wl_interface wl_surface_interface;
5 6
6static const struct wl_interface *types[] = { 7static const struct wl_interface *types[] = {
8 &wl_surface_interface,
9 &wl_surface_interface,
10 NULL,
11 &wl_surface_interface,
12 NULL,
13 &wl_surface_interface,
7 NULL, 14 NULL,
8}; 15};
9 16
10static const struct wl_message zwp_e_session_recovery_requests[] = { 17static const struct wl_message zwp_e_session_recovery_requests[] = {
11 { "provide_uuid", "s", types + 0 }, 18 { "get_uuid", "o", types + 0 },
19 { "set_uuid", "os", types + 1 },
20 { "destroy_uuid", "os", types + 3 },
12}; 21};
13 22
14static const struct wl_message zwp_e_session_recovery_events[] = { 23static const struct wl_message zwp_e_session_recovery_events[] = {
15 { "uuid", "s", types + 0 }, 24 { "create_uuid", "os", types + 5 },
16}; 25};
17 26
18WL_EXPORT const struct wl_interface zwp_e_session_recovery_interface = { 27WL_EXPORT const struct wl_interface zwp_e_session_recovery_interface = {
19 "zwp_e_session_recovery", 1, 28 "zwp_e_session_recovery", 1,
20 1, zwp_e_session_recovery_requests, 29 3, zwp_e_session_recovery_requests,
21 1, zwp_e_session_recovery_events, 30 1, zwp_e_session_recovery_events,
22}; 31};
23 32
diff --git a/src/bin/generated/session-recovery.h b/src/bin/generated/session-recovery.h
new file mode 100644
index 000000000..674c77a6f
--- /dev/null
+++ b/src/bin/generated/session-recovery.h
@@ -0,0 +1,62 @@
1#ifndef E_SESSION_RECOVERY_SERVER_PROTOCOL_H
2#define E_SESSION_RECOVERY_SERVER_PROTOCOL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <stddef.h>
10#include "wayland-server.h"
11
12struct wl_client;
13struct wl_resource;
14
15struct wl_surface;
16struct zwp_e_session_recovery;
17
18extern const struct wl_interface zwp_e_session_recovery_interface;
19
20struct zwp_e_session_recovery_interface {
21 /**
22 * get_uuid - (none)
23 * @surface: (none)
24 */
25 void (*get_uuid)(struct wl_client *client,
26 struct wl_resource *resource,
27 struct wl_resource *surface);
28 /**
29 * set_uuid - (none)
30 * @surface: (none)
31 * @uuid: (none)
32 */
33 void (*set_uuid)(struct wl_client *client,
34 struct wl_resource *resource,
35 struct wl_resource *surface,
36 const char *uuid);
37 /**
38 * destroy_uuid - (none)
39 * @surface: (none)
40 * @uuid: (none)
41 */
42 void (*destroy_uuid)(struct wl_client *client,
43 struct wl_resource *resource,
44 struct wl_resource *surface,
45 const char *uuid);
46};
47
48#define ZWP_E_SESSION_RECOVERY_CREATE_UUID 0
49
50#define ZWP_E_SESSION_RECOVERY_CREATE_UUID_SINCE_VERSION 1
51
52static inline void
53zwp_e_session_recovery_send_create_uuid(struct wl_resource *resource_, struct wl_resource *surface, const char *uuid)
54{
55 wl_resource_post_event(resource_, ZWP_E_SESSION_RECOVERY_CREATE_UUID, surface, uuid);
56}
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
diff --git a/src/protocol/session-recovery.xml b/src/protocol/session-recovery.xml
index 469871e26..3109413bb 100644
--- a/src/protocol/session-recovery.xml
+++ b/src/protocol/session-recovery.xml
@@ -1,10 +1,19 @@
1<protocol name="e_session_recovery"> 1<protocol name="e_session_recovery">
2 2
3 <interface name="zwp_e_session_recovery" version="1"> 3 <interface name="zwp_e_session_recovery" version="1">
4 <request name="provide_uuid"> 4 <request name="get_uuid">
5 <arg name="surface" type="object" interface="wl_surface"/>
6 </request>
7 <request name="set_uuid">
8 <arg name="surface" type="object" interface="wl_surface"/>
9 <arg name="uuid" type="string"/>
10 </request>
11 <request name="destroy_uuid">
12 <arg name="surface" type="object" interface="wl_surface"/>
5 <arg name="uuid" type="string"/> 13 <arg name="uuid" type="string"/>
6 </request> 14 </request>
7 <event name="uuid"> 15 <event name="create_uuid">
16 <arg name="surface" type="object" interface="wl_surface"/>
8 <arg name="uuid" type="string"/> 17 <arg name="uuid" type="string"/>
9 </event> 18 </event>
10 </interface> 19 </interface>