Improve const correctness

This commit is contained in:
Chris Thrasher 2024-04-25 22:58:19 +00:00
parent 1d95c65526
commit 04c36fdd1a
12 changed files with 88 additions and 84 deletions

View File

@ -579,7 +579,7 @@ private:
for (auto i = 0u; i < chunkSize; ++i) 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::int16_t>(std::lround(value * std::numeric_limits<std::int16_t>::max())); m_sampleBuffer[i] = static_cast<std::int16_t>(std::lround(value * std::numeric_limits<std::int16_t>::max()));
m_time += timePerSample; m_time += timePerSample;

View File

@ -45,7 +45,7 @@ AudioDevice::AudioDevice()
// Create the log // Create the log
m_log.emplace(); 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(); m_log.reset();
err() << "Failed to initialize the audio log: " << ma_result_description(result) << std::endl; err() << "Failed to initialize the audio log: " << ma_result_description(result) << std::endl;
@ -53,7 +53,7 @@ AudioDevice::AudioDevice()
} }
// Register our logging callback to output any warning/error messages // Register our logging callback to output any warning/error messages
if (auto result = ma_log_register_callback(&*m_log, if (const auto result = ma_log_register_callback(&*m_log,
ma_log_callback_init( ma_log_callback_init(
[](void*, ma_uint32 level, const char* message) [](void*, ma_uint32 level, const char* message)
{ {
@ -71,7 +71,7 @@ AudioDevice::AudioDevice()
auto contextConfig = ma_context_config_init(); auto contextConfig = ma_context_config_init();
contextConfig.pLog = &*m_log; 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(); m_context.reset();
err() << "Failed to initialize the audio context: " << ma_result_description(result) << std::endl; err() << "Failed to initialize the audio context: " << ma_result_description(result) << std::endl;
@ -81,7 +81,8 @@ AudioDevice::AudioDevice()
// Count the playback devices // Count the playback devices
ma_uint32 deviceCount = 0; 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; err() << "Failed to get audio playback devices: " << ma_result_description(result) << std::endl;
return; return;
@ -104,7 +105,7 @@ AudioDevice::AudioDevice()
if (audioDevice.m_engine) 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) result != MA_SUCCESS)
err() << "Failed to read PCM frames from audio engine: " << ma_result_description(result) << std::endl; 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.pUserData = this;
playbackDeviceConfig.playback.format = ma_format_f32; 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(); m_playbackDevice.reset();
err() << "Failed to initialize the audio playback device: " << ma_result_description(result) << std::endl; err() << "Failed to initialize the audio playback device: " << ma_result_description(result) << std::endl;
@ -127,7 +128,7 @@ AudioDevice::AudioDevice()
m_engine.emplace(); 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(); m_engine.reset();
err() << "Failed to initialize the audio engine: " << ma_result_description(result) << std::endl; 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 // 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) result != MA_SUCCESS)
err() << "Failed to set audio device master volume: " << ma_result_description(result) << std::endl; 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) if (!instance || !instance->m_engine)
return; 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) result != MA_SUCCESS)
err() << "Failed to set audio device master volume: " << ma_result_description(result) << std::endl; err() << "Failed to set audio device master volume: " << ma_result_description(result) << std::endl;
} }

View File

@ -56,7 +56,7 @@ struct SoundRecorder::Impl
// Find the device by its name // Find the device by its name
auto devices = getAvailableDevices(); auto devices = getAvailableDevices();
auto iter = std::find_if(devices.begin(), const auto iter = std::find_if(devices.begin(),
devices.end(), devices.end(),
[this](const ma_device_info& info) { return info.name == deviceName; }); [this](const ma_device_info& info) { return info.name == deviceName; });
@ -91,7 +91,7 @@ struct SoundRecorder::Impl
if (!impl.owner->onProcessSamples(impl.samples.data(), impl.samples.size())) if (!impl.owner->onProcessSamples(impl.samples.data(), impl.samples.size()))
{ {
// If the derived class wants to stop, stop the capture // 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; err() << "Failed to stop audio capture device: " << ma_result_description(result) << std::endl;
return; 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(); captureDevice.reset();
err() << "Failed to initialize the audio capture device: " << ma_result_description(result) << std::endl; err() << "Failed to initialize the audio capture device: " << ma_result_description(result) << std::endl;
@ -116,9 +116,9 @@ struct SoundRecorder::Impl
// Create the context // Create the context
ma_context 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; err() << "Failed to initialize the audio context: " << ma_result_description(result) << std::endl;
return deviceList; return deviceList;
@ -128,7 +128,7 @@ struct SoundRecorder::Impl
ma_device_info* deviceInfos = nullptr; ma_device_info* deviceInfos = nullptr;
ma_uint32 deviceCount = 0; 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) result != MA_SUCCESS)
{ {
err() << "Failed to get audio capture devices: " << ma_result_description(result) << std::endl; err() << "Failed to get audio capture devices: " << ma_result_description(result) << std::endl;
@ -164,7 +164,7 @@ SoundRecorder::SoundRecorder() : m_impl(std::make_unique<Impl>(this))
// Create the log // Create the log
m_impl->log.emplace(); 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(); m_impl->log.reset();
err() << "Failed to initialize the audio log: " << ma_result_description(result) << std::endl; err() << "Failed to initialize the audio log: " << ma_result_description(result) << std::endl;
@ -172,7 +172,7 @@ SoundRecorder::SoundRecorder() : m_impl(std::make_unique<Impl>(this))
} }
// Register our logging callback to output any warning/error messages // Register our logging callback to output any warning/error messages
if (auto result = ma_log_register_callback(&*m_impl->log, if (const auto result = ma_log_register_callback(&*m_impl->log,
ma_log_callback_init( ma_log_callback_init(
[](void*, ma_uint32 level, const char* message) [](void*, ma_uint32 level, const char* message)
{ {
@ -190,7 +190,7 @@ SoundRecorder::SoundRecorder() : m_impl(std::make_unique<Impl>(this))
auto contextConfig = ma_context_config_init(); auto contextConfig = ma_context_config_init();
contextConfig.pLog = &*m_impl->log; 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(); m_impl->context.reset();
err() << "Failed to initialize the audio context: " << ma_result_description(result) << std::endl; 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()) if (onStart())
{ {
// Start the capture // 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; err() << "Failed to start audio capture device: " << ma_result_description(result) << std::endl;
return false; return false;
@ -290,7 +290,7 @@ void SoundRecorder::stop()
if (m_impl->captureDevice && ma_device_is_started(&*m_impl->captureDevice)) if (m_impl->captureDevice && ma_device_is_started(&*m_impl->captureDevice))
{ {
// Stop the capture // 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; err() << "Failed to stop audio capture device: " << ma_result_description(result) << std::endl;
return; return;
@ -410,7 +410,7 @@ const std::vector<SoundChannel>& SoundRecorder::getChannelMap() const
bool SoundRecorder::isAvailable() bool SoundRecorder::isAvailable()
{ {
// Try to open a device for capture to see if recording is available // Try to open a device for capture to see if recording is available
auto config = ma_device_config_init(ma_device_type_capture); const auto config = ma_device_config_init(ma_device_type_capture);
ma_device device; ma_device device;
if (ma_device_init(nullptr, &config, &device) != MA_SUCCESS) if (ma_device_init(nullptr, &config, &device) != MA_SUCCESS)

View File

@ -211,7 +211,7 @@ Vector3f SoundSource::getPosition() const
{ {
if (const auto* sound = static_cast<const ma_sound*>(getSound())) if (const auto* sound = static_cast<const ma_sound*>(getSound()))
{ {
auto position = ma_sound_get_position(sound); const auto position = ma_sound_get_position(sound);
return {position.x, position.y, position.z}; return {position.x, position.y, position.z};
} }
@ -224,7 +224,7 @@ Vector3f SoundSource::getDirection() const
{ {
if (const auto* sound = static_cast<const ma_sound*>(getSound())) if (const auto* sound = static_cast<const ma_sound*>(getSound()))
{ {
auto direction = ma_sound_get_direction(sound); const auto direction = ma_sound_get_direction(sound);
return {direction.x, direction.y, direction.z}; return {direction.x, direction.y, direction.z};
} }
@ -255,7 +255,7 @@ Vector3f SoundSource::getVelocity() const
{ {
if (const auto* sound = static_cast<const ma_sound*>(getSound())) if (const auto* sound = static_cast<const ma_sound*>(getSound()))
{ {
auto velocity = ma_sound_get_velocity(sound); const auto velocity = ma_sound_get_velocity(sound);
return {velocity.x, velocity.y, velocity.z}; return {velocity.x, velocity.y, velocity.z};
} }

View File

@ -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 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 (!impl.streaming && impl.loop)
{ {
if (auto seekPositionAfterLoop = owner->onLoop(); seekPositionAfterLoop != NoLoop) if (const auto seekPositionAfterLoop = owner->onLoop(); seekPositionAfterLoop != NoLoop)
{ {
impl.streaming = true; impl.streaming = true;
impl.samplesProcessed = static_cast<std::uint64_t>(seekPositionAfterLoop); impl.samplesProcessed = static_cast<std::uint64_t>(seekPositionAfterLoop);

View File

@ -305,7 +305,7 @@ EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixe
eglCheck(eglGetConfigs(display, nullptr, 0, &configCount)); eglCheck(eglGetConfigs(display, nullptr, 0, &configCount));
// Retrieve the list of available configs // Retrieve the list of available configs
auto configs = std::make_unique<EGLConfig[]>(static_cast<std::size_t>(configCount)); const auto configs = std::make_unique<EGLConfig[]>(static_cast<std::size_t>(configCount));
eglCheck(eglGetConfigs(display, configs.get(), configCount, &configCount)); eglCheck(eglGetConfigs(display, configs.get(), configCount, &configCount));
@ -434,7 +434,7 @@ XVisualInfo EglContext::selectBestVisual(::Display* xDisplay, unsigned int bitsP
// Get X11 visuals compatible with this EGL config // Get X11 visuals compatible with this EGL config
int visualCount = 0; int visualCount = 0;
auto availableVisuals = X11Ptr<XVisualInfo[]>(XGetVisualInfo(xDisplay, VisualIDMask, &vTemplate, &visualCount)); const auto availableVisuals = X11Ptr<XVisualInfo[]>(XGetVisualInfo(xDisplay, VisualIDMask, &vTemplate, &visualCount));
if (visualCount == 0) if (visualCount == 0)
{ {

View File

@ -79,7 +79,7 @@ bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vecto
bool CursorImpl::loadFromPixelsARGB(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) bool CursorImpl::loadFromPixelsARGB(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot)
{ {
// Create cursor image, convert from RGBA to ARGB. // Create cursor image, convert from RGBA to ARGB.
auto cursorImage = X11Ptr<XcursorImage>(XcursorImageCreate(static_cast<int>(size.x), static_cast<int>(size.y))); const auto cursorImage = X11Ptr<XcursorImage>(XcursorImageCreate(static_cast<int>(size.x), static_cast<int>(size.y)));
cursorImage->xhot = hotspot.x; cursorImage->xhot = hotspot.x;
cursorImage->yhot = hotspot.y; cursorImage->yhot = hotspot.y;

View File

@ -124,7 +124,7 @@ Atom getAtom(const std::string& name, bool onlyIfExists)
{ {
static std::unordered_map<std::string, Atom> atoms; static std::unordered_map<std::string, Atom> atoms;
if (auto it = atoms.find(name); it != atoms.end()) if (const auto it = atoms.find(name); it != atoms.end())
return it->second; return it->second;
const auto display = openDisplay(); const auto display = openDisplay();

View File

@ -313,7 +313,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
// Retrieve all the visuals // Retrieve all the visuals
int count = 0; int count = 0;
auto visuals = X11Ptr<XVisualInfo[]>(XGetVisualInfo(display, 0, nullptr, &count)); const auto visuals = X11Ptr<XVisualInfo[]>(XGetVisualInfo(display, 0, nullptr, &count));
if (visuals) if (visuals)
{ {
// Evaluate all the returned visuals, and pick the best one // Evaluate all the returned visuals, and pick the best one
@ -457,7 +457,7 @@ void GlxContext::updateSettingsFromWindow()
tpl.screen = DefaultScreen(m_display.get()); tpl.screen = DefaultScreen(m_display.get());
tpl.visualid = XVisualIDFromVisual(windowAttributes.visual); tpl.visualid = XVisualIDFromVisual(windowAttributes.visual);
int nbVisuals = 0; int nbVisuals = 0;
auto visualInfo = X11Ptr<XVisualInfo>( const auto visualInfo = X11Ptr<XVisualInfo>(
XGetVisualInfo(m_display.get(), VisualIDMask | VisualScreenMask, &tpl, &nbVisuals)); XGetVisualInfo(m_display.get(), VisualIDMask | VisualScreenMask, &tpl, &nbVisuals));
if (!visualInfo) if (!visualInfo)
@ -494,12 +494,12 @@ void GlxContext::createSurface(GlxContext* shared, const Vector2u& size, unsigne
// the visual we are matching against was already // the visual we are matching against was already
// deemed suitable in selectBestVisual() // deemed suitable in selectBestVisual()
int nbConfigs = 0; int nbConfigs = 0;
auto configs = X11Ptr<GLXFBConfig[]>( const auto configs = X11Ptr<GLXFBConfig[]>(
glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), nullptr, &nbConfigs)); glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), nullptr, &nbConfigs));
for (std::size_t i = 0; configs && (i < static_cast<std::size_t>(nbConfigs)); ++i) for (std::size_t i = 0; configs && (i < static_cast<std::size_t>(nbConfigs)); ++i)
{ {
auto visual = X11Ptr<XVisualInfo>(glXGetVisualFromFBConfig(m_display.get(), configs[i])); const auto visual = X11Ptr<XVisualInfo>(glXGetVisualFromFBConfig(m_display.get(), configs[i]));
if (!visual) if (!visual)
continue; continue;
@ -581,7 +581,7 @@ void GlxContext::createContext(GlxContext* shared)
int attributes[] = {GLX_FBCONFIG_ID, static_cast<int>(fbConfigId), 0, 0}; int attributes[] = {GLX_FBCONFIG_ID, static_cast<int>(fbConfigId), 0, 0};
int count = 0; int count = 0;
auto fbconfig = X11Ptr<GLXFBConfig>( const auto fbconfig = X11Ptr<GLXFBConfig>(
glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), attributes, &count)); glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), attributes, &count));
if (count == 1) if (count == 1)
@ -634,12 +634,12 @@ void GlxContext::createContext(GlxContext* shared)
// the visual we are matching against was already // the visual we are matching against was already
// deemed suitable in selectBestVisual() // deemed suitable in selectBestVisual()
int nbConfigs = 0; int nbConfigs = 0;
auto configs = X11Ptr<GLXFBConfig[]>( const auto configs = X11Ptr<GLXFBConfig[]>(
glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), nullptr, &nbConfigs)); glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), nullptr, &nbConfigs));
for (std::size_t i = 0; configs && (i < static_cast<std::size_t>(nbConfigs)); ++i) for (std::size_t i = 0; configs && (i < static_cast<std::size_t>(nbConfigs)); ++i)
{ {
auto visual = X11Ptr<XVisualInfo>(glXGetVisualFromFBConfig(m_display.get(), configs[i])); const auto visual = X11Ptr<XVisualInfo>(glXGetVisualFromFBConfig(m_display.get(), configs[i]));
if (!visual) if (!visual)
continue; continue;

View File

@ -485,7 +485,7 @@ void ensureMapping()
std::memcpy(name, descriptor->names->keys[keycode].name, XkbKeyNameLength); std::memcpy(name, descriptor->names->keys[keycode].name, XkbKeyNameLength);
name[XkbKeyNameLength] = '\0'; name[XkbKeyNameLength] = '\0';
auto mappedScancode = nameScancodeMap.find(std::string(name)); const auto mappedScancode = nameScancodeMap.find(std::string(name));
scancode = sf::Keyboard::Scan::Unknown; scancode = sf::Keyboard::Scan::Unknown;
if (mappedScancode != nameScancodeMap.end()) if (mappedScancode != nameScancodeMap.end())

View File

@ -68,7 +68,8 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
if (XQueryExtension(display.get(), "RANDR", &version, &version, &version)) if (XQueryExtension(display.get(), "RANDR", &version, &version, &version))
{ {
// Get the current configuration // Get the current configuration
auto config = X11Ptr<XRRScreenConfiguration>(XRRGetScreenInfo(display.get(), RootWindow(display.get(), screen))); const auto config = X11Ptr<XRRScreenConfiguration>(
XRRGetScreenInfo(display.get(), RootWindow(display.get(), screen)));
if (config) if (config)
{ {
// Get the available screen sizes // Get the available screen sizes
@ -78,7 +79,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
{ {
// Get the list of supported depths // Get the list of supported depths
int nbDepths = 0; int nbDepths = 0;
auto depths = X11Ptr<int[]>(XListDepths(display.get(), screen, &nbDepths)); const auto depths = X11Ptr<int[]>(XListDepths(display.get(), screen, &nbDepths));
if (depths && (nbDepths > 0)) if (depths && (nbDepths > 0))
{ {
// Combine depths and sizes to fill the array of supported modes // 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)) if (XQueryExtension(display.get(), "RANDR", &version, &version, &version))
{ {
// Get the current configuration // Get the current configuration
auto config = X11Ptr<XRRScreenConfiguration>(XRRGetScreenInfo(display.get(), RootWindow(display.get(), screen))); const auto config = X11Ptr<XRRScreenConfiguration>(
XRRGetScreenInfo(display.get(), RootWindow(display.get(), screen)));
if (config) if (config)
{ {
// Get the current video mode // Get the current video mode

View File

@ -971,8 +971,8 @@ void WindowImplX11::setIcon(const Vector2u& size, const std::uint8_t* pixels)
// Create the icon pixmap // Create the icon pixmap
Visual* defVisual = DefaultVisual(m_display.get(), m_screen); Visual* defVisual = DefaultVisual(m_display.get(), m_screen);
auto defDepth = static_cast<unsigned int>(DefaultDepth(m_display.get(), m_screen)); const auto defDepth = static_cast<unsigned int>(DefaultDepth(m_display.get(), m_screen));
auto iconImage = X11Ptr<XImage>( const auto iconImage = X11Ptr<XImage>(
XCreateImage(m_display.get(), defVisual, defDepth, ZPixmap, 0, reinterpret_cast<char*>(iconPixels), size.x, size.y, 32, 0)); XCreateImage(m_display.get(), defVisual, defDepth, ZPixmap, 0, reinterpret_cast<char*>(iconPixels), size.x, size.y, 32, 0));
if (!iconImage) if (!iconImage)
{ {
@ -1287,7 +1287,7 @@ void WindowImplX11::setVideoMode(const VideoMode& mode)
::Window rootWindow = RootWindow(m_display.get(), m_screen); ::Window rootWindow = RootWindow(m_display.get(), m_screen);
// Get the screen resources // Get the screen resources
auto res = X11Ptr<XRRScreenResources>(XRRGetScreenResources(m_display.get(), rootWindow)); const auto res = X11Ptr<XRRScreenResources>(XRRGetScreenResources(m_display.get(), rootWindow));
if (!res) if (!res)
{ {
err() << "Failed to get the current screen resources for fullscreen mode, switching to window mode" << std::endl; 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); RROutput output = getOutputPrimary(rootWindow, res.get(), xRandRMajor, xRandRMinor);
// Get output info from output // Get output info from output
auto outputInfo = X11Ptr<XRROutputInfo>(XRRGetOutputInfo(m_display.get(), res.get(), output)); const auto outputInfo = X11Ptr<XRROutputInfo>(XRRGetOutputInfo(m_display.get(), res.get(), output));
if (!outputInfo || outputInfo->connection == RR_Disconnected) if (!outputInfo || outputInfo->connection == RR_Disconnected)
{ {
err() << "Failed to get output info for fullscreen mode, switching to window mode" << std::endl; 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 // Retrieve current RRMode, screen position and rotation
auto crtcInfo = X11Ptr<XRRCrtcInfo>(XRRGetCrtcInfo(m_display.get(), res.get(), outputInfo->crtc)); const auto crtcInfo = X11Ptr<XRRCrtcInfo>(XRRGetCrtcInfo(m_display.get(), res.get(), outputInfo->crtc));
if (!crtcInfo) if (!crtcInfo)
{ {
err() << "Failed to get crtc info for fullscreen mode, switching to window mode" << std::endl; 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; int xRandRMinor = 0;
if (checkXRandR(xRandRMajor, xRandRMinor)) if (checkXRandR(xRandRMajor, xRandRMinor))
{ {
auto res = X11Ptr<XRRScreenResources>( const auto res = X11Ptr<XRRScreenResources>(
XRRGetScreenResources(m_display.get(), DefaultRootWindow(m_display.get()))); XRRGetScreenResources(m_display.get(), DefaultRootWindow(m_display.get())));
if (!res) if (!res)
{ {
@ -1378,7 +1378,7 @@ void WindowImplX11::resetVideoMode()
} }
// Retrieve current screen position and rotation // Retrieve current screen position and rotation
auto crtcInfo = X11Ptr<XRRCrtcInfo>(XRRGetCrtcInfo(m_display.get(), res.get(), m_oldRRCrtc)); const auto crtcInfo = X11Ptr<XRRCrtcInfo>(XRRGetCrtcInfo(m_display.get(), res.get(), m_oldRRCrtc));
if (!crtcInfo) if (!crtcInfo)
{ {
err() << "Failed to get crtc info to reset the video mode" << std::endl; err() << "Failed to get crtc info to reset the video mode" << std::endl;
@ -1717,7 +1717,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
pushEvent(event); pushEvent(event);
// If the window has been previously marked urgent (notification) as a result of a focus request, undo that // If the window has been previously marked urgent (notification) as a result of a focus request, undo that
auto hints = X11Ptr<XWMHints>(XGetWMHints(m_display.get(), m_window)); const auto hints = X11Ptr<XWMHints>(XGetWMHints(m_display.get(), m_window));
if (hints != nullptr) if (hints != nullptr)
{ {
// Remove urgency (notification) flag from hints // Remove urgency (notification) flag from hints
@ -2139,7 +2139,7 @@ Vector2i WindowImplX11::getPrimaryMonitorPosition()
::Window rootWindow = RootWindow(m_display.get(), m_screen); ::Window rootWindow = RootWindow(m_display.get(), m_screen);
// Get the screen resources // Get the screen resources
auto res = X11Ptr<XRRScreenResources>(XRRGetScreenResources(m_display.get(), rootWindow)); const auto res = X11Ptr<XRRScreenResources>(XRRGetScreenResources(m_display.get(), rootWindow));
if (!res) if (!res)
{ {
err() << "Failed to get the current screen resources for primary monitor position" << std::endl; 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); const RROutput output = getOutputPrimary(rootWindow, res.get(), xRandRMajor, xRandRMinor);
// Get output info from output // Get output info from output
auto outputInfo = X11Ptr<XRROutputInfo>(XRRGetOutputInfo(m_display.get(), res.get(), output)); const auto outputInfo = X11Ptr<XRROutputInfo>(XRRGetOutputInfo(m_display.get(), res.get(), output));
if (!outputInfo || outputInfo->connection == RR_Disconnected) if (!outputInfo || outputInfo->connection == RR_Disconnected)
{ {
err() << "Failed to get output info for primary monitor position" << std::endl; 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 // Retrieve current RRMode, screen position and rotation
auto crtcInfo = X11Ptr<XRRCrtcInfo>(XRRGetCrtcInfo(m_display.get(), res.get(), outputInfo->crtc)); const auto crtcInfo = X11Ptr<XRRCrtcInfo>(XRRGetCrtcInfo(m_display.get(), res.get(), outputInfo->crtc));
if (!crtcInfo) if (!crtcInfo)
{ {
err() << "Failed to get crtc info for primary monitor position" << std::endl; err() << "Failed to get crtc info for primary monitor position" << std::endl;