From 04c36fdd1a18181c03808459d8ff63a36f6d1c11 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Thu, 25 Apr 2024 22:58:19 +0000 Subject: [PATCH] Improve const correctness --- examples/sound_effects/SoundEffects.cpp | 2 +- src/SFML/Audio/AudioDevice.cpp | 36 ++++++++++--------- src/SFML/Audio/SoundRecorder.cpp | 46 ++++++++++++------------- src/SFML/Audio/SoundSource.cpp | 6 ++-- src/SFML/Audio/SoundStream.cpp | 2 +- src/SFML/Window/EglContext.cpp | 6 ++-- src/SFML/Window/Unix/CursorImpl.cpp | 6 ++-- src/SFML/Window/Unix/Display.cpp | 2 +- src/SFML/Window/Unix/GlxContext.cpp | 28 +++++++-------- src/SFML/Window/Unix/KeyboardImpl.cpp | 4 +-- src/SFML/Window/Unix/VideoModeImpl.cpp | 10 +++--- src/SFML/Window/Unix/WindowImplX11.cpp | 24 ++++++------- 12 files changed, 88 insertions(+), 84 deletions(-) diff --git a/examples/sound_effects/SoundEffects.cpp b/examples/sound_effects/SoundEffects.cpp index 949985729..23cb55b91 100644 --- a/examples/sound_effects/SoundEffects.cpp +++ b/examples/sound_effects/SoundEffects.cpp @@ -579,7 +579,7 @@ private: for (auto i = 0u; i < chunkSize; ++i) { - auto value = m_amplitude * 2 * (m_time / period - std::floor(0.5f + m_time / period)); + const auto value = m_amplitude * 2 * (m_time / period - std::floor(0.5f + m_time / period)); m_sampleBuffer[i] = static_cast(std::lround(value * std::numeric_limits::max())); m_time += timePerSample; diff --git a/src/SFML/Audio/AudioDevice.cpp b/src/SFML/Audio/AudioDevice.cpp index 69e2777d1..edab9ad62 100644 --- a/src/SFML/Audio/AudioDevice.cpp +++ b/src/SFML/Audio/AudioDevice.cpp @@ -45,7 +45,7 @@ AudioDevice::AudioDevice() // Create the log m_log.emplace(); - if (auto result = ma_log_init(nullptr, &*m_log); result != MA_SUCCESS) + if (const auto result = ma_log_init(nullptr, &*m_log); result != MA_SUCCESS) { m_log.reset(); err() << "Failed to initialize the audio log: " << ma_result_description(result) << std::endl; @@ -53,15 +53,15 @@ AudioDevice::AudioDevice() } // Register our logging callback to output any warning/error messages - if (auto result = ma_log_register_callback(&*m_log, - ma_log_callback_init( - [](void*, ma_uint32 level, const char* message) - { - if (level <= MA_LOG_LEVEL_WARNING) - err() << "miniaudio " << ma_log_level_to_string(level) - << ": " << message << std::flush; - }, - nullptr)); + if (const auto result = ma_log_register_callback(&*m_log, + ma_log_callback_init( + [](void*, ma_uint32 level, const char* message) + { + if (level <= MA_LOG_LEVEL_WARNING) + err() << "miniaudio " << ma_log_level_to_string(level) + << ": " << message << std::flush; + }, + nullptr)); result != MA_SUCCESS) err() << "Failed to register audio log callback: " << ma_result_description(result) << std::endl; @@ -71,7 +71,7 @@ AudioDevice::AudioDevice() auto contextConfig = ma_context_config_init(); contextConfig.pLog = &*m_log; - if (auto result = ma_context_init(nullptr, 0, &contextConfig, &*m_context); result != MA_SUCCESS) + if (const auto result = ma_context_init(nullptr, 0, &contextConfig, &*m_context); result != MA_SUCCESS) { m_context.reset(); err() << "Failed to initialize the audio context: " << ma_result_description(result) << std::endl; @@ -81,7 +81,8 @@ AudioDevice::AudioDevice() // Count the playback devices ma_uint32 deviceCount = 0; - if (auto result = ma_context_get_devices(&*m_context, nullptr, &deviceCount, nullptr, nullptr); result != MA_SUCCESS) + if (const auto result = ma_context_get_devices(&*m_context, nullptr, &deviceCount, nullptr, nullptr); + result != MA_SUCCESS) { err() << "Failed to get audio playback devices: " << ma_result_description(result) << std::endl; return; @@ -104,7 +105,7 @@ AudioDevice::AudioDevice() if (audioDevice.m_engine) { - if (auto result = ma_engine_read_pcm_frames(&*audioDevice.m_engine, output, frameCount, nullptr); + if (const auto result = ma_engine_read_pcm_frames(&*audioDevice.m_engine, output, frameCount, nullptr); result != MA_SUCCESS) err() << "Failed to read PCM frames from audio engine: " << ma_result_description(result) << std::endl; } @@ -112,7 +113,7 @@ AudioDevice::AudioDevice() playbackDeviceConfig.pUserData = this; playbackDeviceConfig.playback.format = ma_format_f32; - if (auto result = ma_device_init(&*m_context, &playbackDeviceConfig, &*m_playbackDevice); result != MA_SUCCESS) + if (const auto result = ma_device_init(&*m_context, &playbackDeviceConfig, &*m_playbackDevice); result != MA_SUCCESS) { m_playbackDevice.reset(); err() << "Failed to initialize the audio playback device: " << ma_result_description(result) << std::endl; @@ -127,7 +128,7 @@ AudioDevice::AudioDevice() m_engine.emplace(); - if (auto result = ma_engine_init(&engineConfig, &*m_engine); result != MA_SUCCESS) + if (const auto result = ma_engine_init(&engineConfig, &*m_engine); result != MA_SUCCESS) { m_engine.reset(); err() << "Failed to initialize the audio engine: " << ma_result_description(result) << std::endl; @@ -135,7 +136,8 @@ AudioDevice::AudioDevice() } // Set master volume, position, velocity, cone and world up vector - if (auto result = ma_device_set_master_volume(ma_engine_get_device(&*m_engine), getListenerProperties().volume * 0.01f); + if (const auto result = ma_device_set_master_volume(ma_engine_get_device(&*m_engine), + getListenerProperties().volume * 0.01f); result != MA_SUCCESS) err() << "Failed to set audio device master volume: " << ma_result_description(result) << std::endl; @@ -210,7 +212,7 @@ void AudioDevice::setGlobalVolume(float volume) if (!instance || !instance->m_engine) return; - if (auto result = ma_device_set_master_volume(ma_engine_get_device(&*instance->m_engine), volume * 0.01f); + if (const auto result = ma_device_set_master_volume(ma_engine_get_device(&*instance->m_engine), volume * 0.01f); result != MA_SUCCESS) err() << "Failed to set audio device master volume: " << ma_result_description(result) << std::endl; } diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp index 170a7b337..202ae0b04 100644 --- a/src/SFML/Audio/SoundRecorder.cpp +++ b/src/SFML/Audio/SoundRecorder.cpp @@ -56,9 +56,9 @@ struct SoundRecorder::Impl // Find the device by its name auto devices = getAvailableDevices(); - auto iter = std::find_if(devices.begin(), - devices.end(), - [this](const ma_device_info& info) { return info.name == deviceName; }); + const auto iter = std::find_if(devices.begin(), + devices.end(), + [this](const ma_device_info& info) { return info.name == deviceName; }); if (iter == devices.end()) return false; @@ -91,7 +91,7 @@ struct SoundRecorder::Impl if (!impl.owner->onProcessSamples(impl.samples.data(), impl.samples.size())) { // If the derived class wants to stop, stop the capture - if (auto result = ma_device_stop(device); result != MA_SUCCESS) + if (const auto result = ma_device_stop(device); result != MA_SUCCESS) { err() << "Failed to stop audio capture device: " << ma_result_description(result) << std::endl; return; @@ -99,7 +99,7 @@ struct SoundRecorder::Impl } }; - if (auto result = ma_device_init(&*context, &captureDeviceConfig, &*captureDevice); result != MA_SUCCESS) + if (const auto result = ma_device_init(&*context, &captureDeviceConfig, &*captureDevice); result != MA_SUCCESS) { captureDevice.reset(); err() << "Failed to initialize the audio capture device: " << ma_result_description(result) << std::endl; @@ -116,9 +116,9 @@ struct SoundRecorder::Impl // Create the context ma_context context; - auto contextConfig = ma_context_config_init(); + const auto contextConfig = ma_context_config_init(); - if (auto result = ma_context_init(nullptr, 0, &contextConfig, &context); result != MA_SUCCESS) + if (const auto result = ma_context_init(nullptr, 0, &contextConfig, &context); result != MA_SUCCESS) { err() << "Failed to initialize the audio context: " << ma_result_description(result) << std::endl; return deviceList; @@ -128,7 +128,7 @@ struct SoundRecorder::Impl ma_device_info* deviceInfos = nullptr; ma_uint32 deviceCount = 0; - if (auto result = ma_context_get_devices(&context, nullptr, nullptr, &deviceInfos, &deviceCount); + if (const auto result = ma_context_get_devices(&context, nullptr, nullptr, &deviceInfos, &deviceCount); result != MA_SUCCESS) { err() << "Failed to get audio capture devices: " << ma_result_description(result) << std::endl; @@ -164,7 +164,7 @@ SoundRecorder::SoundRecorder() : m_impl(std::make_unique(this)) // Create the log m_impl->log.emplace(); - if (auto result = ma_log_init(nullptr, &*m_impl->log); result != MA_SUCCESS) + if (const auto result = ma_log_init(nullptr, &*m_impl->log); result != MA_SUCCESS) { m_impl->log.reset(); err() << "Failed to initialize the audio log: " << ma_result_description(result) << std::endl; @@ -172,15 +172,15 @@ SoundRecorder::SoundRecorder() : m_impl(std::make_unique(this)) } // Register our logging callback to output any warning/error messages - if (auto result = ma_log_register_callback(&*m_impl->log, - ma_log_callback_init( - [](void*, ma_uint32 level, const char* message) - { - if (level <= MA_LOG_LEVEL_WARNING) - err() << "miniaudio " << ma_log_level_to_string(level) - << ": " << message << std::flush; - }, - nullptr)); + if (const auto result = ma_log_register_callback(&*m_impl->log, + ma_log_callback_init( + [](void*, ma_uint32 level, const char* message) + { + if (level <= MA_LOG_LEVEL_WARNING) + err() << "miniaudio " << ma_log_level_to_string(level) + << ": " << message << std::flush; + }, + nullptr)); result != MA_SUCCESS) err() << "Failed to register audio log callback: " << ma_result_description(result) << std::endl; @@ -190,7 +190,7 @@ SoundRecorder::SoundRecorder() : m_impl(std::make_unique(this)) auto contextConfig = ma_context_config_init(); contextConfig.pLog = &*m_impl->log; - if (auto result = ma_context_init(nullptr, 0, &contextConfig, &*m_impl->context); result != MA_SUCCESS) + if (const auto result = ma_context_init(nullptr, 0, &contextConfig, &*m_impl->context); result != MA_SUCCESS) { m_impl->context.reset(); err() << "Failed to initialize the audio context: " << ma_result_description(result) << std::endl; @@ -270,7 +270,7 @@ bool SoundRecorder::start(unsigned int sampleRate) if (onStart()) { // Start the capture - if (auto result = ma_device_start(&*m_impl->captureDevice); result != MA_SUCCESS) + if (const auto result = ma_device_start(&*m_impl->captureDevice); result != MA_SUCCESS) { err() << "Failed to start audio capture device: " << ma_result_description(result) << std::endl; return false; @@ -290,7 +290,7 @@ void SoundRecorder::stop() if (m_impl->captureDevice && ma_device_is_started(&*m_impl->captureDevice)) { // Stop the capture - if (auto result = ma_device_stop(&*m_impl->captureDevice); result != MA_SUCCESS) + if (const auto result = ma_device_stop(&*m_impl->captureDevice); result != MA_SUCCESS) { err() << "Failed to stop audio capture device: " << ma_result_description(result) << std::endl; return; @@ -410,8 +410,8 @@ const std::vector& SoundRecorder::getChannelMap() const bool SoundRecorder::isAvailable() { // Try to open a device for capture to see if recording is available - auto config = ma_device_config_init(ma_device_type_capture); - ma_device device; + const auto config = ma_device_config_init(ma_device_type_capture); + ma_device device; if (ma_device_init(nullptr, &config, &device) != MA_SUCCESS) return false; diff --git a/src/SFML/Audio/SoundSource.cpp b/src/SFML/Audio/SoundSource.cpp index 25e625e9c..7b7d67477 100644 --- a/src/SFML/Audio/SoundSource.cpp +++ b/src/SFML/Audio/SoundSource.cpp @@ -211,7 +211,7 @@ Vector3f SoundSource::getPosition() const { if (const auto* sound = static_cast(getSound())) { - auto position = ma_sound_get_position(sound); + const auto position = ma_sound_get_position(sound); return {position.x, position.y, position.z}; } @@ -224,7 +224,7 @@ Vector3f SoundSource::getDirection() const { if (const auto* sound = static_cast(getSound())) { - auto direction = ma_sound_get_direction(sound); + const auto direction = ma_sound_get_direction(sound); return {direction.x, direction.y, direction.z}; } @@ -255,7 +255,7 @@ Vector3f SoundSource::getVelocity() const { if (const auto* sound = static_cast(getSound())) { - auto velocity = ma_sound_get_velocity(sound); + const auto velocity = ma_sound_get_velocity(sound); return {velocity.x, velocity.y, velocity.z}; } diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 2d1dc95af..538b4f044 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -158,7 +158,7 @@ struct SoundStream::Impl // If we are looping and at the end of the loop, set the cursor back to the beginning of the loop if (!impl.streaming && impl.loop) { - if (auto seekPositionAfterLoop = owner->onLoop(); seekPositionAfterLoop != NoLoop) + if (const auto seekPositionAfterLoop = owner->onLoop(); seekPositionAfterLoop != NoLoop) { impl.streaming = true; impl.samplesProcessed = static_cast(seekPositionAfterLoop); diff --git a/src/SFML/Window/EglContext.cpp b/src/SFML/Window/EglContext.cpp index e145f8526..c8489c2ca 100644 --- a/src/SFML/Window/EglContext.cpp +++ b/src/SFML/Window/EglContext.cpp @@ -305,7 +305,7 @@ EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixe eglCheck(eglGetConfigs(display, nullptr, 0, &configCount)); // Retrieve the list of available configs - auto configs = std::make_unique(static_cast(configCount)); + const auto configs = std::make_unique(static_cast(configCount)); eglCheck(eglGetConfigs(display, configs.get(), configCount, &configCount)); @@ -433,8 +433,8 @@ XVisualInfo EglContext::selectBestVisual(::Display* xDisplay, unsigned int bitsP vTemplate.visualid = static_cast(nativeVisualId); // Get X11 visuals compatible with this EGL config - int visualCount = 0; - auto availableVisuals = X11Ptr(XGetVisualInfo(xDisplay, VisualIDMask, &vTemplate, &visualCount)); + int visualCount = 0; + const auto availableVisuals = X11Ptr(XGetVisualInfo(xDisplay, VisualIDMask, &vTemplate, &visualCount)); if (visualCount == 0) { diff --git a/src/SFML/Window/Unix/CursorImpl.cpp b/src/SFML/Window/Unix/CursorImpl.cpp index 1e0f4e65d..0476fe9d4 100644 --- a/src/SFML/Window/Unix/CursorImpl.cpp +++ b/src/SFML/Window/Unix/CursorImpl.cpp @@ -79,9 +79,9 @@ bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vecto bool CursorImpl::loadFromPixelsARGB(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) { // Create cursor image, convert from RGBA to ARGB. - auto cursorImage = X11Ptr(XcursorImageCreate(static_cast(size.x), static_cast(size.y))); - cursorImage->xhot = hotspot.x; - cursorImage->yhot = hotspot.y; + const auto cursorImage = X11Ptr(XcursorImageCreate(static_cast(size.x), static_cast(size.y))); + cursorImage->xhot = hotspot.x; + cursorImage->yhot = hotspot.y; const std::size_t numPixels = static_cast(size.x) * static_cast(size.y); for (std::size_t pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) diff --git a/src/SFML/Window/Unix/Display.cpp b/src/SFML/Window/Unix/Display.cpp index 28c24a027..f4a0a61a5 100644 --- a/src/SFML/Window/Unix/Display.cpp +++ b/src/SFML/Window/Unix/Display.cpp @@ -124,7 +124,7 @@ Atom getAtom(const std::string& name, bool onlyIfExists) { static std::unordered_map atoms; - if (auto it = atoms.find(name); it != atoms.end()) + if (const auto it = atoms.find(name); it != atoms.end()) return it->second; const auto display = openDisplay(); diff --git a/src/SFML/Window/Unix/GlxContext.cpp b/src/SFML/Window/Unix/GlxContext.cpp index 43721f33d..842d43338 100644 --- a/src/SFML/Window/Unix/GlxContext.cpp +++ b/src/SFML/Window/Unix/GlxContext.cpp @@ -312,8 +312,8 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe const int screen = DefaultScreen(display); // Retrieve all the visuals - int count = 0; - auto visuals = X11Ptr(XGetVisualInfo(display, 0, nullptr, &count)); + int count = 0; + const auto visuals = X11Ptr(XGetVisualInfo(display, 0, nullptr, &count)); if (visuals) { // Evaluate all the returned visuals, and pick the best one @@ -454,10 +454,10 @@ void GlxContext::updateSettingsFromWindow() // Get its visuals XVisualInfo tpl; - tpl.screen = DefaultScreen(m_display.get()); - tpl.visualid = XVisualIDFromVisual(windowAttributes.visual); - int nbVisuals = 0; - auto visualInfo = X11Ptr( + tpl.screen = DefaultScreen(m_display.get()); + tpl.visualid = XVisualIDFromVisual(windowAttributes.visual); + int nbVisuals = 0; + const auto visualInfo = X11Ptr( XGetVisualInfo(m_display.get(), VisualIDMask | VisualScreenMask, &tpl, &nbVisuals)); if (!visualInfo) @@ -493,13 +493,13 @@ void GlxContext::createSurface(GlxContext* shared, const Vector2u& size, unsigne // We don't supply attributes to match against, since // the visual we are matching against was already // deemed suitable in selectBestVisual() - int nbConfigs = 0; - auto configs = X11Ptr( + int nbConfigs = 0; + const auto configs = X11Ptr( glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), nullptr, &nbConfigs)); for (std::size_t i = 0; configs && (i < static_cast(nbConfigs)); ++i) { - auto visual = X11Ptr(glXGetVisualFromFBConfig(m_display.get(), configs[i])); + const auto visual = X11Ptr(glXGetVisualFromFBConfig(m_display.get(), configs[i])); if (!visual) continue; @@ -580,8 +580,8 @@ void GlxContext::createContext(GlxContext* shared) int attributes[] = {GLX_FBCONFIG_ID, static_cast(fbConfigId), 0, 0}; - int count = 0; - auto fbconfig = X11Ptr( + int count = 0; + const auto fbconfig = X11Ptr( glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), attributes, &count)); if (count == 1) @@ -633,13 +633,13 @@ void GlxContext::createContext(GlxContext* shared) // We don't supply attributes to match against, since // the visual we are matching against was already // deemed suitable in selectBestVisual() - int nbConfigs = 0; - auto configs = X11Ptr( + int nbConfigs = 0; + const auto configs = X11Ptr( glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), nullptr, &nbConfigs)); for (std::size_t i = 0; configs && (i < static_cast(nbConfigs)); ++i) { - auto visual = X11Ptr(glXGetVisualFromFBConfig(m_display.get(), configs[i])); + const auto visual = X11Ptr(glXGetVisualFromFBConfig(m_display.get(), configs[i])); if (!visual) continue; diff --git a/src/SFML/Window/Unix/KeyboardImpl.cpp b/src/SFML/Window/Unix/KeyboardImpl.cpp index 2493120e2..49bd72bd4 100644 --- a/src/SFML/Window/Unix/KeyboardImpl.cpp +++ b/src/SFML/Window/Unix/KeyboardImpl.cpp @@ -485,8 +485,8 @@ void ensureMapping() std::memcpy(name, descriptor->names->keys[keycode].name, XkbKeyNameLength); name[XkbKeyNameLength] = '\0'; - auto mappedScancode = nameScancodeMap.find(std::string(name)); - scancode = sf::Keyboard::Scan::Unknown; + const auto mappedScancode = nameScancodeMap.find(std::string(name)); + scancode = sf::Keyboard::Scan::Unknown; if (mappedScancode != nameScancodeMap.end()) scancode = mappedScancode->second; diff --git a/src/SFML/Window/Unix/VideoModeImpl.cpp b/src/SFML/Window/Unix/VideoModeImpl.cpp index a98496297..a02af9c29 100644 --- a/src/SFML/Window/Unix/VideoModeImpl.cpp +++ b/src/SFML/Window/Unix/VideoModeImpl.cpp @@ -68,7 +68,8 @@ std::vector VideoModeImpl::getFullscreenModes() if (XQueryExtension(display.get(), "RANDR", &version, &version, &version)) { // Get the current configuration - auto config = X11Ptr(XRRGetScreenInfo(display.get(), RootWindow(display.get(), screen))); + const auto config = X11Ptr( + XRRGetScreenInfo(display.get(), RootWindow(display.get(), screen))); if (config) { // Get the available screen sizes @@ -77,8 +78,8 @@ std::vector VideoModeImpl::getFullscreenModes() if (sizes && (nbSizes > 0)) { // Get the list of supported depths - int nbDepths = 0; - auto depths = X11Ptr(XListDepths(display.get(), screen, &nbDepths)); + int nbDepths = 0; + const auto depths = X11Ptr(XListDepths(display.get(), screen, &nbDepths)); if (depths && (nbDepths > 0)) { // Combine depths and sizes to fill the array of supported modes @@ -145,7 +146,8 @@ VideoMode VideoModeImpl::getDesktopMode() if (XQueryExtension(display.get(), "RANDR", &version, &version, &version)) { // Get the current configuration - auto config = X11Ptr(XRRGetScreenInfo(display.get(), RootWindow(display.get(), screen))); + const auto config = X11Ptr( + XRRGetScreenInfo(display.get(), RootWindow(display.get(), screen))); if (config) { // Get the current video mode diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 3279c7989..23e2e453e 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -970,9 +970,9 @@ void WindowImplX11::setIcon(const Vector2u& size, const std::uint8_t* pixels) } // Create the icon pixmap - Visual* defVisual = DefaultVisual(m_display.get(), m_screen); - auto defDepth = static_cast(DefaultDepth(m_display.get(), m_screen)); - auto iconImage = X11Ptr( + Visual* defVisual = DefaultVisual(m_display.get(), m_screen); + const auto defDepth = static_cast(DefaultDepth(m_display.get(), m_screen)); + const auto iconImage = X11Ptr( XCreateImage(m_display.get(), defVisual, defDepth, ZPixmap, 0, reinterpret_cast(iconPixels), size.x, size.y, 32, 0)); if (!iconImage) { @@ -1287,7 +1287,7 @@ void WindowImplX11::setVideoMode(const VideoMode& mode) ::Window rootWindow = RootWindow(m_display.get(), m_screen); // Get the screen resources - auto res = X11Ptr(XRRGetScreenResources(m_display.get(), rootWindow)); + const auto res = X11Ptr(XRRGetScreenResources(m_display.get(), rootWindow)); if (!res) { err() << "Failed to get the current screen resources for fullscreen mode, switching to window mode" << std::endl; @@ -1297,7 +1297,7 @@ void WindowImplX11::setVideoMode(const VideoMode& mode) RROutput output = getOutputPrimary(rootWindow, res.get(), xRandRMajor, xRandRMinor); // Get output info from output - auto outputInfo = X11Ptr(XRRGetOutputInfo(m_display.get(), res.get(), output)); + const auto outputInfo = X11Ptr(XRRGetOutputInfo(m_display.get(), res.get(), output)); if (!outputInfo || outputInfo->connection == RR_Disconnected) { err() << "Failed to get output info for fullscreen mode, switching to window mode" << std::endl; @@ -1305,7 +1305,7 @@ void WindowImplX11::setVideoMode(const VideoMode& mode) } // Retrieve current RRMode, screen position and rotation - auto crtcInfo = X11Ptr(XRRGetCrtcInfo(m_display.get(), res.get(), outputInfo->crtc)); + const auto crtcInfo = X11Ptr(XRRGetCrtcInfo(m_display.get(), res.get(), outputInfo->crtc)); if (!crtcInfo) { err() << "Failed to get crtc info for fullscreen mode, switching to window mode" << std::endl; @@ -1369,7 +1369,7 @@ void WindowImplX11::resetVideoMode() int xRandRMinor = 0; if (checkXRandR(xRandRMajor, xRandRMinor)) { - auto res = X11Ptr( + const auto res = X11Ptr( XRRGetScreenResources(m_display.get(), DefaultRootWindow(m_display.get()))); if (!res) { @@ -1378,7 +1378,7 @@ void WindowImplX11::resetVideoMode() } // Retrieve current screen position and rotation - auto crtcInfo = X11Ptr(XRRGetCrtcInfo(m_display.get(), res.get(), m_oldRRCrtc)); + const auto crtcInfo = X11Ptr(XRRGetCrtcInfo(m_display.get(), res.get(), m_oldRRCrtc)); if (!crtcInfo) { err() << "Failed to get crtc info to reset the video mode" << std::endl; @@ -1717,7 +1717,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) pushEvent(event); // If the window has been previously marked urgent (notification) as a result of a focus request, undo that - auto hints = X11Ptr(XGetWMHints(m_display.get(), m_window)); + const auto hints = X11Ptr(XGetWMHints(m_display.get(), m_window)); if (hints != nullptr) { // Remove urgency (notification) flag from hints @@ -2139,7 +2139,7 @@ Vector2i WindowImplX11::getPrimaryMonitorPosition() ::Window rootWindow = RootWindow(m_display.get(), m_screen); // Get the screen resources - auto res = X11Ptr(XRRGetScreenResources(m_display.get(), rootWindow)); + const auto res = X11Ptr(XRRGetScreenResources(m_display.get(), rootWindow)); if (!res) { err() << "Failed to get the current screen resources for primary monitor position" << std::endl; @@ -2155,7 +2155,7 @@ Vector2i WindowImplX11::getPrimaryMonitorPosition() const RROutput output = getOutputPrimary(rootWindow, res.get(), xRandRMajor, xRandRMinor); // Get output info from output - auto outputInfo = X11Ptr(XRRGetOutputInfo(m_display.get(), res.get(), output)); + const auto outputInfo = X11Ptr(XRRGetOutputInfo(m_display.get(), res.get(), output)); if (!outputInfo || outputInfo->connection == RR_Disconnected) { err() << "Failed to get output info for primary monitor position" << std::endl; @@ -2163,7 +2163,7 @@ Vector2i WindowImplX11::getPrimaryMonitorPosition() } // Retrieve current RRMode, screen position and rotation - auto crtcInfo = X11Ptr(XRRGetCrtcInfo(m_display.get(), res.get(), outputInfo->crtc)); + const auto crtcInfo = X11Ptr(XRRGetCrtcInfo(m_display.get(), res.get(), outputInfo->crtc)); if (!crtcInfo) { err() << "Failed to get crtc info for primary monitor position" << std::endl;