From c6606fee8878e8755d04b61e34bbca817ad76bf7 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 14 Jul 2023 15:13:59 +0800 Subject: [PATCH] fix<*>: PerMonitorDpiAwareV2 not working for ContextMenus on multi-displays with difference DPIs --- src/Views/Widgets/CommitChanges.xaml.cs | 8 ++++---- src/Views/Widgets/CommitDetail.xaml.cs | 2 +- src/Views/Widgets/Dashboard.xaml.cs | 8 ++++---- src/Views/Widgets/DiffViewer.xaml.cs | 2 +- src/Views/Widgets/Histories.xaml.cs | 2 +- src/Views/Widgets/PageTabBar.xaml.cs | 2 +- src/Views/Widgets/RevisionFiles.xaml.cs | 4 ++-- src/Views/Widgets/Stashes.xaml.cs | 2 +- src/Views/Widgets/WorkingCopyChanges.xaml.cs | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Views/Widgets/CommitChanges.xaml.cs b/src/Views/Widgets/CommitChanges.xaml.cs index f8b482cf..8dcf0b05 100644 --- a/src/Views/Widgets/CommitChanges.xaml.cs +++ b/src/Views/Widgets/CommitChanges.xaml.cs @@ -229,8 +229,8 @@ namespace SourceGit.Views.Widgets { }); } - private void OpenChangeContextMenu(Models.Change change) { - var menu = new ContextMenu(); + private void OpenChangeContextMenu(Models.Change change, UIElement placement) { + var menu = new ContextMenu() { PlacementTarget = placement }; var path = change.Path; if (change.Index != Models.Change.Status.Deleted) { @@ -329,7 +329,7 @@ namespace SourceGit.Views.Widgets { var node = item.DataContext as ChangeNode; if (node == null || node.IsFolder) return; - OpenChangeContextMenu(node.Change); + OpenChangeContextMenu(node.Change, item); e.Handled = true; } @@ -340,7 +340,7 @@ namespace SourceGit.Views.Widgets { var change = row.Item as Models.Change; if (change == null) return; - OpenChangeContextMenu(change); + OpenChangeContextMenu(change, row); e.Handled = true; } diff --git a/src/Views/Widgets/CommitDetail.xaml.cs b/src/Views/Widgets/CommitDetail.xaml.cs index 3bf4bc8f..d26af6e8 100644 --- a/src/Views/Widgets/CommitDetail.xaml.cs +++ b/src/Views/Widgets/CommitDetail.xaml.cs @@ -123,7 +123,7 @@ namespace SourceGit.Views.Widgets { } var selectedCount = changeList.SelectedItems.Count; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = row }; if (selectedCount == 1) { var change = changeList.SelectedItems[0] as Models.Change; if (change == null) return; diff --git a/src/Views/Widgets/Dashboard.xaml.cs b/src/Views/Widgets/Dashboard.xaml.cs index 9fde9367..0a17f8bc 100644 --- a/src/Views/Widgets/Dashboard.xaml.cs +++ b/src/Views/Widgets/Dashboard.xaml.cs @@ -614,7 +614,7 @@ namespace SourceGit.Views.Widgets { var node = item.DataContext as BranchNode; if (node == null || node.Type == BranchNodeType.Folder) return; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = item }; if (node.Type == BranchNodeType.Remote) { FillRemoteContextMenu(menu, node.Data as Models.Remote); } else { @@ -1049,7 +1049,7 @@ namespace SourceGit.Views.Widgets { ev.Handled = true; }; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = sender as UIElement }; menu.Items.Add(createBranch); menu.Items.Add(new Separator()); menu.Items.Add(pushTag); @@ -1096,7 +1096,7 @@ namespace SourceGit.Views.Widgets { ev.Handled = true; }; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = sender as UIElement }; menu.Items.Add(copy); menu.Items.Add(rm); menu.IsOpen = true; @@ -1158,7 +1158,7 @@ namespace SourceGit.Views.Widgets { ev.Handled = true; }; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = sender as UIElement }; menu.Items.Add(edit); menu.Items.Add(unlink); menu.Items.Add(new Separator()); diff --git a/src/Views/Widgets/DiffViewer.xaml.cs b/src/Views/Widgets/DiffViewer.xaml.cs index 0bb091ec..755509e4 100644 --- a/src/Views/Widgets/DiffViewer.xaml.cs +++ b/src/Views/Widgets/DiffViewer.xaml.cs @@ -475,7 +475,7 @@ namespace SourceGit.Views.Widgets { var grid = sender as DataGrid; if (grid == null) return; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = grid }; var copyIcon = new Path(); copyIcon.Data = FindResource("Icon.Copy") as Geometry; diff --git a/src/Views/Widgets/Histories.xaml.cs b/src/Views/Widgets/Histories.xaml.cs index 1dde76cd..4bcb61f8 100644 --- a/src/Views/Widgets/Histories.xaml.cs +++ b/src/Views/Widgets/Histories.xaml.cs @@ -248,7 +248,7 @@ namespace SourceGit.Views.Widgets { if (current == null) return; var merged = commit.IsMerged; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = row }; var tags = new List(); // Decorators diff --git a/src/Views/Widgets/PageTabBar.xaml.cs b/src/Views/Widgets/PageTabBar.xaml.cs index 4e049677..681019fc 100644 --- a/src/Views/Widgets/PageTabBar.xaml.cs +++ b/src/Views/Widgets/PageTabBar.xaml.cs @@ -309,7 +309,7 @@ namespace SourceGit.Views.Widgets { var tab = (sender as ListBoxItem).DataContext as Tab; if (tab == null) return; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = sender as UIElement }; var close = new MenuItem(); close.Header = App.Text("PageTabBar.Tab.Close"); diff --git a/src/Views/Widgets/RevisionFiles.xaml.cs b/src/Views/Widgets/RevisionFiles.xaml.cs index aed32501..b25e94ea 100644 --- a/src/Views/Widgets/RevisionFiles.xaml.cs +++ b/src/Views/Widgets/RevisionFiles.xaml.cs @@ -196,7 +196,7 @@ namespace SourceGit.Views.Widgets { var grid = sender as DataGrid; if (grid == null) return; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = grid }; var copyIcon = new System.Windows.Shapes.Path(); copyIcon.Data = FindResource("Icon.Copy") as Geometry; @@ -328,7 +328,7 @@ namespace SourceGit.Views.Widgets { ev.Handled = true; }; - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = item }; menu.Items.Add(history); menu.Items.Add(blame); menu.Items.Add(explore); diff --git a/src/Views/Widgets/Stashes.xaml.cs b/src/Views/Widgets/Stashes.xaml.cs index 90f5e122..118436d9 100644 --- a/src/Views/Widgets/Stashes.xaml.cs +++ b/src/Views/Widgets/Stashes.xaml.cs @@ -67,7 +67,7 @@ namespace SourceGit.Views.Widgets { delete.Header = App.Text("StashCM.Drop"); delete.Click += (o, e) => new Popups.StashDropConfirm(repo, stash.Name, stash.Message).Show(); - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = sender as UIElement }; menu.Items.Add(apply); menu.Items.Add(pop); menu.Items.Add(delete); diff --git a/src/Views/Widgets/WorkingCopyChanges.xaml.cs b/src/Views/Widgets/WorkingCopyChanges.xaml.cs index 0caf8963..4b961233 100644 --- a/src/Views/Widgets/WorkingCopyChanges.xaml.cs +++ b/src/Views/Widgets/WorkingCopyChanges.xaml.cs @@ -868,7 +868,7 @@ namespace SourceGit.Views.Widgets { GetChangesFromNode(o as ChangeNode, changes); } - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = sender as UIElement }; if (IsUnstaged) { OpenUnstagedContextMenuByNodes(menu, nodes, changes); } else { @@ -900,7 +900,7 @@ namespace SourceGit.Views.Widgets { } } - var menu = new ContextMenu(); + var menu = new ContextMenu() { PlacementTarget = row }; if (IsUnstaged) { OpenUnstagedContextMenuByChanges(menu, changes); } else {