xdg-shell: Move xdg_shell.get_xdg_popup errors to xdg_shell
authorJonas Ådahl <jadahl@gmail.com>
Wed, 18 Mar 2015 08:37:47 +0000 (16:37 +0800)
committerJonas Ådahl <jadahl@gmail.com>
Tue, 5 May 2015 06:17:11 +0000 (14:17 +0800)
They are errors that may be as a result of calling get_xdg_popup on an
xdg_shell, not a result of calling a request on xdg_popup.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
desktop-shell/shell.c
protocol/xdg-shell.xml

index c903ad7..bcde3fb 100644 (file)
@@ -3398,8 +3398,8 @@ add_popup_grab(struct shell_surface *shsurf,
            (!parent ||
             (top_surface == NULL && !shell_surface_is_xdg_surface(parent)) ||
             (top_surface != NULL && parent != top_surface))) {
-               wl_resource_post_error(shsurf->owner->resource,
-                                      XDG_POPUP_ERROR_NOT_THE_TOPMOST_POPUP,
+               wl_resource_post_error(shsurf->owner_resource,
+                                      XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP,
                                       "xdg_popup was not created on the "
                                       "topmost popup");
                return -1;
@@ -3449,8 +3449,8 @@ remove_popup_grab(struct shell_surface *shsurf)
 
        if (shell_surface_is_xdg_popup(shsurf) &&
            get_top_popup(shseat) != shsurf) {
-               wl_resource_post_error(shsurf->resource,
-                                      XDG_POPUP_ERROR_NOT_THE_TOPMOST_POPUP,
+               wl_resource_post_error(shsurf->owner_resource,
+                                      XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP,
                                       "xdg_popup was destroyed while it was "
                                       "not the topmost popup.");
                return;
@@ -4119,21 +4119,7 @@ create_xdg_popup(struct shell_client *owner, void *shell,
                 uint32_t serial,
                 int32_t x, int32_t y)
 {
-       struct shell_surface *shsurf, *parent_shsurf;
-
-       /* Verify that we are creating the topmost popup when mapping,
-        * as it's not until then we know whether it was mapped as most
-        * top level or not. */
-
-       parent_shsurf = get_shell_surface(parent);
-       if (!parent_shsurf ||
-           (!shell_surface_is_xdg_popup(parent_shsurf) &&
-            !shell_surface_is_xdg_surface(parent_shsurf))) {
-               wl_resource_post_error(owner->resource,
-                                      XDG_POPUP_ERROR_INVALID_PARENT,
-                                      "xdg_popup parent was invalid");
-               return NULL;
-       }
+       struct shell_surface *shsurf;
 
        shsurf = create_common_surface(owner, shell, surface, client);
        if (!shsurf)
@@ -4164,6 +4150,7 @@ xdg_get_xdg_popup(struct wl_client *client,
        struct shell_client *sc = wl_resource_get_user_data(resource);
        struct desktop_shell *shell = sc->shell;
        struct shell_surface *shsurf;
+       struct shell_surface *parent_shsurf;
        struct weston_surface *parent;
        struct shell_seat *seat;
 
@@ -4189,6 +4176,19 @@ xdg_get_xdg_popup(struct wl_client *client,
        parent = wl_resource_get_user_data(parent_resource);
        seat = get_shell_seat(wl_resource_get_user_data(seat_resource));;
 
+       /* Verify that we are creating the top most popup when mapping,
+        * as it's not until then we know whether it was mapped as most
+        * top level or not. */
+
+       parent_shsurf = get_shell_surface(parent);
+       if (!shell_surface_is_xdg_popup(parent_shsurf) &&
+           !shell_surface_is_xdg_surface(parent_shsurf)) {
+               wl_resource_post_error(resource,
+                                      XDG_SHELL_ERROR_INVALID_POPUP_PARENT,
+                                      "xdg_popup parent was invalid");
+               return;
+       }
+
        shsurf = create_xdg_popup(sc, shell, surface, &xdg_popup_client,
                                  parent, seat, serial, x, y);
        if (!shsurf) {
index 866e330..df103c4 100644 (file)
@@ -50,6 +50,8 @@
     <enum name="error">
       <entry name="role" value="0" summary="given wl_surface has another role"/>
       <entry name="defunct_surfaces" value="1" summary="xdg_shell was destroyed before children"/>
+      <entry name="not_the_topmost_popup" value="2" summary="the client tried to map or destroy a non-topmost popup"/>
+      <entry name="invalid_popup_parent" value="3" summary="the client specified an invalid popup parent surface"/>
     </enum>
 
     <request name="destroy" type="destructor">
       parent surface.
     </description>
 
-    <enum name="error">
-      <description summary="xdg_popup error values">
-       These errors can be emitted in response to xdg_popup requests.
-      </description>
-      <entry name="not_the_topmost_popup" value="0" summary="The client tried to map or destroy a non-topmost popup"/>
-      <entry name="invalid_parent" value="1" summary="The client specified an invalid parent surface"/>
-    </enum>
-
     <request name="destroy" type="destructor">
       <description summary="remove xdg_popup interface">
        This destroys the popup. Explicitly destroying the xdg_popup