XResizeWindow

Kristian Benoit kbenoit at matrox.com
Mon Dec 6 14:13:06 PST 2004


Owen Taylor wrote:

>On Fri, 2004-12-03 at 15:54 -0500, Kristian Benoit wrote:
>  
>
>>Kristian Benoit wrote:
>>
>>    
>>
>>>Kristian Benoit wrote:
>>>
>>>      
>>>
>>>>I want to know when a resize comme from XResizeWindow or from the 
>>>>user resizing the window by hand, but cant find any way to do it. 
>>>>Anyone know how to do that ?
>>>>
>>>>        
>>>>
>>>I found a way !!! :)
>>>
>>>XSendEvent({client message "Start Resizing"});
>>>XResizeWindow(...);
>>>XSendEvent({client message "Stop Resizing"});
>>>XFlush();
>>>
>>>Then I know If the resize comme from me !!! :)
>>>
>>>      
>>>
>>That does not seem to work as I always get the ConfigureNotify before 
>>the Start Resizing client message. Even if I sync just before XResizeWindow.
>>Any idea on how to make sure the client message get queued before the 
>>ConfigureNotify ?
>>    
>>
>
>I sort of doubt you'll get the ConfigureNotify first. I don't see
>how that could happen. Maybe you are actually getting the
>ConfigureNotify for a *previous* resize?
>
>Anyways, I would suggest that it's actually not well defined:
>
> - Your window is 100x100
> - You XResizeWindow to 150x150
> - The user grabs the window and resizes to 150x150
> - You get a ConfigureNotify from the user resize
> - The window manager processes your request and sends a
>   synthetic ConfigureNotify because it didn't do anything
>
>When you get the first ConfigureNotify from the user resize, there 
>is no way to tell that it isn't from your request.
>
>You can tell that a new size *wasn't* from a XResizeWindow (because
>you've gotten replies for every request you've made). You can't tell
>that a new size *is* from a XResizeWindow.
>
>I would suggest that in general a properly written program shouldn't
>care where a resize comes from. 
>
>GTK+ does a little bit of optimization - if it knows that it has sent
>out three ConfigureRequests and only has gotten two replies back,
>it will wait for the third reply before processing the new size.
>
>But if the user starts resizing the window at the same time, it will
>process at the third ConfigureNotify even if it's from the user's
>resize.
>
>Regards,
>						Owen
>  
>
Thanks a lot for your help, I managed to do it this way:

XSendEvent({client message "Start Resizing"});
XResizeWindow(...);
XFlush(...);
...
util (XNextEvent(...) == {client message "Start Resizing"})
XSendEvent({client message "Stop Resizing"});

And treat every resize between the start/stop resizing client message as called by me. There is a small possibility that I get some user resize in there, but in my case I better have a few user resize treated as software resize than the opposite.
By the way, that is not my code, I'm porting a window app and must imitate the behaviour. Owen is right dont do that kind of ugly stuff if you dont really need to !!!

Kristian Benoit. 



-- 
Kristian Benoit (Matrox Imaging)
kbenoit at matrox.com
(514) 822-6000 ext. 7225




More information about the xorg mailing list