Commit 05af7264 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Merge branch 'wayland-xdg-surface-setup' into 'master'

wayland: Don't duplicate xdg_surface setup code

See merge request !3191
parents 36347b21 db8bf5e7
Pipeline #275223 passed with stages
in 40 minutes and 45 seconds
......@@ -1721,6 +1721,52 @@ static const struct xdg_surface_listener xdg_surface_listener = {
xdg_surface_configure,
};
static void
zxdg_surface_v6_configure (void *data,
struct zxdg_surface_v6 *xdg_surface,
uint32_t serial)
{
GdkSurface *surface = GDK_SURFACE (data);
gdk_wayland_surface_handle_configure (surface, serial);
}
static const struct zxdg_surface_v6_listener zxdg_surface_v6_listener = {
zxdg_surface_v6_configure,
};
static void
gdk_wayland_surface_create_xdg_surface_resources (GdkSurface *surface)
{
GdkWaylandDisplay *display =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
switch (display->shell_variant)
{
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
impl->display_server.xdg_surface =
xdg_wm_base_get_xdg_surface (display->xdg_wm_base,
impl->display_server.wl_surface);
wl_proxy_set_queue ((struct wl_proxy *) impl->display_server.xdg_surface,
impl->event_queue);
xdg_surface_add_listener (impl->display_server.xdg_surface,
&xdg_surface_listener,
surface);
break;
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
impl->display_server.zxdg_surface_v6 =
zxdg_shell_v6_get_xdg_surface (display->zxdg_shell_v6,
impl->display_server.wl_surface);
zxdg_surface_v6_add_listener (impl->display_server.zxdg_surface_v6,
&zxdg_surface_v6_listener,
surface);
break;
default:
g_assert_not_reached ();
}
}
static void
xdg_toplevel_configure (void *data,
struct xdg_toplevel *xdg_toplevel,
......@@ -1780,19 +1826,8 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = {
static void
create_xdg_toplevel_resources (GdkSurface *surface)
{
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
impl->display_server.xdg_surface =
xdg_wm_base_get_xdg_surface (display_wayland->xdg_wm_base,
impl->display_server.wl_surface);
wl_proxy_set_queue ((struct wl_proxy *) impl->display_server.xdg_surface,
impl->event_queue);
xdg_surface_add_listener (impl->display_server.xdg_surface,
&xdg_surface_listener,
surface);
impl->display_server.xdg_toplevel =
xdg_surface_get_toplevel (impl->display_server.xdg_surface);
xdg_toplevel_add_listener (impl->display_server.xdg_toplevel,
......@@ -1800,20 +1835,6 @@ create_xdg_toplevel_resources (GdkSurface *surface)
surface);
}
static void
zxdg_surface_v6_configure (void *data,
struct zxdg_surface_v6 *xdg_surface,
uint32_t serial)
{
GdkSurface *surface = GDK_SURFACE (data);
gdk_wayland_surface_handle_configure (surface, serial);
}
static const struct zxdg_surface_v6_listener zxdg_surface_v6_listener = {
zxdg_surface_v6_configure,
};
static void
zxdg_toplevel_v6_configure (void *data,
struct zxdg_toplevel_v6 *xdg_toplevel,
......@@ -1873,17 +1894,8 @@ static const struct zxdg_toplevel_v6_listener zxdg_toplevel_v6_listener = {
static void
create_zxdg_toplevel_v6_resources (GdkSurface *surface)
{
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
impl->display_server.zxdg_surface_v6 =
zxdg_shell_v6_get_xdg_surface (display_wayland->zxdg_shell_v6,
impl->display_server.wl_surface);
zxdg_surface_v6_add_listener (impl->display_server.zxdg_surface_v6,
&zxdg_surface_v6_listener,
surface);
impl->display_server.zxdg_toplevel_v6 =
zxdg_surface_v6_get_toplevel (impl->display_server.zxdg_surface_v6);
zxdg_toplevel_v6_add_listener (impl->display_server.zxdg_toplevel_v6,
......@@ -1942,6 +1954,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface)
const char *app_id;
gdk_surface_freeze_updates (surface);
gdk_wayland_surface_create_xdg_surface_resources (surface);
switch (display_wayland->shell_variant)
{
......@@ -2712,19 +2725,11 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
gdk_surface_freeze_updates (surface);
positioner = create_dynamic_positioner (surface, width, height, layout, FALSE);
gdk_wayland_surface_create_xdg_surface_resources (surface);
switch (display->shell_variant)
{
case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
impl->display_server.xdg_surface =
xdg_wm_base_get_xdg_surface (display->xdg_wm_base,
impl->display_server.wl_surface);
wl_proxy_set_queue ((struct wl_proxy *) impl->display_server.xdg_surface,
impl->event_queue);
xdg_surface_add_listener (impl->display_server.xdg_surface,
&xdg_surface_listener,
surface);
impl->display_server.xdg_popup =
xdg_surface_get_popup (impl->display_server.xdg_surface,
parent_impl->display_server.xdg_surface,
......@@ -2735,12 +2740,6 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
xdg_positioner_destroy (positioner);
break;
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
impl->display_server.zxdg_surface_v6 =
zxdg_shell_v6_get_xdg_surface (display->zxdg_shell_v6,
impl->display_server.wl_surface);
zxdg_surface_v6_add_listener (impl->display_server.zxdg_surface_v6,
&zxdg_surface_v6_listener,
surface);
impl->display_server.zxdg_popup_v6 =
zxdg_surface_v6_get_popup (impl->display_server.zxdg_surface_v6,
parent_impl->display_server.zxdg_surface_v6,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment