Skip to content

Commit

Permalink
Middle click to close window via thumbnail (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
dremin committed Sep 3, 2022
1 parent fe47b35 commit 5eabbc3
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions Cairo Desktop/Cairo Desktop/TaskThumbnail.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CairoDesktop.Configuration;
using ManagedShell.Common.Helpers;
using ManagedShell.Common.Helpers;
using ManagedShell.Interop;
using ManagedShell.WindowsTasks;
using System;
Expand Down Expand Up @@ -93,6 +92,23 @@ private void DisableThumbnail()
dwmThumbnail.Visibility = Visibility.Collapsed;
}

private void CloseWindow()
{
bool closeThumbWindow = true;

if (ThumbWindow.TaskButton.WindowGroup.Count > 1)
{
closeThumbWindow = false;
}

_window.Close();

if (closeThumbWindow)
{
ThumbWindow.Close();
}
}

private void ThumbWindow_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
SetupThumbnail();
Expand Down Expand Up @@ -162,6 +178,10 @@ private void bdrThumbInner_MouseUp(object sender, MouseButtonEventArgs e)

ThumbWindow.Close();
}
else if (e.ChangedButton == MouseButton.Middle)
{
CloseWindow();
}
}

#region Context menu
Expand Down Expand Up @@ -249,19 +269,7 @@ private void bdrThumbInner_OnMouseLeave(object sender, MouseEventArgs e)

private void Button_Click(object sender, RoutedEventArgs e)
{
bool closeThumbWindow = true;

if (ThumbWindow.TaskButton.WindowGroup.Count > 1)
{
closeThumbWindow = false;
}

_window.Close();

if (closeThumbWindow)
{
ThumbWindow.Close();
}
CloseWindow();
}
}
}

0 comments on commit 5eabbc3

Please sign in to comment.