From f6a09392bbf959d95cd112b9ce1378a0f952776f Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 7 Jul 2007 02:54:22 +0000 Subject: Allows the popup to be displayed below as long as it can fit on the monitor the cursor is on rather than flipping up above the current point when near bottom of window. Implemented for GTK+ by John Ehresman. Partial Windows implementation #ifdefed out because it uses calls unavailable on Windows 95. --- win32/PlatWin.cxx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 36479e0f2..948e5e655 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1052,6 +1052,34 @@ void Window::SetTitle(const char *s) { ::SetWindowTextA(reinterpret_cast(id), 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 GetMonitorInfoare not available on Windows 95 so are not used. + // There could be conditional code and dynamic loading in a future version + // so this would work on those platforms where they are available. + PRectangle rcPosition = GetPosition(); + POINT ptDesktop = {pt.x + rcPosition.left, pt.y + rcPosition.top}; + HMONITOR hMonitor = ::MonitorFromPoint(ptDesktop, MONITOR_DEFAULTTONEAREST); + MONITORINFOEX mi; + memset(&mi, 0, sizeof(mi)); + mi.cbSize = sizeof(mi); + if (::GetMonitorInfo(hMonitor, &mi)) { + PRectangle rcMonitor( + mi.rcWork.left - rcPosition.left, + mi.rcWork.top - rcPosition.top, + mi.rcWork.right - rcPosition.left, + mi.rcWork.bottom - rcPosition.top); + return rcMonitor; + } +} +#else +PRectangle Window::GetMonitorRect(Point) { + return PRectangle(); +} +#endif + struct ListItemData { const char *text; int pixId; -- cgit v1.2.3