From: Dave Airlie <[email protected]>

This is a port of "composite: use config notify hook to do pixmap resize"
to Xorg 1.7, it avoids breaking ABI and just adds a register callback to hook
config notify into the resize window path for composite only.

Signed-off-by: Dave Airlie <[email protected]>
---
 composite/compinit.c   |   14 +----
 composite/compint.h    |   23 ++------
 composite/compwindow.c |  158 ++++++++++--------------------------------------
 dix/window.c           |   16 +++++
 include/window.h       |   11 +++
 5 files changed, 65 insertions(+), 157 deletions(-)

diff --git a/composite/compinit.c b/composite/compinit.c
index e8b563d..b95ef35 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -69,9 +69,6 @@ compCloseScreen (int index, ScreenPtr pScreen)
     pScreen->InstallColormap = cs->InstallColormap;
     pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
     pScreen->ReparentWindow = cs->ReparentWindow;
-    pScreen->MoveWindow = cs->MoveWindow;
-    pScreen->ResizeWindow = cs->ResizeWindow;
-    pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
     
     pScreen->ClipNotify = cs->ClipNotify;
     pScreen->UnrealizeWindow = cs->UnrealizeWindow;
@@ -362,15 +359,6 @@ compScreenInit (ScreenPtr pScreen)
     cs->ClipNotify = pScreen->ClipNotify;
     pScreen->ClipNotify = compClipNotify;
 
-    cs->MoveWindow = pScreen->MoveWindow;
-    pScreen->MoveWindow = compMoveWindow;
-
-    cs->ResizeWindow = pScreen->ResizeWindow;
-    pScreen->ResizeWindow = compResizeWindow;
-
-    cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
-    pScreen->ChangeBorderWidth = compChangeBorderWidth;
-
     cs->ReparentWindow = pScreen->ReparentWindow;
     pScreen->ReparentWindow = compReparentWindow;
 
@@ -389,6 +377,6 @@ compScreenInit (ScreenPtr pScreen)
     dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs);
 
     RegisterRealChildHeadProc(CompositeRealChildHead);
-
+    RegisterCompositeConfigNotifyProc(compConfigNotify);
     return TRUE;
 }
diff --git a/composite/compint.h b/composite/compint.h
index 845a196..d6a5536 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -126,14 +126,7 @@ typedef struct _CompScreen {
     RealizeWindowProcPtr       RealizeWindow;
     UnrealizeWindowProcPtr     UnrealizeWindow;
     ClipNotifyProcPtr          ClipNotify;
-    /*
-     * Called from ConfigureWindow, these
-     * three track changes to the offscreen storage
-     * geometry
-     */
-    MoveWindowProcPtr          MoveWindow;
-    ResizeWindowProcPtr                ResizeWindow;
-    ChangeBorderWidthProcPtr   ChangeBorderWidth;
+
     /*
      * Reparenting has an effect on Subwindows redirect
      */
@@ -280,16 +273,6 @@ void
 compClipNotify (WindowPtr pWin, int dx, int dy);
 
 void
-compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind);
-
-void
-compResizeWindow (WindowPtr pWin, int x, int y,
-                 unsigned int w, unsigned int h, WindowPtr pSib);
-
-void
-compChangeBorderWidth (WindowPtr pWin, unsigned int border_width);
-
-void
 compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
 
 Bool
@@ -316,4 +299,8 @@ CompositeRealChildHead (WindowPtr pWin);
 int
 DeleteWindowNoInputDevices(pointer value, XID wid);
 
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+                int bw, WindowPtr pSib);
+
 #endif /* _COMPINT_H_ */
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 2f5a717..a895885 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -335,132 +335,6 @@ compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
 }
 
 void
-compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
-{
-    ScreenPtr          pScreen = pWin->drawable.pScreen;
-    CompScreenPtr      cs = GetCompScreen (pScreen);
-
-    compCheckTree (pScreen);
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-       WindowPtr               pParent;
-       int                     draw_x, draw_y;
-       unsigned int            w, h, bw;
-
-       /* if this is a root window, can't be moved */
-       if (!(pParent = pWin->parent))
-          return;
-
-       bw = wBorderWidth (pWin);
-       draw_x = pParent->drawable.x + x + (int)bw;
-       draw_y = pParent->drawable.y + y + (int)bw;
-       w = pWin->drawable.width;
-       h = pWin->drawable.height;
-       compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-    }
-    compCheckTree (pScreen);
-
-    pScreen->MoveWindow = cs->MoveWindow;
-    (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
-    cs->MoveWindow = pScreen->MoveWindow;
-    pScreen->MoveWindow = compMoveWindow;
-
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-       CompWindowPtr   cw = GetCompWindow (pWin);
-       if (cw->pOldPixmap)
-       {
-           (*pScreen->DestroyPixmap) (cw->pOldPixmap);
-           cw->pOldPixmap = NullPixmap;
-       }
-    }
-
-    compCheckTree (pScreen);
-}
-
-void
-compResizeWindow (WindowPtr pWin, int x, int y,
-                 unsigned int w, unsigned int h, WindowPtr pSib)
-{
-    ScreenPtr          pScreen = pWin->drawable.pScreen;
-    CompScreenPtr      cs = GetCompScreen (pScreen);
-
-    compCheckTree (pScreen);
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-       WindowPtr               pParent;
-       int                     draw_x, draw_y;
-       unsigned int            bw;
-
-       /* if this is a root window, can't be moved */
-       if (!(pParent = pWin->parent))
-          return;
-
-       bw = wBorderWidth (pWin);
-       draw_x = pParent->drawable.x + x + (int)bw;
-       draw_y = pParent->drawable.y + y + (int)bw;
-       compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-    }
-    compCheckTree (pScreen);
-
-    pScreen->ResizeWindow = cs->ResizeWindow;
-    (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
-    cs->ResizeWindow = pScreen->ResizeWindow;
-    pScreen->ResizeWindow = compResizeWindow;
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-       CompWindowPtr   cw = GetCompWindow (pWin);
-       if (cw->pOldPixmap)
-       {
-           (*pScreen->DestroyPixmap) (cw->pOldPixmap);
-           cw->pOldPixmap = NullPixmap;
-       }
-    }
-    compCheckTree (pWin->drawable.pScreen);
-}
-
-void
-compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
-{
-    ScreenPtr          pScreen = pWin->drawable.pScreen;
-    CompScreenPtr      cs = GetCompScreen (pScreen);
-
-    compCheckTree (pScreen);
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-       WindowPtr               pParent;
-       int                     draw_x, draw_y;
-       unsigned int            w, h;
-
-       /* if this is a root window, can't be moved */
-       if (!(pParent = pWin->parent))
-          return;
-
-       draw_x = pWin->drawable.x;
-       draw_y = pWin->drawable.y;
-       w = pWin->drawable.width;
-       h = pWin->drawable.height;
-       compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-    }
-    compCheckTree (pScreen);
-
-    pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
-    (*pScreen->ChangeBorderWidth) (pWin, bw);
-    cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
-    pScreen->ChangeBorderWidth = compChangeBorderWidth;
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-       CompWindowPtr   cw = GetCompWindow (pWin);
-       if (cw->pOldPixmap)
-       {
-           (*pScreen->DestroyPixmap) (cw->pOldPixmap);
-           cw->pOldPixmap = NullPixmap;
-       }
-    }
-    compCheckTree (pWin->drawable.pScreen);
-}
-
-void
 compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
 {
     ScreenPtr          pScreen = pWin->drawable.pScreen;
@@ -822,3 +696,35 @@ CompositeRealChildHead (WindowPtr pWin)
        return pChildBefore;
     }
 }
+
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+                int bw, WindowPtr pSib)
+{
+    ScreenPtr          pScreen = pWin->drawable.pScreen;
+    WindowPtr          pParent = pWin->parent;
+    CompWindowPtr       cw;
+    int                        draw_x, draw_y;
+    Bool alloc_ret;
+
+    if (pWin->redirectDraw == RedirectDrawNone)
+       return Success;
+
+    compCheckTree (pScreen);
+
+    draw_x = pParent->drawable.x + x + bw;
+    draw_y = pParent->drawable.y + y + bw;
+    alloc_ret = compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+    
+    cw = GetCompWindow (pWin);
+    if (cw->pOldPixmap)
+    {
+       (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+       cw->pOldPixmap = NullPixmap;
+    }
+    compCheckTree (pScreen);
+
+    if (alloc_ret == FALSE)
+       return BadAlloc;
+    return Success;
+}
diff --git a/dix/window.c b/dix/window.c
index 2676a54..f21119d 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -2102,6 +2102,13 @@ ReflectStackChange(
        WindowsRestructured ();
 }
 
+static compositeConfigNotifyProcPtr compositeConfigNotify;
+void
+RegisterCompositeConfigNotifyProc(compositeConfigNotifyProcPtr proc)
+{
+    compositeConfigNotify = proc;
+}
+
 /*****
  * ConfigureWindow
  *****/
@@ -2218,6 +2225,15 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, 
ClientPtr client)
     else
        pSib = pWin->nextSib;
 
+    if (compositeConfigNotify)
+    {
+       int ret;
+       ret = compositeConfigNotify(pWin, x, y, w, h, bw, pSib);
+       if (ret) {
+           client->errorValue = 0;
+           return ret;
+       }
+    }
 
     if ((!pWin->overrideRedirect) && 
        (RedirectSend(pParent)
diff --git a/include/window.h b/include/window.h
index 6fb2f8c..ea2edab 100644
--- a/include/window.h
+++ b/include/window.h
@@ -266,4 +266,15 @@ extern _X_EXPORT void DisableMapUnmapEvents(
 extern _X_EXPORT void EnableMapUnmapEvents(
     WindowPtr /* pWin */ );
 
+typedef int (* compositeConfigNotifyProcPtr)(
+    WindowPtr /* pWin */,
+    int /* x */,
+    int /* y */,
+    int /* w */,
+    int /* h */,
+    int /* bw */,
+    WindowPtr /*pSib*/);
+
+_X_EXPORT void RegisterCompositeConfigNotifyProc(compositeConfigNotifyProcPtr 
proc);
+
 #endif /* WINDOW_H */
-- 
1.6.5.2

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to