Skip to content

Commit

Permalink
double click to close, fix window chrome fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
not-nullptr committed Sep 18, 2024
1 parent 23d3fcd commit cb80ffe
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
27 changes: 27 additions & 0 deletions Aerochat/Controls/BasicTitlebar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ protected override void OnInitialized(EventArgs e)
if (Window != null)
{
Window.SourceInitialized += Window_SourceInitialized;
Window.StateChanged += Window_StateChanged;
}
}

private void Window_StateChanged(object? sender, EventArgs e)
{
if (IsDwmEnabled) return;
if (Window.WindowState == WindowState.Maximized)
{
Titlebar.Visibility = Visibility.Collapsed;
WindowChrome.SetWindowChrome(Window, null);
FirstBorder.BorderThickness = new Thickness(0);
SecondBorder.BorderThickness = new Thickness(0);
// set the grid's first row to 0
Container.RowDefinitions[0].Height = new GridLength(0);
}
else
{
Titlebar.Visibility = Visibility.Visible;
WindowChrome chrome = new WindowChrome();
chrome.CaptionHeight = 28;
chrome.CornerRadius = new CornerRadius(6, 6, 0, 0);
chrome.GlassFrameThickness = new Thickness(0);
WindowChrome.SetWindowChrome(Window, chrome);
FirstBorder.BorderThickness = new Thickness(1);
SecondBorder.BorderThickness = new Thickness(1);
Container.RowDefinitions[0].Height = new GridLength(28);
}
}

Expand Down
4 changes: 3 additions & 1 deletion Aerochat/Controls/NoDwmTitlebar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Column="1" Source="{Binding Icon}" />
<Button WindowChrome.IsHitTestVisibleInChrome="True" MouseDoubleClick="Button_MouseDoubleClick" Grid.Column="1" Style="{StaticResource TransparentStyle}">
<Image Source="{Binding Icon}" />
</Button>
<TextBlock Grid.Column="2" Foreground="{Binding TextColor}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" Text="{Binding Title}">
<TextBlock.Style>
<Style TargetType="TextBlock">
Expand Down
6 changes: 6 additions & 0 deletions Aerochat/Controls/NoDwmTitlebar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,11 @@ private void Close_Click(object sender, RoutedEventArgs e)
if (Window.GetWindow(this) is not Window window) return;
window.Close();
}

private void Button_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (Window.GetWindow(this) is not Window window) return;
window.Close();
}
}
}

0 comments on commit cb80ffe

Please sign in to comment.