From 1f0b15e380c306ac5e3ae7d157949ca7dde256f0 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 30 Jan 2025 00:05:52 -0600 Subject: [PATCH 1/5] Provide button rect for min/max animation --- RetroBar/Controls/TaskButton.xaml.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/RetroBar/Controls/TaskButton.xaml.cs b/RetroBar/Controls/TaskButton.xaml.cs index 7e9574fe..b05e9908 100644 --- a/RetroBar/Controls/TaskButton.xaml.cs +++ b/RetroBar/Controls/TaskButton.xaml.cs @@ -94,6 +94,7 @@ private void TaskButton_OnLoaded(object sender, RoutedEventArgs e) if (Window != null) { + Window.GetButtonRect += Window_GetButtonRect; Window.PropertyChanged += Window_PropertyChanged; } @@ -105,6 +106,16 @@ private void TaskButton_OnLoaded(object sender, RoutedEventArgs e) _isLoaded = true; } + private void Window_GetButtonRect(ref NativeMethods.ShortRect rect) + { + Point buttonTopLeft = PointToScreen(new Point(0, 0)); + Point buttonBottomRight = PointToScreen(new Point(ActualWidth, ActualHeight)); + rect.Top = (short)buttonTopLeft.Y; + rect.Left = (short)buttonTopLeft.X; + rect.Bottom = (short)buttonBottomRight.Y; + rect.Right = (short)buttonBottomRight.X; + } + private void Window_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "State") @@ -124,6 +135,7 @@ private void TaskButton_OnUnloaded(object sender, RoutedEventArgs e) if (Window != null) { + Window.GetButtonRect -= Window_GetButtonRect; Window.PropertyChanged -= Window_PropertyChanged; } @@ -141,9 +153,9 @@ private void AppButton_OnContextMenuOpening(object sender, ContextMenuEventArgs int ws = Window.WindowStyles; // disable window operations depending on current window state. originally tried implementing via bindings but found there is no notification we get regarding maximized state - MaximizeMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowMaximized && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0); - MinimizeMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowMinimized && (ws & (int)NativeMethods.WindowStyles.WS_MINIMIZEBOX) != 0); - if (RestoreMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowNormal)) + MaximizeMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowMaximized && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0; + MinimizeMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowMinimized && (ws & (int)NativeMethods.WindowStyles.WS_MINIMIZEBOX) != 0; + if (RestoreMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowNormal) { CloseMenuItem.FontWeight = FontWeights.Normal; RestoreMenuItem.FontWeight = FontWeights.Bold; @@ -154,7 +166,7 @@ private void AppButton_OnContextMenuOpening(object sender, ContextMenuEventArgs RestoreMenuItem.FontWeight = FontWeights.Normal; } MoveMenuItem.IsEnabled = wss == NativeMethods.WindowShowStyle.ShowNormal; - SizeMenuItem.IsEnabled = (wss == NativeMethods.WindowShowStyle.ShowNormal && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0); + SizeMenuItem.IsEnabled = wss == NativeMethods.WindowShowStyle.ShowNormal && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0; } private void CloseMenuItem_OnClick(object sender, RoutedEventArgs e) @@ -189,7 +201,7 @@ private void MaximizeMenuItem_OnClick(object sender, RoutedEventArgs e) private void AppButton_OnClick(object sender, RoutedEventArgs e) { - if (PressedWindowState == ApplicationWindow.WindowState.Active) + if (PressedWindowState == ApplicationWindow.WindowState.Active && Window?.CanMinimize == true) { Window?.Minimize(); } From 11cb7838560619674c119feaa35360dc9a64d4c8 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 30 Jan 2025 01:41:12 -0600 Subject: [PATCH 2/5] Use button on primary monitor on some settings --- RetroBar/Controls/TaskButton.xaml.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RetroBar/Controls/TaskButton.xaml.cs b/RetroBar/Controls/TaskButton.xaml.cs index b05e9908..57649750 100644 --- a/RetroBar/Controls/TaskButton.xaml.cs +++ b/RetroBar/Controls/TaskButton.xaml.cs @@ -108,6 +108,12 @@ private void TaskButton_OnLoaded(object sender, RoutedEventArgs e) private void Window_GetButtonRect(ref NativeMethods.ShortRect rect) { + if (Host?.Host?.Screen.Primary != true && Settings.Instance.MultiMonMode != MultiMonOption.SameAsWindow) + { + // If there are multiple instances of a button, use the button on the primary display only + return; + } + Point buttonTopLeft = PointToScreen(new Point(0, 0)); Point buttonBottomRight = PointToScreen(new Point(ActualWidth, ActualHeight)); rect.Top = (short)buttonTopLeft.Y; From 948c6fd01dee1c1accc19c86e9df1c9119dc49ea Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 30 Jan 2025 22:15:23 -0600 Subject: [PATCH 3/5] Fix type --- RetroBar/Controls/ShowDesktopButton.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RetroBar/Controls/ShowDesktopButton.xaml.cs b/RetroBar/Controls/ShowDesktopButton.xaml.cs index c3318462..72696ecb 100644 --- a/RetroBar/Controls/ShowDesktopButton.xaml.cs +++ b/RetroBar/Controls/ShowDesktopButton.xaml.cs @@ -102,7 +102,7 @@ private void PropertiesItem_OnClick(object sender, RoutedEventArgs e) OpenDisplayPropertiesCpl(); } - private void HandleWindowActivated(object sender, WindowActivatedEventArgs e) + private void HandleWindowActivated(object sender, WindowEventArgs e) { if (ShowDesktop.IsChecked == true) { From feaa2dca881f073511e04ed3545e4d2337b28b07 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 31 Jan 2025 00:12:40 -0600 Subject: [PATCH 4/5] Use consistent logic for minimize enabled --- RetroBar/Controls/TaskButton.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RetroBar/Controls/TaskButton.xaml.cs b/RetroBar/Controls/TaskButton.xaml.cs index 57649750..a0c69602 100644 --- a/RetroBar/Controls/TaskButton.xaml.cs +++ b/RetroBar/Controls/TaskButton.xaml.cs @@ -160,7 +160,7 @@ private void AppButton_OnContextMenuOpening(object sender, ContextMenuEventArgs // disable window operations depending on current window state. originally tried implementing via bindings but found there is no notification we get regarding maximized state MaximizeMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowMaximized && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0; - MinimizeMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowMinimized && (ws & (int)NativeMethods.WindowStyles.WS_MINIMIZEBOX) != 0; + MinimizeMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowMinimized && Window.CanMinimize; if (RestoreMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowNormal) { CloseMenuItem.FontWeight = FontWeights.Normal; From b682240935dbbee4dbcdf4c4b9908125444aa968 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 31 Jan 2025 10:14:21 -0600 Subject: [PATCH 5/5] Update ManagedShell --- RetroBar/RetroBar.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RetroBar/RetroBar.csproj b/RetroBar/RetroBar.csproj index 90a9a526..bd56d9be 100644 --- a/RetroBar/RetroBar.csproj +++ b/RetroBar/RetroBar.csproj @@ -42,7 +42,7 @@ - +