X11 Window Resizing Stutters

X11 window resizing stutters

https://tronche.com/gui/x/xlib/events/window-state-change/configure.html

https://tronche.com/gui/x/xlib/events/structure-control/resize.html

From what I can read from those two links ConfigureNotify happens when a change has completed. ResizeRequest happens when a resize is attempted. Specifically:

The X server can report ResizeRequest events to clients wanting
information about another client's attempts to change the size of a
window.

I don´t like the sound of "CAN report", but I suppose you should give it a shot. Don´t forget to set proper event bit as instructed in the link. As for what you should do when capturing event I´m not too sure... I would clear the front buffer and await resize to complete.

X11 in C++ - Cropping happens whenever ResizeRedirectMask is set when the window is resized

ResizeRedirectMask is irrelevant for your purposes. You never want it unless you are writing a window manager. You need StructureNotifyMask. You should virtually always select this mask (maybe unless your window never gets resized).

If you do not select StructureNotifyMask, your window never gets actual resize events and does not get a chance to respond to them.

When you get a ConfigureNotify event, which will only happen if you select StructureNotifyMask, it will contain the new actual geometry, so your window can update itself.

X11 Window isn't updating/drawing automatically

   The XNextEvent function copies the first event from the event queue into the
specified XEvent structure and then removes it from the queue. If the event
queue is empty, XNextEvent flushes the output buffer and blocks until an event
is received.

So, your call to XNextEvent waits until some event happens, and only then redraws. Worse, it redraws on every event, so if multiple events happen, you'll only know that after several frames.

You should use XCheckWindowEvent instead, and re-organise your loop (handle all events first, then render).

Fail to display any image via X11

Having a blank window is the correct behaviour for calling X11(). Usually, you won't need to call that function, but it means that you can specify how tall/wide the plot window is before you create a plot.

If you still have a blank window after you try and plot something, then you are probably writing to a different device.

Have you opened another device (maybe with png, etc.) and forgotten to close it?

What does dev.cur() return?

A reproducible example of this:

png("foo.png")
x11()
dev.set(dev.list()[names(dev.list()) == "png:foo.png"])
plot(1:10)

#Make sure you call this afterwards
graphics.off()


Related Topics



Leave a reply



Submit