diff options
author | nyamatongwe <unknown> | 2010-06-26 08:35:26 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2010-06-26 08:35:26 +0000 |
commit | f568437cfd24a6227d6210080e3610fdf55663aa (patch) | |
tree | dd5b337bc72b19f5d3ec31580052d94e9eba9dda | |
parent | 931e0d9db65fd6b11bd8c220e3d89f0ce31e12d5 (diff) | |
download | scintilla-mirror-f568437cfd24a6227d6210080e3610fdf55663aa.tar.gz |
Fix for bug #3017512 Autocomplete popup not working on secondary monitor
to the left of primary.
-rw-r--r-- | win32/PlatWin.cxx | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 44c2ba440..ab71dbe77 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -25,6 +25,13 @@ #include "XPM.h" #include "FontQuality.h" +// We want to use multi monitor functions, but via LoadLibrary etc +// Luckily microsoft has done the heavy lifting for us, so we'll just use their stub functions! +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define COMPILE_MULTIMON_STUBS +#include "MultiMon.h" +#endif + #ifndef IDC_HAND #define IDC_HAND MAKEINTRESOURCE(32649) #endif @@ -1034,21 +1041,29 @@ void Window::SetPositionRelative(PRectangle rc, Window w) { ::GetWindowRect(reinterpret_cast<HWND>(w.GetID()), &rcOther); rc.Move(rcOther.left, rcOther.top); - // Retrieve desktop bounds and make sure window popup's origin isn't left-top of the screen. - RECT rcDesktop = {0, 0, 0, 0}; -#ifdef SM_XVIRTUALSCREEN - rcDesktop.left = ::GetSystemMetrics(SM_XVIRTUALSCREEN); - rcDesktop.top = ::GetSystemMetrics(SM_YVIRTUALSCREEN); - rcDesktop.right = rcDesktop.left + ::GetSystemMetrics(SM_CXVIRTUALSCREEN); - rcDesktop.bottom = rcDesktop.top + ::GetSystemMetrics(SM_CYVIRTUALSCREEN); -#endif - - if (rc.left < rcDesktop.left) { - rc.Move(rcDesktop.left - rc.left,0); - } - if (rc.top < rcDesktop.top) { - rc.Move(0,rcDesktop.top - rc.top); - } + // We're using the stub functionality of MultiMon.h to decay gracefully on machines + // (ie, pre Win2000, Win95) that do not support the newer functions. + RECT rcMonitor; + memcpy(&rcMonitor, &rc, sizeof(rcMonitor)); // RECT and Rectangle are the same really. + MONITORINFO mi = {0}; + mi.cbSize = sizeof(mi); + + HMONITOR hMonitor = ::MonitorFromRect(&rcMonitor, MONITOR_DEFAULTTONEAREST); + // If hMonitor is NULL, that's just the main screen anyways. + ::GetMonitorInfo(hMonitor, &mi); + + // Now clamp our desired rectangle to fit inside the work area + // This way, the menu will fit wholly on one screen. An improvement even + // if you don't have a second monitor on the left... Menu's appears half on + // one screen and half on the other are just U.G.L.Y.! + if (rc.right > mi.rcWork.right) + rc.Move(mi.rcWork.right - rc.right, 0); + if (rc.bottom > mi.rcWork.bottom) + rc.Move(0, mi.rcWork.bottom - rc.bottom); + if (rc.left < mi.rcWork.left) + rc.Move(mi.rcWork.left - rc.left, 0); + if (rc.top < mi.rcWork.top) + rc.Move(0, mi.rcWork.top - rc.top); } SetPosition(rc); } @@ -1132,7 +1147,6 @@ void Window::SetTitle(const char *s) { /* Returns rectangle of monitor pt is on, both rect and pt are in Window's coordinates */ -#ifdef MULTIPLE_MONITOR_SUPPORT PRectangle Window::GetMonitorRect(Point pt) { // MonitorFromPoint and GetMonitorInfo are not available on Windows 95 so are not used. // There could be conditional code and dynamic loading in a future version @@ -1140,7 +1154,7 @@ PRectangle Window::GetMonitorRect(Point pt) { PRectangle rcPosition = GetPosition(); POINT ptDesktop = {pt.x + rcPosition.left, pt.y + rcPosition.top}; HMONITOR hMonitor = ::MonitorFromPoint(ptDesktop, MONITOR_DEFAULTTONEAREST); - MONITORINFOEX mi; + MONITORINFO mi = {0}; memset(&mi, 0, sizeof(mi)); mi.cbSize = sizeof(mi); if (::GetMonitorInfo(hMonitor, &mi)) { @@ -1150,13 +1164,10 @@ PRectangle Window::GetMonitorRect(Point pt) { mi.rcWork.right - rcPosition.left, mi.rcWork.bottom - rcPosition.top); return rcMonitor; + } else { + return PRectangle(); } } -#else -PRectangle Window::GetMonitorRect(Point) { - return PRectangle(); -} -#endif struct ListItemData { const char *text; |