Application window geometry specifier

Igor Korot ikorot01 at gmail.com
Tue Jan 12 18:02:01 EST 2021


Chris,

On Tue, Jan 12, 2021 at 4:38 PM Chris Angelico <rosuav at gmail.com> wrote:
>
> On Wed, Jan 13, 2021 at 9:30 AM Igor Korot <ikorot01 at gmail.com> wrote:
> >
> > Not sure I follow - frame is a TLW. Dialog is a TLW.
> > Program flow is as follows:
> >
> > 1. Program starts with a frame
> > 2. At some point the user asks to connect to the database.
> > 3. Credentials dialog is shown.
> >
> > Now, while frame is TLW and may follow the renderer rules, the dialog
> > that vask the user for credentials should not.
> >
> > Now, system dialog should probably follow the rules of the WM, but if I want my
> > dialog to appear centered on the parent (not on the screen) - what
> > right the WM have
> > to override it?
> >
> > I also think that ALL dialogs are TLWs independently of whether they
> > are created with
> > the actual parent (frame) or a null-parent (desktop).
> > In regards that they are not buttons/list controls/toolbars/etc.
>
> In one sense you're right, but in another, the creation of a window
> with a parent is very different from the creation of a window without
> a parent. The WM will handle them differently because the user will
> expect them to behave differently. In fact, centering on the parent is
> a very likely position, so don't worry about it - just declare your
> parent correctly.

For the dialog (as well as any other TLW), it should be no difference.
Because if I pass a "parent" as NULL, it means I have a parent as a
"Desktop" window.

That's why frames and dialogs are called TLWs - they don't have to
have an "explicit" parent.

>
> > Are you talking about geometry or a position?
> > For me geometry is a complex thing - position, size of the window and
> > the client size
> > of the window (which is important especially in *nix).
>
> The size of the window is generally governed by its contents, so
> that's under the application's control (within limits set by the WM).
> The position, though, is up to the WM.

And what about client size?
Because if we are talking about *nix (which I think we are) you should
count decorations.

>
> > > > > (That's actually a 100% realistic scenario, given that I'm usually on
> > > > > my desktop system, but occasionally I'll be on my laptop, SSH'd in
> > > > > with X11 forwarding.)
> > > >
> > > > Absolutely.
> > > > I found myself in this situation recently - when I'm in the office I
> > > > have 2 external
> > > > monitors, and when I am at home - I only have a laptop.
> > > > And windows are showing on the primary all the time.
> > > >
> > >
> > > Right! That's the WM's job. Let it do its job, and everyone's lives
> > > will be easier.
> >
> > Well, please re-read my initial statement.
> > You can't decide where to put that credential dialog. It has to appear
> > in the middle
> > of the screen (if there is 1 - on it, if multiple - on the screen
> > where the main frame is).
> >
> > DO you see the problem with that?
>
> Yes, I see a problem with the application trying to remember where the
> dialog was last time. A MAJOR problem. Restoring the dialog's geometry
> might have it completely off screen, or at best, in a position that is
> decidedly unideal. But if you let the WM decide where the dialog
> should be placed, it's guaranteed to be where the user expects it (or
> more precisely, it's guaranteed to be consistent with every *other*
> application that also behaves like this, and the user has the power to
> configure this).

In this particular case there is no need to remember - credentials
dialog need to appear
at the center of the monitor 0 and they should be sized accordingly.

Now here are the scenarios I'm looking at:

1. Program starts - credentials dialog is shown. The parent of this
dialog is "Desktop" window.
It is better to be displayed in the center of the "Monitor 0".
2. Program start - frame is shown. I agree that it is best to let the
WM decide its position.
At some point of time I need to connect to the DB and so credential
dialog is shown.
In this scenario this dialog should also be shown "Monitor 0" centered.
3. Start with scenario 2. Resize the frame and exit the application.
Attach the new monitor.
Start the application again. Frame will probably appear on "Monitor 0"
(depending on the WM rules).
Start the DB connection. The credentials dialog should appear centered
on the screen where the frame is.

As you can see none of those scenarios include system dialogs
(open/save, font selection, etc).
They has to follow system/WM rules and appear as appropriate. Because
they are system based
and user code shouldn't say anything about their positioning.

But for my dialogs (especially for dialogs where I need to ask for
credentials) - I don't think I want
WM to do my job.

Again - we are talking positioning here and not size/client size.

Thank you.

>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list