From adf74495dcaa23bea90a22440790cab6bd945cc9 Mon Sep 17 00:00:00 2001 From: feos Date: Sun, 1 Dec 2024 23:10:18 +0300 Subject: [PATCH] fix #2369 move tasview context menu to the other side of the cursor if it's not fitting into the screen fully. of course if there's not enough space there EITHER, the user must do something about it, meanwhile best we can do is clamp location to 0. not using MouseEventArgs because we need absolute on-screen coords other tastudio menus are small so probably fine? --- .../tools/TAStudio/TAStudio.ListView.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 347456f75c9..00058664abc 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -819,7 +819,24 @@ private void TasView_MouseUp(object sender, MouseEventArgs e) } else { - RightClickMenu.Show(TasView, e.X, e.Y); + var offset = new Point(0); + var topLeft = Cursor.Position; + var bottomRight = new Point( + topLeft.X + RightClickMenu.Width, + topLeft.Y + RightClickMenu.Height); + var screen = Screen.AllScreens + .Where(s => s.WorkingArea.Contains(topLeft)) + .FirstOrDefault(); + // if we don't fully fit, move to the other side of the pointer + if (bottomRight.X > screen.WorkingArea.Right) + offset.X -= RightClickMenu.Width; + if (bottomRight.Y > screen.WorkingArea.Bottom) + offset.Y -= RightClickMenu.Height; + topLeft.Offset(offset); + // if the screen is insultingly tiny, best we can do is avoid negative pos + RightClickMenu.Show( + Math.Max(0, topLeft.X), + Math.Max(0, topLeft.Y)); } } else if (e.Button == MouseButtons.Left)