Skip to content

Going from/to maximized/fullscreen is buggy #1094

Closed
@aybe

Description

@aybe

Summary

Maximize the window, go full screen, try go back, it's stuck.

But if you quickly switch to normal before going full screen, it works; try change bug to false.

Also, the value of window state is wrong sometimes, it doesn't always follow the actual state of the window.

Steps to reproduce

For desktop, version 2.16.0

using System.Drawing;
using Silk.NET.Input;
using Silk.NET.OpenGL;
using Silk.NET.Windowing;

// ReSharper disable AccessToDisposedClosure

namespace Silk_Test;

internal static class Program
{
    private static void Main(string[] args)
    {
        var bug = true; // try change this

        using var window = Window.Create(WindowOptions.Default);

        // ReSharper disable once RedundantAssignment
        IInputContext input = null!;
        GL gl = null!;

        window.Load += () =>
        {
            gl = window.CreateOpenGL();
            input = window.CreateInput();
            input.Keyboards[0].KeyDown += OnKeyDown;
        };

        void OnKeyDown(IKeyboard keyboard, Key key, int code)
        {
            if (keyboard.IsKeyPressed(Key.AltLeft) && keyboard.IsKeyPressed(Key.Enter))
            {
                if (bug)
                {
                    switch (window.WindowState)
                    {
                        case WindowState.Normal:
                            window.WindowState = WindowState.Fullscreen;
                            break;
                        case WindowState.Minimized:
                            break;
                        case WindowState.Maximized:
                            window.WindowState = WindowState.Fullscreen;
                            break;
                        case WindowState.Fullscreen:
                            window.WindowState = WindowState.Normal;
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
                else
                {
                    switch (window.WindowState)
                    {
                        case WindowState.Normal:
                            window.WindowState = WindowState.Fullscreen;
                            break;
                        case WindowState.Minimized:
                            break;
                        case WindowState.Maximized:
                            window.WindowState = WindowState.Normal;
                            window.WindowState = WindowState.Fullscreen;
                            break;
                        case WindowState.Fullscreen:
                            window.WindowState = WindowState.Normal;
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
            }

            if (keyboard.IsKeyPressed(Key.Escape))
                window.Close();
        }

        window.Render += d =>
        {
            var color = window.WindowState switch
            {
                WindowState.Normal => Color.Red,
                WindowState.Minimized => Color.Green,
                WindowState.Maximized => Color.Blue,
                WindowState.Fullscreen => Color.White,
                _ => throw new ArgumentOutOfRangeException()
            };
            gl.ClearColor(color);
            gl.Clear(ClearBufferMask.ColorBufferBit);
        };

        window.Run();
    }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy