Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorCody Russell <cody@jhu.edu>2015-02-07 19:19:39 +0300
committerCody Russell <cody@jhu.edu>2015-02-07 19:21:43 +0300
commit9f29560a79ea9bff73ed7f4af0b8c176ce2327fc (patch)
tree5d650f14bbd2ab00714fab7bd5dd8a415e2a9d6a /main
parentd8457247754eb8dd8708c5032618e06db78d44c1 (diff)
[Core] Fix position calculations of native Mac context menus
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=26170
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs29
1 files changed, 19 insertions, 10 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs
index c59ee5602e..efdf74712a 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs
@@ -3,6 +3,7 @@
//
// Author:
// Greg Munn <greg.munn@xamarin.com>
+// Cody Russell <cody@xamarin.com>
//
// Copyright (c) 2015 Xamarin Inc
//
@@ -54,35 +55,43 @@ namespace MonoDevelop.Components
parent.GrabFocus ();
int x, y;
+ CoreGraphics.CGPoint pt;
+ var toplevel = parent.Toplevel as Gtk.Window;
+ var nsview = MonoDevelop.Components.Mac.GtkMacInterop.GetNSView (parent);
+ var nswindow = MonoDevelop.Components.Mac.GtkMacInterop.GetNSWindow (toplevel);
+
if (evt != null) {
- x = (int)evt.X;
- y = (int)evt.Y;
+ x = (int)evt.XRoot;
+ y = (int)evt.YRoot;
+
+ var screenRect = new CoreGraphics.CGRect ((float)x, Gdk.Screen.Default.Height - (float)y, 0, 0);
+ var windowRect = nswindow.ConvertRectFromScreen (screenRect);
+ pt = nswindow.ContentView.ConvertPointToView (windowRect.Location, nsview);
} else {
Gdk.ModifierType mod;
parent.GdkWindow.GetPointer (out x, out y, out mod);
var titleBarHeight = MonoDevelop.Components.Mac.GtkMacInterop.GetTitleBarHeight ();
y -= titleBarHeight;
- }
- Gtk.Application.Invoke (delegate {
- // Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event
- Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime);
- var nsview = MonoDevelop.Components.Mac.GtkMacInterop.GetNSView (parent);
- var toplevel = parent.Toplevel as Gtk.Window;
int trans_x, trans_y;
parent.TranslateCoordinates (toplevel, (int)x, (int)y, out trans_x, out trans_y);
// Window coordinates in gtk are the same for cocoa, with the exception of the Y coordinate, that has to be flipped.
- var pt = new CoreGraphics.CGPoint ((float)trans_x, (float)trans_y);
+ pt = new CoreGraphics.CGPoint ((float)trans_x, (float)trans_y);
int w,h;
toplevel.GetSize (out w, out h);
pt.Y = h - pt.Y;
+ }
+
+ Gtk.Application.Invoke (delegate {
+ // Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event
+ Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime);
var tmp_event = NSEvent.MouseEvent (NSEventType.LeftMouseDown,
pt,
0, 0,
- MonoDevelop.Components.Mac.GtkMacInterop.GetNSWindow (toplevel).WindowNumber,
+ nswindow.WindowNumber,
null, 0, 0, 0);
NSMenu.PopUpContextMenu (menu, tmp_event, nsview);