Some fixes for the new GLRenderer (#930)

* Some fixes for the new GLRenderer

Changelog:
- Fix transparency of the window on some games on Windows.
- Fix escape key not being able to exit emulation.
- Fix inverted logic in fullscreen event handling.
- Fix a race condition when stoping emulation causing a hang.
- Fix a memory leak of the OpenGL context when stoping emulation (saving ~200MB of RAM when stoping emulation).
- Simplify and document behaviours when exiting the emulator while the
emulation is running.

* Make sure to clear alpha channel when presenting Texture

This fix once and for all the transparency issue on Windows.

* Enforce footer bar size to avoid gl widget to get resized to 1280x724

* Fix full screen inversion in MainWindow and make sure _listStatusBox don't come back when not needed

* Remove previous transparency clear attempt that is useless now

* Remove an extra line return
This commit is contained in:
Thog 2020-02-13 18:43:29 +01:00 committed by GitHub
parent 8d83878f67
commit 416ddd0f6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 72 deletions

View file

@ -53,7 +53,7 @@ namespace Ryujinx.Ui
private Input.NpadController _primaryController;
public GLRenderer(Switch device)
: base (new GraphicsMode(new ColorFormat(24)),
: base (new GraphicsMode(new ColorFormat()),
3, 3,
GraphicsContextFlags.ForwardCompatible)
{
@ -63,6 +63,7 @@ namespace Ryujinx.Ui
this.Initialized += GLRenderer_Initialized;
this.Destroyed += GLRenderer_Destroyed;
this.ShuttingDown += GLRenderer_ShuttingDown;
Initialize();
@ -81,6 +82,11 @@ namespace Ryujinx.Ui
this.Shown += Renderer_Shown;
}
private void GLRenderer_ShuttingDown(object sender, EventArgs args)
{
Exit();
}
private void Parent_FocusOutEvent(object o, Gtk.FocusOutEventArgs args)
{
IsFocused = false;
@ -93,9 +99,7 @@ namespace Ryujinx.Ui
private void GLRenderer_Destroyed(object sender, EventArgs e)
{
Exit();
this.Dispose();
Dispose();
}
protected void Renderer_Shown(object sender, EventArgs e)
@ -106,41 +110,38 @@ namespace Ryujinx.Ui
public void HandleScreenState(KeyboardState keyboard)
{
bool toggleFullscreen = keyboard.IsKeyDown(OpenTK.Input.Key.F11)
|| ((keyboard.IsKeyDown(OpenTK.Input.Key.AltLeft)
|| keyboard.IsKeyDown(OpenTK.Input.Key.AltRight))
&& keyboard.IsKeyDown(OpenTK.Input.Key.Enter));
|| ((keyboard.IsKeyDown(OpenTK.Input.Key.AltLeft)
|| keyboard.IsKeyDown(OpenTK.Input.Key.AltRight))
&& keyboard.IsKeyDown(OpenTK.Input.Key.Enter))
|| keyboard.IsKeyDown(OpenTK.Input.Key.Escape);
if (toggleFullscreen == _toggleFullscreen)
bool fullScreenToggled = ParentWindow.State.HasFlag(Gdk.WindowState.Fullscreen);
if (toggleFullscreen != _toggleFullscreen)
{
return;
if (toggleFullscreen)
{
if (fullScreenToggled)
{
ParentWindow.Unfullscreen();
(Toplevel as MainWindow)?.ToggleExtraWidgets(true);
}
else
{
if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape))
{
Exit();
}
else
{
ParentWindow.Fullscreen();
(Toplevel as MainWindow)?.ToggleExtraWidgets(false);
}
}
}
}
_toggleFullscreen = toggleFullscreen;
Gtk.Application.Invoke(delegate
{
if (this.ParentWindow.State.HasFlag(Gdk.WindowState.Fullscreen))
{
if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape) || _toggleFullscreen)
{
this.ParentWindow.Unfullscreen();
(this.Toplevel as MainWindow)?.ToggleExtraWidgets(true);
}
}
else
{
if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape))
{
Exit();
}
if (_toggleFullscreen)
{
this.ParentWindow.Fullscreen();
(this.Toplevel as MainWindow)?.ToggleExtraWidgets(false);
}
}
});
}
private void GLRenderer_Initialized(object sender, EventArgs e)