From b3f592b481a119922099d53a7881d59a95ded10f Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 23 Sep 2024 17:26:05 +0200 Subject: [PATCH] (!1714) xwayland: use window destructor hook Wrapping ScreenRec's function pointers is problematic for many reasons, so use the new window destructor hook instead. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xwayland/xwayland-screen.c | 3 +-- hw/xwayland/xwayland-screen.h | 1 - hw/xwayland/xwayland-window.c | 20 +++----------------- hw/xwayland/xwayland-window.h | 2 +- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c index 55304569e..1ee12c4a5 100644 --- a/hw/xwayland/xwayland-screen.c +++ b/hw/xwayland/xwayland-screen.c @@ -1134,8 +1134,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) xwl_screen->UnrealizeWindow = pScreen->UnrealizeWindow; pScreen->UnrealizeWindow = xwl_unrealize_window; - xwl_screen->DestroyWindow = pScreen->DestroyWindow; - pScreen->DestroyWindow = xwl_destroy_window; + dixScreenHookWindowDestroy(pScreen, xwl_window_destroy, NULL); xwl_screen->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xwl_close_screen; diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h index 49a167a12..523c01e2d 100644 --- a/hw/xwayland/xwayland-screen.h +++ b/hw/xwayland/xwayland-screen.h @@ -74,7 +74,6 @@ struct xwl_screen { ConfigNotifyProcPtr ConfigNotify; RealizeWindowProcPtr RealizeWindow; UnrealizeWindowProcPtr UnrealizeWindow; - DestroyWindowProcPtr DestroyWindow; XYToWindowProcPtr XYToWindow; SetWindowPixmapProcPtr SetWindowPixmap; ChangeWindowAttributesProcPtr ChangeWindowAttributes; diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index a77f4fb88..ba2e6ff17 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -1939,31 +1939,17 @@ xwl_window_create_frame_callback(struct xwl_window *xwl_window) xwl_present_for_each_frame_callback(xwl_window, xwl_present_reset_timer); } -Bool -xwl_destroy_window(WindowPtr window) +void +xwl_window_destroy(ScreenPtr pScreen, WindowPtr window, void *arg) { - ScreenPtr screen = window->drawable.pScreen; - struct xwl_screen *xwl_screen = xwl_screen_get(screen); + struct xwl_screen *xwl_screen = xwl_screen_get(pScreen); struct xwl_window *xwl_window = xwl_window_get(window); - Bool ret; if (xwl_screen->present) xwl_present_cleanup(window); if (xwl_window) xwl_window_dispose(xwl_window); - - screen->DestroyWindow = xwl_screen->DestroyWindow; - - if (screen->DestroyWindow) - ret = screen->DestroyWindow (window); - else - ret = TRUE; - - xwl_screen->DestroyWindow = screen->DestroyWindow; - screen->DestroyWindow = xwl_destroy_window; - - return ret; } static Bool diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h index ba5c3a078..3d4a33485 100644 --- a/hw/xwayland/xwayland-window.h +++ b/hw/xwayland/xwayland-window.h @@ -146,7 +146,7 @@ void xwl_move_window(WindowPtr window, int x, int y, WindowPtr next_sib, VTKind kind); -Bool xwl_destroy_window(WindowPtr window); +void xwl_window_destroy(ScreenPtr pScreen, WindowPtr window, void *arg); void xwl_window_post_damage(struct xwl_window *xwl_window); void xwl_window_create_frame_callback(struct xwl_window *xwl_window); void xwl_window_surface_do_destroy(struct xwl_wl_surface *xwl_wl_surface);