Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minimize/restore animation, update ManagedShell #1030

Merged
merged 6 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RetroBar/Controls/ShowDesktopButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
28 changes: 23 additions & 5 deletions RetroBar/Controls/TaskButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private void TaskButton_OnLoaded(object sender, RoutedEventArgs e)

if (Window != null)
{
Window.GetButtonRect += Window_GetButtonRect;
Window.PropertyChanged += Window_PropertyChanged;
}

Expand All @@ -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")
Expand All @@ -124,6 +141,7 @@ private void TaskButton_OnUnloaded(object sender, RoutedEventArgs e)

if (Window != null)
{
Window.GetButtonRect -= Window_GetButtonRect;
Window.PropertyChanged -= Window_PropertyChanged;
}

Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion RetroBar/RetroBar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<ItemGroup>
<PackageReference Include="gong-wpf-dragdrop" Version="3.1.1" />
<PackageReference Include="ManagedShell" Version="0.0.285" />
<PackageReference Include="ManagedShell" Version="0.0.296" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.2" />
</ItemGroup>

Expand Down