Re: Checking success/failure of window resizes



Dave Neary <dneary eircom net> writes:
> 
> In gtk+/gdk/gdkwindow.c (gdk_window_resize) there's a call to
> XResizeWindow() which works mostly - but there have been a few
> bugs reported in unusual circumstances in the Gimp which get
> traced to this function.
> 
> There are hacks to get around this, but it would certainly be
> nice if we could verify whether a call to XResizeWindow were
> successful or not. 

(All following discussion is for window-managed toplevel windows; the
resize is guaranteed to succeeed for override redirect or child
windows.)

What gdk_window_resize() does is send a "request for resize" to the
window manager. The window manager can do whatever it feels like;
actually resize, resize differently, etc. Most will resize as
requested, though you can't know for sure.

The way you detect success is to get back a GdkEventConfigure with the
new size, and see if it's the size you wanted, basically. There's no
concept of "success" here because the request isn't considered
mandatory to begin with. (And any idea of "success" would have race
conditions - because even if the request is honored, the size could be
quickly changed again.) So the long and short of it is, anything that
depends on toplevel window size should be done in response to a
configure_event signal, and should be able to handle whatever size
comes through to configure_event.

You mentioned BadWindow, so maybe you mean "success" as in "was the
window valid" - if you have a valid GdkWindow, it will be valid on the
X side, unless GDK_WINDOW_DESTROYED(window). So you can just check
whether it's destroyed.

Havoc





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]