Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
Tom1
Messages: 1212
Registered: March 2007
Senior 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 #34259 is a reply to message #34258] Mon, 07 November 2011 09:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks, patch applied.
Re: TopWindow::SerializePlacement () on dual-head display [message #34262 is a reply to message #34258] Mon, 07 November 2011 10:52 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Thanks! That really annoyed me Smile
Re: TopWindow::SerializePlacement () on dual-head display [message #34263 is a reply to message #34259] Mon, 07 November 2011 10:56 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Well, that was fast, Mirek! Thanks!

Best regards,

Tom
Re: TopWindow::SerializePlacement () on dual-head display [message #34271 is a reply to message #34263] Mon, 07 November 2011 15:54 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior 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 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior 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 #36377 is a reply to message #36293] Wed, 23 May 2012 12:58 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi,

I had a severe and exhausting battle with TopWindow::SerializePlacement and friends...

Finally, here is the version of TopWin32.cpp that properly stores and restores windows in dual-head display environment in all modes, including fullscreen. Additionally on the way, I enabled fullscreen mode on the monitor where the window is when FullScreen is activated.

Mirek, please test, cleanup if you wish and merge. For me it worked on Windows 7 Pro 64-bit (dual-head displays) and Win XP Pro 32-bit (only one display).

Best regards,

Tom
  • Attachment: TopWin32.cpp
    (Size: 10.12KB, Downloaded 342 times)
Re: TopWindow::SerializePlacement () on dual-head display [message #36384 is a reply to message #36377] Wed, 23 May 2012 15:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Patch applied: I have fixed versioning, then being there, I attempted to fix issue with maximized windows I have encountered as well. Please check.
Re: TopWindow::SerializePlacement () on dual-head display [message #36404 is a reply to message #36384] Thu, 24 May 2012 08:53 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior 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
Re: TopWindow::SerializePlacement () on dual-head display [message #36406 is a reply to message #36404] Thu, 24 May 2012 08:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Thu, 24 May 2012 02:53

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.



In changes like these, I like to keep them for a while (like year or so). If you scan through CtrlCore, you might find similar comments with origin being me or 'trc' (Tomas Rylek).
Re: TopWindow::SerializePlacement () on dual-head display [message #36407 is a reply to message #36406] Thu, 24 May 2012 09:02 Go to previous message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
OK, by all means!

Thanks and best regards,

Tom
Previous Topic: How to call a new window?
Next Topic: TopWindow "WhenOpen" callback
Goto Forum:
  


Current Time: Tue Apr 16 18:38:56 CEST 2024

Total time taken to generate the page: 0.02148 seconds