From c793b81235eba6e9e9144792dcd0366c8d73c2eb Mon Sep 17 00:00:00 2001 From: Maximilian Wagenbach Date: Wed, 7 Feb 2018 15:31:02 +0100 Subject: [PATCH 1/3] Implementation for the new window states API on MacOS. --- include/SFML/Window/Window.hpp | 27 +++++++++- include/SFML/Window/WindowState.hpp | 47 ++++++++++++++++ include/SFML/Window/WindowStyle.hpp | 1 + src/SFML/Window/CMakeLists.txt | 1 + src/SFML/Window/OSX/SFWindowController.mm | 53 ++++++++++++++++++- src/SFML/Window/OSX/WindowImplCocoa.hpp | 17 ++++++ src/SFML/Window/OSX/WindowImplCocoa.mm | 47 ++++++++++++++++ .../Window/OSX/WindowImplDelegateProtocol.h | 42 +++++++++++++++ src/SFML/Window/Window.cpp | 25 +++++++-- src/SFML/Window/WindowImpl.hpp | 19 ++++++- 10 files changed, 271 insertions(+), 8 deletions(-) create mode 100644 include/SFML/Window/WindowState.hpp diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 7ff81e29..3bdb5a27 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -472,6 +473,30 @@ public: //////////////////////////////////////////////////////////// bool hasFocus() const; + //////////////////////////////////////////////////////////// + /// \brief Set the window state + /// + /// Set the window state. + /// + /// \param state The new state + /// + /// \see getState + /// + //////////////////////////////////////////////////////////// + void setState(State state); + + //////////////////////////////////////////////////////////// + /// \brief Get the windows state + /// + /// Get the window state. + /// + /// \return The window state + /// + /// \see setState + /// + //////////////////////////////////////////////////////////// + State getState() const; + //////////////////////////////////////////////////////////// /// \brief Display on screen what has been rendered to the window so far /// @@ -537,7 +562,7 @@ private: /// \brief Perform some common internal initializations /// //////////////////////////////////////////////////////////// - void initialize(); + void initialize(Uint32 style); //////////////////////////////////////////////////////////// // Member data diff --git a/include/SFML/Window/WindowState.hpp b/include/SFML/Window/WindowState.hpp new file mode 100644 index 00000000..16c441c8 --- /dev/null +++ b/include/SFML/Window/WindowState.hpp @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2018 Foaly (foaly@posteo.de) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_WINDOWSTATE_HPP +#define SFML_WINDOWSTATE_HPP + + +namespace sf +{ +//////////////////////////////////////////////////////////// +/// \ingroup window +/// \brief Enumeration of the window states +/// +//////////////////////////////////////////////////////////// +enum State +{ + Windowed, + Minimized, + Maximized, + Fullscreen +}; + +} // namespace sf + + +#endif // SFML_WINDOWSTATE_HPP diff --git a/include/SFML/Window/WindowStyle.hpp b/include/SFML/Window/WindowStyle.hpp index 53e2c9df..8847efb1 100644 --- a/include/SFML/Window/WindowStyle.hpp +++ b/include/SFML/Window/WindowStyle.hpp @@ -42,6 +42,7 @@ namespace Style Resize = 1 << 1, ///< Title bar + resizable border + maximize button Close = 1 << 2, ///< Title bar + close button Fullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive) + Hidden = 1 << 4, ///< Hidden window Default = Titlebar | Resize | Close ///< Default window style }; diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 98ea4394..f9f4ae5b 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -45,6 +45,7 @@ set(SRC ${SRCROOT}/WindowImpl.cpp ${SRCROOT}/WindowImpl.hpp ${INCROOT}/WindowStyle.hpp + ${INCROOT}/WindowState.hpp ) if(SFML_OPENGL_ES AND NOT SFML_OS_IOS) list(APPEND SRC ${SRCROOT}/EGLCheck.cpp) diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm index 186a0fbe..cb5148e0 100644 --- a/src/SFML/Window/OSX/SFWindowController.mm +++ b/src/SFML/Window/OSX/SFWindowController.mm @@ -158,6 +158,9 @@ [self setupWindowWithMode:mode andStyle:style]; [m_oglView finishInit]; + + if (style & sf::Style::Hidden) + [m_window orderOut:self]; } return self; } @@ -492,7 +495,7 @@ //////////////////////////////////////////////////////// -(void)hideWindow { - [m_window orderOut:nil]; + [m_window orderOut:self]; } @@ -530,6 +533,54 @@ } +//////////////////////////////////////////////////////// +-(void)minimize +{ + [m_window miniaturize:self]; +} + + +//////////////////////////////////////////////////////// +-(void)unminimize +{ + [m_window deminiaturize:self]; +} + + +//////////////////////////////////////////////////////// +-(void)toogleMaximize +{ + [m_window zoom:self]; +} + + +//////////////////////////////////////////////////////// +-(BOOL)isMinimized +{ + return [m_window isMiniaturized]; +} + + +//////////////////////////////////////////////////////// +-(BOOL)isMaximized +{ + // isZoomed is always true when the windows has the style NSBorderlessWindowMask or is fullscreen + // also the other SFML styles besides Resize can't be maximized, so we filter here + NSUInteger style = [m_window styleMask]; + if ( !(style & NSResizableWindowMask) ) + return NO; + + return [m_window isZoomed]; +} + + +//////////////////////////////////////////////////////// +-(BOOL)isFullscreen +{ + return m_fullscreen; +} + + //////////////////////////////////////////////////////// -(void)enableKeyRepeat { diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index eea318de..9c4d09c3 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -352,6 +352,23 @@ public: //////////////////////////////////////////////////////////// virtual bool hasFocus() const; + //////////////////////////////////////////////////////////// + /// \brief Set the window state + /// + /// \param state The new state + /// + //////////////////////////////////////////////////////////// + virtual void setState(State state); + + + //////////////////////////////////////////////////////////// + /// \brief Get the window state + /// + /// \return The window state + /// + //////////////////////////////////////////////////////////// + virtual State getState() const; + protected: //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index edb69358..2206b4f8 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -524,6 +524,53 @@ bool WindowImplCocoa::hasFocus() const } +//////////////////////////////////////////////////////////// +void WindowImplCocoa::setState(State state) +{ + State currentState = getState(); + + switch(state) + { + case State::Minimized: + [m_delegate minimize]; + break; + + case State::Maximized: + if (currentState == State::Windowed) + [m_delegate toogleMaximize]; + if (currentState == State::Minimized) + { + [m_delegate unminimize]; + [m_delegate toogleMaximize]; + } + break; + + case State::Windowed: + if (currentState == State::Minimized) + [m_delegate unminimize]; + else if (currentState == State::Maximized) + [m_delegate toogleMaximize]; + break; + + case Fullscreen: + sf::err() << "Switching to fullscreen is not implemtent on OSX yet." << std::endl; + break; + } +} + + +//////////////////////////////////////////////////////////// +State WindowImplCocoa::getState() const +{ + if ([m_delegate isFullscreen]) + return State::Fullscreen; + if ([m_delegate isMinimized]) + return State::Minimized; + if ([m_delegate isMaximized]) + return State::Maximized; + return State::Windowed; +} + } // namespace priv } // namespace sf diff --git a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h index d6cfa901..9d92be09 100644 --- a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h +++ b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h @@ -195,6 +195,48 @@ namespace sf { //////////////////////////////////////////////////////////// -(BOOL)hasFocus; +//////////////////////////////////////////////////////////// +/// \brief Minimize the window +/// +//////////////////////////////////////////////////////////// +-(void)minimize; + +//////////////////////////////////////////////////////////// +/// \brief Unminimize the window +/// +//////////////////////////////////////////////////////////// +-(void)unminimize; + +//////////////////////////////////////////////////////////// +/// \brief Maximize or unmaximizes the window +/// +//////////////////////////////////////////////////////////// +-(void)toogleMaximize; + +//////////////////////////////////////////////////////////// +/// \brief Check whether the window is minimized +/// +/// \return True if window is minimized, false otherwise +/// +//////////////////////////////////////////////////////////// +-(BOOL)isMinimized; + +//////////////////////////////////////////////////////////// +/// \brief Check whether the window is maximized +/// +/// \return True if window is maximized, false otherwise +/// +//////////////////////////////////////////////////////////// +-(BOOL)isMaximized; + +//////////////////////////////////////////////////////////// +/// \brief Check whether the window is fullscreen +/// +/// \return True if window is fullscreen, false otherwise +/// +//////////////////////////////////////////////////////////// +-(BOOL)isFullscreen; + //////////////////////////////////////////////////////////// /// \brief Enable key repeat /// diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index b1ed548a..ef70f57b 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -127,7 +127,7 @@ void Window::create(VideoMode mode, const String& title, Uint32 style, const Con m_context = priv::GlContext::create(settings, m_impl, mode.bitsPerPixel); // Perform common initializations - initialize(); + initialize(style); } @@ -144,7 +144,7 @@ void Window::create(WindowHandle handle, const ContextSettings& settings) m_context = priv::GlContext::create(settings, m_impl, VideoMode::getDesktopMode().bitsPerPixel); // Perform common initializations - initialize(); + initialize(sf::Style::Default); } @@ -368,7 +368,21 @@ bool Window::hasFocus() const //////////////////////////////////////////////////////////// +void Window::setState(State state) +{ + if (m_impl) + m_impl->setState(state); +} + +//////////////////////////////////////////////////////////// +State Window::getState() const +{ + return m_impl ? m_impl->getState() : State::Windowed; +} + + +//////////////////////////////////////////////////////////// void Window::display() { // Display the backbuffer on screen @@ -424,15 +438,16 @@ bool Window::filterEvent(const Event& event) //////////////////////////////////////////////////////////// -void Window::initialize() +void Window::initialize(Uint32 style) { // Setup default behaviors (to get a consistent behavior across different implementations) - setVisible(true); - setMouseCursorVisible(true); setVerticalSyncEnabled(false); setKeyRepeatEnabled(true); setFramerateLimit(0); + if (!(style & Style::Hidden)) + setVisible(true); + // Get and cache the initial size of the window m_size = m_impl->getSize(); diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index a360a018..ead8822f 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -39,8 +39,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -227,6 +228,22 @@ public: //////////////////////////////////////////////////////////// virtual bool hasFocus() const = 0; + //////////////////////////////////////////////////////////// + /// \brief Set the window state + /// + /// \param state The new state + /// + //////////////////////////////////////////////////////////// + virtual void setState(State state) = 0; + + //////////////////////////////////////////////////////////// + /// \brief Get the window state + /// + /// \return The window state + /// + //////////////////////////////////////////////////////////// + virtual State getState() const = 0; + protected: //////////////////////////////////////////////////////////// From 0317f83b70fc546a7e6ddcc8add5142bba6121a7 Mon Sep 17 00:00:00 2001 From: Maximilian Wagenbach Date: Sun, 11 Feb 2018 16:56:36 +0100 Subject: [PATCH 2/3] Implementation for the window states API on Windows. --- src/SFML/Window/Win32/WindowImplWin32.cpp | 139 +++++++++++++++++----- src/SFML/Window/Win32/WindowImplWin32.hpp | 32 ++++- src/SFML/Window/Window.cpp | 23 ++++ 3 files changed, 161 insertions(+), 33 deletions(-) diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index e8e17fe5..bb3ef848 100755 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -123,6 +123,28 @@ namespace FreeLibrary(user32Dll); } } + + DWORD translateStyle(sf::Uint32 style) + { + // Choose the window style according to the Style parameter + DWORD win32Style = WS_VISIBLE; + if (style == sf::Style::None) + { + win32Style |= WS_POPUP; + } + else + { + if (style & sf::Style::Titlebar) win32Style |= WS_CAPTION | WS_MINIMIZEBOX; + if (style & sf::Style::Resize) win32Style |= WS_THICKFRAME | WS_MAXIMIZEBOX; + if (style & sf::Style::Close) win32Style |= WS_SYSMENU; + } + if (!(style & sf::Style::Hidden)) + { + win32Style |= WS_VISIBLE; + } + + return win32Style; + } } namespace sf @@ -141,8 +163,9 @@ m_lastSize (0, 0), m_resizing (false), m_surrogate (0), m_mouseInside (false), -m_fullscreen (false), -m_cursorGrabbed (false) +m_cursorGrabbed (false), +m_win32Style (translateStyle(Style::None)), +m_mode (VideoMode::getDesktopMode()) { // Set that this process is DPI aware and can handle DPI scaling setProcessDpiAware(); @@ -174,8 +197,9 @@ m_lastSize (mode.width, mode.height), m_resizing (false), m_surrogate (0), m_mouseInside (false), -m_fullscreen ((style & Style::Fullscreen) != 0), -m_cursorGrabbed (m_fullscreen) +m_cursorGrabbed ((style & Style::Fullscreen) != 0), +m_win32Style (translateStyle(style)), +m_mode (mode) { // Set that this process is DPI aware and can handle DPI scaling setProcessDpiAware(); @@ -192,30 +216,17 @@ m_cursorGrabbed (m_fullscreen) int height = mode.height; ReleaseDC(NULL, screenDC); - // Choose the window style according to the Style parameter - DWORD win32Style = WS_VISIBLE; - if (style == Style::None) - { - win32Style |= WS_POPUP; - } - else - { - if (style & Style::Titlebar) win32Style |= WS_CAPTION | WS_MINIMIZEBOX; - if (style & Style::Resize) win32Style |= WS_THICKFRAME | WS_MAXIMIZEBOX; - if (style & Style::Close) win32Style |= WS_SYSMENU; - } - // In windowed mode, adjust width and height so that window will have the requested client area - if (!m_fullscreen) + if (!(style & Style::Fullscreen)) { RECT rectangle = {0, 0, width, height}; - AdjustWindowRect(&rectangle, win32Style, false); + AdjustWindowRect(&rectangle, m_win32Style, false); width = rectangle.right - rectangle.left; height = rectangle.bottom - rectangle.top; } // Create the window - m_handle = CreateWindowW(className, title.toWideString().c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this); + m_handle = CreateWindowW(className, title.toWideString().c_str(), m_win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this); // Register to receive device interface change notifications (used for joystick connection handling) DEV_BROADCAST_DEVICEINTERFACE deviceInterface = {sizeof(DEV_BROADCAST_DEVICEINTERFACE), DBT_DEVTYP_DEVICEINTERFACE, 0, GUID_DEVINTERFACE_HID, 0}; @@ -230,13 +241,13 @@ m_cursorGrabbed (m_fullscreen) ++handleCount; } - // By default, the OS limits the size of the window the the desktop size, + // By default, the OS limits the size of the window to the desktop size, // we have to resize it after creation to apply the real size setSize(Vector2u(mode.width, mode.height)); // Switch to fullscreen if requested - if (m_fullscreen) - switchToFullscreen(mode); + if (style & Style::Fullscreen) + switchToFullscreen(); // Increment window count windowCount++; @@ -467,6 +478,51 @@ bool WindowImplWin32::hasFocus() const } +//////////////////////////////////////////////////////////// +void WindowImplWin32::setState(State state) +{ + State currentState = getState(); + + switch (state) + { + case State::Windowed: + if (currentState == State::Fullscreen) + switchToWindowed(); + else + ShowWindow(m_handle, SW_RESTORE); + break; + case State::Minimized: + ShowWindow(m_handle, SW_MINIMIZE); + break; + case State::Maximized: + ShowWindow(m_handle, SW_MAXIMIZE); + break; + case State::Fullscreen: + if (currentState != State::Fullscreen) + switchToFullscreen(); + break; + + } +} + + +//////////////////////////////////////////////////////////// +State WindowImplWin32::getState() const +{ + WINDOWPLACEMENT currentState; + currentState.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(m_handle, ¤tState); + + if ((currentState.showCmd == SW_MINIMIZE) || (currentState.showCmd == SW_SHOWMINIMIZED)) + return State::Minimized; + if ((currentState.showCmd == SW_MAXIMIZE) || (currentState.showCmd == SW_SHOWMAXIMIZED)) + return State::Maximized; + if (fullscreenWindow == this) + return State::Fullscreen; + + return State::Windowed; +} + //////////////////////////////////////////////////////////// void WindowImplWin32::registerWindowClass() { @@ -486,13 +542,13 @@ void WindowImplWin32::registerWindowClass() //////////////////////////////////////////////////////////// -void WindowImplWin32::switchToFullscreen(const VideoMode& mode) +void WindowImplWin32::switchToFullscreen() { DEVMODE devMode; devMode.dmSize = sizeof(devMode); - devMode.dmPelsWidth = mode.width; - devMode.dmPelsHeight = mode.height; - devMode.dmBitsPerPel = mode.bitsPerPixel; + devMode.dmPelsWidth = m_mode.width; + devMode.dmPelsHeight = m_mode.height; + devMode.dmBitsPerPel = m_mode.bitsPerPixel; devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; // Apply fullscreen mode @@ -507,7 +563,7 @@ void WindowImplWin32::switchToFullscreen(const VideoMode& mode) SetWindowLongW(m_handle, GWL_EXSTYLE, WS_EX_APPWINDOW); // Resize the window so that it fits the entire screen - SetWindowPos(m_handle, HWND_TOP, 0, 0, mode.width, mode.height, SWP_FRAMECHANGED); + SetWindowPos(m_handle, HWND_TOP, 0, 0, m_mode.width, m_mode.height, SWP_FRAMECHANGED); ShowWindow(m_handle, SW_SHOW); // Set "this" as the current fullscreen window @@ -515,6 +571,33 @@ void WindowImplWin32::switchToFullscreen(const VideoMode& mode) } +//////////////////////////////////////////////////////////// +void WindowImplWin32::switchToWindowed() +{ + // Restore the graphics mode of the display device back to the values from the registry + ChangeDisplaySettings(NULL, 0); + + // Set the window flags to what the user requested before switching to fullscreen + SetWindowLongW(m_handle, GWL_STYLE, m_win32Style); + + // Compute position and size + HDC screenDC = GetDC(NULL); + int left = (GetDeviceCaps(screenDC, HORZRES) - static_cast(m_mode.width)) / 2; + int top = (GetDeviceCaps(screenDC, VERTRES) - static_cast(m_mode.height)) / 2; + ReleaseDC(NULL, screenDC); + + RECT rectangle = {0, 0, static_cast(m_mode.width), static_cast(m_mode.height)}; + AdjustWindowRect(&rectangle, m_win32Style, false); + int width = rectangle.right - rectangle.left; + int height = rectangle.bottom - rectangle.top; + + SetWindowPos(m_handle, HWND_TOP, left, top, width, height, SWP_FRAMECHANGED); + + + fullscreenWindow = NULL; +} + + //////////////////////////////////////////////////////////// void WindowImplWin32::cleanup() { diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index 4114c51b..afef5f65 100755 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -184,6 +184,22 @@ public: //////////////////////////////////////////////////////////// virtual bool hasFocus() const; + //////////////////////////////////////////////////////////// + /// \brief Set the window state + /// + /// \param state The new state + /// + //////////////////////////////////////////////////////////// + virtual void setState(State state); + + //////////////////////////////////////////////////////////// + /// \brief Get the window state + /// + /// \return The window state + /// + //////////////////////////////////////////////////////////// + virtual State getState() const; + protected: //////////////////////////////////////////////////////////// @@ -201,12 +217,16 @@ private: void registerWindowClass(); //////////////////////////////////////////////////////////// - /// \brief Switch to fullscreen mode - /// - /// \param mode Video mode to switch to + /// \brief Switch to fullscreen state /// //////////////////////////////////////////////////////////// - void switchToFullscreen(const VideoMode& mode); + void switchToFullscreen(); + + //////////////////////////////////////////////////////////// + /// \brief Switch to windowed state + /// + //////////////////////////////////////////////////////////// + void switchToWindowed(); //////////////////////////////////////////////////////////// /// \brief Free all the graphical resources attached to the window @@ -282,8 +302,10 @@ private: bool m_resizing; ///< Is the window being resized? Uint16 m_surrogate; ///< First half of the surrogate pair, in case we're receiving a Unicode character in two events bool m_mouseInside; ///< Mouse is inside the window? - bool m_fullscreen; ///< Is the window fullscreen? bool m_cursorGrabbed; ///< Is the mouse cursor trapped? + + const DWORD m_win32Style; ///< Window style in the windows format + const VideoMode m_mode; ///< Video mode of the window }; } // namespace priv diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index ef70f57b..8cf5fa82 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -31,6 +31,8 @@ #include #include +#include + namespace { @@ -371,7 +373,28 @@ bool Window::hasFocus() const void Window::setState(State state) { if (m_impl) + { + // TODO: this if never evaluates to true, even if state IS State::Windowed + // I can't figure out why. This is ehy you can only switch to fullscreen once + if (state == State::Windowed) + { + if (this == fullscreenWindow) + fullscreenWindow == NULL; + } + + if (state == State::Fullscreen) + if (fullscreenWindow != NULL) + { + err() << "Creating more than one fullscreen window is not allowed" << std::endl; + return; + } + else + { + fullscreenWindow = this; + } + m_impl->setState(state); + } } From 2e4a791bd60049b5a0a2935b4080239af18f4f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sat, 5 Jan 2019 00:52:11 +0100 Subject: [PATCH 3/3] Started some fixes for Windows --- src/SFML/Window/Win32/WindowImplWin32.cpp | 3 +-- src/SFML/Window/Window.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index bb3ef848..49651c23 100755 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -127,7 +127,7 @@ namespace DWORD translateStyle(sf::Uint32 style) { // Choose the window style according to the Style parameter - DWORD win32Style = WS_VISIBLE; + DWORD win32Style = 0; if (style == sf::Style::None) { win32Style |= WS_POPUP; @@ -593,7 +593,6 @@ void WindowImplWin32::switchToWindowed() SetWindowPos(m_handle, HWND_TOP, left, top, width, height, SWP_FRAMECHANGED); - fullscreenWindow = NULL; } diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 8cf5fa82..afb1d13e 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -379,7 +379,7 @@ void Window::setState(State state) if (state == State::Windowed) { if (this == fullscreenWindow) - fullscreenWindow == NULL; + fullscreenWindow = NULL; } if (state == State::Fullscreen)