From 8acbaa873bd00c2e87b316f58aa284568a88774e Mon Sep 17 00:00:00 2001 From: rylek Date: Fri, 27 Mar 2009 21:48:01 +0000 Subject: [PATCH] Multimonitor fixes: window resizing, MenuBar & PopUpTable positioning git-svn-id: svn://ultimatepp.org/upp/trunk@1012 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/CtrlCore.h | 2 ++ uppsrc/CtrlCore/CtrlPos.cpp | 2 +- uppsrc/CtrlCore/Win32Wnd.cpp | 22 ++++++++++++++++++++-- uppsrc/CtrlCore/X11App.cpp | 15 +++++++++++++++ uppsrc/CtrlLib/MenuBar.cpp | 4 ++-- uppsrc/CtrlLib/PopupTable.cpp | 2 +- uppsrc/ide/version.h | 2 +- 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 5cd9c95b2..bda4cf418 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -1296,6 +1296,8 @@ public: static Rect GetVirtualScreenArea(); static Rect GetPrimaryWorkArea(); static Rect GetPrimaryScreenArea(); + static void GetWorkArea(Array& rc); + static Rect GetWorkArea(Point pt); static int GetKbdDelay(); static int GetKbdSpeed(); static bool IsAlphaSupported(); diff --git a/uppsrc/CtrlCore/CtrlPos.cpp b/uppsrc/CtrlCore/CtrlPos.cpp index d08cf0d8e..6c436b9bf 100644 --- a/uppsrc/CtrlCore/CtrlPos.cpp +++ b/uppsrc/CtrlCore/CtrlPos.cpp @@ -133,7 +133,7 @@ Size Ctrl::GetStdSize() const Size Ctrl::GetMaxSize() const { - return GetWorkArea().Size(); + return GetVirtualWorkArea().Size(); } void Ctrl::SyncLayout(int force) diff --git a/uppsrc/CtrlCore/Win32Wnd.cpp b/uppsrc/CtrlCore/Win32Wnd.cpp index 7e1c89bb0..40ef2399a 100644 --- a/uppsrc/CtrlCore/Win32Wnd.cpp +++ b/uppsrc/CtrlCore/Win32Wnd.cpp @@ -828,17 +828,35 @@ static BOOL CALLBACK sMonEnumProc(HMONITOR monitor, HDC hdc, LPRECT lprcMonitor, Zero(moninfo); moninfo.cbSize = sizeof(moninfo); MultiMon().GetMonitorInfo(monitor, &moninfo); - *(Rect *)data |= Rect(moninfo.rcWork); + ((Array *)data)->Add(Rect(moninfo.rcWork)); return TRUE; } +void Ctrl::GetWorkArea(Array& rc) +{ + MultiMon().EnumDisplayMonitors(NULL, NULL, &sMonEnumProc, (LPARAM)&rc); +} + Rect Ctrl::GetVirtualWorkArea() { Rect out = GetPrimaryWorkArea(); - MultiMon().EnumDisplayMonitors(NULL, NULL, &sMonEnumProc, (LPARAM)&out); + Array rc; + GetWorkArea(rc); + for(int i = 0; i < rc.GetCount(); i++) + out |= rc[i]; return out; } +Rect Ctrl::GetWorkArea(Point pt) +{ + Array rc; + GetWorkArea(rc); + for(int i = 0; i < rc.GetCount(); i++) + if(rc[i].Contains(pt)) + return rc[i]; + return GetPrimaryWorkArea(); +} + Rect Ctrl::GetVirtualScreenArea() { return RectC(GetSystemMetrics(SM_XVIRTUALSCREEN), diff --git a/uppsrc/CtrlCore/X11App.cpp b/uppsrc/CtrlCore/X11App.cpp index ea0cd0717..1059babda 100644 --- a/uppsrc/CtrlCore/X11App.cpp +++ b/uppsrc/CtrlCore/X11App.cpp @@ -417,11 +417,26 @@ Rect Ctrl::GetDefaultWindowRect() return RectC(pos + 20, pos + 20, cx, cy); } +void Ctrl::GetWorkArea(Array& out) +{ + out.Add(GetPrimaryWorkArea()); +} + Rect Ctrl::GetWorkArea() const { return GetPrimaryWorkArea(); } +Rect Ctrl::GetWorkArea(Point pt) +{ + Array rc; + GetWorkArea(rc); + for(int i = 0; i < rc.GetCount(); i++) + if(rc[i].Contains(pt)) + return rc[i]; + return GetPrimaryWorkArea(); +} + Rect Ctrl::GetVirtualWorkArea() { return GetPrimaryWorkArea(); diff --git a/uppsrc/CtrlLib/MenuBar.cpp b/uppsrc/CtrlLib/MenuBar.cpp index 523039ed6..a6c68f6e6 100644 --- a/uppsrc/CtrlLib/MenuBar.cpp +++ b/uppsrc/CtrlLib/MenuBar.cpp @@ -487,7 +487,7 @@ void MenuBar::PopUp(Ctrl *owner, Point p, Size rsz) szcy = false; WhenHelp = parentmenu->WhenHelp; } - Rect r = GetWorkArea(); + Rect r = GetWorkArea(p); restorefocus = GetFocusCtrl(); LLOG("PopUp " << UPP::Name(this) << " set restorefocus:" << UPP::Name(restorefocus)); DistributeAccessKeys(); @@ -517,7 +517,7 @@ void MenuBar::PopUp(Ctrl *owner, Point p, Size rsz) } } if(p.x + sz.cx > r.right) { - p.x = max(p.x + rsz.cx - sz.cx, 0); + p.x = max(p.x + rsz.cx - sz.cx, r.left); szx = szcx; pane.LeftPos(0, sz.cx); } diff --git a/uppsrc/CtrlLib/PopupTable.cpp b/uppsrc/CtrlLib/PopupTable.cpp index 5fa7c25ac..22722da3a 100644 --- a/uppsrc/CtrlLib/PopupTable.cpp +++ b/uppsrc/CtrlLib/PopupTable.cpp @@ -71,7 +71,7 @@ void PopUpTable::PopUp(Ctrl *owner, int x, int top, int bottom, int width) { DoClose(); int h = AddFrameSize(width, min(droplines * GetLineCy(), GetTotalCy())).cy; Rect rt = RectC(x, bottom, width, h); - Rect area = Ctrl::GetWorkArea(); + Rect area = Ctrl::GetWorkArea(Point(x, top)); bool up = false; if(rt.bottom > area.bottom) { up = true; diff --git a/uppsrc/ide/version.h b/uppsrc/ide/version.h index 9b56be1fb..8987db902 100644 --- a/uppsrc/ide/version.h +++ b/uppsrc/ide/version.h @@ -1 +1 @@ -#define IDE_VERSION "902r182" +#define IDE_VERSION "902r183"