fix<*>: PerMonitorDpiAwareV2 not working for ContextMenus on multi-displays with difference DPIs

This commit is contained in:
leo 2023-07-14 15:13:59 +08:00
parent 611d3c7db0
commit c6606fee88
9 changed files with 17 additions and 17 deletions

View file

@ -229,8 +229,8 @@ namespace SourceGit.Views.Widgets {
}); });
} }
private void OpenChangeContextMenu(Models.Change change) { private void OpenChangeContextMenu(Models.Change change, UIElement placement) {
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = placement };
var path = change.Path; var path = change.Path;
if (change.Index != Models.Change.Status.Deleted) { if (change.Index != Models.Change.Status.Deleted) {
@ -329,7 +329,7 @@ namespace SourceGit.Views.Widgets {
var node = item.DataContext as ChangeNode; var node = item.DataContext as ChangeNode;
if (node == null || node.IsFolder) return; if (node == null || node.IsFolder) return;
OpenChangeContextMenu(node.Change); OpenChangeContextMenu(node.Change, item);
e.Handled = true; e.Handled = true;
} }
@ -340,7 +340,7 @@ namespace SourceGit.Views.Widgets {
var change = row.Item as Models.Change; var change = row.Item as Models.Change;
if (change == null) return; if (change == null) return;
OpenChangeContextMenu(change); OpenChangeContextMenu(change, row);
e.Handled = true; e.Handled = true;
} }

View file

@ -123,7 +123,7 @@ namespace SourceGit.Views.Widgets {
} }
var selectedCount = changeList.SelectedItems.Count; var selectedCount = changeList.SelectedItems.Count;
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = row };
if (selectedCount == 1) { if (selectedCount == 1) {
var change = changeList.SelectedItems[0] as Models.Change; var change = changeList.SelectedItems[0] as Models.Change;
if (change == null) return; if (change == null) return;

View file

@ -614,7 +614,7 @@ namespace SourceGit.Views.Widgets {
var node = item.DataContext as BranchNode; var node = item.DataContext as BranchNode;
if (node == null || node.Type == BranchNodeType.Folder) return; if (node == null || node.Type == BranchNodeType.Folder) return;
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = item };
if (node.Type == BranchNodeType.Remote) { if (node.Type == BranchNodeType.Remote) {
FillRemoteContextMenu(menu, node.Data as Models.Remote); FillRemoteContextMenu(menu, node.Data as Models.Remote);
} else { } else {
@ -1049,7 +1049,7 @@ namespace SourceGit.Views.Widgets {
ev.Handled = true; ev.Handled = true;
}; };
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = sender as UIElement };
menu.Items.Add(createBranch); menu.Items.Add(createBranch);
menu.Items.Add(new Separator()); menu.Items.Add(new Separator());
menu.Items.Add(pushTag); menu.Items.Add(pushTag);
@ -1096,7 +1096,7 @@ namespace SourceGit.Views.Widgets {
ev.Handled = true; ev.Handled = true;
}; };
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = sender as UIElement };
menu.Items.Add(copy); menu.Items.Add(copy);
menu.Items.Add(rm); menu.Items.Add(rm);
menu.IsOpen = true; menu.IsOpen = true;
@ -1158,7 +1158,7 @@ namespace SourceGit.Views.Widgets {
ev.Handled = true; ev.Handled = true;
}; };
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = sender as UIElement };
menu.Items.Add(edit); menu.Items.Add(edit);
menu.Items.Add(unlink); menu.Items.Add(unlink);
menu.Items.Add(new Separator()); menu.Items.Add(new Separator());

View file

@ -475,7 +475,7 @@ namespace SourceGit.Views.Widgets {
var grid = sender as DataGrid; var grid = sender as DataGrid;
if (grid == null) return; if (grid == null) return;
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = grid };
var copyIcon = new Path(); var copyIcon = new Path();
copyIcon.Data = FindResource("Icon.Copy") as Geometry; copyIcon.Data = FindResource("Icon.Copy") as Geometry;

View file

@ -248,7 +248,7 @@ namespace SourceGit.Views.Widgets {
if (current == null) return; if (current == null) return;
var merged = commit.IsMerged; var merged = commit.IsMerged;
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = row };
var tags = new List<string>(); var tags = new List<string>();
// Decorators // Decorators

View file

@ -309,7 +309,7 @@ namespace SourceGit.Views.Widgets {
var tab = (sender as ListBoxItem).DataContext as Tab; var tab = (sender as ListBoxItem).DataContext as Tab;
if (tab == null) return; if (tab == null) return;
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = sender as UIElement };
var close = new MenuItem(); var close = new MenuItem();
close.Header = App.Text("PageTabBar.Tab.Close"); close.Header = App.Text("PageTabBar.Tab.Close");

View file

@ -196,7 +196,7 @@ namespace SourceGit.Views.Widgets {
var grid = sender as DataGrid; var grid = sender as DataGrid;
if (grid == null) return; if (grid == null) return;
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = grid };
var copyIcon = new System.Windows.Shapes.Path(); var copyIcon = new System.Windows.Shapes.Path();
copyIcon.Data = FindResource("Icon.Copy") as Geometry; copyIcon.Data = FindResource("Icon.Copy") as Geometry;
@ -328,7 +328,7 @@ namespace SourceGit.Views.Widgets {
ev.Handled = true; ev.Handled = true;
}; };
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = item };
menu.Items.Add(history); menu.Items.Add(history);
menu.Items.Add(blame); menu.Items.Add(blame);
menu.Items.Add(explore); menu.Items.Add(explore);

View file

@ -67,7 +67,7 @@ namespace SourceGit.Views.Widgets {
delete.Header = App.Text("StashCM.Drop"); delete.Header = App.Text("StashCM.Drop");
delete.Click += (o, e) => new Popups.StashDropConfirm(repo, stash.Name, stash.Message).Show(); 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(apply);
menu.Items.Add(pop); menu.Items.Add(pop);
menu.Items.Add(delete); menu.Items.Add(delete);

View file

@ -868,7 +868,7 @@ namespace SourceGit.Views.Widgets {
GetChangesFromNode(o as ChangeNode, changes); GetChangesFromNode(o as ChangeNode, changes);
} }
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = sender as UIElement };
if (IsUnstaged) { if (IsUnstaged) {
OpenUnstagedContextMenuByNodes(menu, nodes, changes); OpenUnstagedContextMenuByNodes(menu, nodes, changes);
} else { } else {
@ -900,7 +900,7 @@ namespace SourceGit.Views.Widgets {
} }
} }
var menu = new ContextMenu(); var menu = new ContextMenu() { PlacementTarget = row };
if (IsUnstaged) { if (IsUnstaged) {
OpenUnstagedContextMenuByChanges(menu, changes); OpenUnstagedContextMenuByChanges(menu, changes);
} else { } else {