[patch:SDL] Window default position

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

[patch:SDL] Window default position

#1 Post by Mitten.O »

Geoff the Medio wrote:In the SDL / SDK branch build, it's mostly running OK on Windows in windowed mode.

As seen in the attached, though, it always creates the window such that the title bar is above the top of the screen, and the left side is hidden under the taskbar I've got at the left side due to poorly-designed laptop aspect ratio. It should be appearing by default to the right of the taskbar, and so that the window title bar is visible.
Here is a patch that moves the definition of the default window geometry to HumanClientApp, which is allows the default position to be set to a constant that tells SDL to let the window manager decide. The downside is that the user will see this numerical constant in the settings window. Does this fix the window positioning?
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: [patch:SDL] Window default position

#2 Post by Geoff the Medio »

With this patch, the default position for the top-left of the window is the centre of the screen. This is not an improvement...

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: [patch:SDL] Window default position

#3 Post by Mitten.O »

Here is a version that centers the window by default. Better?
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: [patch:SDL] Window default position

#4 Post by Geoff the Medio »

Somewhat better, but the window top bar is off the screen so I can't move the window around...
Attachments
default window position
default window position
sdl_window_position.png (501.87 KiB) Viewed 2176 times

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: [patch:SDL] Window default position

#5 Post by Mitten.O »

That is not centered. I'm telling it to be centered, but it is not. Sigh...

New version: center it horizontally, and hard code 100 as the top position. A bit stupid, but a reasonable default if it works, I think.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: [patch:SDL] Window default position

#6 Post by Geoff the Medio »

That defaults to a too-low position...
Attachments
another default window position
another default window position
sdl_window_pos.png (501.11 KiB) Viewed 2169 times

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: [patch:SDL] Window default position

#7 Post by adrian_broher »

Why don't you let the window manager decide?

Pass SDL_WINDOWPOS_UNDEFINED as initial default. If the user wants to place it somewhere else then he can still drag it.

Edit: I see you already tried that in a previous patch. Did you check if you still get SDL_WINDOWPOS_UNDEFINED as value when you pull it out of the OptionsDB?
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: [patch:SDL] Window default position

#8 Post by Mitten.O »

Didn't test that precisely, but the constant makes the window behave as expected on linux and the settings window shows a very large number that seems like the sort of number the constant ought to be.
Any code by me in this post is released under GPL 2.0 or later.

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: [patch:SDL] Window default position

#9 Post by Vezzra »

The second and third version of the patch (sdl_default_window_pos_centered and sdl_default_window_pos.2) work perfectly on OSX. Both solve the issue that when maximizing the FO window, after exiting and restarting it is resized to a minimum size and put in the upper left corner of the screen. With these patches applied, that doesn't happen anymore, the FO window is restored exactly at the size it had when you exited FO the last time.

I'm very much in favor of committing this patch (after the issues on Windows have been resolved).

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: [patch:SDL] Window default position

#10 Post by Mitten.O »

Geoff the Medio wrote:That defaults to a too-low position...
Well, it's always gonna be a bit off for someone. The main point is that the bar with which you can drag it to a good place is visible along with some edge that lets you resize it. Nonetheless, 100 may make this phenomenon unnecessarily common. I lowered it to 50. That should still avoid being below a possible top bar.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: [patch:SDL] Window default position

#11 Post by Geoff the Medio »

What version is patch 3 relative to? I don't have the lines being changed in HumanClientApp.cpp

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: [patch:SDL] Window default position

#12 Post by Mitten.O »

Sorry, I accidentally left one of the commits that are part of this patch out. Here should be a working version.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: [patch:SDL] Window default position

#13 Post by Geoff the Medio »

Better. It doesn't seem to put the window where I left it when I exit and restart...
before exiting
before exiting
before.jpg (73.58 KiB) Viewed 2137 times
after restarting
after restarting
after.jpg (71.81 KiB) Viewed 2137 times
Not a major issue, really, but annoying...

However, it also doesn't save and restore the window size if I resize it small enough to actually fit on my (relatively small) laptop screen.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: [patch:SDL] Window default position

#14 Post by adrian_broher »

Geoff the Medio wrote:Better. It doesn't seem to put the window where I left it when I exit and restart...
before.jpg
after.jpg
Not a major issue, really, but annoying...

However, it also doesn't save and restore the window size if I resize it small enough to actually fit on my (relatively small) laptop screen.
Could you please provide the value of the x and y position over a series of restarts? I suspect that we have different point of origins when calling SDL_CreateWindow and SDL_GetPosition. One function seems to consider the window decorations and the other one doesn't.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: [patch:SDL] Window default position

#15 Post by Geoff the Medio »

adrian_broher wrote:Could you please provide the value of the x and y position over a series of restarts?
After a fresh start (no config.xml present), config.xml has:

Code: Select all

  <app-height>768</app-height>
  <app-height-windowed>745</app-height-windowed>
  <app-left-windowed>805240832</app-left-windowed>
  <app-top-windowed>50</app-top-windowed>
  <app-width>1024</app-width>
  <app-width-windowed>1024</app-width-windowed>
After restarting, config.xml is apparently unchanged. After resizing the window and moving it around, the width and height values in the options screen have changed, but the left and top values haven't. After exiting, config.xml has:

Code: Select all

  <app-height>768</app-height>
  <app-height-windowed>725</app-height-windowed>
  <app-left-windowed>805240832</app-left-windowed>
  <app-top-windowed>50</app-top-windowed>
  <app-width>1024</app-width>
  <app-width-windowed>1277</app-width-windowed>
After restarting, it appears that the top of 50 is used, and the window is centred on the whole screen horizontally, not portion of the screen to the right of the taskbar (which is at the left) so that the left edge of the window is under the taskbar, but there's empty space to the right of the window.

Post Reply