ecore-wl2: add ecore_wl2_window_popup_input_set()
authorMike Blumenkrantz <zmike@osg.samsung.com>
Wed, 17 May 2017 20:02:53 +0000 (16:02 -0400)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Fri, 19 May 2017 16:41:17 +0000 (12:41 -0400)
this is a function for explicitly setting the seat which will be used
for popup grabs

@feature

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_input.c
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_window.c

index e2aee99..f8a1307 100644 (file)
@@ -1490,6 +1490,18 @@ EAPI void ecore_wl2_session_recovery_disable(void);
  * @since 1.20
  */
 EAPI Eina_Bool ecore_wl2_window_activated_get(const Ecore_Wl2_Window *window);
+
+/**
+ * @brief Set the seat for a popup window to be used with grab
+ * @param window The window
+ * @param input The seat
+ *
+ * Use this function for desktop shell requests involving popup grabs which require
+ * a seat for the grab.
+ *
+ * @since 1.20
+ */
+EAPI void ecore_wl2_window_popup_input_set(Ecore_Wl2_Window *window, Ecore_Wl2_Input *input);
 # endif
 
 # undef EAPI
index 935f09c..3b55941 100644 (file)
@@ -1567,7 +1567,7 @@ _ecore_wl2_input_del(Ecore_Wl2_Input *input)
      eina_inlist_remove(display->inputs, EINA_INLIST_GET(input));
 
    EINA_INLIST_FOREACH(display->windows, window)
-     if (window->input == input) window->input = NULL;
+     if (window->grab == input) window->grab = NULL;
 
    eina_stringshare_replace(&input->name, NULL);
    free(input);
index 69c066c..08ec98b 100644 (file)
@@ -140,6 +140,7 @@ struct _Ecore_Wl2_Window
    Ecore_Wl2_Input *input;
 
    Ecore_Wl2_Window *parent;
+   Ecore_Wl2_Input *grab;
 
    int id, rotation, surface_id;
    const char *title;
index a3e84f5..4b9dc6d 100644 (file)
@@ -61,7 +61,7 @@ _xdg_popup_cb_done(void *data, struct xdg_popup *xdg_popup EINA_UNUSED)
    win = data;
    if (!win) return;
 
-   _ecore_wl2_input_ungrab(win->input);
+   if (win->grab) _ecore_wl2_input_ungrab(win->grab);
 }
 
 static const struct xdg_popup_listener _xdg_popup_listener =
@@ -241,7 +241,7 @@ _zxdg_popup_cb_done(void *data, struct zxdg_popup_v6 *zxdg_popup EINA_UNUSED)
    win = data;
    if (!win) return;
 
-   _ecore_wl2_input_ungrab(win->input);
+   if (win->grab) _ecore_wl2_input_ungrab(win->grab);
 }
 
 static const struct zxdg_popup_v6_listener _zxdg_popup_listener =
@@ -279,7 +279,7 @@ _ecore_wl2_window_zxdg_popup_create(Ecore_Wl2_Window *win)
      }
 
    zxdg_positioner_v6_destroy(pos);
-   zxdg_popup_v6_grab(win->zxdg_popup, win->input->wl.seat,
+   zxdg_popup_v6_grab(win->zxdg_popup, win->grab->wl.seat,
                       wl_display_get_serial(win->display->wl.display));
    zxdg_popup_v6_set_user_data(win->zxdg_popup, win);
    zxdg_popup_v6_add_listener(win->zxdg_popup, &_zxdg_popup_listener, win);
@@ -296,16 +296,6 @@ _ecore_wl2_window_type_set(Ecore_Wl2_Window *win)
      {
       case ECORE_WL2_WINDOW_TYPE_MENU:
           {
-             Ecore_Wl2_Input *input;
-
-             input = win->input;
-             if ((!input) && (win->parent))
-               {
-                  input = win->parent->input;
-               }
-
-             if ((!input) || (!input->wl.seat)) return;
-
              if (win->zxdg_surface)
                _ecore_wl2_window_zxdg_popup_create(win);
              else if (win->xdg_surface)
@@ -313,7 +303,7 @@ _ecore_wl2_window_type_set(Ecore_Wl2_Window *win)
                   win->xdg_popup =
                     xdg_shell_get_xdg_popup(win->display->wl.xdg_shell,
                                             win->surface, win->parent->surface,
-                                            input->wl.seat,
+                                            win->grab->wl.seat,
                                             wl_display_get_serial(win->display->wl.display),
                                             win->geometry.x, win->geometry.y);
                   if (!win->xdg_popup)
@@ -1150,10 +1140,12 @@ ecore_wl2_window_type_set(Ecore_Wl2_Window *window, Ecore_Wl2_Window_Type type)
 }
 
 EAPI void
-ecore_wl2_window_type_set(Ecore_Wl2_Window *window, Ecore_Wl2_Window_Type type)
+ecore_wl2_window_popup_input_set(Ecore_Wl2_Window *window, Ecore_Wl2_Input *input)
 {
    EINA_SAFETY_ON_NULL_RETURN(window);
-   window->type = type;
+   EINA_SAFETY_ON_NULL_RETURN(input);
+   EINA_SAFETY_ON_TRUE_RETURN(window->type != ECORE_WL2_WINDOW_TYPE_MENU);
+   window->grab = input;
 }
 
 EAPI Ecore_Wl2_Display *