[Xquartz-dev] XRandR update

Jeremy Huddleston jeremyhu at apple.com
Sat Jul 17 12:45:52 PDT 2010


Hi Jan,

On Jul 17, 2010, at 09:00, Jan Hauffa wrote:

> I apologize for the lack of communication from my side. The problem of
> enabling/disabling rootless mode when changing the screen resolution
> turned out to be more complicated than expected, and only recently did I
> find the time to investigate further.

Thanks for getting back to me.  I was starting to wonder if everything was alright.  I've reviewed the patches and applied them (with the rootless change broken out into a separate patch) to my server-1.9-apple git branch for anyone who is interested in testing.  I haven't done much testing beyond 'xrandr -s 1' and 'xrandr -s 0'


> If a client requests this screen mode, rootless mode is
> enabled, for all other modes it is disabled.

Great.  This seems like the way we want to go.


> The problem I was struggling with is that if the screen resolution was
> changed while the root window was visible, the server would crash. When
> the resolution is changed, he event handler in darwinEvents.c calls
> QuartzUpdateScreens, which resizes the root window and fills it with the
> background color. To resize the window, RootlessWindowResize is called,
> which contains a special case for resizing the root window:
> xprResizeFrame is not called for the root window, so the subsequent call
> to xprStartDrawing will return a pointer to a buffer that is smaller
> than expected.


Hmm... I'm surprised we haven't run into this before.  I just did a quick test on the existing code without your change, and found indeed:

1) Put the display preferences in the menu bar and set X11's preferences so you can access the menu bar in fullscreen mode
2) Set the resolution of your screen lower than normal.
3) Start X11 in fullscreen mode.  The root window will cover the screen as expected.
4) Use the menu bar to increase the resolution of the display.  The root window will now cover the old area and not the full screen, but 'xwininfo -root' will report the full width.
5) Run 'xsetroot -solid red', and we have the crash you mention above.

Leaving/entering fullscreen after #4 will fix the problem.  This is because the WINREC is erased when we leave fullscreen mode and it is recreated upon re-entry:

RootlessUpdateRooted(FALSE)
    RootlessDisableRoot(screenInfo.screens[0])
        RootlessDestroyFrame (pRoot, winRec);
RootlessUpdateRooted(TRUE)
    RootlessEnableRoot(screenInfo.screens[0])
        RootlessEnsureFrame(screenInfo.screens[0]->pRoot)
            creates a new WINREC...

> I have implemented two methods of working around this problem: The first
> patch (0002-<...>.patch) simply makes RootlessWindowResize call
> xprResizeFrame. This is the most straightforward approach, but it adds
> an "ifdef XQUARTZ" block to unrelated code.


I think that this issue should be dealt with in a separate patch applicable to everyone.  I'll run it by the XMinGW / XCygwin guys to see what they think, but this issue really a dependency of this Changeset rather than a part of it.  I've CC'd you on this correspondence.

> The only alternative, as far as I can see, is to destroy the root window
> before changing the screen resolution, and to ensure that a new root
> window of correct size is created afterwards. As you can see in patch
> "alt-0002-<...>.patch", this makes the logic in
> QuartzRandRSetConfiguration rather complex.
> 
> Perhaps I'm just missing an obvious solution, as I've been staring at
> this code for too long...

No, you just stumbled upon a bug which has existed for eons that nobody else seems to have found. =)

Thanks,
Jeremy




More information about the Xquartz-dev mailing list