From 669391f477e18bf383faaf6b9de385ef319fd68b Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 25 Sep 2024 21:19:47 +0200 Subject: [PATCH] dbe: use window position notify hook Wrapping ScreenRec's function pointers is problematic for many reasons, so use the new window position notify hook instead. Signed-off-by: Enrico Weigelt, metux IT consult --- composite/compint.h | 2 ++ dbe/dbe.c | 7 ++--- dbe/dbestruct.h | 5 ---- dbe/midbe.c | 69 +++++++++------------------------------------ dbe/midbe.h | 5 +++- dix/screen_hooks.c | 3 ++ 6 files changed, 24 insertions(+), 67 deletions(-) diff --git a/composite/compint.h b/composite/compint.h index 2c2bfd9ea..42fe9f45b 100644 --- a/composite/compint.h +++ b/composite/compint.h @@ -48,6 +48,8 @@ #ifndef _COMPINT_H_ #define _COMPINT_H_ +#include "dix/screen_hooks_priv.h" + #include "misc.h" #include "scrnintstr.h" #include "os.h" diff --git a/dbe/dbe.c b/dbe/dbe.c index 0ac546ae1..0cf4c7df2 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -82,9 +82,6 @@ DbeStubScreen(DbeScreenPrivPtr pDbeScreenPriv, int *nStubbedScreens) /* Stub DIX. */ pDbeScreenPriv->SetupBackgroundPainter = NULL; - /* Do not unwrap PositionWindow. If the DDX initialization function failed, - we assume that it did not wrap PositionWindow. */ - /* Stub DDX. */ pDbeScreenPriv->GetVisualInfo = NULL; pDbeScreenPriv->AllocBackBufferName = NULL; @@ -1226,7 +1223,7 @@ DbeResetProc(ExtensionEntry * extEntry) if (pDbeScreenPriv) { dixScreenUnhookWindowDestroy(pScreen, miDbeWindowDestroy); - pScreen->PositionWindow = pDbeScreenPriv->PositionWindow; + dixScreenUnhookWindowPosition(pScreen, miDbeWindowPosition); free(pDbeScreenPriv); } } @@ -1341,7 +1338,7 @@ DbeExtensionInit(void) if (ddxInitSuccess) { /* Hook in our window destructor. The DDX initialization function - * already wrapped PositionWindow for us. + * already added WindowPosition hook for us. */ dixScreenHookWindowDestroy(pScreen, miDbeWindowDestroy); } diff --git a/dbe/dbestruct.h b/dbe/dbestruct.h index bfecf0266..8f52a551d 100644 --- a/dbe/dbestruct.h +++ b/dbe/dbestruct.h @@ -169,11 +169,6 @@ typedef struct _DbeWindowPrivRec { */ typedef struct _DbeScreenPrivRec { - /* Wrapped functions - * It is the responsibility of the DDX layer to wrap PositionWindow(). - */ - PositionWindowProcPtr PositionWindow; - /* Per-screen DIX routines */ Bool (*SetupBackgroundPainter) (WindowPtr /*pWin */ , GCPtr /*pGC */ diff --git a/dbe/midbe.c b/dbe/midbe.c index f39a58b22..ccf5aa167 100644 --- a/dbe/midbe.c +++ b/dbe/midbe.c @@ -381,7 +381,7 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) * - miDbeAllocBackBufferName() calls FreeResource() to clean up resources * after a buffer allocation failure. * - * - The PositionWindow wrapper, miDbePositionWindow(), calls + * - The WindowPosition hook, miDbeWindowPosition(), calls * FreeResource() when it fails to create buffers of the new size. * FreeResource() is called for all DBE buffer IDs. * @@ -431,22 +431,20 @@ miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId) if (pDbeWindowPriv->pBackBuffer) dixDestroyPixmap(pDbeWindowPriv->pBackBuffer, 0); } /* miDbeWinPrivDelete() */ - + /****************************************************************************** * - * DBE MI Procedure: miDbePositionWindow + * DBE MI Procedure: miDbeWindowPosition * * Description: * - * This function was cloned from miMbxPositionWindow() in mimultibuf.c. + * This function was cloned from miMbxWindowPosition() in mimultibuf.c. * This function resizes the buffer when the window is resized. * *****************************************************************************/ -static Bool -miDbePositionWindow(WindowPtr pWin, int x, int y) +void miDbeWindowPosition(CallbackListPtr *pcbl, ScreenPtr pScreen, XorgScreenWindowPositionParamRec *param) { - ScreenPtr pScreen; DbeScreenPrivPtr pDbeScreenPriv; DbeWindowPrivPtr pDbeWindowPriv; int width, height; @@ -459,43 +457,9 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) Bool clear; GCPtr pGC; xRectangle clearRect; - Bool ret; - /* - ************************************************************************** - ** 1. Unwrap the member routine. - ************************************************************************** - */ - - pScreen = pWin->drawable.pScreen; + WindowPtr pWin = param->window; pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen); - pScreen->PositionWindow = pDbeScreenPriv->PositionWindow; - - /* - ************************************************************************** - ** 2. Do any work necessary before the member routine is called. - ** - ** In this case we do not need to do anything. - ************************************************************************** - */ - - /* - ************************************************************************** - ** 3. Call the member routine, saving its result if necessary. - ************************************************************************** - */ - - ret = (*pScreen->PositionWindow) (pWin, x, y); - - /* - ************************************************************************** - ** 4. Rewrap the member routine, restoring the wrapper value first in case - ** the wrapper (or something that it wrapped) change this value. - ************************************************************************** - */ - - pDbeScreenPriv->PositionWindow = pScreen->PositionWindow; - pScreen->PositionWindow = miDbePositionWindow; /* ************************************************************************** @@ -503,14 +467,12 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) ************************************************************************** */ - if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin))) { - return ret; - } + if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin))) + return; if (pDbeWindowPriv->width == pWin->drawable.width && - pDbeWindowPriv->height == pWin->drawable.height) { - return ret; - } + pDbeWindowPriv->height == pWin->drawable.height) + return; width = pWin->drawable.width; height = pWin->drawable.height; @@ -594,7 +556,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) } FreeScratchGC(pGC); - return FALSE; + return; } else { @@ -644,11 +606,8 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) FreeScratchGC(pGC); } +} - return ret; - -} /* miDbePositionWindow() */ - /****************************************************************************** * * DBE MI Procedure: miDbeInit @@ -662,9 +621,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) Bool miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv) { - /* Wrap functions. */ - pDbeScreenPriv->PositionWindow = pScreen->PositionWindow; - pScreen->PositionWindow = miDbePositionWindow; + dixScreenHookWindowPosition(pScreen, miDbeWindowPosition); /* Initialize the per-screen DBE function pointers. */ pDbeScreenPriv->GetVisualInfo = miDbeGetVisualInfo; diff --git a/dbe/midbe.h b/dbe/midbe.h index 67320eabf..019375756 100644 --- a/dbe/midbe.h +++ b/dbe/midbe.h @@ -36,7 +36,8 @@ #ifndef MIDBE_H #define MIDBE_H -#include "privates.h" +#include "dix/screen_hooks_priv.h" +#include "include/privates.h" /* EXTERNS */ @@ -53,4 +54,6 @@ extern DevPrivateKeyRec dbeWindowPrivKeyRec; extern RESTYPE dbeDrawableResType; extern RESTYPE dbeWindowPrivResType; +void miDbeWindowPosition(CallbackListPtr *pcbl, ScreenPtr pScreen, XorgScreenWindowPositionParamRec *param); + #endif /* MIDBE_H */ diff --git a/dix/screen_hooks.c b/dix/screen_hooks.c index 1bfff195d..fb979b376 100644 --- a/dix/screen_hooks.c +++ b/dix/screen_hooks.c @@ -40,6 +40,9 @@ int dixScreenRaiseWindowDestroy(WindowPtr pWin) void dixScreenRaiseWindowPosition(WindowPtr pWin, uint32_t x, uint32_t y) { + if (!pWin) + return; + ScreenPtr pScreen = pWin->drawable.pScreen; XorgScreenWindowPositionParamRec param = {