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) { diff --git a/RetroBar/Controls/TaskButton.xaml.cs b/RetroBar/Controls/TaskButton.xaml.cs index 7e9574fe..a0c69602 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,22 @@ private void TaskButton_OnLoaded(object sender, RoutedEventArgs e) _isLoaded = true; } + 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; + 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 +141,7 @@ private void TaskButton_OnUnloaded(object sender, RoutedEventArgs e) if (Window != null) { + Window.GetButtonRect -= Window_GetButtonRect; Window.PropertyChanged -= Window_PropertyChanged; } @@ -141,9 +159,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 && Window.CanMinimize; + if (RestoreMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowNormal) { CloseMenuItem.FontWeight = FontWeights.Normal; RestoreMenuItem.FontWeight = FontWeights.Bold; @@ -154,7 +172,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 +207,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(); } 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 @@ - +