From f8f23bf8999f5e4e2ead01b797c31353267ce815 Mon Sep 17 00:00:00 2001
From: Ac_K <Acoustik666@gmail.com>
Date: Thu, 19 Nov 2020 01:34:28 +0100
Subject: [PATCH] gui: Toggle Docked/Handheld mode and VSync by clicking status
 bar (#1726)

* gui: Toggle between docked/handheld mode by clicking status bar

This PR just add a way to toggle between the docked and the handheld mode by clicking the lable in the status bar.
Nothing more.

* Fix glade file formatting

* Add VSync toggle
---
 Ryujinx/Ui/MainWindow.cs    | 14 ++++++++++++--
 Ryujinx/Ui/MainWindow.glade | 34 +++++++++++++++++++++++++---------
 2 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs
index b1ab2bdff6..6bcb4235d2 100644
--- a/Ryujinx/Ui/MainWindow.cs
+++ b/Ryujinx/Ui/MainWindow.cs
@@ -117,9 +117,9 @@ namespace Ryujinx.Ui
                 End(null);
             }
 
-            _virtualFileSystem = VirtualFileSystem.CreateInstance();
+            _virtualFileSystem      = VirtualFileSystem.CreateInstance();
             _userChannelPersistence = new UserChannelPersistence();
-            _contentManager    = new ContentManager(_virtualFileSystem);
+            _contentManager         = new ContentManager(_virtualFileSystem);
 
             if (migrationNeeded)
             {
@@ -848,6 +848,16 @@ namespace Ryujinx.Ui
             LoadApplication(path);
         }
 
+        private void VSyncStatus_Clicked(object sender, ButtonReleaseEventArgs args)
+        {
+            _emulationContext.EnableDeviceVsync = !_emulationContext.EnableDeviceVsync;
+        }
+
+        private void DockedMode_Clicked(object sender, ButtonReleaseEventArgs args)
+        {
+            ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
+        }
+
         private void Row_Clicked(object sender, ButtonReleaseEventArgs args)
         {
             if (args.Event.Button != 3) return;
diff --git a/Ryujinx/Ui/MainWindow.glade b/Ryujinx/Ui/MainWindow.glade
index 87946e20b8..1dbec21365 100644
--- a/Ryujinx/Ui/MainWindow.glade
+++ b/Ryujinx/Ui/MainWindow.glade
@@ -470,13 +470,21 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkLabel" id="_vSyncStatus">
+                      <object class="GtkEventBox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="halign">start</property>
-                        <property name="margin_left">5</property>
-                        <property name="margin_right">5</property>
-                        <property name="label" translatable="yes">VSync</property>
+                        <property name="margin_left">0</property>
+                        <signal name="button-release-event" handler="VSyncStatus_Clicked" swapped="no"/>
+                        <child>
+                          <object class="GtkLabel" id="_vSyncStatus">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="halign">start</property>
+                            <property name="margin_left">5</property>
+                            <property name="margin_right">5</property>
+                            <property name="label" translatable="yes">VSync</property>
+                          </object>
+                        </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -496,12 +504,20 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="_dockedMode">
+                      <object class="GtkEventBox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="halign">start</property>
-                        <property name="margin_left">5</property>
-                        <property name="margin_right">5</property>
+                        <property name="margin_left">0</property>
+                        <signal name="button-release-event" handler="DockedMode_Clicked" swapped="no"/>
+                        <child>
+                          <object class="GtkLabel" id="_dockedMode">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="halign">start</property>
+                            <property name="margin_left">5</property>
+                            <property name="margin_right">5</property>
+                          </object>
+                        </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>