fix grabinput to work better with multiple compositor backends
authorMike Blumenkrantz <zmike@osg.samsung.com>
Thu, 25 Jun 2015 23:41:04 +0000 (19:41 -0400)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Fri, 26 Jun 2015 00:12:03 +0000 (20:12 -0400)
check root window to determine existence of X11 compositor,
use both wayland and non-wayland define codepaths where available

src/bin/e_grabinput.c

index de78c09..a0ca5a8 100644 (file)
@@ -39,7 +39,7 @@ e_grabinput_get(Ecore_Window mouse_win, int confine_mouse, Ecore_Window key_win)
    if (grab_mouse_win)
      {
 #ifndef HAVE_WAYLAND_ONLY
-        if (e_comp->comp_type == E_PIXMAP_TYPE_X)
+        if (e_comp->root)
           ecore_x_pointer_ungrab();
 #else
         if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
@@ -50,7 +50,7 @@ e_grabinput_get(Ecore_Window mouse_win, int confine_mouse, Ecore_Window key_win)
    if (grab_key_win)
      {
 #ifndef HAVE_WAYLAND_ONLY
-        if (e_comp->comp_type == E_PIXMAP_TYPE_X)
+        if (e_comp->root)
           ecore_x_keyboard_ungrab();
 #else
         if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
@@ -63,7 +63,7 @@ e_grabinput_get(Ecore_Window mouse_win, int confine_mouse, Ecore_Window key_win)
    if (mouse_win)
      {
 #ifndef HAVE_WAYLAND_ONLY
-        if (e_comp->comp_type == E_PIXMAP_TYPE_X)
+        if (e_comp->root)
           {
              int ret = 0;
              if (confine_mouse)
@@ -86,7 +86,7 @@ e_grabinput_get(Ecore_Window mouse_win, int confine_mouse, Ecore_Window key_win)
    if (key_win)
      {
 #ifndef HAVE_WAYLAND_ONLY
-        if (e_comp->comp_type == E_PIXMAP_TYPE_X)
+        if (e_comp->root)
           {
              int ret = 0;
 
@@ -124,7 +124,7 @@ e_grabinput_release(Ecore_Window mouse_win, Ecore_Window key_win)
    if (mouse_win == grab_mouse_win)
      {
 #ifndef HAVE_WAYLAND_ONLY
-        if (e_comp->comp_type == E_PIXMAP_TYPE_X)
+        if (e_comp->root)
           ecore_x_pointer_ungrab();
 #else
         if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
@@ -136,7 +136,7 @@ e_grabinput_release(Ecore_Window mouse_win, Ecore_Window key_win)
    if (key_win == grab_key_win)
      {
 #ifndef HAVE_WAYLAND_ONLY
-        if (e_comp->comp_type == E_PIXMAP_TYPE_X)
+        if (e_comp->root)
           ecore_x_keyboard_ungrab();
 #else
         if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
@@ -211,7 +211,7 @@ _e_grabinput_focus_check(void *data EINA_UNUSED)
 static void
 _e_grabinput_focus_do(Ecore_Window win, E_Focus_Method method)
 {
-#ifdef HAVE_WAYLAND_ONLY
+#ifdef HAVE_WAYLAND
    Ecore_Wl_Window *wl_win;
 #endif
 
@@ -223,34 +223,49 @@ _e_grabinput_focus_do(Ecore_Window win, E_Focus_Method method)
 
       case E_FOCUS_METHOD_LOCALLY_ACTIVE:
 #ifndef HAVE_WAYLAND_ONLY
-        ecore_x_window_focus_at_time(win, ecore_x_current_time_get());
-        ecore_x_icccm_take_focus_send(win, ecore_x_current_time_get());
-#else
-        if ((wl_win = ecore_wl_window_find(win)))
+        if (e_comp->root)
           {
-             /* FIXME: Need to add an ecore_wl_window_focus function */
+             ecore_x_window_focus_at_time(win, ecore_x_current_time_get());
+             ecore_x_icccm_take_focus_send(win, ecore_x_current_time_get());
+          }
+#endif
+#ifdef HAVE_WAYLAND
+        if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
+          {
+             if ((wl_win = ecore_wl_window_find(win)))
+               {
+                  /* FIXME: Need to add an ecore_wl_window_focus function */
+               }
           }
 #endif
         break;
 
       case E_FOCUS_METHOD_GLOBALLY_ACTIVE:
 #ifndef HAVE_WAYLAND_ONLY
-        ecore_x_icccm_take_focus_send(win, ecore_x_current_time_get());
+        if (e_comp->root)
+          ecore_x_icccm_take_focus_send(win, ecore_x_current_time_get());
 #else
-        if ((wl_win = ecore_wl_window_find(win)))
+        if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
           {
-             /* FIXME: Need to add an ecore_wl_window_focus function */
+             if ((wl_win = ecore_wl_window_find(win)))
+               {
+                  /* FIXME: Need to add an ecore_wl_window_focus function */
+               }
           }
 #endif
         break;
 
       case E_FOCUS_METHOD_PASSIVE:
 #ifndef HAVE_WAYLAND_ONLY
-        ecore_x_window_focus_at_time(win, ecore_x_current_time_get());
+        if (e_comp->root)
+          ecore_x_window_focus_at_time(win, ecore_x_current_time_get());
 #else
-        if ((wl_win = ecore_wl_window_find(win)))
+        if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
           {
-             /* FIXME: Need to add an ecore_wl_window_focus function */
+             if ((wl_win = ecore_wl_window_find(win)))
+               {
+                  /* FIXME: Need to add an ecore_wl_window_focus function */
+               }
           }
 #endif
         break;
@@ -269,7 +284,6 @@ _e_grabinput_focus(Ecore_Window win, E_Focus_Method method)
    _e_grabinput_focus_do(win, method);
    last_focus_time = ecore_loop_time_get();
 #ifndef HAVE_WAYLAND_ONLY
-   if (e_comp->comp_type != E_PIXMAP_TYPE_X) return;
    if (focus_fix_timer) ecore_timer_del(focus_fix_timer);
    focus_fix_timer = ecore_timer_add(0.2, _e_grabinput_focus_check, NULL);
 #endif