Home » U++ Library support » TopWindow&PopUp, TrayIcon » TopWindow::SerializePlacement () on dual-head display
TopWindow::SerializePlacement () on dual-head display [message #34258] |
Mon, 07 November 2011 09:42  |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi,
I'm having trouble using SerializePlacement() with a dual head display system. It always pulls windows stored on the secondary display (i.e. the right side display) to the primary display (i.e. left side) when restored.
I noticed changing the limit to use GetVirtualWorkArea() instead of GetWorkArea() rectifies this problem on Windows. (No idea what happens on Linux though.)
Anyway, would it be possible to have this changed in TopWindow.cpp:: TopWindow::SerializePlacement(Stream& s, bool reminimize): as follows:
if(s.IsLoading()) {
if(mn) rect = overlapped;
Rect limit = GetWorkArea();
To this:
if(s.IsLoading()) {
if(mn) rect = overlapped;
Rect limit = GetVirtualWorkArea();
Please?
Best regards,
Tom
|
|
|
|
|
|
Re: TopWindow::SerializePlacement () on dual-head display [message #34271 is a reply to message #34263] |
Mon, 07 November 2011 15:54   |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi,
Yet more. The maximized status is not properly retained (at least in Windows 7) if the window is already opened. (See below the if(IsOpen()) statement.) Also restoring to secondary display in maximized state does not work correctly.
Here is the new tail part of the TopWindow::SerializePlacement() as I have it now and this works for me. Please check if it works for you and merge to upp.
...
if(IsOpen()) {
#ifdef PLATFORM_WIN32
WINDOWPLACEMENT wp;
memset(&wp,0,sizeof(WINDOWPLACEMENT));
wp.length=sizeof(WINDOWPLACEMENT);
wp.showCmd = state==MINIMIZED ? SW_MINIMIZE : state==MAXIMIZED ? SW_MAXIMIZE : SW_RESTORE;
wp.rcNormalPosition.left=rect.left;
wp.rcNormalPosition.top=rect.top;
wp.rcNormalPosition.right=rect.right;
wp.rcNormalPosition.bottom=rect.bottom;
::SetWindowPlacement(GetHWND(),&wp);
#endif
#ifdef PLATFORM_X11
if(state == MINIMIZED)
Minimize(false);
if(state == MAXIMIZED)
Maximize(false);
#endif
}
}
#endif
}
Best regards,
Tom
|
|
|
Re: TopWindow::SerializePlacement () on dual-head display [message #36293 is a reply to message #34271] |
Fri, 18 May 2012 15:36   |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi,
I found that having stored maximized window loses the normal size information when restored. Here's the fixed version of SerializePlacement:
void TopWindow::SerializePlacement(Stream& s, bool reminimize)
{
GuiLock __;
#ifndef PLATFORM_WINCE
int version = 0;
s / version;
Rect rect = GetRect();
s % overlapped % rect;
bool mn = state == MINIMIZED;
bool mx = state == MAXIMIZED;
s.Pack(mn, mx);
LLOG("TopWindow::SerializePlacement / " << (s.IsStoring() ? "write" : "read"));
LLOG("minimized = " << mn << ", maximized = " << mx);
LLOG("rect = " << rect << ", overlapped = " << overlapped);
if(s.IsLoading()) {
rect = overlapped;
Rect limit = GetVirtualWorkArea();
Rect outer = rect;
::AdjustWindowRect(outer, WS_OVERLAPPEDWINDOW, FALSE);
limit.left += rect.left - outer.left;
limit.top += rect.top - outer.top;
limit.right += rect.right - outer.right;
limit.bottom += rect.bottom - outer.bottom;
Size sz = min(rect.Size(), limit.Size());
rect = RectC(
minmax(rect.left, limit.left, limit.right - sz.cx),
minmax(rect.top, limit.top, limit.bottom - sz.cy),
sz.cx, sz.cy);
state = OVERLAPPED;
SetRect(rect);
if(mn && reminimize)
state = MINIMIZED;
if(mx)
state = MAXIMIZED;
if(IsOpen()) {
WINDOWPLACEMENT wp;
memset(&wp,0,sizeof(WINDOWPLACEMENT));
wp.length=sizeof(WINDOWPLACEMENT);
wp.showCmd = state==MINIMIZED ? SW_MINIMIZE : state==MAXIMIZED ? SW_MAXIMIZE : SW_RESTORE;
wp.rcNormalPosition.left=rect.left;
wp.rcNormalPosition.top=rect.top;
wp.rcNormalPosition.right=rect.right;
wp.rcNormalPosition.bottom=rect.bottom;
::SetWindowPlacement(GetHWND(),&wp);
}
}
#endif
}
Unfortunately, I'm still unable to fix another problem with FullScreen mode: At this time it is serialized as if it was a maximized window. Additionally, it also loses the normal window position information in the process.
Best regards,
Tom
|
|
|
|
|
Re: TopWindow::SerializePlacement () on dual-head display [message #36404 is a reply to message #36384] |
Thu, 24 May 2012 08:53   |
Tom1
Messages: 1301 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi,
I could not figure out any behavioral change with maximized windows, but it does not matter as long as it works. And it does.
As for the comments "// Tom added, changed, removed" etc... They were in the file just for you to easily find the location of changes. I think you can remove these comments from the source now.
Best regards,
Tom
|
|
|
|
|
Goto Forum:
Current Time: Tue Apr 29 08:41:52 CEST 2025
Total time taken to generate the page: 0.03308 seconds
|