ds_creamer's picture

Problems with WindowState, WindowBorder, and window size

(I think I put this post in the wrong section)
Hello! I've been trying to implement fullscreen and a custom resize, but I've run into a few problems:

First, GameWindow.Height / Width / Size seem to still suffer from the bugs mentioned in these posts:
node/1457 and node/1081 (The spam filter wouldn't let me post the full URLs, sorry.)

(in testing, Height was always equal to ClientRectangle.Height, and same for Width. I'm using OpenTK 1.0 - 6)

Second, I've experienced a few WindowBorder-related bugs that may be related:
If I call WindowState = WindowState.Fullscreen and then WindowState = WindowState.Normal, the drawing surface (the context?) returns to its normal size and location, but the window border (including title and minimize/maximize/exit buttons) is gone.

The only way I've found to get the border & title back is to call WindowBorder = WindowBorder.Fixed *before* setting WindowState to Normal, and then WindowBorder = WindowBorder.Resizable *after* setting WindowState to Normal.

However, when I do this, the borders are not actually resizable!

I've searched the forums and bug reported and found nothing relevant, except as noted above.

Any ideas or help would be much appreciated. Thanks.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

The spam filter is a bit overzealous esp. on first posts, it usually gets better afterwards.

Am I right in assuming you are on Linux? If so, which distro and desktop environment are you using? Each DE is a little bit different, and if something works on, say, Gnome/Mutter, it will not necessarily work the same way on KDE/KWin.

OpenTK 1.1 beta3 and beta4 contain multiple bugfixes for GameWindow on Linux, including one for the issue at node/1457. Can you please test your application using a local build of opent/develop? There is a chance that the issue are already fixed there.

git clone https://github.com/opentk/opentk
cd opentk
xbuild OpenTK.sln /p:Configuration=Debug

(If you get a build error about a missing "GlobalAssemblyInfo.cs" just execute the xbuild command again. Older versions of mono sometimes have trouble getting the build order right.)

Now you need to remove OpenTK 1.0 from your project references and add OpenTK 1.1 from opentk/Binaries/OpenTK/Debug.

If the issues are still reproducible there, please post a bug report at https://github.com/opentk/opentk/issues with instructions on how to reproduce (including OS, desktop environment and a debug log from MonoDevelop if you are using that.)

ds_creamer's picture

Thanks for the quick reply.

I'm not on Linux at the moment (although I will be making sure it works there, too). This is on Win 7 x64, but I am testing this with Mono.

Now that you reminded me to test both Mono and .NET, I've found two different behaviors:
(Height/ClientRectangle.Height (and Width) are still always equal under both Mono and .NET)

When I remove my hacky WindowBorder code (leaving only WindowState = Fullscreen / Normal), the program works as expected under .NET, but the title/menu/borders disappear under Mono. (The drawing surface/context also grows larger under Mono, but only once. I haven't ruled out a bug in my own code, but I suspect it's not me.)

With the hacky WindowBorder code in place:
On both Mono and .NET, toggling Fullscreen on and off makes the drawing surface/context grow larger EACH time Fullscreen is toggled.
On Mono, the borders become Fixed (or otherwise unresizable) after toggling Fullscreen on and off.
On .NET, it works almost as expected, except for the window growing as mentioned above.

I'll try to find time to test all of this on Linux so that I can report what happens. Thanks.

the Fiddler's picture

I don't see why Mono and .Net are giving different results in this case. Bug report please: https://github.com/opentk/opentk

Widthand Heightare aliases for ClientRectangle.Width and ClientRectangle.Height. This is by design.

Size is an alias for Bounds.Size, which includes the window border. Setting:
Size = new Size(Width, Height) will indeed increase the window size. This is by mis-design. :)

Size, Width and Height should all reflect the size of the drawing area (ClientRectangle). Can you please file another bug report at https://github.com/opentk/opentk?

(Without bug reports these issues will soon drown in the noise.)

ds_creamer's picture

I reported the "no title+borders" bug, and then I discovered what I'd guess to be the source of that bug - WindowBorder always returns Resizable on Mono - so I reported that, too.

(I'm not clear on your statement about Size/Width/Height or what that bug report should contain. Do you just mean that the bug report should say "Size property should alias ClientRectangle instead of Bounds.Size"?)

Thanks.

(oh, one more question: does base.OnResize(e) do anything important, and if so does it matter whether I call it at the beginning or end of any custom resize code?)

the Fiddler's picture

Thanks.

About the Size/Width/Height issue, I misread your post - you actually said this only happens once on Mono, so it's probably part of the same bug that you reported. No need for a separate report then.

You can safely remove the call to base.OnResize(), it is an empty method unless you overload it.