summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-10-20 00:02:05 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-10-20 00:05:02 -0200
commit37839e70cf011dce98568a1e350eb5c32acb5369 (patch)
treedc5b80e4f665482f9b9d2e7ff675deac1b2570a1
parente9dfef704816b7efde2eba04dbfc82e8f0497548 (diff)
Hide help window when other shortcuts are pressed
Otherwise many unexpected issues could happen, like open multiple help popups, opening the rulers box with "@" as string, killing eruler instead of just closing the windows when "ESC" is pressed. The reason the help popup is not imeadiatelly deleted is because if done so, the keydown callback is called twice. Honestly I didn't understand the reason, but it's easy to be avoided with an idler.
-rw-r--r--src/bin/main.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index eeff1d8..2aa7fcc 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -30,6 +30,8 @@ struct _Zone {
30 Evas_Object *guide_v; 30 Evas_Object *guide_v;
31 Evas_Object *display_pos; 31 Evas_Object *display_pos;
32 Evas_Object *cmdbox; 32 Evas_Object *cmdbox;
33 Evas_Object *help_popup;
34 Ecore_Idler *del_help_popup_idler;
33 struct { 35 struct {
34 Evas_Object *frame; 36 Evas_Object *frame;
35 Evas_Object *main_box; 37 Evas_Object *main_box;
@@ -1435,8 +1437,9 @@ zone_zoom_pre_setup(Zone *zone)
1435static void 1437static void
1436_popup_dismiss_cb(void *data, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED) 1438_popup_dismiss_cb(void *data, Evas_Object *o EINA_UNUSED, void *event EINA_UNUSED)
1437{ 1439{
1438 Evas_Object *popup = data; 1440 Zone *zone = data;
1439 evas_object_del(popup); 1441 evas_object_del(zone->help_popup);
1442 zone->help_popup = NULL;
1440} 1443}
1441 1444
1442static void 1445static void
@@ -1491,10 +1494,11 @@ show_gui_help(Zone *zone)
1491 1494
1492 bt = elm_button_add(popup); 1495 bt = elm_button_add(popup);
1493 elm_object_text_set(bt, "Close"); 1496 elm_object_text_set(bt, "Close");
1494 evas_object_smart_callback_add(bt, "clicked", _popup_dismiss_cb, popup); 1497 evas_object_smart_callback_add(bt, "clicked", _popup_dismiss_cb, zone);
1495 elm_object_part_content_set(popup, "button1", bt); 1498 elm_object_part_content_set(popup, "button1", bt);
1496 1499
1497 evas_object_show(popup); 1500 evas_object_show(popup);
1501 zone->help_popup = popup;
1498 elm_object_focus_set(bt, EINA_TRUE); 1502 elm_object_focus_set(bt, EINA_TRUE);
1499} 1503}
1500 1504
@@ -2090,6 +2094,18 @@ _toggle_visibility_cb(void *data EINA_UNUSED, const char *keyname EINA_UNUSED)
2090 platform_funcs->windows_visibility_set(visible); 2094 platform_funcs->windows_visibility_set(visible);
2091} 2095}
2092 2096
2097static Eina_Bool
2098_del_help_popup(void *data)
2099{
2100 Zone *zone = data;
2101
2102 evas_object_del(zone->help_popup);
2103 zone->help_popup = NULL;
2104 zone->del_help_popup_idler = NULL;
2105
2106 return ECORE_CALLBACK_CANCEL;
2107}
2108
2093static void 2109static void
2094_zone_win_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info) 2110_zone_win_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
2095{ 2111{
@@ -2101,6 +2117,14 @@ _zone_win_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSE
2101 2117
2102 if (zone->screenshot.ee) return; 2118 if (zone->screenshot.ee) return;
2103 2119
2120 if (zone->del_help_popup_idler) return;
2121
2122 if (zone->help_popup)
2123 {
2124 zone->del_help_popup_idler = ecore_idler_add(_del_help_popup, zone);
2125 return;
2126 }
2127
2104 if (strcmp(keyname, "Escape") == 0) 2128 if (strcmp(keyname, "Escape") == 0)
2105 { 2129 {
2106 DBG("User requested exit!"); 2130 DBG("User requested exit!");
@@ -2315,6 +2339,8 @@ zone_del(Zone *zone)
2315{ 2339{
2316 if (zone->tracker) 2340 if (zone->tracker)
2317 ecore_animator_del(zone->tracker); 2341 ecore_animator_del(zone->tracker);
2342 if (zone->del_help_popup_idler)
2343 ecore_idler_del(zone->del_help_popup_idler);
2318 2344
2319 /* all objects are deleted when canvas goes away. 2345 /* all objects are deleted when canvas goes away.
2320 * when ruler and distance objects are deleted, they remove themselves from 2346 * when ruler and distance objects are deleted, they remove themselves from