summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry <thierry@substantiel.fr>2019-02-13 11:28:01 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-02-13 11:39:39 -0500
commit56f06d21c19cddb056f6ced6822b275c08ebfc3a (patch)
tree3d83873e8af26882b49377c6e6e4744d1c6faabf
parent87cf5188b466d3fa1e8c8ff7ad6d5039b28e298a (diff)
ecore-x: only modify _ecore_key_grabs when key is toggled
A New entry is added to _ecore_key_grabs even when no key was grabbed. Summary: The key grab and ungrab functions should return which keycode was used. Proposed by pascal@ordissimo.com Reviewers: zmike Reviewed By: zmike Subscribers: zmike, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7923
-rw-r--r--src/lib/ecore_x/ecore_x.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/ecore_x/ecore_x.c b/src/lib/ecore_x/ecore_x.c
index bab8a41f6d..ae357df542 100644
--- a/src/lib/ecore_x/ecore_x.c
+++ b/src/lib/ecore_x/ecore_x.c
@@ -1921,7 +1921,7 @@ struct _Keygrab
1921}; 1921};
1922Keygrab *_ecore_key_grabs = NULL; 1922Keygrab *_ecore_key_grabs = NULL;
1923 1923
1924static void 1924static KeyCode
1925_ecore_x_window_key_grab_internal(Ecore_X_Window win, 1925_ecore_x_window_key_grab_internal(Ecore_X_Window win,
1926 const char *key, 1926 const char *key,
1927 int mod, 1927 int mod,
@@ -1940,13 +1940,13 @@ _ecore_x_window_key_grab_internal(Ecore_X_Window win,
1940 { 1940 {
1941 keysym = XStringToKeysym(key); 1941 keysym = XStringToKeysym(key);
1942 if (keysym == NoSymbol) 1942 if (keysym == NoSymbol)
1943 return; 1943 return 0;
1944 1944
1945 keycode = XKeysymToKeycode(_ecore_x_disp, keysym); 1945 keycode = XKeysymToKeycode(_ecore_x_disp, keysym);
1946 } 1946 }
1947 1947
1948 if (keycode == 0) 1948 if (keycode == 0)
1949 return; 1949 return 0;
1950 1950
1951 m = _ecore_x_event_modifier(mod); 1951 m = _ecore_x_event_modifier(mod);
1952 if (any_mod) 1952 if (any_mod)
@@ -1966,6 +1966,7 @@ _ecore_x_window_key_grab_internal(Ecore_X_Window win,
1966 win, False, GrabModeAsync, GrabModeAsync); 1966 win, False, GrabModeAsync, GrabModeAsync);
1967 if (_ecore_xlib_sync) ecore_x_sync(); 1967 if (_ecore_xlib_sync) ecore_x_sync();
1968 } 1968 }
1969 return keycode;
1969} 1970}
1970 1971
1971EAPI void 1972EAPI void
@@ -1975,9 +1976,11 @@ ecore_x_window_key_grab(Ecore_X_Window win,
1975 int any_mod) 1976 int any_mod)
1976{ 1977{
1977 Keygrab *t; 1978 Keygrab *t;
1979 KeyCode keycode;
1978 1980
1979 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp); 1981 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
1980 _ecore_x_window_key_grab_internal(win, key, mod, any_mod); 1982 if (!(keycode = _ecore_x_window_key_grab_internal(win, key, mod, any_mod)))
1983 return;
1981 _ecore_key_grabs_num++; 1984 _ecore_key_grabs_num++;
1982 t = realloc(_ecore_key_grabs, 1985 t = realloc(_ecore_key_grabs,
1983 _ecore_key_grabs_num * sizeof(Keygrab)); 1986 _ecore_key_grabs_num * sizeof(Keygrab));
@@ -2034,7 +2037,7 @@ _ecore_x_key_grab_remove(Ecore_X_Window win,
2034 return shuffle; 2037 return shuffle;
2035} 2038}
2036 2039
2037static void 2040static KeyCode
2038_ecore_x_window_key_ungrab_internal(Ecore_X_Window win, 2041_ecore_x_window_key_ungrab_internal(Ecore_X_Window win,
2039 const char *key, 2042 const char *key,
2040 int mod, 2043 int mod,
@@ -2053,13 +2056,13 @@ _ecore_x_window_key_ungrab_internal(Ecore_X_Window win,
2053 { 2056 {
2054 keysym = XStringToKeysym(key); 2057 keysym = XStringToKeysym(key);
2055 if (keysym == NoSymbol) 2058 if (keysym == NoSymbol)
2056 return; 2059 return 0;
2057 2060
2058 keycode = XKeysymToKeycode(_ecore_x_disp, keysym); 2061 keycode = XKeysymToKeycode(_ecore_x_disp, keysym);
2059 } 2062 }
2060 2063
2061 if (keycode == 0) 2064 if (keycode == 0)
2062 return; 2065 return 0;
2063 2066
2064 m = _ecore_x_event_modifier(mod); 2067 m = _ecore_x_event_modifier(mod);
2065 if (any_mod) 2068 if (any_mod)
@@ -2075,6 +2078,7 @@ _ecore_x_window_key_ungrab_internal(Ecore_X_Window win,
2075 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; 2078 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
2076 for (i = 0; i < 8; i++) 2079 for (i = 0; i < 8; i++)
2077 XUngrabKey(_ecore_x_disp, keycode, m | locks[i], win); 2080 XUngrabKey(_ecore_x_disp, keycode, m | locks[i], win);
2081 return keycode;
2078} 2082}
2079 2083
2080EAPI void 2084EAPI void