Re: Preserved Window Placement



On Wed, 2012-10-24 at 08:28 -0500, Jason Simanek wrote:

> I would think simply preserving the specific absolute position of the 
> windows of the various applications a user regularly employs would be 
> much easier than calculating a dynamic position on the fly every time a 
> new application is launched.

Disclaimer/introduction:  In the past I've said that saving window
geometries is the job of the window manager and shouldn't be done by
applications.  THIS IS WRONG.  I retract myself.  Applications should be
responsible for saving their own window geometries.  This may have been
different when we had working session saving/restoring in the late Gnoem
1.x and early Gnome 2.x releases, but that is no longer the case (not
necessarily a bad thing; session saving/restoring is not as useful as it
may seem.)

Now, for the real explanation.

It would seem that saving window geometries is an easy problem ("for
each window on the screen, save its geometry to some configuration
file").  However, in practice this is hard to do from the window
manager's perspective.

Not every application has a single, uniquely-identifiable window.  That
is, applications have multiple, ambiguously-identified windows.  Window
managers in the past have done some heuristics with the WM_NAME,
WM_CLASS, WM_WINDOW_ROLE properties to distinguish windows.  Not all
software sets these properties to convenient / unique values, so
identifying windows remains hard.

(Applications of course know what their windows are - so they could in
principle save their geometries robustly.  Exercise: what happens when
you have two instances of an application - which one wins?)

Now, we could very well have an easy API that lets applications save
their window geometries easily.  The toolkit could provide a pair of
functions

  char *gtk_window_get_geometry_string (GtkWindow *window);
  gtk_window_restore_geometry_from_string (GtkWindow *window, char *s);

that do all the magic behind figuring out all the values related to
geometry (position, size, flags, etc.), and setting them back.

Then, the "only" problems from the application's point of view is
saving/restoring those geometries at the right time, saving the
(hopefully opaque) strings in the right place, garbage-collecting old
settings, doing something useful when the expected monitor size is
different from the current monitor size, doing something reasonable when
you have two instances of the same application...

  Federico



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