Fixes [#21791] Toggle Fullscreen (Alt + F11) returns to non-maximized window

Applied patch provided by Elia Sarti
This commit is contained in:
Nathan Letwory
2010-06-01 06:18:17 +00:00
parent eab7f6d3c2
commit b96a2c346c
4 changed files with 25 additions and 1 deletions

View File

@@ -64,6 +64,7 @@
LPCSTR GHOST_WindowWin32::s_windowClassName = "GHOST_WindowClass";
const int GHOST_WindowWin32::s_maxTitleLength = 128;
HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL;
HDC GHOST_WindowWin32::s_firstHDC = NULL;
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd);
static int EnumPixelFormats(HDC hdc);
@@ -134,6 +135,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
m_top(top),
m_width(width),
m_height(height),
m_normal_state(GHOST_kWindowStateNormal),
m_stereo(stereoVisual),
m_nextWindow(NULL)
{
@@ -202,6 +204,10 @@ GHOST_WindowWin32::GHOST_WindowWin32(
// Store the device context
m_hDC = ::GetDC(m_hWnd);
if(!s_firstHDC) {
s_firstHDC = m_hDC;
}
// Show the window
int nCmdShow;
switch (state) {
@@ -308,10 +314,11 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
m_customCursor = NULL;
}
::wglMakeCurrent(NULL, NULL);
m_multisampleEnabled = GHOST_kFailure;
m_multisample = 0;
setDrawingContextType(GHOST_kDrawingContextTypeNone);
if (m_hDC) {
if (m_hDC && m_hDC != s_firstHDC) {
::ReleaseDC(m_hWnd, m_hDC);
m_hDC = 0;
}
@@ -482,9 +489,13 @@ void GHOST_WindowWin32::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST
GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state)
{
GHOST_TWindowState curstate = getState();
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
::GetWindowPlacement(m_hWnd, &wp);
if (state == GHOST_kWindowStateNormal)
state = m_normal_state;
switch (state) {
case GHOST_kWindowStateMinimized:
wp.showCmd = SW_SHOWMINIMIZED;
@@ -495,6 +506,8 @@ GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state)
SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
break;
case GHOST_kWindowStateFullScreen:
if (curstate != state && curstate != GHOST_kWindowStateMinimized)
m_normal_state = curstate;
wp.showCmd = SW_SHOWMAXIMIZED;
wp.ptMaxPosition.x = 0;
wp.ptMaxPosition.y = 0;
@@ -637,6 +650,7 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp
m_hGlRc = ::wglCreateContext(m_hDC);
if (m_hGlRc) {
if (s_firsthGLRc) {
::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS);
wglShareLists(s_firsthGLRc, m_hGlRc);
} else {
s_firsthGLRc = m_hGlRc;

View File

@@ -315,6 +315,8 @@ protected:
HGLRC m_hGlRc;
/** The first created OpenGL context (for sharing display lists) */
static HGLRC s_firsthGLRc;
/** The first created device context handle. */
static HDC s_firstHDC;
/** Flag for if window has captured the mouse */
bool m_hasMouseCaptured;
/** Count of number of pressed buttons */
@@ -351,6 +353,7 @@ protected:
GHOST_TInt32 m_top;
GHOST_TUns32 m_width;
GHOST_TUns32 m_height;
GHOST_TWindowState m_normal_state;
bool m_stereo;
/** The GHOST_System passes this to wm if this window is being replaced */

View File

@@ -159,6 +159,7 @@ GHOST_WindowX11(
GHOST_Window(title,left,top,width,height,state,type,stereoVisual,numOfAASamples),
m_context(NULL),
m_display(display),
m_normal_state(GHOST_kWindowStateNormal),
m_system (system),
m_valid_setup (false),
m_invalid_window(false),
@@ -1036,6 +1037,9 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
is_motif_full = motifIsFullScreen();
if (state == GHOST_kWindowStateNormal)
state = m_normal_state;
if (state == GHOST_kWindowStateNormal) {
if (is_max == True)
netwmMaximized(False);
@@ -1055,6 +1059,8 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
if (cur_state == GHOST_kWindowStateMinimized)
return (GHOST_kFailure);
m_normal_state = cur_state;
if (is_max == True)
netwmMaximized(False);
if (is_full == False)

View File

@@ -327,6 +327,7 @@ private :
Window m_window;
Display *m_display;
XVisualInfo *m_visual;
GHOST_TWindowState m_normal_state;
/** The first created OpenGL context (for sharing display lists) */
static GLXContext s_firstContext;