[PATCH] shadowfb: Fix initialization

Michael Thayer michael.thayer at oracle.com
Wed May 21 07:04:17 PDT 2014


On 21/05/14 15:23, Adam Jackson wrote:
> This has to run at initial CreateWindow time, at CreateScreenResources
> the root window doesn't actually exist yet.
>
> Tested-by: Michael Thayer <michael.thayer at oracle.com>
> Signed-off-by: Adam Jackson <ajax at redhat.com>

I'm not an expert in that area of the code, but I did also go over the 
actual content of the patch.  So:

Reviewed-by: Michael Thayer <michael.thayer at oracle.com>

> ---
>   hw/xfree86/shadowfb/shadow.c | 26 +++++++++++++++-----------
>   1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
> index 10f72cc..d2481ed 100644
> --- a/hw/xfree86/shadowfb/shadow.c
> +++ b/hw/xfree86/shadowfb/shadow.c
> @@ -29,14 +29,14 @@
>   #include "picturestr.h"
>
>   static Bool ShadowCloseScreen(ScreenPtr pScreen);
> -static Bool ShadowCreateScreenResources(ScreenPtr pScreen);
> +static Bool ShadowCreateRootWindow(WindowPtr pWin);
>
>   typedef struct {
>       ScrnInfoPtr pScrn;
>       RefreshAreaFuncPtr preRefresh;
>       RefreshAreaFuncPtr postRefresh;
>       CloseScreenProcPtr CloseScreen;
> -    CreateScreenResourcesProcPtr CreateScreenResources;
> +    CreateWindowProcPtr CreateWindow;
>   } ShadowScreenRec, *ShadowScreenPtr;
>
>   static DevPrivateKeyRec ShadowScreenKeyRec;
> @@ -71,10 +71,10 @@ ShadowFBInit2(ScreenPtr pScreen,
>       pPriv->postRefresh = postRefreshArea;
>
>       pPriv->CloseScreen = pScreen->CloseScreen;
> -    pPriv->CreateScreenResources = pScreen->CreateScreenResources;
> +    pPriv->CreateWindow = pScreen->CreateWindow;
>
>       pScreen->CloseScreen = ShadowCloseScreen;
> -    pScreen->CreateScreenResources = ShadowCreateScreenResources;
> +    pScreen->CreateWindow = ShadowCreateRootWindow;
>
>       return TRUE;
>   }
> @@ -117,16 +117,21 @@ shadowfbReportPost(DamagePtr damage, RegionPtr reg, void *closure)
>   }
>
>   static Bool
> -ShadowCreateScreenResources(ScreenPtr pScreen)
> +ShadowCreateRootWindow(WindowPtr pWin)
>   {
>       Bool ret;
> -    WindowPtr pWin = pScreen->root;
> +    ScreenPtr pScreen = pWin->drawable.pScreen;
>       ShadowScreenPtr pPriv = shadowfbGetScreenPrivate(pScreen);
>
> -    pScreen->CreateScreenResources = pPriv->CreateScreenResources;
> -    ret = pScreen->CreateScreenResources(pScreen);
> -    pPriv->CreateScreenResources = pScreen->CreateScreenResources;
> -    pScreen->CreateScreenResources = ShadowCreateScreenResources;
> +    /* paranoia */
> +    if (pWin != pScreen->root)
> +        ErrorF("ShadowCreateRootWindow called unexpectedly\n");
> +
> +    /* call down, but don't hook ourselves back in; we know the first time
> +     * we're called it's for the root window.
> +     */
> +    pScreen->CreateWindow = pPriv->CreateWindow;
> +    ret = pScreen->CreateWindow(pWin);
>
>       /* this might look like it leaks, but the damage code reaps listeners
>        * when their drawable disappears.
> @@ -159,7 +164,6 @@ ShadowCloseScreen(ScreenPtr pScreen)
>       ShadowScreenPtr pPriv = shadowfbGetScreenPrivate(pScreen);
>
>       pScreen->CloseScreen = pPriv->CloseScreen;
> -    pScreen->CreateScreenResources = pPriv->CreateScreenResources;
>
>       free(pPriv);
>
>


-- 
ORACLE Deutschland B.V. & Co. KG   Michael Thayer
Werkstrasse 24                     VirtualBox engineering
71384 Weinstadt, Germany           mailto:michael.thayer at oracle.com

Hauptverwaltung: Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603
Geschäftsführer: Jürgen Kunz

Komplementärin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Astrid Kepper, Val Maher


More information about the xorg-devel mailing list