input: Fixes TouchPoint wrong attribute (#2390)

This commit is contained in:
Ac_K 2021-06-23 23:44:09 +02:00 committed by GitHub
parent c71ae9c85c
commit d6b2ac33aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 32 deletions

View file

@ -74,6 +74,8 @@ namespace Ryujinx.Ui
public RendererWidgetBase RendererWidget;
public InputManager InputManager;
public bool IsFocused;
private static bool UseVulkan = false;
#pragma warning disable CS0169, CS0649, IDE0044
@ -157,6 +159,8 @@ namespace Ryujinx.Ui
WindowStateEvent += WindowStateEvent_Changed;
DeleteEvent += Window_Close;
FocusInEvent += MainWindow_FocusInEvent;
FocusOutEvent += MainWindow_FocusOutEvent;
_applicationLibrary.ApplicationAdded += Application_Added;
_applicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated;
@ -272,6 +276,16 @@ namespace Ryujinx.Ui
_fullScreen.Label = args.Event.NewWindowState.HasFlag(Gdk.WindowState.Fullscreen) ? "Exit Fullscreen" : "Enter Fullscreen";
}
private void MainWindow_FocusOutEvent(object o, FocusOutEventArgs args)
{
IsFocused = false;
}
private void MainWindow_FocusInEvent(object o, FocusInEventArgs args)
{
IsFocused = true;
}
private void UpdateColumns()
{
foreach (TreeViewColumn column in _gameTable.Columns)

View file

@ -37,7 +37,6 @@ namespace Ryujinx.Ui
private bool _isActive;
private bool _isStopped;
private bool _isFocused;
private bool _toggleFullscreen;
private bool _toggleDockedMode;
@ -91,8 +90,6 @@ namespace Ryujinx.Ui
| EventMask.KeyPressMask
| EventMask.KeyReleaseMask));
Shown += Renderer_Shown;
_exitEvent = new ManualResetEvent(false);
_hideCursorOnIdle = ConfigurationState.Instance.HideCursorOnIdle;
@ -124,16 +121,6 @@ namespace Ryujinx.Ui
});
}
private void Parent_FocusOutEvent(object o, Gtk.FocusOutEventArgs args)
{
_isFocused = false;
}
private void Parent_FocusInEvent(object o, Gtk.FocusInEventArgs args)
{
_isFocused = true;
}
private void Renderer_Destroyed(object sender, EventArgs e)
{
ConfigurationState.Instance.HideCursorOnIdle.Event -= HideCursorStateChanged;
@ -142,11 +129,6 @@ namespace Ryujinx.Ui
Dispose();
}
private void Renderer_Shown(object sender, EventArgs e)
{
_isFocused = ParentWindow.State.HasFlag(Gdk.WindowState.Focused);
}
protected override bool OnMotionNotifyEvent(EventMotion evnt)
{
if (_hideCursorOnIdle)
@ -341,10 +323,7 @@ namespace Ryujinx.Ui
_isActive = true;
Gtk.Window parent = this.Toplevel as Gtk.Window;
parent.FocusInEvent += Parent_FocusInEvent;
parent.FocusOutEvent += Parent_FocusOutEvent;
Gtk.Window parent = Toplevel as Gtk.Window;
Application.Invoke(delegate
{
@ -445,9 +424,9 @@ namespace Ryujinx.Ui
return false;
}
if (_isFocused)
if ((Toplevel as MainWindow).IsFocused)
{
Gtk.Application.Invoke(delegate
Application.Invoke(delegate
{
KeyboardStateSnapshot keyboard = _keyboardInterface.GetKeyboardStateSnapshot();
@ -465,7 +444,7 @@ namespace Ryujinx.Ui
NpadManager.Update();
if (_isFocused)
if ((Toplevel as MainWindow).IsFocused)
{
KeyboardHotkeyState currentHotkeyState = GetHotkeyState();
@ -481,10 +460,10 @@ namespace Ryujinx.Ui
// Touchscreen
bool hasTouch = false;
// Get screen touch position from left mouse click
if (_isFocused && (_inputManager.MouseDriver as GTK3MouseDriver).IsButtonPressed(MouseButton.Button1))
// Get screen touch position
if ((Toplevel as MainWindow).IsFocused)
{
hasTouch = TouchScreenManager.Update(true, ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as GTK3MouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
}
if (!hasTouch)