From aadd4ce1c89980674edda64086c1fa52d499bba1 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Wed, 30 Nov 2022 13:41:25 +0100 Subject: [PATCH] Remove screen realloc argument Replaced with explicit reset function --- include/x11/connection.hpp | 3 ++- src/components/screen.cpp | 3 ++- src/x11/connection.cpp | 10 ++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/x11/connection.hpp b/include/x11/connection.hpp index e554279c..9991041e 100644 --- a/include/x11/connection.hpp +++ b/include/x11/connection.hpp @@ -108,7 +108,8 @@ class connection : public detail::connection_base& dest); - xcb_screen_t* screen(bool realloc = false); + void reset_screen(); + xcb_screen_t* screen(); string id(xcb_window_t w) const; diff --git a/src/components/screen.cpp b/src/components/screen.cpp index fd5815d8..1f11da30 100644 --- a/src/components/screen.cpp +++ b/src/components/screen.cpp @@ -98,7 +98,8 @@ void screen::handle(const evt::randr_screen_change_notify& evt) { return; } - auto screen = m_connection.screen(true); + m_connection.reset_screen(); + auto screen = m_connection.screen(); auto changed = false; // We need to reload if the screen size changed as well diff --git a/src/x11/connection.cpp b/src/x11/connection.cpp index 80277604..55433805 100644 --- a/src/x11/connection.cpp +++ b/src/x11/connection.cpp @@ -79,13 +79,15 @@ string connection::id(xcb_window_t w) const { return sstream() << "0x" << std::hex << std::setw(7) << std::setfill('0') << w; } +void connection::reset_screen() { + m_screen = nullptr; +} + /** * Get pointer to the default xcb screen - * - * TODO remove realloc param. Create explicit realloc function */ -xcb_screen_t* connection::screen(bool realloc) { - if (m_screen == nullptr || realloc) { +xcb_screen_t* connection::screen() { + if (m_screen == nullptr) { m_screen = screen_of_display(default_screen()); } return m_screen;