From 8150b190d6133f0d085245e38e00831c04e41543 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 27 Jun 2012 10:22:58 -0400 Subject: [PATCH] shell: Take a wl_surface as parent for transient and popup windows --- clients/window.c | 4 ++-- src/compositor.h | 2 +- src/shell.c | 18 ++++++++---------- src/xwayland/window-manager.c | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/clients/window.c b/clients/window.c index d160b08..438eaf6 100644 --- a/clients/window.c +++ b/clients/window.c @@ -3009,7 +3009,7 @@ window_create_transient(struct display *display, struct window *parent, if (display->shell) wl_shell_surface_set_transient(window->shell_surface, - window->parent->shell_surface, + window->parent->surface, window->x, window->y, flags); return window; @@ -3155,7 +3155,7 @@ window_show_menu(struct display *display, input_ungrab(input); wl_shell_surface_set_popup(window->shell_surface, input->seat, display_get_serial(window->display), - window->parent->shell_surface, + window->parent->surface, window->x, window->y, 0); widget_set_redraw_handler(menu->widget, menu_redraw_handler); diff --git a/src/compositor.h b/src/compositor.h index 5bb0ca6..a144e5f 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -82,7 +82,7 @@ struct weston_shell_interface { void (*set_toplevel)(struct shell_surface *shsurf); void (*set_transient)(struct shell_surface *shsurf, - struct shell_surface *pshsurf, + struct weston_surface *parent, int x, int y, uint32_t flags); int (*move)(struct shell_surface *shsurf, struct weston_seat *ws); int (*resize)(struct shell_surface *shsurf, diff --git a/src/shell.c b/src/shell.c index 1d82e43..5d79e2e 100644 --- a/src/shell.c +++ b/src/shell.c @@ -145,7 +145,7 @@ struct shell_surface { struct weston_surface *surface; struct wl_listener surface_destroy_listener; - struct shell_surface *parent; + struct weston_surface *parent; struct desktop_shell *shell; enum shell_surface_type type, next_type; @@ -1233,8 +1233,7 @@ static void set_surface_type(struct shell_surface *shsurf) { struct weston_surface *surface = shsurf->surface; - struct shell_surface *pshsurf = shsurf->parent; - struct weston_surface *pes; + struct weston_surface *pes = shsurf->parent; reset_shell_surface_type(shsurf); @@ -1245,7 +1244,6 @@ set_surface_type(struct shell_surface *shsurf) case SHELL_SURFACE_TOPLEVEL: break; case SHELL_SURFACE_TRANSIENT: - pes = pshsurf->surface; weston_surface_set_position(surface, pes->geometry.x + shsurf->transient.x, pes->geometry.y + shsurf->transient.y); @@ -1292,10 +1290,10 @@ shell_surface_set_toplevel(struct wl_client *client, static void set_transient(struct shell_surface *shsurf, - struct shell_surface *pshsurf, int x, int y, uint32_t flags) + struct weston_surface *parent, int x, int y, uint32_t flags) { /* assign to parents output */ - shsurf->parent = pshsurf; + shsurf->parent = parent; shsurf->transient.x = x; shsurf->transient.y = y; shsurf->transient.flags = flags; @@ -1309,9 +1307,9 @@ shell_surface_set_transient(struct wl_client *client, int x, int y, uint32_t flags) { struct shell_surface *shsurf = resource->data; - struct shell_surface *pshsurf = parent_resource->data; + struct weston_surface *parent = parent_resource->data; - set_transient(shsurf, pshsurf, x, y, flags); + set_transient(shsurf, parent, x, y, flags); } static struct desktop_shell * @@ -1584,7 +1582,7 @@ shell_map_popup(struct shell_surface *shsurf) { struct wl_seat *seat = shsurf->popup.seat; struct weston_surface *es = shsurf->surface; - struct weston_surface *parent = shsurf->parent->surface; + struct weston_surface *parent = shsurf->parent; es->output = parent->output; shsurf->popup.grab.interface = &popup_grab_interface; @@ -2572,7 +2570,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface, switch (surface_type) { case SHELL_SURFACE_POPUP: case SHELL_SURFACE_TRANSIENT: - parent = shsurf->parent->surface; + parent = shsurf->parent; wl_list_insert(parent->layer_link.prev, &surface->layer_link); break; case SHELL_SURFACE_FULLSCREEN: diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c index ac72458..6e032ea 100644 --- a/src/xwayland/window-manager.c +++ b/src/xwayland/window-manager.c @@ -1329,7 +1329,7 @@ xserver_map_shell_surface(struct weston_wm *wm, } parent = hash_table_lookup(wm->window_hash, window->transient_for->id); - shell_interface->set_transient(window->shsurf, parent->shsurf, + shell_interface->set_transient(window->shsurf, parent->surface, window->x - parent->x + t->margin + t->width, window->y - parent->y + t->margin + t->titlebar_height, WL_SHELL_SURFACE_TRANSIENT_INACTIVE); -- 2.7.4