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 » Community » Newbie corner » FullScreen: why does not work?
FullScreen: why does not work? [message #28742] Tue, 14 September 2010 18:02 Go to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Please have a look to the attached example. While Maximize does work, FullScreen doesn’t. Why?

Cheers,

Javier
Re: FullScreen: why does not work? [message #28743 is a reply to message #28742] Tue, 14 September 2010 18:57 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Because FullScreen only effects the next "creation by the underlying windowing API" of the window, while Maximize is an imperative method that changes the status of the window.

Implementation wise one either needs to call some API or force recreate the HWND as is often the case for Windows API when changing a few select parameters.

I'll put it on my never ending list of things to investigate. For now you can call FullScreen in the constructor.

icon1.gif  Re: FullScreen: why does not work? [message #30047 is a reply to message #28742] Sun, 05 December 2010 04:56 Go to previous messageGo to next message
alendar is currently offline  alendar
Messages: 47
Registered: January 2010
Location: Idaho, USA
Member
I solved this with Win32 APIs. First I tried to use the U++ wrappers but I could not get them to work.

Here's the code:
bool isFullScreenModeActive;

virtual bool Key(dword key, int count) {
	static dword style;
	static Rect normalwindowrect;
		
	switch (key) {
		case K_F11:
			if (!isFullScreenModeActive) {
				// Get the current Top window's style bits
				style = GetStyle();
				// Strips the caption bit, which is the title bar
				style = (style & ~WS_CAPTION);
				// Save the "overlapped" or normal window shape
				normalwindowrect = GetRect(); 
				SetWindowLong(GetHWND(), GWL_STYLE, style);  
					
				// Get the full size of the screen
				long cx = GetSystemMetrics(SM_CXSCREEN);
	   			long cy = GetSystemMetrics(SM_CYSCREEN);
	   			// Expand the window to full size
		   		SetWindowPos(GetHWND(),HWND_TOP,0,0,cx,cy,SWP_SHOWWINDOW); 
				//or use Maximize(false) if you like a 
				//delayed resizing, even with zoom effects turned off
			} else {
				// Set the caption bit back so we can get our title bar back
				style |= WS_CAPTION;
				// Pass to windows (Style() method gets confused on SyncCaption0)
				SetWindowLong(GetHWND(), GWL_STYLE, style);
				// Return size to normal; key flag is SWP_FRAMECHANGED
				SetWindowPos(GetHWND(),HWND_TOP, 
					normalwindowrect.left, 
					normalwindowrect.top, 
					normalwindowrect.Width(), 
					normalwindowrect.Height(), SWP_SHOWWINDOW|SWP_FRAMECHANGED);
				}
				// Track logically in our application
				isFullScreenModeActive = !isFullScreenModeActive;
				break;
	}
	return false;
}


This was on MS Windows XP Professional V 2002 SP 3
U++ 2791
This is a win32 only fix. This works on a TopWindow while your in it, so you don't have to use the constructor method.

I might try getting the virtual window size so I can zoom across multiple screens.
The trick to getting the title bar back after your zoom is the SWP_FRAMECHANGED flag. Without this Windoze doesn't know to rebuild the window frame after you added the WS_CAPTION bit back in.
You can use the TopWindow.Maximize() function, but for some reason it still tries to do effects when you pass a false bit, so I used the SetWindowPos instead for the zoom.
I haven't tried this with any windows besides a TopWindow.
This covers the taskbar on the bottom on my computer. Sometimes there is a delay in minimizing the taskbar.

Edit from 5 min later:
To go across all screens just change:

cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
long cy = GetSystemMetrics(SM_CYSCREEN);
cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);


cd7651feeb698f6ac6cec1f6deda5e5b

[Updated on: Sun, 05 December 2010 05:03]

Report message to a moderator

Re: FullScreen: why does not work? [message #30055 is a reply to message #30047] Sun, 05 December 2010 11:06 Go to previous messageGo to next message
koldo is currently online  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Very interesting Smile.

X11 experts, could it be done in Linux?


Best regards
Iñaki
Re: FullScreen: why does not work? [message #30261 is a reply to message #30055] Tue, 21 December 2010 10:47 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
could this somehow be included in Ctrl::FullScreen() in a platform dependant manner? it'd be really nice to have this feature switchable at runtime..
Re: FullScreen: why does not work? [message #30263 is a reply to message #30261] Tue, 21 December 2010 11:20 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Quote:

could this somehow be included in Ctrl::FullScreen() in a platform dependant manner? it'd be really nice to have this feature switchable at runtime..


I utterly encourage the implementation of this.

Thanks,

Javier.
Toggle FullScreen on X11 [message #30297 is a reply to message #30055] Wed, 22 December 2010 12:54 Go to previous messageGo to next message
oan1971 is currently offline  oan1971
Messages: 7
Registered: April 2010
Promising Member
Hello Koldo,

I am no X11 expert at all, but the following seems to work on Linux. I guess that the window manager needs to support "Extended Window Manager Hints" (see http://standards.freedesktop.org/wm-spec/wm-spec-latest.html #id2551694).

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class FullScreenTest : public TopWindow
{
public:
	typedef FullScreenTest CLASSNAME;
	FullScreenTest();
	virtual bool Key(dword key, int count);
	virtual void Paint(Draw& w);
	void SetFullScreen(bool b);
};

FullScreenTest::FullScreenTest()
{
	Title("FullScreenTest").Sizeable();
}

void FullScreenTest::Paint(Draw & w)
{
	Rect r = GetView();
	w.DrawRect(r, Blue);
}

bool FullScreenTest::Key(dword key, int count)
{
	if (key == K_F11)
		if (IsFullScreen())
			SetFullScreen(false);
		else
			SetFullScreen(true);
}

void FullScreenTest::SetFullScreen(bool b)
{
	Sizeable(!b);
	FullScreen(b);
	
	XEvent event;
	event.xclient.type = ClientMessage;
	event.xclient.serial = 0;
	event.xclient.send_event = true;
	event.xclient.message_type = XAtom("_NET_WM_STATE");
	event.xclient.window = GetWindow();
	event.xclient.format = 32;
	event.xclient.data.l[0] = b;
	event.xclient.data.l[1] = XAtom("_NET_WM_STATE_FULLSCREEN");
	event.xclient.data.l[2] = 0;
	event.xclient.data.l[3] = 0;
	event.xclient.data.l[4] = 0;
	
	XSendEvent(Xdisplay, Xroot, false, SubstructureRedirectMask | SubstructureNotifyMask, &event);
	
	if (b)
		SetRect(0, 0, Xwidth, Xheight);
}

GUI_APP_MAIN
{
	FullScreenTest().Run();
}


Best regards,
Oliver


910eb20c14e026a87ffb2b0d38b9ddb7
Re: Toggle FullScreen on X11 [message #30300 is a reply to message #30297] Wed, 22 December 2010 14:12 Go to previous messageGo to next message
koldo is currently online  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Great. I have to try it Smile.

"Extended Window Manager Hints" seems to be supported at least by Gnome.


Best regards
Iñaki

[Updated on: Wed, 22 December 2010 14:14]

Report message to a moderator

Re: Toggle FullScreen on X11 [message #30372 is a reply to message #30300] Sun, 26 December 2010 17:10 Go to previous messageGo to next message
koldo is currently online  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Confused

Windows code runs perfect, but X11 no. And I do not understand: oan1971 code seems to be right.

I have included both in last SDLCtrl_demo, demo1 (demo1main.cpp).


Best regards
Iñaki
Re: Toggle FullScreen on X11 [message #30379 is a reply to message #30372] Mon, 27 December 2010 11:22 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Windows version works but partially in my computer (Windows XP SP3), for it is happening the following:

1.- the lower Windows Tool Bar is not occupied;

2.- when pressing F11 successively, the size of the minimized windows is smaller and smaller; why?

3.- I reckon that the correct initialization of isFullScreenModeActive=false; Is it correct?

4.- I do not understand this:

Quote:

Edit from 5 min later:
To go across all screens just change:

cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
long cy = GetSystemMetrics(SM_CYSCREEN);
cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);



So in my case it partially works. Is there any special consideration that I am not aware?

Thank you.

Best wishes,

Javier
Re: Toggle FullScreen on X11 [message #30393 is a reply to message #30379] Mon, 27 December 2010 18:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
TopWindow FullScreen fixed in X11...

Mirek

[Updated on: Mon, 27 December 2010 18:53]

Report message to a moderator

Re: Toggle FullScreen on X11 [message #30396 is a reply to message #30393] Mon, 27 December 2010 19:04 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Mirek, please don't forget Windows users...
Re: Toggle FullScreen on X11 [message #30397 is a reply to message #30396] Mon, 27 December 2010 19:32 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
281264 wrote on Mon, 27 December 2010 13:04

Mirek, please don't forget Windows users...


I do not. Unfortunately, I have spent last hour trying to do that, to no avail. That said, original contract was that it would work only before opening the window...

Mirek
Previous Topic: Any tuple examples?
Next Topic: Multiple users over LAN
Goto Forum:
  


Current Time: Thu Mar 28 17:19:44 CET 2024

Total time taken to generate the page: 0.01592 seconds