diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2015-06-25 17:07:08 +1000 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2015-06-25 17:07:08 +1000 |
commit | cd077c8562b1ef0f1ad1c36c3c780af33296b6d5 (patch) | |
tree | cd84e317cdbc2774e3c0c3e1c587ea649b065f37 | |
parent | 51756a5c355d8239709dfd6e9bcb347c212fbe1b (diff) | |
download | scintilla-mirror-cd077c8562b1ef0f1ad1c36c3c780af33296b6d5.tar.gz |
Bug [#1740]. Improve autocompletion positioning to avoid being off-screen.
Not perfect when the Scintilla view is overlapping the screen edge or dock
as the position moved to is based on the view's area.
-rw-r--r-- | cocoa/PlatCocoa.mm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 8a0f942f4..1d62385cc 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1329,16 +1329,28 @@ PRectangle Window::GetMonitorRect(Point) if (wid) { id idWin = reinterpret_cast<id>(wid); + if ([idWin isKindOfClass: [NSView class]]) + { + NSView* view = reinterpret_cast<NSView*>(idWin); + idWin = [view window]; + } if ([idWin isKindOfClass: [NSWindow class]]) { + PRectangle rcPosition = GetPosition(); + NSWindow* win = reinterpret_cast<NSWindow*>(idWin); NSScreen* screen = [win screen]; - NSRect rect = [screen frame]; + NSRect rect = [screen visibleFrame]; CGFloat screenHeight = rect.origin.y + rect.size.height; // Invert screen positions to match Scintilla - return PRectangle( + PRectangle rcWork( static_cast<XYPOSITION>(NSMinX(rect)), static_cast<XYPOSITION>(screenHeight - NSMaxY(rect)), static_cast<XYPOSITION>(NSMaxX(rect)), static_cast<XYPOSITION>(screenHeight - NSMinY(rect))); + PRectangle rcMonitor(rcWork.left - rcPosition.left, + rcWork.top - rcPosition.top, + rcWork.right - rcPosition.left, + rcWork.bottom - rcPosition.top); + return rcMonitor; } } return PRectangle(); |