rootless: 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-27 17:28:17 +02:00
parent 669391f477
commit eca6201e98
4 changed files with 13 additions and 19 deletions

View File

@ -91,7 +91,6 @@ typedef struct _RootlessScreenRec {
RestackWindowProcPtr RestackWindow; RestackWindowProcPtr RestackWindow;
ReparentWindowProcPtr ReparentWindow; ReparentWindowProcPtr ReparentWindow;
ChangeBorderWidthProcPtr ChangeBorderWidth; ChangeBorderWidthProcPtr ChangeBorderWidth;
PositionWindowProcPtr PositionWindow;
ChangeWindowAttributesProcPtr ChangeWindowAttributes; ChangeWindowAttributesProcPtr ChangeWindowAttributes;
PaintWindowProcPtr PaintWindow; PaintWindowProcPtr PaintWindow;

View File

@ -651,6 +651,7 @@ RootlessWrap(ScreenPtr pScreen)
RootlessScreenRec *s = SCREENREC(pScreen); RootlessScreenRec *s = SCREENREC(pScreen);
dixScreenHookWindowDestroy(pScreen, RootlessWindowDestroy); dixScreenHookWindowDestroy(pScreen, RootlessWindowDestroy);
dixScreenHookWindowPosition(pScreen, RootlessWindowPosition);
#define WRAP(a) \ #define WRAP(a) \
if (pScreen->a) { \ if (pScreen->a) { \
@ -672,7 +673,6 @@ RootlessWrap(ScreenPtr pScreen)
WRAP(RealizeWindow); WRAP(RealizeWindow);
WRAP(UnrealizeWindow); WRAP(UnrealizeWindow);
WRAP(MoveWindow); WRAP(MoveWindow);
WRAP(PositionWindow);
WRAP(ResizeWindow); WRAP(ResizeWindow);
WRAP(RestackWindow); WRAP(RestackWindow);
WRAP(ReparentWindow); WRAP(ReparentWindow);

View File

@ -304,20 +304,20 @@ RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask)
} }
/* /*
* RootlessPositionWindow * @brief DIX move/resize hook
* This is a hook for when DIX moves or resizes a window. *
* Update the frame position now although the physical window is moved * This is a hook for when DIX moves or resizes a window.
* in RootlessMoveWindow. (x, y) are *inside* position. After this, * Update the frame position now although the physical window is moved
* mi and fb are expecting the pixmap to be at the new location. * in RootlessMoveWindow. (x, y) are *inside* position. After this,
* mi and fb are expecting the pixmap to be at the new location.
*/ */
Bool void RootlessWindowPosition(CallbackListPtr *pcbl, ScreenPtr pScreen, XorgScreenWindowPositionParamRec *param)
RootlessPositionWindow(WindowPtr pWin, int x, int y)
{ {
ScreenPtr pScreen = pWin->drawable.pScreen; WindowPtr pWin = param->window;
RootlessWindowRec *winRec = WINREC(pWin); RootlessWindowRec *winRec = WINREC(pWin);
Bool result;
RL_DEBUG_MSG("positionwindow start (win %p (%lu) @ %i, %i)\n", pWin, RootlessWID(pWin), x, y); RL_DEBUG_MSG("positionwindow start (win %p (%lu) @ %i, %i)\n", pWin,
RootlessWID(pWin), param->x, param->y);
if (winRec) { if (winRec) {
if (winRec->is_drawing) { if (winRec->is_drawing) {
@ -325,16 +325,11 @@ RootlessPositionWindow(WindowPtr pWin, int x, int y)
int bw = wBorderWidth(pWin); int bw = wBorderWidth(pWin);
winRec->pixmap->devPrivate.ptr = winRec->pixelData; winRec->pixmap->devPrivate.ptr = winRec->pixelData;
SetPixmapBaseToScreen(winRec->pixmap, x - bw, y - bw); SetPixmapBaseToScreen(winRec->pixmap, param->x - bw, param->y - bw);
} }
} }
SCREEN_UNWRAP(pScreen, PositionWindow);
result = pScreen->PositionWindow(pWin, x, y);
SCREEN_WRAP(pScreen, PositionWindow);
RL_DEBUG_MSG("positionwindow end\n"); RL_DEBUG_MSG("positionwindow end\n");
return result;
} }
/* /*

View File

@ -42,7 +42,7 @@ void RootlessWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr p
void RootlessSetShape(WindowPtr pWin, int kind); void RootlessSetShape(WindowPtr pWin, int kind);
Bool RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask); Bool RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask);
Bool RootlessPositionWindow(WindowPtr pWin, int x, int y); void RootlessWindowPosition(CallbackListPtr *pcbl, ScreenPtr pScreen, XorgScreenWindowPositionParamRec *param);
Bool RootlessRealizeWindow(WindowPtr pWin); Bool RootlessRealizeWindow(WindowPtr pWin);
Bool RootlessUnrealizeWindow(WindowPtr pWin); Bool RootlessUnrealizeWindow(WindowPtr pWin);
void RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib); void RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib);