(!1714) 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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-09-25 21:19:47 +02:00
parent a801164bf5
commit e5f5bb62f3
5 changed files with 19 additions and 64 deletions

View File

@ -81,9 +81,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;
@ -1225,7 +1222,7 @@ DbeResetProc(ExtensionEntry * extEntry)
if (pDbeScreenPriv) {
dixScreenUnhookWindowDestroy(pScreen, miDbeWindowDestroy, NULL);
pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
dixScreenUnhookWindowPosition(pScreen, miDbeWindowPosition, NULL);
free(pDbeScreenPriv);
}
}
@ -1340,7 +1337,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, NULL);
}

View File

@ -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 */

View File

@ -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(ScreenPtr pScreen, WindowPtr pWin, void *arg, int32_t x, int32_t y)
{
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;
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
@ -663,8 +622,7 @@ Bool
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
{
/* Wrap functions. */
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
pScreen->PositionWindow = miDbePositionWindow;
dixScreenUnhookWindowPosition(pScreen, miDbeWindowPosition, NULL);
/* Initialize the per-screen DBE function pointers. */
pDbeScreenPriv->GetVisualInfo = miDbeGetVisualInfo;

View File

@ -53,4 +53,6 @@ extern DevPrivateKeyRec dbeWindowPrivKeyRec;
extern RESTYPE dbeDrawableResType;
extern RESTYPE dbeWindowPrivResType;
void miDbeWindowPosition(ScreenPtr pScreen, WindowPtr pWin, void *arg, int32_t x, int32_t y);
#endif /* MIDBE_H */

View File

@ -59,6 +59,9 @@ int dixScreenRaiseWindowDestroy(WindowPtr pWin)
void dixScreenRaiseWindowPosition(WindowPtr pWin, uint32_t x, uint32_t y)
{
if (!pWin)
return;
ScreenPtr pScreen = pWin->drawable.pScreen;
ARRAY_FOR_EACH(pScreen->_notify_window_position, walk) {