ecore-x: reject successive MappingNotify events if they are identical
authorMike Blumenkrantz <zmike@osg.samsung.com>
Fri, 22 Sep 2017 13:54:37 +0000 (09:54 -0400)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Fri, 22 Sep 2017 14:10:07 +0000 (10:10 -0400)
in some cases loading an xmodmap on enlightenment startup can trigger an infinite
number of identical events which hard locks the xserver for a very, very long time

@fix

src/lib/ecore_x/ecore_x_events.c
src/lib/efl_wl/efl_wl.c

index acd0d67..11d0988 100644 (file)
@@ -2047,34 +2047,40 @@ void
 _ecore_x_event_handle_mapping_notify(XEvent *xevent)
 {
    Ecore_X_Event_Mapping_Change *e;
+   static unsigned long last_serial;
+   int type;
 
    _ecore_x_last_event_mouse_move = 0;
 
-   _ecore_x_window_grab_suspend();
-   _ecore_x_key_grab_suspend();
-
-   XRefreshKeyboardMapping((XMappingEvent *)xevent);
-   _ecore_x_modifiers_get();
-
-   _ecore_x_window_grab_resume();
-   _ecore_x_key_grab_resume();
-   e = calloc(1, sizeof(Ecore_X_Event_Mapping_Change));
-   if (!e) return;
    switch (xevent->xmapping.request)
      {
       case MappingModifier:
-        e->type = ECORE_X_MAPPING_MODIFIER;
+        type = ECORE_X_MAPPING_MODIFIER;
         break;
 
       case MappingKeyboard:
-        e->type = ECORE_X_MAPPING_KEYBOARD;
+        if ((last_serial && (xevent->xmapping.serial == last_serial))) return;
+        type = ECORE_X_MAPPING_KEYBOARD;
+        last_serial = xevent->xmapping.serial;
         break;
 
       case MappingPointer:
       default:
-        e->type = ECORE_X_MAPPING_MOUSE;
+        type = ECORE_X_MAPPING_MOUSE;
         break;
      }
+
+   _ecore_x_window_grab_suspend();
+   _ecore_x_key_grab_suspend();
+
+   XRefreshKeyboardMapping((XMappingEvent *)xevent);
+   _ecore_x_modifiers_get();
+
+   _ecore_x_window_grab_resume();
+   _ecore_x_key_grab_resume();
+   e = calloc(1, sizeof(Ecore_X_Event_Mapping_Change));
+   if (!e) return;
+   e->type = type;
    e->keycode = xevent->xmapping.first_keycode;
    e->num = xevent->xmapping.count;
    ecore_event_add(ECORE_X_EVENT_MAPPING_CHANGE, e, NULL, NULL);
index 5c31714..8a1a7c2 100644 (file)
@@ -5355,7 +5355,7 @@ efl_wl_run(Evas_Object *obj, const char *cmd)
         if (gl) gl = strdup(gl);
         setenv("ELM_ACCEL", "gl", 1);
      }
-   exe = ecore_exe_run(cmd, c);
+   exe = ecore_exe_pipe_run(cmd, ECORE_EXE_TERM_WITH_PARENT, c);
    if (disp) setenv("DISPLAY", disp, 1);
    if (env) setenv("WAYLAND_DISPLAY", env, 1);
    else unsetenv("WAYLAND_DISPLAY");