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/src
diff options
context:
space:
mode:
authorMichael Hutchinson <m.j.hutchinson@gmail.com>2011-11-22 00:33:55 +0400
committerMichael Hutchinson <m.j.hutchinson@gmail.com>2011-11-22 01:49:45 +0400
commit3fe6dd991519175ec57b1ecfcb5ac6ff40bb4004 (patch)
tree71b55e2aa9a0ef4384b061ae6c7b008dfc69f8e8 /main/src
parentefa4c623618abca9ee9020e2af4f010c572d4ec8 (diff)
[Gtk] Better context menu positioning
Diffstat (limited to 'main/src')
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/GtkWorkarounds.cs24
1 files changed, 20 insertions, 4 deletions
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/GtkWorkarounds.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/GtkWorkarounds.cs
index 732a7f3eef..d01d4c0194 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/GtkWorkarounds.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/GtkWorkarounds.cs
@@ -301,11 +301,27 @@ namespace Mono.TextEditor
var screen = parent.Screen;
Gdk.Rectangle geometry = GetUsableMonitorGeometry (screen, screen.GetMonitorAtPoint (x, y));
- if (x + request.Width > geometry.Right) {
- x -= request.Width;
+ //whether to push or flip menus that would extend offscreen
+ //FIXME: this is the correct behaviour for mac, check other platforms
+ bool flip_left = true;
+ bool flip_up = false;
+
+ int x_over = x + request.Width - geometry.Right;
+ if (x_over > 0) {
+ if (flip_left) {
+ x -= request.Width;
+ } else {
+ x -= x_over;
+ }
}
- if (y + request.Height > geometry.Bottom) {
- y -= request.Height;
+
+ int y_over = y + request.Height - geometry.Bottom;
+ if (y_over > 0) {
+ if (flip_up) {
+ y -= request.Height;
+ } else {
+ y -= y_over;
+ }
}
y = System.Math.Max (geometry.Top, System.Math.Min (y, geometry.Bottom - request.Height));
x = System.Math.Max (geometry.Left, System.Math.Min (x, geometry.Right - request.Width));