Re: Alignment of multiple top-level windows



Havoc Pennington wrote:
On Thu, 2005-12-29 at 05:09 +1100, Russell Shaw wrote:

Hi,
How can i enforce the relative arrangement of multiple top-level
X windows in an ICCCM compliant way? I want this arrangement of
three windows on startup:

You have to first map the menubar and wait for the WM to set the
_NET_FRAME_EXTENTS property (you must synchronously block until the
menubar is shown). Then you can read the position and frame extents of
the menubar. Position the panel based on that, and again synchronously
block to see where the WM puts it and how large the frame is. With these
numbers you can then position the work area. The user will see the three
windows map one, two, three instead of all at once; there's no way I
know of to avoid that because if you don't synchronously wait for the
windows to map, you will have a race condition where you might read the
position or frame extents prior to them being set to their final values.
gtk_widget_show_now() is probably good enough for blocking
synchronously. I don't remember if there's a gdk call for getting frame
extents.

If you do the above, newer WMs that support _NET_FRAME_EXTENTS and that
have "typical" window placement policies will work. Older ICCCM-only
WMs, and more unusual WMs, will not work. There's no sane way to do this
with ICCCM only, you need the newer _NET_FRAME_EXTENTS property.

Hi,
The problem is that the WM may auto-place the first small window (the menubar)
at a non-optimal place such as near the center of the screen.

More weight needs to be hinted that it should be put near the top-left
corner of the screen.

I propose a new EWMH application window property size hint,
something like:

  _NET_WM_APP_EXTENTS, width, height, CARDINAL[2]/32

where width and height specify an area that all the long-term top-level
windows of an application should fit within, on app startup.

Every top-level window that should be aligned relative to other windows
of the same app nearby should also have the same _NET_WM_APP_EXTENTS
setting.

So for the menubar which is the application main window and group leader,
_NET_WM_APP_EXTENTS would be set to the extents of the whole app such as
800x600, and the same for the other windows.

The whole idea is that as each of the three windows are placed, the WM
can make the same assumptions for positioning, because it then knows
that the relative window positioning is important.

In the ICCCM XSizeHints structure, x and y are marked obsolete.
These should be put to use so that they're interpreted as the
required positioning of each window relative to the top-left
(or depending on gravity) corner of the _NET_WM_APP_EXTENTS
frame.

When the first window is mapped, it will get a notify event to say
what the actual size of the window is. The app can then scale this
size to the whole app layout for placing the other windows, and those
windows will be guaranteed not to be resized by the WM if they also
have the same _NET_WM_APP_EXTENTS set on them.

I see the gimp could use this after trying the latest version
just now (under icewm).

+----------------------------------------------------+
|                      Menubar                       |
+----------------------------------------------------+
+-----+ +--------------------------------------------+
|     | |                                            |
|  P  | |                                            |
|  a  | |                                            |
|  n  | |           Work area                        |
|  e  | |                                            |
|  l  | |                                            |
|     | |                                            |
|     | |                                            |
|     | |                                            |
|     | |                                            |
|     | |                                            |
|     | |                                            |
|     | |                                            |
|     | |                                            |
+-----+ +--------------------------------------------+



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