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:
parent
9dad5500ac
commit
669391f477
|
@ -48,6 +48,8 @@
|
||||||
#ifndef _COMPINT_H_
|
#ifndef _COMPINT_H_
|
||||||
#define _COMPINT_H_
|
#define _COMPINT_H_
|
||||||
|
|
||||||
|
#include "dix/screen_hooks_priv.h"
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "scrnintstr.h"
|
#include "scrnintstr.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
|
@ -82,9 +82,6 @@ DbeStubScreen(DbeScreenPrivPtr pDbeScreenPriv, int *nStubbedScreens)
|
||||||
/* Stub DIX. */
|
/* Stub DIX. */
|
||||||
pDbeScreenPriv->SetupBackgroundPainter = NULL;
|
pDbeScreenPriv->SetupBackgroundPainter = NULL;
|
||||||
|
|
||||||
/* Do not unwrap PositionWindow. If the DDX initialization function failed,
|
|
||||||
we assume that it did not wrap PositionWindow. */
|
|
||||||
|
|
||||||
/* Stub DDX. */
|
/* Stub DDX. */
|
||||||
pDbeScreenPriv->GetVisualInfo = NULL;
|
pDbeScreenPriv->GetVisualInfo = NULL;
|
||||||
pDbeScreenPriv->AllocBackBufferName = NULL;
|
pDbeScreenPriv->AllocBackBufferName = NULL;
|
||||||
|
@ -1226,7 +1223,7 @@ DbeResetProc(ExtensionEntry * extEntry)
|
||||||
|
|
||||||
if (pDbeScreenPriv) {
|
if (pDbeScreenPriv) {
|
||||||
dixScreenUnhookWindowDestroy(pScreen, miDbeWindowDestroy);
|
dixScreenUnhookWindowDestroy(pScreen, miDbeWindowDestroy);
|
||||||
pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
|
dixScreenUnhookWindowPosition(pScreen, miDbeWindowPosition);
|
||||||
free(pDbeScreenPriv);
|
free(pDbeScreenPriv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1341,7 +1338,7 @@ DbeExtensionInit(void)
|
||||||
|
|
||||||
if (ddxInitSuccess) {
|
if (ddxInitSuccess) {
|
||||||
/* Hook in our window destructor. The DDX initialization function
|
/* Hook in our window destructor. The DDX initialization function
|
||||||
* already wrapped PositionWindow for us.
|
* already added WindowPosition hook for us.
|
||||||
*/
|
*/
|
||||||
dixScreenHookWindowDestroy(pScreen, miDbeWindowDestroy);
|
dixScreenHookWindowDestroy(pScreen, miDbeWindowDestroy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,11 +169,6 @@ typedef struct _DbeWindowPrivRec {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _DbeScreenPrivRec {
|
typedef struct _DbeScreenPrivRec {
|
||||||
/* Wrapped functions
|
|
||||||
* It is the responsibility of the DDX layer to wrap PositionWindow().
|
|
||||||
*/
|
|
||||||
PositionWindowProcPtr PositionWindow;
|
|
||||||
|
|
||||||
/* Per-screen DIX routines */
|
/* Per-screen DIX routines */
|
||||||
Bool (*SetupBackgroundPainter) (WindowPtr /*pWin */ ,
|
Bool (*SetupBackgroundPainter) (WindowPtr /*pWin */ ,
|
||||||
GCPtr /*pGC */
|
GCPtr /*pGC */
|
||||||
|
|
69
dbe/midbe.c
69
dbe/midbe.c
|
@ -381,7 +381,7 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
|
||||||
* - miDbeAllocBackBufferName() calls FreeResource() to clean up resources
|
* - miDbeAllocBackBufferName() calls FreeResource() to clean up resources
|
||||||
* after a buffer allocation failure.
|
* 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() when it fails to create buffers of the new size.
|
||||||
* FreeResource() is called for all DBE buffer IDs.
|
* FreeResource() is called for all DBE buffer IDs.
|
||||||
*
|
*
|
||||||
|
@ -431,22 +431,20 @@ miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId)
|
||||||
if (pDbeWindowPriv->pBackBuffer)
|
if (pDbeWindowPriv->pBackBuffer)
|
||||||
dixDestroyPixmap(pDbeWindowPriv->pBackBuffer, 0);
|
dixDestroyPixmap(pDbeWindowPriv->pBackBuffer, 0);
|
||||||
} /* miDbeWinPrivDelete() */
|
} /* miDbeWinPrivDelete() */
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* DBE MI Procedure: miDbePositionWindow
|
* DBE MI Procedure: miDbeWindowPosition
|
||||||
*
|
*
|
||||||
* Description:
|
* 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.
|
* This function resizes the buffer when the window is resized.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
static Bool
|
void miDbeWindowPosition(CallbackListPtr *pcbl, ScreenPtr pScreen, XorgScreenWindowPositionParamRec *param)
|
||||||
miDbePositionWindow(WindowPtr pWin, int x, int y)
|
|
||||||
{
|
{
|
||||||
ScreenPtr pScreen;
|
|
||||||
DbeScreenPrivPtr pDbeScreenPriv;
|
DbeScreenPrivPtr pDbeScreenPriv;
|
||||||
DbeWindowPrivPtr pDbeWindowPriv;
|
DbeWindowPrivPtr pDbeWindowPriv;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
@ -459,43 +457,9 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
|
||||||
Bool clear;
|
Bool clear;
|
||||||
GCPtr pGC;
|
GCPtr pGC;
|
||||||
xRectangle clearRect;
|
xRectangle clearRect;
|
||||||
Bool ret;
|
|
||||||
|
|
||||||
/*
|
WindowPtr pWin = param->window;
|
||||||
**************************************************************************
|
|
||||||
** 1. Unwrap the member routine.
|
|
||||||
**************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
pScreen = pWin->drawable.pScreen;
|
|
||||||
pDbeScreenPriv = DBE_SCREEN_PRIV(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))) {
|
if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
|
||||||
return ret;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (pDbeWindowPriv->width == pWin->drawable.width &&
|
if (pDbeWindowPriv->width == pWin->drawable.width &&
|
||||||
pDbeWindowPriv->height == pWin->drawable.height) {
|
pDbeWindowPriv->height == pWin->drawable.height)
|
||||||
return ret;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
width = pWin->drawable.width;
|
width = pWin->drawable.width;
|
||||||
height = pWin->drawable.height;
|
height = pWin->drawable.height;
|
||||||
|
@ -594,7 +556,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeScratchGC(pGC);
|
FreeScratchGC(pGC);
|
||||||
return FALSE;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -644,11 +606,8 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
|
||||||
|
|
||||||
FreeScratchGC(pGC);
|
FreeScratchGC(pGC);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
} /* miDbePositionWindow() */
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* DBE MI Procedure: miDbeInit
|
* DBE MI Procedure: miDbeInit
|
||||||
|
@ -662,9 +621,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
|
||||||
Bool
|
Bool
|
||||||
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
|
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
|
||||||
{
|
{
|
||||||
/* Wrap functions. */
|
dixScreenHookWindowPosition(pScreen, miDbeWindowPosition);
|
||||||
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
|
|
||||||
pScreen->PositionWindow = miDbePositionWindow;
|
|
||||||
|
|
||||||
/* Initialize the per-screen DBE function pointers. */
|
/* Initialize the per-screen DBE function pointers. */
|
||||||
pDbeScreenPriv->GetVisualInfo = miDbeGetVisualInfo;
|
pDbeScreenPriv->GetVisualInfo = miDbeGetVisualInfo;
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
#ifndef MIDBE_H
|
#ifndef MIDBE_H
|
||||||
#define MIDBE_H
|
#define MIDBE_H
|
||||||
|
|
||||||
#include "privates.h"
|
#include "dix/screen_hooks_priv.h"
|
||||||
|
#include "include/privates.h"
|
||||||
|
|
||||||
/* EXTERNS */
|
/* EXTERNS */
|
||||||
|
|
||||||
|
@ -53,4 +54,6 @@ extern DevPrivateKeyRec dbeWindowPrivKeyRec;
|
||||||
extern RESTYPE dbeDrawableResType;
|
extern RESTYPE dbeDrawableResType;
|
||||||
extern RESTYPE dbeWindowPrivResType;
|
extern RESTYPE dbeWindowPrivResType;
|
||||||
|
|
||||||
|
void miDbeWindowPosition(CallbackListPtr *pcbl, ScreenPtr pScreen, XorgScreenWindowPositionParamRec *param);
|
||||||
|
|
||||||
#endif /* MIDBE_H */
|
#endif /* MIDBE_H */
|
||||||
|
|
|
@ -40,6 +40,9 @@ int dixScreenRaiseWindowDestroy(WindowPtr pWin)
|
||||||
|
|
||||||
void dixScreenRaiseWindowPosition(WindowPtr pWin, uint32_t x, uint32_t y)
|
void dixScreenRaiseWindowPosition(WindowPtr pWin, uint32_t x, uint32_t y)
|
||||||
{
|
{
|
||||||
|
if (!pWin)
|
||||||
|
return;
|
||||||
|
|
||||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||||
|
|
||||||
XorgScreenWindowPositionParamRec param = {
|
XorgScreenWindowPositionParamRec param = {
|
||||||
|
|
Loading…
Reference in New Issue