From c0acaef204e1e0f1dc55e48236986d56f3630016 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Thu, 15 Dec 2022 00:41:19 -0700 Subject: [PATCH] Use in-class member initializers --- include/SFML/Window/Joystick.hpp | 8 ++-- include/SFML/Window/VideoMode.hpp | 4 +- src/SFML/Window/Android/CursorImpl.cpp | 8 ---- src/SFML/Window/Android/CursorImpl.hpp | 2 +- src/SFML/Window/Android/WindowImplAndroid.cpp | 11 +----- src/SFML/Window/Android/WindowImplAndroid.hpp | 6 +-- src/SFML/Window/DRM/CursorImpl.cpp | 6 --- src/SFML/Window/DRM/CursorImpl.hpp | 2 +- src/SFML/Window/DRM/DRMContext.cpp | 36 ++---------------- src/SFML/Window/DRM/DRMContext.hpp | 18 ++++----- src/SFML/Window/DRM/InputImplUDev.cpp | 8 +--- src/SFML/Window/DRM/WindowImplDRM.cpp | 2 +- src/SFML/Window/EglContext.cpp | 18 ++------- src/SFML/Window/EglContext.hpp | 8 ++-- src/SFML/Window/Joystick.cpp | 6 --- src/SFML/Window/OSX/HIDInputManager.hpp | 8 ++-- src/SFML/Window/OSX/HIDInputManager.mm | 2 +- src/SFML/Window/OSX/HIDJoystickManager.cpp | 2 +- src/SFML/Window/OSX/HIDJoystickManager.hpp | 4 +- src/SFML/Window/OSX/SFContext.hpp | 6 +-- src/SFML/Window/OSX/SFContext.mm | 12 ++---- src/SFML/Window/OSX/WindowImplCocoa.hpp | 4 +- src/SFML/Window/OSX/WindowImplCocoa.mm | 5 +-- src/SFML/Window/Unix/ClipboardImpl.cpp | 2 +- src/SFML/Window/Unix/ClipboardImpl.hpp | 20 +++++----- src/SFML/Window/Unix/CursorImpl.cpp | 3 +- src/SFML/Window/Unix/CursorImpl.hpp | 2 +- src/SFML/Window/Unix/GlxContext.cpp | 25 +++--------- src/SFML/Window/Unix/GlxContext.hpp | 10 ++--- src/SFML/Window/Unix/JoystickImpl.cpp | 7 ---- src/SFML/Window/Unix/JoystickImpl.hpp | 14 ++----- src/SFML/Window/Unix/VulkanImplX11.cpp | 16 ++------ src/SFML/Window/Unix/WindowImplX11.cpp | 37 +----------------- src/SFML/Window/Unix/WindowImplX11.hpp | 38 +++++++++---------- src/SFML/Window/VideoMode.cpp | 4 +- src/SFML/Window/Win32/CursorImpl.cpp | 8 ---- src/SFML/Window/Win32/CursorImpl.hpp | 6 +-- src/SFML/Window/Win32/JoystickImpl.cpp | 5 +-- src/SFML/Window/Win32/VulkanImplWin32.cpp | 16 ++------ src/SFML/Window/Win32/WglContext.cpp | 14 +------ src/SFML/Window/Win32/WglContext.hpp | 10 ++--- src/SFML/Window/Win32/WindowImplWin32.cpp | 23 +---------- src/SFML/Window/Win32/WindowImplWin32.hpp | 25 ++++++------ src/SFML/Window/Window.cpp | 10 ++--- src/SFML/Window/WindowBase.cpp | 8 ++-- src/SFML/Window/WindowImpl.cpp | 2 +- src/SFML/Window/WindowImpl.hpp | 2 +- src/SFML/Window/iOS/CursorImpl.cpp | 8 ---- src/SFML/Window/iOS/CursorImpl.hpp | 2 +- src/SFML/Window/iOS/EaglContext.hpp | 12 +++--- src/SFML/Window/iOS/EaglContext.mm | 22 ++--------- 51 files changed, 152 insertions(+), 385 deletions(-) diff --git a/include/SFML/Window/Joystick.hpp b/include/SFML/Window/Joystick.hpp index debd1334..1859737a 100644 --- a/include/SFML/Window/Joystick.hpp +++ b/include/SFML/Window/Joystick.hpp @@ -75,11 +75,9 @@ public: //////////////////////////////////////////////////////////// struct SFML_WINDOW_API Identification { - Identification(); - - String name; //!< Name of the joystick - unsigned int vendorId; //!< Manufacturer identifier - unsigned int productId; //!< Product identifier + String name{"No Joystick"}; //!< Name of the joystick + unsigned int vendorId{0}; //!< Manufacturer identifier + unsigned int productId{0}; //!< Product identifier }; //////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/VideoMode.hpp b/include/SFML/Window/VideoMode.hpp index 9201c8ab..993d47b9 100644 --- a/include/SFML/Window/VideoMode.hpp +++ b/include/SFML/Window/VideoMode.hpp @@ -100,8 +100,8 @@ public: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - Vector2u size; //!< Video mode width and height, in pixels - unsigned int bitsPerPixel; //!< Video mode pixel depth, in bits per pixels + Vector2u size; //!< Video mode width and height, in pixels + unsigned int bitsPerPixel{0}; //!< Video mode pixel depth, in bits per pixels }; //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/Android/CursorImpl.cpp b/src/SFML/Window/Android/CursorImpl.cpp index 8cf6e5df..5834b664 100644 --- a/src/SFML/Window/Android/CursorImpl.cpp +++ b/src/SFML/Window/Android/CursorImpl.cpp @@ -31,14 +31,6 @@ namespace sf { namespace priv { - -//////////////////////////////////////////////////////////// -CursorImpl::CursorImpl() -{ - // Nothing. -} - - //////////////////////////////////////////////////////////// bool CursorImpl::loadFromPixels(const std::uint8_t* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) { diff --git a/src/SFML/Window/Android/CursorImpl.hpp b/src/SFML/Window/Android/CursorImpl.hpp index a00504d0..4287e9ee 100644 --- a/src/SFML/Window/Android/CursorImpl.hpp +++ b/src/SFML/Window/Android/CursorImpl.hpp @@ -52,7 +52,7 @@ public: /// Refer to sf::Cursor::Cursor(). /// //////////////////////////////////////////////////////////// - CursorImpl(); + CursorImpl() = default; //////////////////////////////////////////////////////////// /// \brief Deleted copy constructor diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index 6a2dda8d..d64ba7ea 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -52,11 +52,7 @@ namespace priv WindowImplAndroid* WindowImplAndroid::singleInstance = nullptr; //////////////////////////////////////////////////////////// -WindowImplAndroid::WindowImplAndroid(WindowHandle /* handle */) : -m_size(0, 0), -m_windowBeingCreated(false), -m_windowBeingDestroyed(false), -m_hasFocus(false) +WindowImplAndroid::WindowImplAndroid(WindowHandle /* handle */) { } @@ -66,10 +62,7 @@ WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& /* title */, unsigned long style, const ContextSettings& /* settings */) : -m_size(mode.size), -m_windowBeingCreated(false), -m_windowBeingDestroyed(false), -m_hasFocus(false) +m_size(mode.size) { ActivityStates& states = getActivity(); std::scoped_lock lock(states.mutex); diff --git a/src/SFML/Window/Android/WindowImplAndroid.hpp b/src/SFML/Window/Android/WindowImplAndroid.hpp index 01bfdc47..8012a19d 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.hpp +++ b/src/SFML/Window/Android/WindowImplAndroid.hpp @@ -233,9 +233,9 @@ private: static int getUnicode(AInputEvent* event); Vector2u m_size; - bool m_windowBeingCreated; - bool m_windowBeingDestroyed; - bool m_hasFocus; + bool m_windowBeingCreated{false}; + bool m_windowBeingDestroyed{false}; + bool m_hasFocus{false}; }; } // namespace priv diff --git a/src/SFML/Window/DRM/CursorImpl.cpp b/src/SFML/Window/DRM/CursorImpl.cpp index 46d8f526..2baeb82a 100644 --- a/src/SFML/Window/DRM/CursorImpl.cpp +++ b/src/SFML/Window/DRM/CursorImpl.cpp @@ -34,12 +34,6 @@ namespace sf { namespace priv { -//////////////////////////////////////////////////////////// -CursorImpl::CursorImpl() -{ -} - - //////////////////////////////////////////////////////////// bool CursorImpl::loadFromPixels(const std::uint8_t* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/) { diff --git a/src/SFML/Window/DRM/CursorImpl.hpp b/src/SFML/Window/DRM/CursorImpl.hpp index 11e8eec1..757b0f30 100644 --- a/src/SFML/Window/DRM/CursorImpl.hpp +++ b/src/SFML/Window/DRM/CursorImpl.hpp @@ -50,7 +50,7 @@ public: /// Refer to sf::Cursor::Cursor(). /// //////////////////////////////////////////////////////////// - CursorImpl(); + CursorImpl() = default; //////////////////////////////////////////////////////////// /// \brief Deleted copy constructor diff --git a/src/SFML/Window/DRM/DRMContext.cpp b/src/SFML/Window/DRM/DRMContext.cpp index 320610c5..a9d9d3a2 100644 --- a/src/SFML/Window/DRM/DRMContext.cpp +++ b/src/SFML/Window/DRM/DRMContext.cpp @@ -511,17 +511,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -DRMContext::DRMContext(DRMContext* shared) : -m_display(EGL_NO_DISPLAY), -m_context(EGL_NO_CONTEXT), -m_surface(EGL_NO_SURFACE), -m_config(nullptr), -m_currentBO(nullptr), -m_nextBO(nullptr), -m_gbmSurface(nullptr), -m_size(0, 0), -m_shown(false), -m_scanOut(false) +DRMContext::DRMContext(DRMContext* shared) { contextCount++; @@ -543,17 +533,7 @@ m_scanOut(false) //////////////////////////////////////////////////////////// -DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel) : -m_display(EGL_NO_DISPLAY), -m_context(EGL_NO_CONTEXT), -m_surface(EGL_NO_SURFACE), -m_config(nullptr), -m_currentBO(nullptr), -m_nextBO(nullptr), -m_gbmSurface(nullptr), -m_size(0, 0), -m_shown(false), -m_scanOut(false) +DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel) { contextCount++; @@ -573,17 +553,7 @@ m_scanOut(false) //////////////////////////////////////////////////////////// -DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, const Vector2u& size) : -m_display(EGL_NO_DISPLAY), -m_context(EGL_NO_CONTEXT), -m_surface(EGL_NO_SURFACE), -m_config(nullptr), -m_currentBO(nullptr), -m_nextBO(nullptr), -m_gbmSurface(nullptr), -m_size(0, 0), -m_shown(false), -m_scanOut(false) +DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, const Vector2u& size) { contextCount++; diff --git a/src/SFML/Window/DRM/DRMContext.hpp b/src/SFML/Window/DRM/DRMContext.hpp index dd208e57..da3bf4c2 100644 --- a/src/SFML/Window/DRM/DRMContext.hpp +++ b/src/SFML/Window/DRM/DRMContext.hpp @@ -199,17 +199,17 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - EGLDisplay m_display; ///< The internal EGL display - EGLContext m_context; ///< The internal EGL context - EGLSurface m_surface; ///< The internal EGL surface - EGLConfig m_config; ///< The internal EGL config + EGLDisplay m_display{EGL_NO_DISPLAY}; ///< The internal EGL display + EGLContext m_context{EGL_NO_CONTEXT}; ///< The internal EGL context + EGLSurface m_surface{EGL_NO_SURFACE}; ///< The internal EGL surface + EGLConfig m_config{nullptr}; ///< The internal EGL config - gbm_bo* m_currentBO; - gbm_bo* m_nextBO; - gbm_surface* m_gbmSurface; + gbm_bo* m_currentBO{nullptr}; + gbm_bo* m_nextBO{nullptr}; + gbm_surface* m_gbmSurface{nullptr}; Vector2u m_size; - bool m_shown; - bool m_scanOut; + bool m_shown{false}; + bool m_scanOut{false}; }; } // namespace priv diff --git a/src/SFML/Window/DRM/InputImplUDev.cpp b/src/SFML/Window/DRM/InputImplUDev.cpp index 219a774e..a6163877 100644 --- a/src/SFML/Window/DRM/InputImplUDev.cpp +++ b/src/SFML/Window/DRM/InputImplUDev.cpp @@ -47,13 +47,9 @@ namespace { struct TouchSlot { - int oldId; - int id; + int oldId{-1}; + int id{-1}; sf::Vector2i pos; - - TouchSlot() : oldId(-1), id(-1), pos(0, 0) - { - } }; std::recursive_mutex inputMutex; // threadsafe? maybe... diff --git a/src/SFML/Window/DRM/WindowImplDRM.cpp b/src/SFML/Window/DRM/WindowImplDRM.cpp index 3246976d..7deac97a 100644 --- a/src/SFML/Window/DRM/WindowImplDRM.cpp +++ b/src/SFML/Window/DRM/WindowImplDRM.cpp @@ -38,7 +38,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -WindowImplDRM::WindowImplDRM(WindowHandle /*handle*/) : m_size(0, 0) +WindowImplDRM::WindowImplDRM(WindowHandle /*handle*/) { sf::priv::InputImpl::setTerminalConfig(); } diff --git a/src/SFML/Window/EglContext.cpp b/src/SFML/Window/EglContext.cpp index ffc4c6de..ea1e6a49 100644 --- a/src/SFML/Window/EglContext.cpp +++ b/src/SFML/Window/EglContext.cpp @@ -102,11 +102,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -EglContext::EglContext(EglContext* shared) : -m_display(EGL_NO_DISPLAY), -m_context(EGL_NO_CONTEXT), -m_surface(EGL_NO_SURFACE), -m_config(nullptr) +EglContext::EglContext(EglContext* shared) { EglContextImpl::ensureInit(); @@ -132,11 +128,7 @@ m_config(nullptr) EglContext::EglContext(EglContext* shared, const ContextSettings& settings, [[maybe_unused]] const WindowImpl& owner, - unsigned int bitsPerPixel) : -m_display(EGL_NO_DISPLAY), -m_context(EGL_NO_CONTEXT), -m_surface(EGL_NO_SURFACE), -m_config(nullptr) + unsigned int bitsPerPixel) { EglContextImpl::ensureInit(); @@ -170,11 +162,7 @@ m_config(nullptr) //////////////////////////////////////////////////////////// -EglContext::EglContext(EglContext* /*shared*/, const ContextSettings& /*settings*/, const Vector2u& /*size*/) : -m_display(EGL_NO_DISPLAY), -m_context(EGL_NO_CONTEXT), -m_surface(EGL_NO_SURFACE), -m_config(nullptr) +EglContext::EglContext(EglContext* /*shared*/, const ContextSettings& /*settings*/, const Vector2u& /*size*/) { EglContextImpl::ensureInit(); diff --git a/src/SFML/Window/EglContext.hpp b/src/SFML/Window/EglContext.hpp index f6abbb9f..dce013af 100644 --- a/src/SFML/Window/EglContext.hpp +++ b/src/SFML/Window/EglContext.hpp @@ -188,10 +188,10 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - EGLDisplay m_display; //!< The internal EGL display - EGLContext m_context; //!< The internal EGL context - EGLSurface m_surface; //!< The internal EGL surface - EGLConfig m_config; //!< The internal EGL config + EGLDisplay m_display{EGL_NO_DISPLAY}; //!< The internal EGL display + EGLContext m_context{EGL_NO_CONTEXT}; //!< The internal EGL context + EGLSurface m_surface{EGL_NO_SURFACE}; //!< The internal EGL surface + EGLConfig m_config{nullptr}; //!< The internal EGL config }; } // namespace priv diff --git a/src/SFML/Window/Joystick.cpp b/src/SFML/Window/Joystick.cpp index a443ed48..60c77ba4 100644 --- a/src/SFML/Window/Joystick.cpp +++ b/src/SFML/Window/Joystick.cpp @@ -79,10 +79,4 @@ void Joystick::update() return priv::JoystickManager::getInstance().update(); } - -//////////////////////////////////////////////////////////// -Joystick::Identification::Identification() : name("No Joystick"), vendorId(0), productId(0) -{ -} - } // namespace sf diff --git a/src/SFML/Window/OSX/HIDInputManager.hpp b/src/SFML/Window/OSX/HIDInputManager.hpp index 1ad132bf..90cce0dd 100644 --- a/src/SFML/Window/OSX/HIDInputManager.hpp +++ b/src/SFML/Window/OSX/HIDInputManager.hpp @@ -220,10 +220,10 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - bool m_isValid; ///< If any error occurs this variable is false - CFDataRef m_layoutData; ///< CFData containing the layout - UCKeyboardLayout* m_layout; ///< Current Keyboard Layout - IOHIDManagerRef m_manager; ///< HID Manager + bool m_isValid{true}; ///< If any error occurs this variable is false + CFDataRef m_layoutData{0}; ///< CFData containing the layout + UCKeyboardLayout* m_layout{nullptr}; ///< Current Keyboard Layout + IOHIDManagerRef m_manager{0}; ///< HID Manager IOHIDElements m_keys[Keyboard::KeyCount]; ///< All the keys on any connected keyboard diff --git a/src/SFML/Window/OSX/HIDInputManager.mm b/src/SFML/Window/OSX/HIDInputManager.mm index b850369d..4539d6fe 100644 --- a/src/SFML/Window/OSX/HIDInputManager.mm +++ b/src/SFML/Window/OSX/HIDInputManager.mm @@ -94,7 +94,7 @@ CFDictionaryRef HIDInputManager::copyDevicesMask(UInt32 page, UInt32 usage) //////////////////////////////////////////////////////////// -HIDInputManager::HIDInputManager() : m_isValid(true), m_layoutData(0), m_layout(0), m_manager(0) +HIDInputManager::HIDInputManager() { // Get the current keyboard layout TISInputSourceRef tis = TISCopyCurrentKeyboardLayoutInputSource(); diff --git a/src/SFML/Window/OSX/HIDJoystickManager.cpp b/src/SFML/Window/OSX/HIDJoystickManager.cpp index 34b11cfd..8d83c352 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.cpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.cpp @@ -69,7 +69,7 @@ CFSetRef HIDJoystickManager::copyJoysticks() //////////////////////////////////////////////////////////// -HIDJoystickManager::HIDJoystickManager() : m_manager(0), m_joystickCount(0) +HIDJoystickManager::HIDJoystickManager() { m_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); diff --git a/src/SFML/Window/OSX/HIDJoystickManager.hpp b/src/SFML/Window/OSX/HIDJoystickManager.hpp index 1a9f2c68..720ff299 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.hpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.hpp @@ -123,8 +123,8 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - IOHIDManagerRef m_manager; ///< HID Manager - unsigned int m_joystickCount; ///< Number of joysticks currently connected + IOHIDManagerRef m_manager{0}; ///< HID Manager + unsigned int m_joystickCount{0}; ///< Number of joysticks currently connected }; diff --git a/src/SFML/Window/OSX/SFContext.hpp b/src/SFML/Window/OSX/SFContext.hpp index c9b20b13..60311a5f 100644 --- a/src/SFML/Window/OSX/SFContext.hpp +++ b/src/SFML/Window/OSX/SFContext.hpp @@ -156,9 +156,9 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - NSOpenGLContextRef m_context; ///< OpenGL context. - NSOpenGLViewRef m_view; ///< Only for offscreen context. - NSWindowRef m_window; ///< Only for offscreen context. + NSOpenGLContextRef m_context{0}; ///< OpenGL context. + NSOpenGLViewRef m_view{0}; ///< Only for offscreen context. + NSWindowRef m_window{0}; ///< Only for offscreen context. }; } // namespace priv diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm index 5a1cdece..0529b7f9 100644 --- a/src/SFML/Window/OSX/SFContext.mm +++ b/src/SFML/Window/OSX/SFContext.mm @@ -44,7 +44,7 @@ namespace priv //////////////////////////////////////////////////////////// -SFContext::SFContext(SFContext* shared) : m_context(0), m_view(0), m_window(0) +SFContext::SFContext(SFContext* shared) { AutoreleasePool pool; // Create the context @@ -53,10 +53,7 @@ SFContext::SFContext(SFContext* shared) : m_context(0), m_view(0), m_window(0) //////////////////////////////////////////////////////////// -SFContext::SFContext(SFContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel) : -m_context(0), -m_view(0), -m_window(0) +SFContext::SFContext(SFContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel) { AutoreleasePool pool; // Create the context. @@ -69,10 +66,7 @@ m_window(0) //////////////////////////////////////////////////////////// -SFContext::SFContext(SFContext* shared, const ContextSettings& settings, const Vector2u& size) : -m_context(0), -m_view(0), -m_window(0) +SFContext::SFContext(SFContext* shared, const ContextSettings& settings, const Vector2u& size) { AutoreleasePool pool; // Ensure the process is setup in order to create a valid window. diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index aae2e6c9..ba9d47d2 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -364,8 +364,8 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - WindowImplDelegateRef m_delegate; ///< Implementation in Obj-C. - bool m_showCursor; ///< Is the cursor displayed or hidden? + WindowImplDelegateRef m_delegate; ///< Implementation in Obj-C. + bool m_showCursor{true}; ///< Is the cursor displayed or hidden? }; } // namespace priv diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 6c3698e5..1080a1ae 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -85,7 +85,7 @@ void showMouseCursor() #pragma mark WindowImplCocoa's ctor/dtor //////////////////////////////////////////////////////////// -WindowImplCocoa::WindowImplCocoa(WindowHandle handle) : m_showCursor(true) +WindowImplCocoa::WindowImplCocoa(WindowHandle handle) { AutoreleasePool pool; // Treat the handle as it real type @@ -118,8 +118,7 @@ WindowImplCocoa::WindowImplCocoa(WindowHandle handle) : m_showCursor(true) //////////////////////////////////////////////////////////// -WindowImplCocoa::WindowImplCocoa(VideoMode mode, const String& title, unsigned long style, const ContextSettings& /*settings*/) : -m_showCursor(true) +WindowImplCocoa::WindowImplCocoa(VideoMode mode, const String& title, unsigned long style, const ContextSettings& /*settings*/) { AutoreleasePool pool; // Transform the app process. diff --git a/src/SFML/Window/Unix/ClipboardImpl.cpp b/src/SFML/Window/Unix/ClipboardImpl.cpp index 5a3948dd..a6eac3bf 100644 --- a/src/SFML/Window/Unix/ClipboardImpl.cpp +++ b/src/SFML/Window/Unix/ClipboardImpl.cpp @@ -74,7 +74,7 @@ void ClipboardImpl::processEvents() //////////////////////////////////////////////////////////// -ClipboardImpl::ClipboardImpl() : m_window(0), m_requestResponded(false) +ClipboardImpl::ClipboardImpl() { // Open a connection with the X server m_display = openDisplay(); diff --git a/src/SFML/Window/Unix/ClipboardImpl.hpp b/src/SFML/Window/Unix/ClipboardImpl.hpp index 6f21ca39..85d5f9a0 100644 --- a/src/SFML/Window/Unix/ClipboardImpl.hpp +++ b/src/SFML/Window/Unix/ClipboardImpl.hpp @@ -136,16 +136,16 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - ::Window m_window; ///< X identifier defining our window - ::Display* m_display; ///< Pointer to the display - Atom m_clipboard; ///< X Atom identifying the CLIPBOARD selection - Atom m_targets; ///< X Atom identifying TARGETS - Atom m_text; ///< X Atom identifying TEXT - Atom m_utf8String; ///< X Atom identifying UTF8_STRING - Atom m_targetProperty; ///< X Atom identifying our destination window property - String m_clipboardContents; ///< Our clipboard contents - std::deque m_events; ///< Queue we use to store pending events for this window - bool m_requestResponded; ///< Holds whether our selection request has been responded to or not + ::Window m_window{0}; ///< X identifier defining our window + ::Display* m_display; ///< Pointer to the display + Atom m_clipboard; ///< X Atom identifying the CLIPBOARD selection + Atom m_targets; ///< X Atom identifying TARGETS + Atom m_text; ///< X Atom identifying TEXT + Atom m_utf8String; ///< X Atom identifying UTF8_STRING + Atom m_targetProperty; ///< X Atom identifying our destination window property + String m_clipboardContents; ///< Our clipboard contents + std::deque m_events; ///< Queue we use to store pending events for this window + bool m_requestResponded{false}; ///< Holds whether our selection request has been responded to or not }; } // namespace priv diff --git a/src/SFML/Window/Unix/CursorImpl.cpp b/src/SFML/Window/Unix/CursorImpl.cpp index b0a3eefc..9196095f 100644 --- a/src/SFML/Window/Unix/CursorImpl.cpp +++ b/src/SFML/Window/Unix/CursorImpl.cpp @@ -42,9 +42,8 @@ namespace priv { //////////////////////////////////////////////////////////// -CursorImpl::CursorImpl() : m_display(openDisplay()), m_cursor(None) +CursorImpl::CursorImpl() : m_display(openDisplay()) { - // That's it. } diff --git a/src/SFML/Window/Unix/CursorImpl.hpp b/src/SFML/Window/Unix/CursorImpl.hpp index c55b661d..e5751a8d 100644 --- a/src/SFML/Window/Unix/CursorImpl.hpp +++ b/src/SFML/Window/Unix/CursorImpl.hpp @@ -125,7 +125,7 @@ private: // Member data //////////////////////////////////////////////////////////// ::Display* m_display; - ::Cursor m_cursor; + ::Cursor m_cursor{None}; }; } // namespace priv diff --git a/src/SFML/Window/Unix/GlxContext.cpp b/src/SFML/Window/Unix/GlxContext.cpp index 687f8db7..6e31cd56 100644 --- a/src/SFML/Window/Unix/GlxContext.cpp +++ b/src/SFML/Window/Unix/GlxContext.cpp @@ -81,7 +81,7 @@ int handleXError(::Display*, XErrorEvent*) class GlxErrorHandler { public: - GlxErrorHandler(::Display* display) : m_lock(glxErrorMutex), m_display(display) + GlxErrorHandler(::Display* display) : m_display(display) { glxErrorOccurred = false; m_previousHandler = XSetErrorHandler(handleXError); @@ -94,7 +94,7 @@ public: } private: - std::scoped_lock m_lock; + std::scoped_lock m_lock{glxErrorMutex}; ::Display* m_display; int (*m_previousHandler)(::Display*, XErrorEvent*); }; @@ -106,12 +106,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -GlxContext::GlxContext(GlxContext* shared) : -m_display(nullptr), -m_window(0), -m_context(nullptr), -m_pbuffer(0), -m_ownsWindow(false) +GlxContext::GlxContext(GlxContext* shared) { // Save the creation settings m_settings = ContextSettings(); @@ -131,12 +126,7 @@ m_ownsWindow(false) //////////////////////////////////////////////////////////// -GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int /*bitsPerPixel*/) : -m_display(nullptr), -m_window(0), -m_context(nullptr), -m_pbuffer(0), -m_ownsWindow(false) +GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int /*bitsPerPixel*/) { // Save the creation settings m_settings = settings; @@ -156,12 +146,7 @@ m_ownsWindow(false) //////////////////////////////////////////////////////////// -GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const Vector2u& size) : -m_display(nullptr), -m_window(0), -m_context(nullptr), -m_pbuffer(0), -m_ownsWindow(false) +GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const Vector2u& size) { // Save the creation settings m_settings = settings; diff --git a/src/SFML/Window/Unix/GlxContext.hpp b/src/SFML/Window/Unix/GlxContext.hpp index c59113be..81b2ae33 100644 --- a/src/SFML/Window/Unix/GlxContext.hpp +++ b/src/SFML/Window/Unix/GlxContext.hpp @@ -176,11 +176,11 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - ::Display* m_display; ///< Connection to the X server - ::Window m_window; ///< Window to which the context is attached - GLXContext m_context; ///< OpenGL context - GLXPbuffer m_pbuffer; ///< GLX pbuffer ID if one was created - bool m_ownsWindow; ///< Do we own the window associated to the context? + ::Display* m_display{nullptr}; ///< Connection to the X server + ::Window m_window{0}; ///< Window to which the context is attached + GLXContext m_context{nullptr}; ///< OpenGL context + GLXPbuffer m_pbuffer{0}; ///< GLX pbuffer ID if one was created + bool m_ownsWindow{false}; ///< Do we own the window associated to the context? }; } // namespace priv diff --git a/src/SFML/Window/Unix/JoystickImpl.cpp b/src/SFML/Window/Unix/JoystickImpl.cpp index 0bd54151..2c978214 100644 --- a/src/SFML/Window/Unix/JoystickImpl.cpp +++ b/src/SFML/Window/Unix/JoystickImpl.cpp @@ -434,13 +434,6 @@ namespace sf { namespace priv { -//////////////////////////////////////////////////////////// -JoystickImpl::JoystickImpl() : m_file(-1) -{ - std::fill(m_mapping, m_mapping + ABS_MAX + 1, 0); -} - - //////////////////////////////////////////////////////////// void JoystickImpl::initialize() { diff --git a/src/SFML/Window/Unix/JoystickImpl.hpp b/src/SFML/Window/Unix/JoystickImpl.hpp index a4732bfe..52744697 100644 --- a/src/SFML/Window/Unix/JoystickImpl.hpp +++ b/src/SFML/Window/Unix/JoystickImpl.hpp @@ -44,12 +44,6 @@ namespace priv class JoystickImpl { public: - //////////////////////////////////////////////////////////// - /// \brief Constructor - /// - //////////////////////////////////////////////////////////// - JoystickImpl(); - //////////////////////////////////////////////////////////// /// \brief Perform the global initialization of the joystick module /// @@ -116,10 +110,10 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - int m_file; ///< File descriptor of the joystick - char m_mapping[ABS_MAX + 1]; ///< Axes mapping (index to axis id) - JoystickState m_state; ///< Current state of the joystick - sf::Joystick::Identification m_identification; ///< Identification of the joystick + int m_file{-1}; ///< File descriptor of the joystick + char m_mapping[ABS_MAX + 1]{0}; ///< Axes mapping (index to axis id) + JoystickState m_state; ///< Current state of the joystick + sf::Joystick::Identification m_identification; ///< Identification of the joystick }; } // namespace priv diff --git a/src/SFML/Window/Unix/VulkanImplX11.cpp b/src/SFML/Window/Unix/VulkanImplX11.cpp index ccb45796..d0e9a91b 100644 --- a/src/SFML/Window/Unix/VulkanImplX11.cpp +++ b/src/SFML/Window/Unix/VulkanImplX11.cpp @@ -41,14 +41,6 @@ namespace { struct VulkanLibraryWrapper { - VulkanLibraryWrapper() : - library(nullptr), - vkGetInstanceProcAddr(nullptr), - vkEnumerateInstanceLayerProperties(nullptr), - vkEnumerateInstanceExtensionProperties(nullptr) - { - } - ~VulkanLibraryWrapper() { if (library) @@ -98,11 +90,11 @@ struct VulkanLibraryWrapper return (entryPoint != nullptr); } - void* library; + void* library{nullptr}; - PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; - PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties; - PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr{nullptr}; + PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties{nullptr}; + PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties{nullptr}; }; VulkanLibraryWrapper wrapper; diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 6efe6b6b..219c3f25 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -478,25 +478,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -WindowImplX11::WindowImplX11(WindowHandle handle) : -m_window(0), -m_screen(0), -m_inputMethod(nullptr), -m_inputContext(nullptr), -m_isExternal(true), -m_oldVideoMode(0), -m_oldRRCrtc(0), -m_hiddenCursor(0), -m_lastCursor(None), -m_keyRepeat(true), -m_previousSize(-1, -1), -m_useSizeHints(false), -m_fullscreen(false), -m_cursorGrabbed(false), -m_windowMapped(false), -m_iconPixmap(0), -m_iconMaskPixmap(0), -m_lastInputTime(0) +WindowImplX11::WindowImplX11(WindowHandle handle) : m_isExternal(true) { using namespace WindowsImplX11Impl; @@ -530,24 +512,9 @@ m_lastInputTime(0) //////////////////////////////////////////////////////////// WindowImplX11::WindowImplX11(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings) : -m_window(0), -m_screen(0), -m_inputMethod(nullptr), -m_inputContext(nullptr), m_isExternal(false), -m_oldVideoMode(0), -m_oldRRCrtc(0), -m_hiddenCursor(0), -m_lastCursor(None), -m_keyRepeat(true), -m_previousSize(-1, -1), -m_useSizeHints(false), m_fullscreen((style & Style::Fullscreen) != 0), -m_cursorGrabbed(m_fullscreen), -m_windowMapped(false), -m_iconPixmap(0), -m_iconMaskPixmap(0), -m_lastInputTime(0) +m_cursorGrabbed(m_fullscreen) { using namespace WindowsImplX11Impl; diff --git a/src/SFML/Window/Unix/WindowImplX11.hpp b/src/SFML/Window/Unix/WindowImplX11.hpp index 66b8f662..667649f2 100644 --- a/src/SFML/Window/Unix/WindowImplX11.hpp +++ b/src/SFML/Window/Unix/WindowImplX11.hpp @@ -297,25 +297,25 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - ::Window m_window; ///< X identifier defining our window - ::Display* m_display; ///< Pointer to the display - int m_screen; ///< Screen identifier - XIM m_inputMethod; ///< Input method linked to the X display - XIC m_inputContext; ///< Input context used to get unicode input in our window - bool m_isExternal; ///< Tell whether the window has been created externally or by SFML - RRMode m_oldVideoMode; ///< Video mode in use before we switch to fullscreen - RRCrtc m_oldRRCrtc; ///< RRCrtc in use before we switch to fullscreen - ::Cursor m_hiddenCursor; ///< As X11 doesn't provide cursor hiding, we must create a transparent one - ::Cursor m_lastCursor; ///< Last cursor used -- this data is not owned by the window and is required to be always valid - bool m_keyRepeat; ///< Is the KeyRepeat feature enabled? - Vector2i m_previousSize; ///< Previous size of the window, to find if a ConfigureNotify event is a resize event (could be a move event only) - bool m_useSizeHints; ///< Is the size of the window fixed with size hints? - bool m_fullscreen; ///< Is the window in fullscreen? - bool m_cursorGrabbed; ///< Is the mouse cursor trapped? - bool m_windowMapped; ///< Has the window been mapped by the window manager? - Pixmap m_iconPixmap; ///< The current icon pixmap if in use - Pixmap m_iconMaskPixmap; ///< The current icon mask pixmap if in use - ::Time m_lastInputTime; ///< Last time we received user input + ::Window m_window{0}; ///< X identifier defining our window + ::Display* m_display; ///< Pointer to the display + int m_screen; ///< Screen identifier + XIM m_inputMethod{nullptr}; ///< Input method linked to the X display + XIC m_inputContext{nullptr}; ///< Input context used to get unicode input in our window + bool m_isExternal; ///< Tell whether the window has been created externally or by SFML + RRMode m_oldVideoMode{0}; ///< Video mode in use before we switch to fullscreen + RRCrtc m_oldRRCrtc{0}; ///< RRCrtc in use before we switch to fullscreen + ::Cursor m_hiddenCursor{0}; ///< As X11 doesn't provide cursor hiding, we must create a transparent one + ::Cursor m_lastCursor{None}; ///< Last cursor used -- this data is not owned by the window and is required to be always valid + bool m_keyRepeat{true}; ///< Is the KeyRepeat feature enabled? + Vector2i m_previousSize{-1, -1}; ///< Previous size of the window, to find if a ConfigureNotify event is a resize event (could be a move event only) + bool m_useSizeHints{false}; ///< Is the size of the window fixed with size hints? + bool m_fullscreen{false}; ///< Is the window in fullscreen? + bool m_cursorGrabbed{false}; ///< Is the mouse cursor trapped? + bool m_windowMapped{false}; ///< Has the window been mapped by the window manager? + Pixmap m_iconPixmap{0}; ///< The current icon pixmap if in use + Pixmap m_iconMaskPixmap{0}; ///< The current icon mask pixmap if in use + ::Time m_lastInputTime{0}; ///< Last time we received user input }; } // namespace priv diff --git a/src/SFML/Window/VideoMode.cpp b/src/SFML/Window/VideoMode.cpp index 7fa3bc84..8cb34b55 100644 --- a/src/SFML/Window/VideoMode.cpp +++ b/src/SFML/Window/VideoMode.cpp @@ -35,9 +35,7 @@ namespace sf { //////////////////////////////////////////////////////////// -VideoMode::VideoMode() : size(0, 0), bitsPerPixel(0) -{ -} +VideoMode::VideoMode() = default; //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/Win32/CursorImpl.cpp b/src/SFML/Window/Win32/CursorImpl.cpp index 52b59d8f..d268e22b 100644 --- a/src/SFML/Window/Win32/CursorImpl.cpp +++ b/src/SFML/Window/Win32/CursorImpl.cpp @@ -37,14 +37,6 @@ namespace sf { namespace priv { - -//////////////////////////////////////////////////////////// -CursorImpl::CursorImpl() : m_cursor(nullptr), m_systemCursor(false) -{ - // That's it. -} - - //////////////////////////////////////////////////////////// CursorImpl::~CursorImpl() { diff --git a/src/SFML/Window/Win32/CursorImpl.hpp b/src/SFML/Window/Win32/CursorImpl.hpp index 9734b3b7..6781811d 100644 --- a/src/SFML/Window/Win32/CursorImpl.hpp +++ b/src/SFML/Window/Win32/CursorImpl.hpp @@ -49,7 +49,7 @@ public: /// Refer to sf::Cursor::Cursor(). /// //////////////////////////////////////////////////////////// - CursorImpl(); + CursorImpl() = default; //////////////////////////////////////////////////////////// /// \brief Destructor @@ -99,8 +99,8 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - void* m_cursor; // Type erasure via `void*` is used here to avoid depending on `windows.h` - bool m_systemCursor; + void* m_cursor{nullptr}; // Type erasure via `void*` is used here to avoid depending on `windows.h` + bool m_systemCursor{false}; }; } // namespace priv diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp index 22b2e718..1890299b 100644 --- a/src/SFML/Window/Win32/JoystickImpl.cpp +++ b/src/SFML/Window/Win32/JoystickImpl.cpp @@ -103,10 +103,7 @@ namespace { struct ConnectionCache { - ConnectionCache() : connected(false) - { - } - bool connected; + bool connected{false}; sf::Clock timer; }; const sf::Time connectionRefreshDelay = sf::milliseconds(500); diff --git a/src/SFML/Window/Win32/VulkanImplWin32.cpp b/src/SFML/Window/Win32/VulkanImplWin32.cpp index b74f49b7..cd5ac569 100644 --- a/src/SFML/Window/Win32/VulkanImplWin32.cpp +++ b/src/SFML/Window/Win32/VulkanImplWin32.cpp @@ -40,14 +40,6 @@ namespace { struct VulkanLibraryWrapper { - VulkanLibraryWrapper() : - library(nullptr), - vkGetInstanceProcAddr(nullptr), - vkEnumerateInstanceLayerProperties(nullptr), - vkEnumerateInstanceExtensionProperties(nullptr) - { - } - ~VulkanLibraryWrapper() { if (library) @@ -97,11 +89,11 @@ struct VulkanLibraryWrapper return (entryPoint != nullptr); } - HMODULE library; + HMODULE library{nullptr}; - PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; - PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties; - PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr{nullptr}; + PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties{nullptr}; + PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties{nullptr}; }; VulkanLibraryWrapper wrapper; diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp index 9ff15fc9..1c546b5a 100644 --- a/src/SFML/Window/Win32/WglContext.cpp +++ b/src/SFML/Window/Win32/WglContext.cpp @@ -116,12 +116,7 @@ WglContext::WglContext(WglContext* shared) : WglContext(shared, ContextSettings( //////////////////////////////////////////////////////////// -WglContext::WglContext(WglContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel) : -m_window(nullptr), -m_pbuffer(nullptr), -m_deviceContext(nullptr), -m_context(nullptr), -m_ownsWindow(false) +WglContext::WglContext(WglContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel) { WglContextImpl::ensureInit(); @@ -137,12 +132,7 @@ m_ownsWindow(false) //////////////////////////////////////////////////////////// -WglContext::WglContext(WglContext* shared, const ContextSettings& settings, const Vector2u& size) : -m_window(nullptr), -m_pbuffer(nullptr), -m_deviceContext(nullptr), -m_context(nullptr), -m_ownsWindow(false) +WglContext::WglContext(WglContext* shared, const ContextSettings& settings, const Vector2u& size) { WglContextImpl::ensureInit(); diff --git a/src/SFML/Window/Win32/WglContext.hpp b/src/SFML/Window/Win32/WglContext.hpp index 36fe97e7..d8aee6a5 100644 --- a/src/SFML/Window/Win32/WglContext.hpp +++ b/src/SFML/Window/Win32/WglContext.hpp @@ -179,11 +179,11 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - HWND m_window; //!< Window to which the context is attached - HPBUFFERARB m_pbuffer; //!< Handle to a pbuffer if one was created - HDC m_deviceContext; //!< Device context associated to the context - HGLRC m_context; //!< OpenGL context - bool m_ownsWindow; //!< Do we own the target window? + HWND m_window{nullptr}; //!< Window to which the context is attached + HPBUFFERARB m_pbuffer{nullptr}; //!< Handle to a pbuffer if one was created + HDC m_deviceContext{nullptr}; //!< Device context associated to the context + HGLRC m_context{nullptr}; //!< OpenGL context + bool m_ownsWindow{false}; //!< Do we own the target window? }; } // namespace priv diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 48ceec0d..6e70b07b 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -130,19 +130,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -WindowImplWin32::WindowImplWin32(WindowHandle handle) : -m_handle(handle), -m_callback(0), -m_cursorVisible(true), // might need to call GetCursorInfo -m_lastCursor(LoadCursor(nullptr, IDC_ARROW)), -m_icon(nullptr), -m_keyRepeatEnabled(true), -m_lastSize(0, 0), -m_resizing(false), -m_surrogate(0), -m_mouseInside(false), -m_fullscreen(false), -m_cursorGrabbed(false) +WindowImplWin32::WindowImplWin32(WindowHandle handle) : m_handle(handle) { // Set that this process is DPI aware and can handle DPI scaling setProcessDpiAware(); @@ -164,16 +152,7 @@ m_cursorGrabbed(false) //////////////////////////////////////////////////////////// WindowImplWin32::WindowImplWin32(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& /*settings*/) : -m_handle(nullptr), -m_callback(0), -m_cursorVisible(true), // might need to call GetCursorInfo -m_lastCursor(LoadCursor(nullptr, IDC_ARROW)), -m_icon(nullptr), -m_keyRepeatEnabled(true), m_lastSize(mode.size), -m_resizing(false), -m_surrogate(0), -m_mouseInside(false), m_fullscreen((style & Style::Fullscreen) != 0), m_cursorGrabbed(m_fullscreen) { diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index f036b6b2..bac5c9b5 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -269,18 +269,19 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - HWND m_handle; //!< Win32 handle of the window - LONG_PTR m_callback; //!< Stores the original event callback function of the control - bool m_cursorVisible; //!< Is the cursor visible or hidden? - HCURSOR m_lastCursor; //!< Last cursor used -- this data is not owned by the window and is required to be always valid - HICON m_icon; //!< Custom icon assigned to the window - bool m_keyRepeatEnabled; //!< Automatic key-repeat state for keydown events - Vector2u m_lastSize; //!< The last handled size of the window - bool m_resizing; //!< Is the window being resized? - std::uint16_t 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? + HWND m_handle{nullptr}; //!< Win32 handle of the window + LONG_PTR m_callback{0}; //!< Stores the original event callback function of the control + bool m_cursorVisible{true}; //!< Is the cursor visible or hidden? + HCURSOR m_lastCursor{ + LoadCursor(nullptr, IDC_ARROW)}; //!< Last cursor used -- this data is not owned by the window and is required to be always valid + HICON m_icon{nullptr}; //!< Custom icon assigned to the window + bool m_keyRepeatEnabled{true}; //!< Automatic key-repeat state for keydown events + Vector2u m_lastSize; //!< The last handled size of the window + bool m_resizing{false}; //!< Is the window being resized? + std::uint16_t m_surrogate{0}; //!< First half of the surrogate pair, in case we're receiving a Unicode character in two events + bool m_mouseInside{false}; //!< Mouse is inside the window? + bool m_fullscreen{false}; //!< Is the window fullscreen? + bool m_cursorGrabbed{false}; //!< Is the mouse cursor trapped? }; } // namespace priv diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 3043f27f..6182fdfd 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -37,22 +37,18 @@ namespace sf { //////////////////////////////////////////////////////////// -Window::Window() : m_context(), m_frameTimeLimit(Time::Zero) -{ -} +Window::Window() = default; //////////////////////////////////////////////////////////// -Window::Window(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& settings) : -m_context(), -m_frameTimeLimit(Time::Zero) +Window::Window(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& settings) { Window::create(mode, title, style, settings); } //////////////////////////////////////////////////////////// -Window::Window(WindowHandle handle, const ContextSettings& settings) : m_context(), m_frameTimeLimit(Time::Zero) +Window::Window(WindowHandle handle, const ContextSettings& settings) { Window::create(handle, settings); } diff --git a/src/SFML/Window/WindowBase.cpp b/src/SFML/Window/WindowBase.cpp index 553550c8..f51f9850 100644 --- a/src/SFML/Window/WindowBase.cpp +++ b/src/SFML/Window/WindowBase.cpp @@ -46,20 +46,18 @@ const sf::WindowBase* fullscreenWindow = nullptr; namespace sf { //////////////////////////////////////////////////////////// -WindowBase::WindowBase() : m_impl(), m_size(0, 0) -{ -} +WindowBase::WindowBase() = default; //////////////////////////////////////////////////////////// -WindowBase::WindowBase(VideoMode mode, const String& title, std::uint32_t style) : m_impl(), m_size(0, 0) +WindowBase::WindowBase(VideoMode mode, const String& title, std::uint32_t style) { WindowBase::create(mode, title, style); } //////////////////////////////////////////////////////////// -WindowBase::WindowBase(WindowHandle handle) : m_impl(), m_size(0, 0) +WindowBase::WindowBase(WindowHandle handle) { WindowBase::create(handle); } diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index 5c017807..e621d5a1 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -115,7 +115,7 @@ std::unique_ptr WindowImpl::create(WindowHandle handle) //////////////////////////////////////////////////////////// -WindowImpl::WindowImpl() : m_joystickStatesImpl(std::make_unique()), m_joystickThreshold(0.1f) +WindowImpl::WindowImpl() : m_joystickStatesImpl(std::make_unique()) { // Get the initial joystick states JoystickManager::getInstance().update(); diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index 46e9d475..24e43b5c 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -298,7 +298,7 @@ private: std::queue m_events; //!< Queue of available events std::unique_ptr m_joystickStatesImpl; //!< Previous state of the joysticks (PImpl) Vector3f m_sensorValue[Sensor::Count]; //!< Previous value of the sensors - float m_joystickThreshold; //!< Joystick threshold (minimum motion for "move" event to be generated) + float m_joystickThreshold{0.1f}; //!< Joystick threshold (minimum motion for "move" event to be generated) float m_previousAxes[Joystick::Count][Joystick::AxisCount]; //!< Position of each axis last time a move event triggered, in range [-100, 100] }; diff --git a/src/SFML/Window/iOS/CursorImpl.cpp b/src/SFML/Window/iOS/CursorImpl.cpp index 61a2c27c..a889d4e2 100644 --- a/src/SFML/Window/iOS/CursorImpl.cpp +++ b/src/SFML/Window/iOS/CursorImpl.cpp @@ -31,14 +31,6 @@ namespace sf { namespace priv { - -//////////////////////////////////////////////////////////// -CursorImpl::CursorImpl() -{ - // Nothing. -} - - //////////////////////////////////////////////////////////// bool CursorImpl::loadFromPixels(const std::uint8_t* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) { diff --git a/src/SFML/Window/iOS/CursorImpl.hpp b/src/SFML/Window/iOS/CursorImpl.hpp index 0de47cdf..63f954be 100644 --- a/src/SFML/Window/iOS/CursorImpl.hpp +++ b/src/SFML/Window/iOS/CursorImpl.hpp @@ -52,7 +52,7 @@ public: /// Refer to sf::Cursor::Cursor(). /// //////////////////////////////////////////////////////////// - CursorImpl(); + CursorImpl() = default; //////////////////////////////////////////////////////////// /// \brief Deleted copy constructor diff --git a/src/SFML/Window/iOS/EaglContext.hpp b/src/SFML/Window/iOS/EaglContext.hpp index 9680e22b..0a5aefa7 100644 --- a/src/SFML/Window/iOS/EaglContext.hpp +++ b/src/SFML/Window/iOS/EaglContext.hpp @@ -159,12 +159,12 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - EAGLContext* m_context; ///< The internal context - GLuint m_framebuffer; ///< Frame buffer associated to the context - GLuint m_colorbuffer; ///< Color render buffer - GLuint m_depthbuffer; ///< Depth render buffer - bool m_vsyncEnabled; ///< Vertical sync activation flag - Clock m_clock; ///< Measures the elapsed time for the fake v-sync implementation + EAGLContext* m_context; ///< The internal context + GLuint m_framebuffer{0}; ///< Frame buffer associated to the context + GLuint m_colorbuffer{0}; ///< Color render buffer + GLuint m_depthbuffer{0}; ///< Depth render buffer + bool m_vsyncEnabled{false}; ///< Vertical sync activation flag + Clock m_clock; ///< Measures the elapsed time for the fake v-sync implementation }; } // namespace priv diff --git a/src/SFML/Window/iOS/EaglContext.mm b/src/SFML/Window/iOS/EaglContext.mm index d7bc6720..7ac51bad 100644 --- a/src/SFML/Window/iOS/EaglContext.mm +++ b/src/SFML/Window/iOS/EaglContext.mm @@ -93,13 +93,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -EaglContext::EaglContext(EaglContext* shared) : -m_context(nil), -m_framebuffer(0), -m_colorbuffer(0), -m_depthbuffer(0), -m_vsyncEnabled(false), -m_clock() +EaglContext::EaglContext(EaglContext* shared) : m_context(nil) { ensureInit(); @@ -114,12 +108,7 @@ m_clock() //////////////////////////////////////////////////////////// EaglContext::EaglContext(EaglContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel) : -m_context(nil), -m_framebuffer(0), -m_colorbuffer(0), -m_depthbuffer(0), -m_vsyncEnabled(false), -m_clock() +m_context(nil) { ensureInit(); @@ -131,12 +120,7 @@ m_clock() //////////////////////////////////////////////////////////// EaglContext::EaglContext(EaglContext* /* shared */, const ContextSettings& /* settings */, const Vector2u& /* size */) : -m_context(nil), -m_framebuffer(0), -m_colorbuffer(0), -m_depthbuffer(0), -m_vsyncEnabled(false), -m_clock() +m_context(nil) { ensureInit();