[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54806] trunk/blender: fix for fullscreen on X11 (used by the BGE, not blender application),

Campbell Barton ideasman42 at gmail.com
Sun Feb 24 06:05:30 CET 2013


Revision: 54806
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54806
Author:   campbellbarton
Date:     2013-02-24 05:05:29 +0000 (Sun, 24 Feb 2013)
Log Message:
-----------
fix for fullscreen on X11 (used by the BGE, not blender application),
changing the screen resolution wasn't still allowed for larger virtual desktops.

added an exclusive option to ghost so the fullscreen window is ignored by the window manager and we get all events. (common practice for games on X11).

Modified Paths:
--------------
    trunk/blender/intern/ghost/GHOST_ISystem.h
    trunk/blender/intern/ghost/GHOST_IWindow.h
    trunk/blender/intern/ghost/intern/GHOST_System.cpp
    trunk/blender/intern/ghost/intern/GHOST_System.h
    trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
    trunk/blender/intern/ghost/intern/GHOST_SystemX11.h
    trunk/blender/intern/ghost/intern/GHOST_Window.cpp
    trunk/blender/intern/ghost/intern/GHOST_Window.h
    trunk/blender/intern/ghost/intern/GHOST_WindowManager.cpp
    trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp
    trunk/blender/intern/ghost/intern/GHOST_WindowX11.h
    trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Application.cpp

Modified: trunk/blender/intern/ghost/GHOST_ISystem.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_ISystem.h	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/GHOST_ISystem.h	2013-02-24 05:05:29 UTC (rev 54806)
@@ -253,6 +253,7 @@
 	    GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
 	    GHOST_TWindowState state, GHOST_TDrawingContextType type,
 	    const bool stereoVisual = false,
+	    const bool exclusive = false,
 	    const GHOST_TUns16 numOfAASamples = 0,
 	    const GHOST_TEmbedderWindowID parentWindow = 0) = 0;
 

Modified: trunk/blender/intern/ghost/GHOST_IWindow.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_IWindow.h	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/GHOST_IWindow.h	2013-02-24 05:05:29 UTC (rev 54806)
@@ -305,7 +305,10 @@
 	 */
 	virtual GHOST_TSuccess setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_Rect *bounds, GHOST_TInt32 mouse_ungrab_xy[2]) { return GHOST_kSuccess; }
 
-	
+	/** */
+	virtual GHOST_TSuccess beginFullScreen() const = 0;
+	virtual GHOST_TSuccess endFullScreen() const = 0;
+
 	virtual float getNativePixelSize(void) = 0;
 
 	

Modified: trunk/blender/intern/ghost/intern/GHOST_System.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_System.cpp	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/intern/GHOST_System.cpp	2013-02-24 05:05:29 UTC (rev 54806)
@@ -152,7 +152,7 @@
 			success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting);
 			if (success == GHOST_kSuccess) {
 				//GHOST_PRINT("GHOST_System::beginFullScreen(): creating full-screen window\n");
-				success = createFullScreenWindow((GHOST_Window **)window, stereoVisual, numOfAASamples);
+				success = createFullScreenWindow((GHOST_Window **)window, setting, stereoVisual, numOfAASamples);
 				if (success == GHOST_kSuccess) {
 					m_windowManager->beginFullScreen(*window, stereoVisual);
 				}
@@ -347,26 +347,22 @@
 	return GHOST_kSuccess;
 }
 
-
-GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window, const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
+GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window, const GHOST_DisplaySetting &settings,
+                                                    const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
 {
-	GHOST_TSuccess success;
+	/* note: don't use getCurrentDisplaySetting() because on X11 we may
+	 * be zoomed in and the desktop may be bigger then the viewport. */
 	GHOST_ASSERT(m_displayManager, "GHOST_System::createFullScreenWindow(): invalid display manager");
-	GHOST_DisplaySetting settings;
-
-	success = m_displayManager->getCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, settings);
-	if (success) {
-		//GHOST_PRINT("GHOST_System::createFullScreenWindow(): creating full-screen window\n");
-		*window = (GHOST_Window *)createWindow(
-		    STR_String(""),
-		    0, 0, settings.xPixels, settings.yPixels,
-		    GHOST_kWindowStateFullScreen,
-		    GHOST_kDrawingContextTypeOpenGL,
-		    stereoVisual,
-		    numOfAASamples);
-		success = *window == 0 ? GHOST_kFailure : GHOST_kSuccess;
-	}
-	return success;
+	//GHOST_PRINT("GHOST_System::createFullScreenWindow(): creating full-screen window\n");
+	*window = (GHOST_Window *)createWindow(
+	    STR_String(""),
+	    0, 0, settings.xPixels, settings.yPixels,
+	    GHOST_kWindowStateNormal,
+	    GHOST_kDrawingContextTypeOpenGL,
+	    stereoVisual,
+	    true,  /* exclusive */
+	    numOfAASamples);
+	return (*window == NULL) ? GHOST_kFailure : GHOST_kSuccess;
 }
 
 

Modified: trunk/blender/intern/ghost/intern/GHOST_System.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_System.h	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/intern/GHOST_System.h	2013-02-24 05:05:29 UTC (rev 54806)
@@ -330,7 +330,7 @@
 	 * \param window The window created.
 	 * \return Indication of success.
 	 */
-	virtual GHOST_TSuccess createFullScreenWindow(GHOST_Window **window,
+	virtual GHOST_TSuccess createFullScreenWindow(GHOST_Window **window, const GHOST_DisplaySetting &settings,
 	                                              const bool stereoVisual, const GHOST_TUns16 numOfAASamples = 0);
 
 	/** The display manager (platform dependant). */

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2013-02-24 05:05:29 UTC (rev 54806)
@@ -278,6 +278,8 @@
  * \param	state	The state of the window when opened.
  * \param	type	The type of drawing context installed in this window.
  * \param	stereoVisual	Stereo visual for quad buffered stereo.
+ * \param	exclusive	Use to show the window ontop and ignore others
+ *						(used fullscreen).
  * \param	numOfAASamples	Number of samples used for AA (zero if no AA)
  * \param	parentWindow    Parent (embedder) window
  * \return	The new window (or 0 if creation failed).
@@ -292,7 +294,8 @@
 		GHOST_TUns32 height,
 		GHOST_TWindowState state,
 		GHOST_TDrawingContextType type,
-		bool stereoVisual,
+		const bool stereoVisual,
+		const bool exclusive,
 		const GHOST_TUns16 numOfAASamples,
 		const GHOST_TEmbedderWindowID parentWindow)
 {
@@ -305,7 +308,9 @@
 
 	window = new GHOST_WindowX11(this, m_display, title,
 	                             left, top, width, height,
-	                             state, parentWindow, type, stereoVisual, numOfAASamples);
+	                             state, parentWindow, type,
+	                             stereoVisual, exclusive,
+	                             numOfAASamples);
 
 	if (window) {
 		/* Both are now handle in GHOST_WindowX11.cpp

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemX11.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemX11.h	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemX11.h	2013-02-24 05:05:29 UTC (rev 54806)
@@ -137,7 +137,9 @@
 	 * \param	height		The height the window.
 	 * \param	state		The state of the window when opened.
 	 * \param	type		The type of drawing context installed in this window.
-	 * \param       stereoVisual    Create a stereo visual for quad buffered stereo.
+	 * \param	stereoVisual    Create a stereo visual for quad buffered stereo.
+	 * \param	exclusive	Use to show the window ontop and ignore others
+	 *						(used fullscreen).
 	 * \param	parentWindow    Parent (embedder) window
 	 * \return	The new window (or 0 if creation failed).
 	 */
@@ -151,6 +153,7 @@
 	    GHOST_TWindowState state,
 	    GHOST_TDrawingContextType type,
 	    const bool stereoVisual,
+	    const bool exclusive = false,
 	    const GHOST_TUns16 numOfAASamples = 0,
 	    const GHOST_TEmbedderWindowID parentWindow = 0
 	    );

Modified: trunk/blender/intern/ghost/intern/GHOST_Window.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_Window.cpp	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/intern/GHOST_Window.cpp	2013-02-24 05:05:29 UTC (rev 54806)
@@ -45,6 +45,7 @@
     GHOST_TWindowState state,
     GHOST_TDrawingContextType type,
     const bool stereoVisual,
+    const bool exclusive,
     const GHOST_TUns16 numOfAASamples)
 	:
 	m_drawingContextType(type),

Modified: trunk/blender/intern/ghost/intern/GHOST_Window.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_Window.h	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/intern/GHOST_Window.h	2013-02-24 05:05:29 UTC (rev 54806)
@@ -80,6 +80,8 @@
 	 * \param state				The state the window is initially opened with.
 	 * \param type				The type of drawing context installed in this window.
 	 * \param stereoVisual		Stereo visual for quad buffered stereo.
+	 * \param exclusive			Use to show the window ontop and ignore others
+	 *							(used fullscreen).
 	 * \param numOfAASamples	Number of samples used for AA (zero if no AA)
 	 */
 	GHOST_Window(
@@ -88,6 +90,7 @@
 	    GHOST_TWindowState state,
 	    GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
 	    const bool stereoVisual = false,
+	    const bool exclusive = false,
 	    const GHOST_TUns16 numOfAASamples = 0);
 
 	/**

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowManager.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowManager.cpp	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowManager.cpp	2013-02-24 05:05:29 UTC (rev 54806)
@@ -130,12 +130,12 @@
 		m_fullScreenWindow = window;
 		m_activeWindowBeforeFullScreen = getActiveWindow();
 		setActiveWindow(m_fullScreenWindow);
+		m_fullScreenWindow->beginFullScreen();
 		success = GHOST_kSuccess;
 	}
 	return success;
 }
 
-
 GHOST_TSuccess GHOST_WindowManager::endFullScreen(void)
 {
 	GHOST_TSuccess success = GHOST_kFailure;
@@ -143,6 +143,7 @@
 		if (m_fullScreenWindow != 0) {
 			//GHOST_PRINT("GHOST_WindowManager::endFullScreen(): deleting full-screen window\n");
 			setWindowInactive(m_fullScreenWindow);
+			m_fullScreenWindow->endFullScreen();
 			delete m_fullScreenWindow;
 			//GHOST_PRINT("GHOST_WindowManager::endFullScreen(): done\n");
 			m_fullScreenWindow = 0;

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp	2013-02-24 03:39:20 UTC (rev 54805)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp	2013-02-24 05:05:29 UTC (rev 54806)
@@ -165,9 +165,10 @@
     const GHOST_TEmbedderWindowID parentWindow,
     GHOST_TDrawingContextType type,
     const bool stereoVisual,
+    const bool exclusive,
     const GHOST_TUns16 numOfAASamples
     ) :
-	GHOST_Window(width, height, state, type, stereoVisual, numOfAASamples),
+	GHOST_Window(width, height, state, type, stereoVisual, exclusive, numOfAASamples),

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list