Window Resizing: seeking clarification - Xwindows
This is a discussion on Window Resizing: seeking clarification - Xwindows ; Hi,
I've recently joined the wonderful world of X programming, and I've run
into a little stumbling block. I have a window which I've successfully
reparented and resized. I'm just not sure why it works. I've been through
the ICCCM ...
-
Window Resizing: seeking clarification
Hi,
I've recently joined the wonderful world of X programming, and I've run
into a little stumbling block. I have a window which I've successfully
reparented and resized. I'm just not sure why it works. I've been through
the ICCCM documentation (which is how I got the program to work) but I'm
still a little fuzzy on the concepts. I was hoping someone will shed some
light on the problem. Here's what I'm doing:
1. I create a window of size 800x600 (call it window A)
2. I start a copy of mplayer (a movie player) which plays a 320x240 movie
3. I reparent the mplayer window to window A successfully.
4. I use XResizeWindow() to resize the mplayer window to 640x480
Result: The border of the mplayer window shows that it's been resized to
640x480, but the movie still only occupies 320x240 of the 640x480 window.
So I went thru the ICCCM documentation and discovered WM_NORMAL_HINTS, and
with it, the XSetWMSizeHints() function. Now I do the following:
1. Create the 800x600 window
2. Start mplayer
3. Reparent
4. Set the base width and height with XSetWMSizeHints()
5. Run XResizeWindow()
and it works like I want. These are the things I dont understand fully:
1. What's the purpose of XResizeWindow() if there's a XSetWMSizeHints() ?
After reading the docs, I thought that just using XSetWMSizeHints() would
be sufficient, but I still needed XResizeWindow(). So what exactly does
XSetWMSizeHints() do? I changed the base width and height values used in
XSetWMSizeHints() to several values and they all worked. So I'm pretty
confused about XSetWMSizeHints()' role in the whole setup
2. I tried first changing the window size then reparenting, but this didnt
work. I have a few suspicions as to why this might be, but I'm not
sure. Can anyone clarify? If I reparent after resizing, X windows
crashes
Any explanations for the above will be appreciated.
Thanks in advance
kodgehopper
-
Re: Window Resizing: seeking clarification
In article ,
kodgehopper wrote:
>1. What's the purpose of XResizeWindow() if there's a XSetWMSizeHints() ?
> After reading the docs, I thought that just using XSetWMSizeHints() would
> be sufficient, but I still needed XResizeWindow(). So what exactly does
> XSetWMSizeHints() do? I changed the base width and height values used in
> XSetWMSizeHints() to several values and they all worked. So I'm pretty
> confused about XSetWMSizeHints()' role in the whole setup
XSetWMSizeHints is used by a window manager to tell the application "Please
change your window size". XResizeWindow is used by the application to tell
the X server the new size of the window -- either in response to the
request from the window manager or due to something internal to the
application.
--
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
-
Re: Window Resizing: seeking clarification
kodgehopper wrote:
>
> 1. What's the purpose of XResizeWindow() if there's a XSetWMSizeHints() ?
> After reading the docs, I thought that just using XSetWMSizeHints() would
> be sufficient, but I still needed XResizeWindow(). So what exactly does
> XSetWMSizeHints() do? I changed the base width and height values used in
> XSetWMSizeHints() to several values and they all worked. So I'm pretty
> confused about XSetWMSizeHints()' role in the whole setup
When there is a window manager (WM) present it manages window states
positions and sizes. WM's provide controls in their decorations that
allow users to change these attributes outside the context of the
application that "owns" the windows.
If XResizeWindow() is used on an application the resize request is
redirected by the X server to the WM who registers itself as interested
in those redirections when it asserts itself as the WM. The WM decides
whether or not to grant the request based on it's configuration and
what it thinks the user wants.
What XSetWMSizeHints() does is provide the client a mechanism to let
the WM know that it is the user who is requesting this change which
gives the request more weight since the WM recognizes that the client
is not contradicting the user.
So when you don't call XSetWMSizeHints() your WM thinks what you are
requesting is contrary to what the user wants. When you call it you
follow the convention of communicating to the WM that the user asked
you to do this. It's kind of ugly but that's basically how it works.
> 2. I tried first changing the window size then reparenting, but this didnt
> work. I have a few suspicions as to why this might be, but I'm not
> sure. Can anyone clarify? If I reparent after resizing, X windows
> crashes
Crash == bug
-- ced
>
> Any explanations for the above will be appreciated.
>
> Thanks in advance
>
> kodgehopper
--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.
-
Re: Window Resizing: seeking clarification
Barry Margolin wrote:
> XSetWMSizeHints is used by a window manager to tell the application "Please
> change your window size". XResizeWindow is used by the application to tell
> the X server the new size of the window -- either in response to the
> request from the window manager or due to something internal to the
> application.
The other way round: With XSetWMSizeHints() the application tells the WM,
what sizes are useful. The XResizeWindow() request is intercepted by the
WM and adjusted regarding to the hints and implemented policy. The
application is ConfigureNotifiy'd about the new dimensions.
Regards,
Daniel
-
Re: Window Resizing: seeking clarification
Chuck Dillon wrote:
> kodgehopper wrote:
Cit from the OP:
| 1. Create the 800x600 window
| 2. Start mplayer
| 3. Reparent
| 4. Set the base width and height with XSetWMSizeHints()
| 5. Run XResizeWindow()
|
| and it works like I want. These are the things I dont understand fully:
>> 1. What's the purpose of XResizeWindow() if there's a XSetWMSizeHints()
[explanation of wm communication]
You forgot the point, that the window in question is already reparented
and is no longer under control of the window manager.
| 1. I create a window of size 800x600 (call it window A)
| 2. I start a copy of mplayer (a movie player) which plays a 320x240
| movie
| 3. I reparent the mplayer window to window A successfully.
| 4. I use XResizeWindow() to resize the mplayer window to 640x480
|
| Result: The border of the mplayer window shows that it's been resized to
| 640x480, but the movie still only occupies 320x240 of the 640x480 window.
From the X view you succeeded, but the application doesn't respond. It's
most likely the mplayer code, which only works (as expected, without
workarounds) when being a toplevel window.
Regards,
Daniel
-
Re: Window Resizing: seeking clarification
Daniel Rakel wrote:
> [explanation of wm communication]
>
> You forgot the point, that the window in question is already reparented
> and is no longer under control of the window manager.
I'll admit my X skills are a bit rusty but as far as I know
reparenting does not necessarily take the WM out of the picture. Even
if the WM decides to drop control of the window when it gets a reparent
event there is a race condition as to whether or not it will see a
resize request. At any rate there's room in there for the WM to be
mucking things up.
I'm assuming the WM is in play since the OP doesn't state otherwise and
the WM hints affect the outcome.
-- ced
--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.