From 5879577692d51b4b64082262d6cbaa9a16b2c8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:31 +0200 Subject: [PATCH 01/27] Add CMake preset with clang-tidy So it shows up in VSCode. --- CMakePresets.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakePresets.json b/CMakePresets.json index a4cc3b3..f478f2e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -75,6 +75,17 @@ "CMAKE_BUILD_TYPE": "Release" } }, + { + "name": "release-clangtidy", + "displayName": "Release with clang-tidy", + "inherits": [ + "release" + ], + "binaryDir": "${sourceDir}/build/Release-clangtidy", + "cacheVariables": { + "CMAKE_CXX_CLANG_TIDY": "clang-tidy" + } + }, { "name": "profile", "displayName": "Profile", From 3c223a8ddeeb48ba7ad9c8dd292e799d181d445b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:31 +0200 Subject: [PATCH 02/27] Silence some clang-tidy warnings It warned about unused variable as the SPDLOG_LOGGER_DEBUG is compiled out in release builds. --- src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp b/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp index 2c51c24..0f81dc6 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp @@ -90,6 +90,7 @@ void LinuxXcbPlatformEventLoop::processXcbEvents() switch (eventType) { case XCB_EXPOSE: { const auto *expose = reinterpret_cast(xcbEvent); + KD_UNUSED(expose); // Silence unused warning in Release build SPDLOG_LOGGER_DEBUG(m_logger, "{}: Window {} exposed. Region to be redrawn at location ({}, {}), with dimension ({}, {})", xcbEvent->sequence, expose->window, expose->x, expose->y, expose->width, expose->height); @@ -257,6 +258,7 @@ void LinuxXcbPlatformEventLoop::processXcbEvents() case XCB_MAP_NOTIFY: { const auto *mapEvent = reinterpret_cast(xcbEvent); + KD_UNUSED(mapEvent); // Silence unused warning in Release build SPDLOG_LOGGER_DEBUG(m_logger, "Map event for window {}", mapEvent->window); @@ -265,6 +267,7 @@ void LinuxXcbPlatformEventLoop::processXcbEvents() case XCB_UNMAP_NOTIFY: { const auto *unmapEvent = reinterpret_cast(xcbEvent); + KD_UNUSED(unmapEvent); // Silence unused warning in Release build SPDLOG_LOGGER_DEBUG(m_logger, "Unmap event for window {}", unmapEvent->window); From 114ca4dc4b0c654691e2d24379136920e2ede756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:32 +0200 Subject: [PATCH 03/27] Fix typos in parameter names --- src/KDGui/platform/linux/wayland/linux_wayland_platform_input.h | 2 +- src/KDGui/platform/linux/xcb/linux_xcb_platform_window.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.h b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.h index 69d7461..9abd439 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.h +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.h @@ -55,7 +55,7 @@ class LinuxWaylandPlatformInput void destroyPointerConstraintsV1(); private: - void capabilities(wl_seat *seaat, uint32_t caps); + void capabilities(wl_seat *seat, uint32_t caps); void name(wl_seat *seat, const char *name); void initPointer(); diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.h b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.h index 3a38b65..cfff940 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.h +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.h @@ -24,7 +24,7 @@ class LinuxXcbPlatformIntegration; class KDGUI_API LinuxXcbPlatformWindow : public AbstractPlatformWindow { public: - explicit LinuxXcbPlatformWindow(LinuxXcbPlatformIntegration *platformIntegraton, + explicit LinuxXcbPlatformWindow(LinuxXcbPlatformIntegration *platformIntegration, Window *window); LinuxXcbPlatformWindow() = delete; From 25135cc62ba2d226cd3730ff7d83670889cd8709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:32 +0200 Subject: [PATCH 04/27] Use !::empty() instead of ::size() > 0 for vectors --- .../platform/linux/wayland/linux_wayland_platform_input.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp index 1bb444a..0de203e 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp @@ -505,7 +505,7 @@ void LinuxWaylandPlatformInput::touchDown(wl_touch *touch, uint32_t serial, uint wl_surface *surface, int32_t id, wl_fixed_t x, wl_fixed_t y) { // We don't support touch yet, so just use the first touch point as mouse input - if (m_touch.points.size() > 0) { + if (!m_touch.points.empty()) { return; } @@ -543,7 +543,7 @@ void LinuxWaylandPlatformInput::touchFrame(wl_touch *touch) void LinuxWaylandPlatformInput::touchCancel(wl_touch *touch) { - if (m_touch.points.size() > 0) { + if (!m_touch.points.empty()) { m_touch.focus->handleMouseRelease(m_touch.time, MouseButton::LeftButton, int16_t(m_touch.points[0].pos.x), int16_t(m_touch.points[0].pos.y)); m_touch.points.clear(); } From 1b829807e8394cfedeb74c24a3c10118ee6e8aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:33 +0200 Subject: [PATCH 05/27] Fix [[nodiscard]] warnings coming from KDBindings std::ignore used in cases where we don't need to store the connection. I think it's more descriptive than (void). Technically, using std::ignore is UB until Peppe's P2968 is ratified in C++26 but every implementation we target does the right thing so I don't care. Sue me. --- examples/gui_window/gui_window.cpp | 4 +++- src/KDFoundation/platform/linux/linux_platform_timer.cpp | 6 +++--- src/KDFoundation/platform/linux/linux_platform_timer.h | 5 +++++ src/KDFoundation/platform/win32/win32_platform_timer.cpp | 4 ++-- src/KDFoundation/platform/win32/win32_platform_timer.h | 3 +++ src/KDGui/abstract_platform_window.cpp | 2 +- src/KDGui/abstract_platform_window.h | 3 +++ .../linux/wayland/linux_wayland_platform_input.cpp | 8 +++++--- .../linux/wayland/linux_wayland_platform_window.cpp | 5 +++-- .../linux/wayland/linux_wayland_platform_window.h | 1 + .../platform/linux/xcb/linux_xcb_platform_event_loop.cpp | 4 +++- src/KDGui/window.cpp | 8 +++++--- tests/auto/foundation/common/signal_spy.h | 3 ++- .../foundation/core_application/tst_core_application.cpp | 5 +++-- tests/auto/foundation/object/tst_object.cpp | 3 ++- .../tst_win32_platform_event_loop.cpp | 7 ++++--- tests/auto/utils/signal/tst_signal.cpp | 9 +++++---- 17 files changed, 53 insertions(+), 27 deletions(-) diff --git a/examples/gui_window/gui_window.cpp b/examples/gui_window/gui_window.cpp index 59b0a99..1da38cf 100644 --- a/examples/gui_window/gui_window.cpp +++ b/examples/gui_window/gui_window.cpp @@ -12,6 +12,8 @@ #include #include +#include + class ExampleWindow : public KDGui::Window { void mouseMoveEvent(KDGui::MouseMoveEvent *ev) override @@ -68,7 +70,7 @@ int main() w.title = "KDGui window example"; w.visible = true; - w.visible.valueChanged().connect([&app](bool visible) { + std::ignore = w.visible.valueChanged().connect([&app](bool visible) { if (!visible) { app.quit(); } diff --git a/src/KDFoundation/platform/linux/linux_platform_timer.cpp b/src/KDFoundation/platform/linux/linux_platform_timer.cpp index cfb4630..9e496ec 100644 --- a/src/KDFoundation/platform/linux/linux_platform_timer.cpp +++ b/src/KDFoundation/platform/linux/linux_platform_timer.cpp @@ -23,21 +23,21 @@ using namespace KDFoundation; LinuxPlatformTimer::LinuxPlatformTimer(Timer *timer) : m_notifier(timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC), FileDescriptorNotifier::NotificationType::Read) { - m_notifier.triggered.connect([this, timer]() { + m_notifierConnection = m_notifier.triggered.connect([this, timer]() { char buf[8]; const auto bytes = read(m_notifier.fileDescriptor(), buf, 8); KD_UNUSED(bytes); timer->timeout.emit(); }); - timer->running.valueChanged().connect([this, timer](bool running) { + m_timerRunningConnection = timer->running.valueChanged().connect([this, timer](bool running) { if (running) { arm(timer->interval.get()); } else { disarm(); } }); - timer->interval.valueChanged().connect([this, timer]() { + m_timerIntervalConnection = timer->interval.valueChanged().connect([this, timer]() { if (timer->running.get()) { arm(timer->interval.get()); } diff --git a/src/KDFoundation/platform/linux/linux_platform_timer.h b/src/KDFoundation/platform/linux/linux_platform_timer.h index 0cdca59..2c7aef5 100644 --- a/src/KDFoundation/platform/linux/linux_platform_timer.h +++ b/src/KDFoundation/platform/linux/linux_platform_timer.h @@ -13,6 +13,8 @@ #include +#include + #include #include @@ -35,6 +37,9 @@ class KDFOUNDATION_API LinuxPlatformTimer : public AbstractPlatformTimer int fd; } m_fdCloser; FileDescriptorNotifier m_notifier; + KDBindings::ScopedConnection m_notifierConnection; + KDBindings::ScopedConnection m_timerRunningConnection; + KDBindings::ScopedConnection m_timerIntervalConnection; }; } // namespace KDFoundation diff --git a/src/KDFoundation/platform/win32/win32_platform_timer.cpp b/src/KDFoundation/platform/win32/win32_platform_timer.cpp index 3a19ce0..e7a6803 100644 --- a/src/KDFoundation/platform/win32/win32_platform_timer.cpp +++ b/src/KDFoundation/platform/win32/win32_platform_timer.cpp @@ -27,14 +27,14 @@ inline Win32PlatformEventLoop *eventLoop() Win32PlatformTimer::Win32PlatformTimer(Timer *timer) : m_timer(timer) { - timer->running.valueChanged().connect([this, timer](bool running) { + m_timerRunningConnection = timer->running.valueChanged().connect([this, timer](bool running) { if (running) { arm(timer->interval.get()); } else { disarm(); } }); - timer->interval.valueChanged().connect([this, timer]() { + m_timerIntervalConnection = timer->interval.valueChanged().connect([this, timer]() { if (timer->running.get()) { arm(timer->interval.get()); } diff --git a/src/KDFoundation/platform/win32/win32_platform_timer.h b/src/KDFoundation/platform/win32/win32_platform_timer.h index 8a47f1d..beac29d 100644 --- a/src/KDFoundation/platform/win32/win32_platform_timer.h +++ b/src/KDFoundation/platform/win32/win32_platform_timer.h @@ -13,6 +13,7 @@ #include #include +#include #undef max #include @@ -33,6 +34,8 @@ class KDFOUNDATION_API Win32PlatformTimer : public AbstractPlatformTimer static void callback(HWND hwnd, UINT uMsg, UINT_PTR timerId, DWORD dwTime); Timer *m_timer; + KDBindings::ScopedConnection m_timerRunningConnection; + KDBindings::ScopedConnection m_timerIntervalConnection; uintptr_t m_id{ 0 }; }; diff --git a/src/KDGui/abstract_platform_window.cpp b/src/KDGui/abstract_platform_window.cpp index 6f41172..ac84d45 100644 --- a/src/KDGui/abstract_platform_window.cpp +++ b/src/KDGui/abstract_platform_window.cpp @@ -21,7 +21,7 @@ AbstractPlatformWindow::AbstractPlatformWindow(Window *window, AbstractPlatformW , m_type(type) { assert(window); - window->title.valueChanged().connect(&AbstractPlatformWindow::setTitle, this); + m_titleChangedConnection = window->title.valueChanged().connect(&AbstractPlatformWindow::setTitle, this); } AbstractPlatformWindow::Type AbstractPlatformWindow::type() const diff --git a/src/KDGui/abstract_platform_window.h b/src/KDGui/abstract_platform_window.h index a664278..5bf14e0 100644 --- a/src/KDGui/abstract_platform_window.h +++ b/src/KDGui/abstract_platform_window.h @@ -15,6 +15,8 @@ #include #include +#include + #include namespace KDGui { @@ -86,6 +88,7 @@ class KDGUI_API AbstractPlatformWindow protected: Window *m_window; + KDBindings::ScopedConnection m_titleChangedConnection; AbstractPlatformWindow::Type m_type; }; diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp index 0de203e..ccaf456 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp @@ -26,6 +26,8 @@ #include #include +#include + using namespace KDGui; LinuxWaylandPlatformInput::LinuxWaylandPlatformInput(LinuxWaylandPlatformIntegration *integration, @@ -41,7 +43,7 @@ LinuxWaylandPlatformInput::LinuxWaylandPlatformInput(LinuxWaylandPlatformIntegra }; wl_seat_add_listener(seat, &listener, this); - m_keyboard.repeat.timer.timeout.connect(&LinuxWaylandPlatformInput::keyboardRepeatKey, this); + std::ignore = m_keyboard.repeat.timer.timeout.connect(&LinuxWaylandPlatformInput::keyboardRepeatKey, this); } LinuxWaylandPlatformInput::~LinuxWaylandPlatformInput() @@ -223,7 +225,7 @@ void LinuxWaylandPlatformInput::pointerEnter(wl_pointer *pointer, uint32_t seria m_pointer.accumulatedEvent.focusChange = true; } else { m_pointer.focus = LinuxWaylandPlatformWindow::fromSurface(surface); - m_pointer.focus->cursorChanged.connect(&LinuxWaylandPlatformInput::setCursor, this); + std::ignore = m_pointer.focus->cursorChanged.connect(&LinuxWaylandPlatformInput::setCursor, this); setCursor(); } } @@ -333,7 +335,7 @@ void LinuxWaylandPlatformInput::pointerFrame(wl_pointer *pointer) auto &ev = m_pointer.accumulatedEvent; if (ev.focusChange && ev.focus) { m_pointer.focus = ev.focus; - m_pointer.focus->cursorChanged.connect(&LinuxWaylandPlatformInput::setCursor, this); + std::ignore = m_pointer.focus->cursorChanged.connect(&LinuxWaylandPlatformInput::setCursor, this); setCursor(); } diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp index 20e2670..86eb89b 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp @@ -24,6 +24,7 @@ #include #include +#include using namespace KDFoundation; using namespace KDGui; @@ -34,12 +35,12 @@ LinuxWaylandPlatformWindow::LinuxWaylandPlatformWindow( : AbstractPlatformWindow(window, AbstractPlatformWindow::Type::Wayland) , m_platformIntegration{ platformIntegration } { - CoreApplication::instance()->applicationName.valueChanged().connect([this]() { + std::ignore = CoreApplication::instance()->applicationName.valueChanged().connect([this]() { if (m_toplevel) { setAppId(); } }); - window->scaleFactor.valueChanged().connect([this](float value) { + m_scaleChangedConnection = window->scaleFactor.valueChanged().connect([this](float value) { if (m_surface) { wl_surface_set_buffer_scale(m_surface, int32_t(value)); } diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h index ff1a7e6..1191189 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h @@ -115,6 +115,7 @@ class KDGUI_API LinuxWaylandPlatformWindow : public AbstractPlatformWindow CursorMode m_cursorMode{ CursorMode::Normal }; MouseButtons m_mouseButtons{ MouseButton::NoButton }; std::vector m_enteredOutputs; + KDBindings::ScopedConnection m_scaleChangedConnection; }; } // namespace KDGui diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp b/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp index 0f81dc6..a4b1e56 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp @@ -21,6 +21,8 @@ #include +#include + using namespace KDFoundation; using namespace KDGui; @@ -39,7 +41,7 @@ LinuxXcbPlatformEventLoop::LinuxXcbPlatformEventLoop(LinuxXcbPlatformIntegration auto xcbfd = xcb_get_file_descriptor(connection); SPDLOG_LOGGER_DEBUG(m_logger, "Registering xcb fd {} with event loop", xcbfd); m_xcbNotifier = std::make_unique(xcbfd, FileDescriptorNotifier::NotificationType::Read); - m_xcbNotifier->triggered.connect([this](const int &) { + std::ignore = m_xcbNotifier->triggered.connect([this](const int &) { this->m_xcbEventsPending = true; }); diff --git a/src/KDGui/window.cpp b/src/KDGui/window.cpp index fe73e00..53bfeb6 100644 --- a/src/KDGui/window.cpp +++ b/src/KDGui/window.cpp @@ -16,6 +16,8 @@ #include #include +#include + using namespace KDFoundation; using namespace KDGui; @@ -24,13 +26,13 @@ Window::Window() , m_logger{ KDUtils::Logger::logger("window", spdlog::level::info) } { - visible.valueChanged().connect(&Window::onVisibleChanged, this); + std::ignore = visible.valueChanged().connect(&Window::onVisibleChanged, this); m_resizeConnectionIds = { width.valueChanged().connect(&Window::onSizeChanged, this), height.valueChanged().connect(&Window::onSizeChanged, this) }; - cursorEnabled.valueChanged().connect(&Window::onCursorEnabledChanged, this); - rawMouseInputEnabled.valueChanged().connect(&Window::onRawMouseInputEnabledChanged, this); + std::ignore = cursorEnabled.valueChanged().connect(&Window::onCursorEnabledChanged, this); + std::ignore = rawMouseInputEnabled.valueChanged().connect(&Window::onRawMouseInputEnabledChanged, this); } Window::~Window() diff --git a/tests/auto/foundation/common/signal_spy.h b/tests/auto/foundation/common/signal_spy.h index dae7277..028e06f 100644 --- a/tests/auto/foundation/common/signal_spy.h +++ b/tests/auto/foundation/common/signal_spy.h @@ -23,7 +23,7 @@ class SignalSpy template explicit SignalSpy(Signal &s) { - s.connect([this](Args... args) { + m_connection = s.connect([this](Args... args) { callback(args...); }); } @@ -74,4 +74,5 @@ class SignalSpy uint32_t m_count = 0; std::tuple m_args; + KDBindings::ScopedConnection m_connection; }; diff --git a/tests/auto/foundation/core_application/tst_core_application.cpp b/tests/auto/foundation/core_application/tst_core_application.cpp index 9fd06f5..5597980 100644 --- a/tests/auto/foundation/core_application/tst_core_application.cpp +++ b/tests/auto/foundation/core_application/tst_core_application.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include @@ -203,7 +204,7 @@ TEST_CASE("Timer handling") int timeout = 0; auto startTime = std::chrono::steady_clock::now(); auto time = startTime; - timer.timeout.connect([&]() { + std::ignore = timer.timeout.connect([&]() { const auto endTime = std::chrono::steady_clock::now(); REQUIRE(endTime - time > 50ms); REQUIRE(endTime - time < 150ms); @@ -240,7 +241,7 @@ TEST_CASE("Timer handling") bool fired = false; - timer.timeout.connect([&] { + std::ignore = timer.timeout.connect([&] { fired = true; }); diff --git a/tests/auto/foundation/object/tst_object.cpp b/tests/auto/foundation/object/tst_object.cpp index e9d2803..bc70cc6 100644 --- a/tests/auto/foundation/object/tst_object.cpp +++ b/tests/auto/foundation/object/tst_object.cpp @@ -19,6 +19,7 @@ #include #include +#include #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include @@ -288,7 +289,7 @@ TEST_CASE("Object destruction") for (int i = 0; i < 10; ++i) { auto child = parent->createChild(i); - child->aboutToBeDestroyed.connect(onAboutToBeDestroyed); + std::ignore = child->aboutToBeDestroyed.connect(onAboutToBeDestroyed); } // THEN REQUIRE(childRemovedSpy.count() == 0); diff --git a/tests/auto/foundation/win32_platform_event_loop/tst_win32_platform_event_loop.cpp b/tests/auto/foundation/win32_platform_event_loop/tst_win32_platform_event_loop.cpp index 8f93459..74fa02a 100644 --- a/tests/auto/foundation/win32_platform_event_loop/tst_win32_platform_event_loop.cpp +++ b/tests/auto/foundation/win32_platform_event_loop/tst_win32_platform_event_loop.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -185,7 +186,7 @@ TEST_CASE("Wait for events") // A notifier for testing deregistration int unregisteredCalls = 0; FileDescriptorNotifier unregistered(clientSock, FileDescriptorNotifier::NotificationType::Read); - unregistered.triggered.connect([&unregisteredCalls] { + std::ignore = unregistered.triggered.connect([&unregisteredCalls] { unregisteredCalls++; }); loop.registerNotifier(&unregistered); @@ -193,7 +194,7 @@ TEST_CASE("Wait for events") // Set up read notifier to receive the data FileDescriptorNotifier readNotifier(clientSock, FileDescriptorNotifier::NotificationType::Read); - readNotifier.triggered.connect([&dataReceived](int fd) { + std::ignore = readNotifier.triggered.connect([&dataReceived](int fd) { char buf[128] = {}; recv(fd, buf, 128, 0); const int recvSize = recv(fd, buf, 128, 0); @@ -205,7 +206,7 @@ TEST_CASE("Wait for events") // A notifier for testing Write notification type FileDescriptorNotifier writeNotifier(clientSock, FileDescriptorNotifier::NotificationType::Write); int writeTriggered = 0; - writeNotifier.triggered.connect([&writeTriggered]() { + std::ignore = writeNotifier.triggered.connect([&writeTriggered]() { writeTriggered++; }); loop.registerNotifier(&writeNotifier); diff --git a/tests/auto/utils/signal/tst_signal.cpp b/tests/auto/utils/signal/tst_signal.cpp index 4e8da0d..d2f4740 100644 --- a/tests/auto/utils/signal/tst_signal.cpp +++ b/tests/auto/utils/signal/tst_signal.cpp @@ -14,6 +14,7 @@ #include #include +#include using namespace KDUtils; @@ -31,13 +32,13 @@ TEST_SUITE("Signal") KDBindings::Signal signal2; std::thread thread1([&] { - signal1.connectDeferred(app.connectionEvaluator(), [&val](int value) { + std::ignore = signal1.connectDeferred(app.connectionEvaluator(), [&val](int value) { val += value; }); }); std::thread thread2([&] { - signal2.connectDeferred(app.connectionEvaluator(), [&val](int value) { + std::ignore = signal2.connectDeferred(app.connectionEvaluator(), [&val](int value) { val += value; }); }); @@ -91,11 +92,11 @@ TEST_SUITE("Signal") int val1 = 4; int val2 = 4; - signal1.connectDeferred(app.connectionEvaluator(), [&val1](int value) { + std::ignore = signal1.connectDeferred(app.connectionEvaluator(), [&val1](int value) { val1 += value; }); - signal2.connectDeferred(app.connectionEvaluator(), [&val2](int value) { + std::ignore = signal2.connectDeferred(app.connectionEvaluator(), [&val2](int value) { val2 += value; }); From 62c25d6eb3c4195eaf5ead8dc9b1ebd2caa71335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:34 +0200 Subject: [PATCH 06/27] Fix readability-redundant-member-init warnings https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html --- src/KDFoundation/core_application.cpp | 3 +-- src/KDFoundation/file_descriptor_notifier.cpp | 3 +-- src/KDFoundation/platform/linux/linux_platform_event_loop.cpp | 1 - .../linux/wayland/linux_wayland_platform_event_loop.cpp | 3 +-- src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp | 3 +-- src/KDGui/window.cpp | 3 +-- 6 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/KDFoundation/core_application.cpp b/src/KDFoundation/core_application.cpp index d429a8d..45ec8ef 100644 --- a/src/KDFoundation/core_application.cpp +++ b/src/KDFoundation/core_application.cpp @@ -28,8 +28,7 @@ using namespace KDFoundation; CoreApplication *CoreApplication::ms_application = nullptr; CoreApplication::CoreApplication(std::unique_ptr &&platformIntegration) - : Object() - , m_defaultLogger{ KDUtils::Logger::logger("default_log", spdlog::level::info) } + : m_defaultLogger{ KDUtils::Logger::logger("default_log", spdlog::level::info) } , m_platformIntegration{ std::move(platformIntegration) } , m_logger{ KDUtils::Logger::logger("core_application") } { diff --git a/src/KDFoundation/file_descriptor_notifier.cpp b/src/KDFoundation/file_descriptor_notifier.cpp index 1f7fbb4..ed0196a 100644 --- a/src/KDFoundation/file_descriptor_notifier.cpp +++ b/src/KDFoundation/file_descriptor_notifier.cpp @@ -20,8 +20,7 @@ using namespace KDFoundation; FileDescriptorNotifier::FileDescriptorNotifier(int fd, NotificationType type) - : Object() - , m_fd{ fd } + : m_fd{ fd } , m_type{ type } { assert(m_fd >= 0); diff --git a/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp b/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp index f3de4a6..9d5318f 100644 --- a/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp +++ b/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp @@ -20,7 +20,6 @@ using namespace KDFoundation; LinuxPlatformEventLoop::LinuxPlatformEventLoop() - : AbstractPlatformEventLoop() { // We use epoll to multiplex as it has much better performance than // select or poll. diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_event_loop.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_event_loop.cpp index 9005434..9341212 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_event_loop.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_event_loop.cpp @@ -18,8 +18,7 @@ using namespace KDGui; using namespace KDFoundation; LinuxWaylandPlatformEventLoop::LinuxWaylandPlatformEventLoop(LinuxWaylandPlatformIntegration *platformIntegration) - : LinuxPlatformEventLoop() - , m_platformIntegration{ platformIntegration } + : m_platformIntegration{ platformIntegration } { } diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp b/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp index a4b1e56..3740f56 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_event_loop.cpp @@ -27,8 +27,7 @@ using namespace KDFoundation; using namespace KDGui; LinuxXcbPlatformEventLoop::LinuxXcbPlatformEventLoop(LinuxXcbPlatformIntegration *platformIntegration) - : LinuxPlatformEventLoop() - , m_platformIntegration{ platformIntegration } + : m_platformIntegration{ platformIntegration } { m_logger = m_platformIntegration->logger(); diff --git a/src/KDGui/window.cpp b/src/KDGui/window.cpp index 53bfeb6..f682358 100644 --- a/src/KDGui/window.cpp +++ b/src/KDGui/window.cpp @@ -22,8 +22,7 @@ using namespace KDFoundation; using namespace KDGui; Window::Window() - : Object() - , m_logger{ KDUtils::Logger::logger("window", spdlog::level::info) } + : m_logger{ KDUtils::Logger::logger("window", spdlog::level::info) } { std::ignore = visible.valueChanged().connect(&Window::onVisibleChanged, this); From e7db91d5fec2642ef9a59df177b6a7ed9de59396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:34 +0200 Subject: [PATCH 07/27] Fix misc-const-correctness warnings https://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html --- .../platform/linux/linux_platform_event_loop.cpp | 4 ++-- .../platform/linux/linux_platform_timer.cpp | 6 +++--- .../wayland/linux_wayland_platform_event_loop.cpp | 4 ++-- .../linux/wayland/linux_wayland_platform_input.cpp | 6 +++--- .../wayland/linux_wayland_platform_window.cpp | 2 +- .../linux/xcb/linux_xcb_platform_window.cpp | 14 +++++++------- src/KDGui/window.cpp | 4 ++-- src/KDUtils/file.cpp | 2 +- src/KDUtils/url.cpp | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp b/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp index 9d5318f..9c08fb3 100644 --- a/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp +++ b/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp @@ -65,7 +65,7 @@ void LinuxPlatformEventLoop::waitForEventsImpl(int timeout) const int maxEventCount = 16; epoll_event events[maxEventCount]; - int eventCount = epoll_wait(m_epollHandle, events, maxEventCount, timeout); + const int eventCount = epoll_wait(m_epollHandle, events, maxEventCount, timeout); SPDLOG_DEBUG("epoll_wait() returned {} events within {} msecs", eventCount, timeout); // Let interested parties know if something happened. @@ -106,7 +106,7 @@ void LinuxPlatformEventLoop::waitForEventsImpl(int timeout) void LinuxPlatformEventLoop::wakeUp() { - eventfd_t value{ 1 }; + const eventfd_t value{ 1 }; eventfd_write(m_eventfd, value); } diff --git a/src/KDFoundation/platform/linux/linux_platform_timer.cpp b/src/KDFoundation/platform/linux/linux_platform_timer.cpp index 9e496ec..ffa6933 100644 --- a/src/KDFoundation/platform/linux/linux_platform_timer.cpp +++ b/src/KDFoundation/platform/linux/linux_platform_timer.cpp @@ -61,7 +61,7 @@ void LinuxPlatformTimer::arm(std::chrono::microseconds us) timespec time; time.tv_sec = us.count() / 1'000'000; time.tv_nsec = (us.count() - time.tv_sec * 1'000'000) * 1000; - itimerspec spec = { + const itimerspec spec = { .it_interval = time, .it_value = time }; @@ -70,8 +70,8 @@ void LinuxPlatformTimer::arm(std::chrono::microseconds us) void LinuxPlatformTimer::disarm() { - timespec time = { 0, 0 }; - itimerspec spec = { + const timespec time = { 0, 0 }; + const itimerspec spec = { .it_interval = time, .it_value = time }; diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_event_loop.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_event_loop.cpp index 9341212..1234c92 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_event_loop.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_event_loop.cpp @@ -26,7 +26,7 @@ void LinuxWaylandPlatformEventLoop::init() { m_logger = m_platformIntegration->logger(); - int fd = wl_display_get_fd(m_platformIntegration->display()); + const int fd = wl_display_get_fd(m_platformIntegration->display()); registerFileDescriptor(fd, FileDescriptorNotifier::NotificationType::Read); } @@ -47,7 +47,7 @@ void LinuxWaylandPlatformEventLoop::waitForEventsImpl(int timeout) // Call the base class to do the actual multiplexing LinuxPlatformEventLoop::waitForEventsImpl(timeout); - int fd = wl_display_get_fd(dpy); + const int fd = wl_display_get_fd(dpy); if (epollEventFromFdPlusType(fd, FileDescriptorNotifier::NotificationType::Read)) { wl_display_read_events(dpy); wl_display_dispatch_queue_pending(dpy, queue); diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp index ccaf456..170cb38 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp @@ -374,9 +374,9 @@ void LinuxWaylandPlatformInput::pointerAxisDiscrete(wl_pointer *pointer, uint32_ void LinuxWaylandPlatformInput::pointerRelativeMotionV1(zwp_relative_pointer_v1 *pointer, uint32_t utimeHi, uint32_t utimeLow, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dxUnaccel, wl_fixed_t dyUnaccel) { - Position pos{ wl_fixed_to_int(dx), wl_fixed_to_int(dy) }; - uint64_t utime = uint64_t(utimeHi) << 32 | utimeLow; - uint32_t time = utime / 1000; + const Position pos{ wl_fixed_to_int(dx), wl_fixed_to_int(dy) }; + const uint64_t utime = uint64_t(utimeHi) << 32 | utimeLow; + const uint32_t time = utime / 1000; if (m_version >= WL_POINTER_FRAME_SINCE_VERSION) { m_pointer.accumulatedEvent.delta = pos; diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp index 86eb89b..8dc6de5 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp @@ -199,7 +199,7 @@ void LinuxWaylandPlatformWindow::handleMouseMove(uint32_t timestamp, MouseButton void LinuxWaylandPlatformWindow::handleMouseMoveRelative(uint32_t timestamp, int64_t dx, int64_t dy) { if (m_cursorMode == CursorMode::Disabled) { - Position pos = window()->cursorPosition.get() + Position(dx, dy); + const Position pos = window()->cursorPosition.get() + Position(dx, dy); MouseMoveEvent ev{ timestamp, MouseButton::NoButton, pos.x, pos.y }; CoreApplication::instance()->sendEvent(m_window, &ev); } diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp index 5caf76e..498411c 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp @@ -41,8 +41,8 @@ bool LinuxXcbPlatformWindow::create() const auto screen = m_platformIntegration->screen(); m_xcbWindow = xcb_generate_id(connection); - uint32_t mask = XCB_CW_EVENT_MASK; - uint32_t values[1] = { + const uint32_t mask = XCB_CW_EVENT_MASK; + const uint32_t values[1] = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | @@ -77,10 +77,10 @@ bool LinuxXcbPlatformWindow::create() // Register for the WM_DELETE_WINDOW client message events. This prevents the // server from disconnecting us when a top-level window is closed. Allows us to // just unmap the window gracefully. - xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); - xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookie, nullptr); - xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); - xcb_intern_atom_reply_t *reply2 = xcb_intern_atom_reply(connection, cookie2, nullptr); + const xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); + const xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookie, nullptr); + const xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); + const xcb_intern_atom_reply_t *reply2 = xcb_intern_atom_reply(connection, cookie2, nullptr); m_closeAtom = reply2->atom; xcb_change_property( connection, @@ -97,7 +97,7 @@ bool LinuxXcbPlatformWindow::create() m_platformIntegration->registerWindowForEvents(m_xcbWindow, this); // Create a hidden cursor from an unset 1x1 pixmap - xcb_pixmap_t pixmap = xcb_generate_id(connection); + const xcb_pixmap_t pixmap = xcb_generate_id(connection); m_hiddenCursor = xcb_generate_id(connection); xcb_create_pixmap(connection, 1, pixmap, screen->root, 1, 1); xcb_create_cursor(connection, m_hiddenCursor, pixmap, pixmap, diff --git a/src/KDGui/window.cpp b/src/KDGui/window.cpp index f682358..cfd8558 100644 --- a/src/KDGui/window.cpp +++ b/src/KDGui/window.cpp @@ -210,12 +210,12 @@ void Window::resizeEvent(ResizeEvent *ev) ev->height()); // Block internal connection to onSizeChanged() to avoid a loop { - KDBindings::ConnectionBlocker widthBlocker{ m_resizeConnectionIds[0] }; + const KDBindings::ConnectionBlocker widthBlocker{ m_resizeConnectionIds[0] }; width = ev->width(); } { - KDBindings::ConnectionBlocker heightBlocker{ m_resizeConnectionIds[1] }; + const KDBindings::ConnectionBlocker heightBlocker{ m_resizeConnectionIds[1] }; height = ev->height(); } diff --git a/src/KDUtils/file.cpp b/src/KDUtils/file.cpp index e772eb2..708585e 100644 --- a/src/KDUtils/file.cpp +++ b/src/KDUtils/file.cpp @@ -152,7 +152,7 @@ void File::write(const ByteArray &data) std::string File::fileName() const { - std::filesystem::path p(m_path); + const std::filesystem::path p(m_path); return p.filename().u8string(); } diff --git a/src/KDUtils/url.cpp b/src/KDUtils/url.cpp index 5692986..d7fdac4 100644 --- a/src/KDUtils/url.cpp +++ b/src/KDUtils/url.cpp @@ -20,7 +20,7 @@ namespace KDUtils { Url::Url(const std::string &url) : m_url(url) { - std::regex rexExp(u8"(?:([^\\/]{2,})?:(?:\\/\\/)?)?(.*\\/)*(.+\\..+)?"s); + const std::regex rexExp(u8"(?:([^\\/]{2,})?:(?:\\/\\/)?)?(.*\\/)*(.+\\..+)?"s); std::smatch match; const bool hasMatch = std::regex_match(m_url, match, rexExp); if (hasMatch) { From 51c98eefe015d2941ef978aa1f42ef65267a5e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:35 +0200 Subject: [PATCH 08/27] Fix misc-use-anonymous-namespace warning https://clang.llvm.org/extra/clang-tidy/checks/misc/use-anonymous-namespace.html --- src/KDUtils/file_mapper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/KDUtils/file_mapper.cpp b/src/KDUtils/file_mapper.cpp index ba2914d..a7de9be 100644 --- a/src/KDUtils/file_mapper.cpp +++ b/src/KDUtils/file_mapper.cpp @@ -60,8 +60,9 @@ FileMapper::FileMapper(File &&file) // a default deleter without knowing the size of the type. FileMapper::~FileMapper() = default; +namespace { template -static const uint8_t *mapImpl( +const uint8_t *mapImpl( std::unique_ptr &output, const std::string &path, std::uintmax_t offset, @@ -108,6 +109,7 @@ static const uint8_t *mapImpl( return output->readOnlyMap().data(); } } +} // namespace const uint8_t *FileMapper::map(std::uintmax_t offset, std::uintmax_t length) const { From 0ecc79bbe75f65dadd18cc1eb0879546f6b65c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:35 +0200 Subject: [PATCH 09/27] Fix readability-redundant-inline-specifier warning --- src/KDUtils/file_mapper.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/KDUtils/file_mapper.cpp b/src/KDUtils/file_mapper.cpp index a7de9be..04686f7 100644 --- a/src/KDUtils/file_mapper.cpp +++ b/src/KDUtils/file_mapper.cpp @@ -21,9 +21,9 @@ using WriteMap = mio::basic_mmap; struct FileMapper::Map { std::variant map; - inline ~Map() {}; + ~Map() {}; - inline Map(bool writeable) + Map(bool writeable) { // NOTE: mio's maps consist of primitive types which won't throw. but // the constructors are not marked noexcept @@ -33,17 +33,17 @@ struct FileMapper::Map { map = ReadMap(); } - [[nodiscard]] inline bool writable() const noexcept + [[nodiscard]] bool writable() const noexcept { return std::holds_alternative(map); } - inline WriteMap &writableMap() + WriteMap &writableMap() { return std::get(map); } - inline ReadMap &readOnlyMap() + ReadMap &readOnlyMap() { return std::get(map); } From 57c2130eb057f6df6a8e7892fc2644bfce663878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:36 +0200 Subject: [PATCH 10/27] Fix concurrency-mt-unsafe warnings --- src/KDFoundation/core_application.cpp | 2 +- .../platform/linux/linux_platform_event_loop.cpp | 10 +++++++++- src/KDGui/gui_application.cpp | 2 +- .../wayland/linux_wayland_platform_integration.cpp | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/KDFoundation/core_application.cpp b/src/KDFoundation/core_application.cpp index 45ec8ef..03a75fd 100644 --- a/src/KDFoundation/core_application.cpp +++ b/src/KDFoundation/core_application.cpp @@ -38,7 +38,7 @@ CoreApplication::CoreApplication(std::unique_ptr && spdlog::set_default_logger(m_defaultLogger); // Helps with debugging setup on remote hosts - if (const char *display = std::getenv("DISPLAY")) + if (const char *display = std::getenv("DISPLAY")) // NOLINT(concurrency-mt-unsafe) SPDLOG_LOGGER_INFO(m_logger, "DISPLAY={}", display); // Create a default postman object diff --git a/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp b/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp index 9c08fb3..4996e1c 100644 --- a/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp +++ b/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp @@ -9,6 +9,10 @@ Contact KDAB at for commercial licensing options. */ +#if !defined(_GNU_SOURCE) +#error "Project must be compiled with _GNU_SOURCE define for GNU variant of strerror_r" +#endif + #include #include #include @@ -17,6 +21,9 @@ #include #include +#include +#include + using namespace KDFoundation; LinuxPlatformEventLoop::LinuxPlatformEventLoop() @@ -174,7 +181,8 @@ bool LinuxPlatformEventLoop::unregisterFileDescriptor(int fd, FileDescriptorNoti // proceed as if unregistering the file descriptor was successful. // This way we ensure notifiers are reset / deleted properly. if (rv && (errno != EBADF)) { - SPDLOG_ERROR("Failed to unregister file descriptor {}. Error {}: {}.", fd, errno, strerror(errno)); + std::array buf; + SPDLOG_ERROR("Failed to unregister file descriptor {}. Error {}: {}.", fd, errno, strerror_r(errno, buf.data(), buf.size())); return false; } diff --git a/src/KDGui/gui_application.cpp b/src/KDGui/gui_application.cpp index b55ea24..ba90c28 100644 --- a/src/KDGui/gui_application.cpp +++ b/src/KDGui/gui_application.cpp @@ -33,7 +33,7 @@ static std::unique_ptr createLinuxIntegra bool prefersXcb = false; // TODO(doc): document this behavior - if (const char *preferredPlatform = std::getenv("KDGUI_PLATFORM")) { + if (const char *preferredPlatform = std::getenv("KDGUI_PLATFORM")) { //NOLINT(concurrency-mt-unsafe) prefersXcb = std::string_view{ preferredPlatform } == "xcb"; } diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp index a8ce8ef..3186446 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp @@ -24,6 +24,8 @@ #include #include +#include + using namespace KDGui; LinuxWaylandPlatformIntegration::LinuxWaylandPlatformIntegration() @@ -49,7 +51,7 @@ void LinuxWaylandPlatformIntegration::init() { m_logger = KDUtils::Logger::logger("wayland", spdlog::level::info); - SPDLOG_LOGGER_INFO(m_logger, "Wayland display is: {}", getenv("WAYLAND_DISPLAY")); + SPDLOG_LOGGER_INFO(m_logger, "Wayland display is: {}", std::getenv("WAYLAND_DISPLAY")); // NOLINT(concurrency-mt-unsafe) m_display = wl_display_connect(nullptr); if (!m_display) { From 656b5f8fda5fc7a34e772a43226e20ad2c539fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:37 +0200 Subject: [PATCH 11/27] Fix bugprone-narrowing-conversions warning LinuxWaylandPlatformWindow::scaleByFactor converted to template so it can work both for signed and unsigned types without warning. --- .../platform/linux/wayland/linux_wayland_platform_window.cpp | 5 +++-- .../platform/linux/wayland/linux_wayland_platform_window.h | 3 ++- src/KDUtils/bytearray.cpp | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp index 8dc6de5..7be69e5 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp @@ -300,7 +300,8 @@ void LinuxWaylandPlatformWindow::updateScaleFactor() window()->scaleFactor = factor; } -int32_t LinuxWaylandPlatformWindow::scaleByFactor(const int32_t value) const +template +T LinuxWaylandPlatformWindow::scaleByFactor(T value) const { - return value * m_window->scaleFactor.get(); + return value * m_window->scaleFactor.get(); // NOLINT(bugprone-narrowing-conversions) } diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h index 1191189..fc8bca7 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h @@ -106,7 +106,8 @@ class KDGUI_API LinuxWaylandPlatformWindow : public AbstractPlatformWindow void setAppId(); void updateScaleFactor(); - int32_t scaleByFactor(int32_t value) const; + template + T scaleByFactor(T value) const; LinuxWaylandPlatformIntegration *m_platformIntegration; wl_surface *m_surface{ nullptr }; diff --git a/src/KDUtils/bytearray.cpp b/src/KDUtils/bytearray.cpp index 2ebab1d..aa08602 100644 --- a/src/KDUtils/bytearray.cpp +++ b/src/KDUtils/bytearray.cpp @@ -83,7 +83,7 @@ ByteArray ByteArray::mid(size_t pos, size_t len) const if (len == 0) len = size() - pos; len = std::min(len, size()); - return ByteArray({ m_data.begin() + pos, m_data.begin() + int64_t(pos + len) }); + return ByteArray({ m_data.begin() + int64_t(pos), m_data.begin() + int64_t(pos + len) }); } ByteArray ByteArray::left(size_t left) const @@ -105,7 +105,7 @@ ByteArray &ByteArray::remove(size_t pos, size_t len) if (pos >= size()) return *this; len = std::min(size() - pos, len); - m_data.erase(m_data.begin() + pos, m_data.begin() + int64_t(pos + len)); + m_data.erase(m_data.begin() + int64_t(pos), m_data.begin() + int64_t(pos + len)); return *this; } From 310bad0fbbb1d12202415b5ad7bd8371d7644f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:37 +0200 Subject: [PATCH 12/27] Dont't run clang-tidy on fmt Setting SYSTEM on FetchContent_Declare for fmt is not good as it requires CMake 3.25 (we want to support older ones) and doesn't work as clang-tidy is still invoked. --- cmake/dependencies.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 69e67dd..f517d8f 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -32,6 +32,7 @@ if(NOT TARGET spdlog::spdlog) GIT_TAG e69e5f977d458f2650bb346dadf2ad30c5320281 # 10.2.1 ) FetchContent_MakeAvailable(fmt) + set_target_properties(fmt PROPERTIES CXX_CLANG_TIDY "") endif() set(SPDLOG_FMT_EXTERNAL_HO ON) # with this spdlog is included as a system library and won't e.g. trigger From 1083366efe1f6a845e896120c17f0271ed052ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:38 +0200 Subject: [PATCH 13/27] Fix misc-header-include-cycle from mio --- src/KDUtils/file_mapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KDUtils/file_mapper.cpp b/src/KDUtils/file_mapper.cpp index 04686f7..9049e51 100644 --- a/src/KDUtils/file_mapper.cpp +++ b/src/KDUtils/file_mapper.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include // NOLINT(misc-header-include-cycle) namespace KDUtils { using ReadMap = mio::basic_mmap; From dfe51f1e2c6776759174430bf440e66fff4aa577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:38 +0200 Subject: [PATCH 14/27] Fix modernize-avoid-c-arrays warning For better readability, in xcb-facing code I retained C arrays. While we're at it, replaced one KD_UNUSED with std::ignore. --- .../linux/linux_platform_event_loop.cpp | 4 ++-- .../platform/linux/linux_platform_timer.cpp | 14 +++++++------ .../linux/xcb/linux_xcb_platform_window.cpp | 5 +++-- .../platform/linux/xcb/linux_xkb_keyboard.cpp | 20 ++++++++++--------- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp b/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp index 4996e1c..5dc9211 100644 --- a/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp +++ b/src/KDFoundation/platform/linux/linux_platform_event_loop.cpp @@ -70,9 +70,9 @@ LinuxPlatformEventLoop::~LinuxPlatformEventLoop() void LinuxPlatformEventLoop::waitForEventsImpl(int timeout) { const int maxEventCount = 16; - epoll_event events[maxEventCount]; + std::array events; - const int eventCount = epoll_wait(m_epollHandle, events, maxEventCount, timeout); + const int eventCount = epoll_wait(m_epollHandle, events.data(), events.size(), timeout); SPDLOG_DEBUG("epoll_wait() returned {} events within {} msecs", eventCount, timeout); // Let interested parties know if something happened. diff --git a/src/KDFoundation/platform/linux/linux_platform_timer.cpp b/src/KDFoundation/platform/linux/linux_platform_timer.cpp index ffa6933..49256e5 100644 --- a/src/KDFoundation/platform/linux/linux_platform_timer.cpp +++ b/src/KDFoundation/platform/linux/linux_platform_timer.cpp @@ -11,22 +11,24 @@ #include -#include -#include - #include "KDFoundation/core_application.h" #include "KDFoundation/timer.h" #include "KDFoundation/platform/linux/linux_platform_event_loop.h" +#include +#include + +#include +#include + using namespace KDFoundation; LinuxPlatformTimer::LinuxPlatformTimer(Timer *timer) : m_notifier(timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC), FileDescriptorNotifier::NotificationType::Read) { m_notifierConnection = m_notifier.triggered.connect([this, timer]() { - char buf[8]; - const auto bytes = read(m_notifier.fileDescriptor(), buf, 8); - KD_UNUSED(bytes); + std::array buf; + std::ignore = read(m_notifier.fileDescriptor(), buf.data(), buf.size()); timer->timeout.emit(); }); diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp index 498411c..0a12ed9 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp @@ -42,6 +42,7 @@ bool LinuxXcbPlatformWindow::create() m_xcbWindow = xcb_generate_id(connection); const uint32_t mask = XCB_CW_EVENT_MASK; + // NOLINTNEXTLINE(modernize-avoid-c-arrays) const uint32_t values[1] = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | @@ -169,7 +170,7 @@ void LinuxXcbPlatformWindow::disableCursor() // Hide the cursor const auto connection = m_platformIntegration->connection(); - uint32_t values[] = { m_hiddenCursor }; + uint32_t values[] = { m_hiddenCursor }; // NOLINT(modernize-avoid-c-arrays) xcb_change_window_attributes(connection, m_xcbWindow, XCB_CURSOR, &values); // Move cursor to centre of the window @@ -208,7 +209,7 @@ void LinuxXcbPlatformWindow::enableCursor() int16_t(m_cursorRestorePosition.x), int16_t(m_cursorRestorePosition.y)); // Reset the default cursor (inherit from parent window) - uint32_t values[] = { 0 }; + uint32_t values[] = { 0 }; // NOLINT(modernize-avoid-c-arrays) xcb_change_window_attributes(connection, m_xcbWindow, XCB_CURSOR, &values); xcb_flush(connection); } diff --git a/src/KDGui/platform/linux/xcb/linux_xkb_keyboard.cpp b/src/KDGui/platform/linux/xcb/linux_xkb_keyboard.cpp index 8b95c18..2c9c05f 100644 --- a/src/KDGui/platform/linux/xcb/linux_xkb_keyboard.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xkb_keyboard.cpp @@ -20,6 +20,8 @@ #include #undef explicit +#include + using namespace KDGui; LinuxXkbKeyboard::LinuxXkbKeyboard(LinuxXcbPlatformIntegration *platformIntegration) @@ -131,9 +133,9 @@ void LinuxXkbKeyboard::handleKeyPress(xcb_key_press_event_t *ev) // Update the xkb state (void)xkb_state_update_key(m_state.get(), keycode, XKB_KEY_DOWN); - char s[16]; - xkb_keysym_get_name(keysym, s, sizeof(s)); - SPDLOG_LOGGER_TRACE(m_logger, "keysym: {} => name: {}", keysym, s); + std::array s; + xkb_keysym_get_name(keysym, s.data(), s.size()); + SPDLOG_LOGGER_TRACE(m_logger, "keysym: {} => name: {}", keysym, s.data()); // Lookup the KDGui key enum auto key = xkb::keysymToKey(keysym); @@ -145,9 +147,9 @@ void LinuxXkbKeyboard::handleKeyPress(xcb_key_press_event_t *ev) window->handleKeyPress(ev->time, ev->detail, key, modifiers); // Get the unicode characters - xkb_state_key_get_utf8(m_state.get(), keycode, s, sizeof(s)); - if (strlen(s) > 0) - window->handleTextInput(s); + xkb_state_key_get_utf8(m_state.get(), keycode, s.data(), s.size()); + if (strlen(s.data()) > 0) + window->handleTextInput(s.data()); } void LinuxXkbKeyboard::handleKeyRelease(xcb_key_release_event_t *ev) @@ -162,9 +164,9 @@ void LinuxXkbKeyboard::handleKeyRelease(xcb_key_release_event_t *ev) // Update the xkb state (void)xkb_state_update_key(m_state.get(), keycode, XKB_KEY_UP); - char s[16]; - xkb_keysym_get_name(keysym, s, sizeof(s)); - SPDLOG_LOGGER_TRACE(m_logger, "keysym: {} => name: {}", keysym, s); + std::array s; + xkb_keysym_get_name(keysym, s.data(), s.size()); + SPDLOG_LOGGER_TRACE(m_logger, "keysym: {} => name: {}", keysym, s.data()); // Lookup the KDGui key enum auto key = xkb::keysymToKey(keysym); From 0a90990c08186a5913bd7d4ff6f1fae40061a0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:39 +0200 Subject: [PATCH 15/27] Fix readability-convert-member-functions-to-static Some got NOLINT treatment because they are used as wayland callbacks and it's easier to have them this way. --- src/KDFoundation/platform/linux/linux_platform_event_loop.h | 2 +- .../linux/wayland/linux_wayland_platform_integration.cpp | 1 + .../platform/linux/wayland/linux_wayland_platform_window.cpp | 1 + src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.h | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/KDFoundation/platform/linux/linux_platform_event_loop.h b/src/KDFoundation/platform/linux/linux_platform_event_loop.h index be07762..449381e 100644 --- a/src/KDFoundation/platform/linux/linux_platform_event_loop.h +++ b/src/KDFoundation/platform/linux/linux_platform_event_loop.h @@ -49,7 +49,7 @@ class KDFOUNDATION_API LinuxPlatformEventLoop : public AbstractPlatformEventLoop int epollEventFromFdPlusType(int fd, FileDescriptorNotifier::NotificationType type); int epollEventFromFdMinusType(int fd, FileDescriptorNotifier::NotificationType type); - int epollEventFromNotifierTypes(bool read, bool write, bool exception); + static int epollEventFromNotifierTypes(bool read, bool write, bool exception); protected: void waitForEventsImpl(int timeout) override; diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp index 3186446..431c3e1 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp @@ -206,6 +206,7 @@ void LinuxWaylandPlatformIntegration::globalRemove(wl_registry *registry, uint32 } } +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) void LinuxWaylandPlatformIntegration::ping(xdg_wm_base *xdgShell, uint32_t serial) { xdg_wm_base_pong(xdgShell, serial); diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp index 7be69e5..9bd8e9e 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp @@ -248,6 +248,7 @@ void LinuxWaylandPlatformWindow::leave(wl_surface *surface, wl_output *output) updateScaleFactor(); } +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) void LinuxWaylandPlatformWindow::configure(xdg_surface *xdgSurface, uint32_t serial) { xdg_surface_ack_configure(xdgSurface, serial); diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.h b/src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.h index 0c5fe3e..b5bf574 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.h +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.h @@ -53,7 +53,7 @@ class KDGUI_API LinuxXcbPlatformIntegration : public AbstractGuiPlatformIntegrat LinuxXcbPlatformWindow *createPlatformWindowImpl(Window *window) override; bool initializeXkbExtension(); - void dumpScreenInfo(xcb_screen_t *screen); + static void dumpScreenInfo(xcb_screen_t *screen); std::shared_ptr m_logger; xcb_connection_t *m_connection{ nullptr }; From fbe039e7537e812e4ad6719b962f765550d1c22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:40 +0200 Subject: [PATCH 16/27] Fortify ~Object against exceptions --- src/KDFoundation/object.cpp | 16 ++++++++++++++-- src/KDFoundation/object.h | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/KDFoundation/object.cpp b/src/KDFoundation/object.cpp index d03a343..e4e355e 100644 --- a/src/KDFoundation/object.cpp +++ b/src/KDFoundation/object.cpp @@ -42,11 +42,23 @@ void Object::deleteLater() Object::~Object() { - destroyed.emit(this); + try { + destroyed.emit(this); + } catch (...) { + SPDLOG_ERROR("Exception caught in ~Object({}) during Object::destroyed emission. Ignoring.", + objectName()); + } // Destroy the children in LIFO to be more like the stack while (!m_children.empty()) { - childRemoved.emit(this, m_children.back().get()); + Object *child = m_children.back().get(); + try { + childRemoved.emit(this, child); + } catch (...) { + SPDLOG_ERROR("Exception thrown in ~Object on Object::childRemoved ({}) for child object {}. Ignoring.", + objectName(), + child->objectName()); + } m_children.pop_back(); } } diff --git a/src/KDFoundation/object.h b/src/KDFoundation/object.h index 429a8fa..cbcd834 100644 --- a/src/KDFoundation/object.h +++ b/src/KDFoundation/object.h @@ -29,6 +29,9 @@ class KDFOUNDATION_API Object : public EventReceiver { public: Object(); + /// @warning This destructor emits #destroyed signal and #childRemoved for each child. If any of + /// the slots connected to these signals throws (which is UB in KDBindings anyway) the exception + /// will be eaten and error will be logged. virtual ~Object(); // Not copyable From 3539436cda59b37fa24fbda4fa556a70c533ef16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:40 +0200 Subject: [PATCH 17/27] Fix bugprone-easily-swappable-parameters warnings --- src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp | 4 ++++ .../platform/linux/wayland/linux_wayland_platform_input.cpp | 5 +++++ .../platform/linux/wayland/linux_wayland_platform_output.cpp | 3 +++ .../platform/linux/wayland/linux_wayland_platform_window.cpp | 2 ++ 4 files changed, 14 insertions(+) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp index e432c9b..0026e34 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp @@ -80,19 +80,23 @@ LinuxWaylandClipboard::LinuxWaylandClipboard(KDGui::LinuxWaylandPlatformIntegrat { } +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandClipboard::dataOffer(wl_data_device *data_device, wl_data_offer *offer) { m_dataOffer = offer; } +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandClipboard::dragEnter(wl_data_device *wl_data_device, uint32_t serial, wl_surface *surface, wl_fixed_t x, wl_fixed_t y, wl_data_offer *id) { } +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandClipboard::dragLeave(wl_data_device *wl_data_device) { } +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandClipboard::dragMotion(wl_data_device *wl_data_device, uint32_t time, wl_fixed_t x, wl_fixed_t y) { } diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp index 170cb38..d533540 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp @@ -30,6 +30,9 @@ using namespace KDGui; +// Wayland requires lots of callbacks that trip this check so turn it off for the entire file +// NOLINTBEGIN(bugprone-easily-swappable-parameters) + LinuxWaylandPlatformInput::LinuxWaylandPlatformInput(LinuxWaylandPlatformIntegration *integration, wl_seat *seat, uint32_t version, uint32_t id) : m_integration(integration) @@ -457,6 +460,7 @@ void LinuxWaylandPlatformInput::keybordKey(wl_keyboard *keyboard, uint32_t seria // Get the modifier state const auto modifiers = xkb::modifierState(m_keyboard.state); + // NOLINTNEXTLINE(readability-suspicious-call-argument) m_keyboard.focus->handleKeyRelease(time, keycode, skey, modifiers); m_keyboard.repeat.timer.running = false; } @@ -558,3 +562,4 @@ void LinuxWaylandPlatformInput::touchShape(wl_touch *touch, int32_t id, wl_fixed void LinuxWaylandPlatformInput::touchOrientation(wl_touch *touch, int32_t id, wl_fixed_t orientation) { } +// NOLINTEND(bugprone-easily-swappable-parameters) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_output.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_output.cpp index 13c0890..1daeef9 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_output.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_output.cpp @@ -16,6 +16,7 @@ using namespace KDGui; +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) LinuxWaylandPlatformOutput::LinuxWaylandPlatformOutput(wl_output *output, uint32_t version, uint32_t id) : m_output(output) , m_version(version) @@ -44,6 +45,7 @@ LinuxWaylandPlatformOutput *LinuxWaylandPlatformOutput::fromOutput(wl_output *ou return static_cast(wl_output_get_user_data(output)); } +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandPlatformOutput::geometry(wl_output *output, int32_t x, int32_t y, int32_t physicalWidth, int32_t physicalHeight, int32_t subpixel, const char *make, const char *model, int32_t transform) { @@ -51,6 +53,7 @@ void LinuxWaylandPlatformOutput::geometry(wl_output *output, int32_t x, int32_t m_model = model; } +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandPlatformOutput::mode(wl_output *output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) { } diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp index 9bd8e9e..0710c38 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp @@ -196,6 +196,7 @@ void LinuxWaylandPlatformWindow::handleMouseMove(uint32_t timestamp, MouseButton } } +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandPlatformWindow::handleMouseMoveRelative(uint32_t timestamp, int64_t dx, int64_t dy) { if (m_cursorMode == CursorMode::Disabled) { @@ -267,6 +268,7 @@ void LinuxWaylandPlatformWindow::close(xdg_toplevel *toplevel) window()->visible = false; } +// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandPlatformWindow::configureBounds(xdg_toplevel *toplevel, int32_t width, int32_t height) { int32_t w = int32_t(window()->width()); From b9ec493180782daa492db757b8872acadbfb7199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:41 +0200 Subject: [PATCH 18/27] Fix misc-unused-parameters warnings --- .../linux/wayland/linux_wayland_clipboard.cpp | 2 +- .../wayland/linux_wayland_platform_input.cpp | 40 +++++++++---------- .../linux_wayland_platform_integration.cpp | 2 +- .../wayland/linux_wayland_platform_output.cpp | 6 +-- .../wayland/linux_wayland_platform_window.cpp | 10 ++--- .../xcb/linux_xcb_platform_integration.cpp | 1 + src/KDGui/window.cpp | 6 +++ 7 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp index 0026e34..8ae1730 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_clipboard.cpp @@ -81,7 +81,7 @@ LinuxWaylandClipboard::LinuxWaylandClipboard(KDGui::LinuxWaylandPlatformIntegrat } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) -void LinuxWaylandClipboard::dataOffer(wl_data_device *data_device, wl_data_offer *offer) +void LinuxWaylandClipboard::dataOffer(wl_data_device * /*data_device*/, wl_data_offer *offer) { m_dataOffer = offer; } diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp index d533540..516e964 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp @@ -84,7 +84,7 @@ void LinuxWaylandPlatformInput::destroyPointerConstraintsV1() } } -void LinuxWaylandPlatformInput::capabilities(wl_seat *seat, uint32_t caps) +void LinuxWaylandPlatformInput::capabilities(wl_seat * /*seat*/, uint32_t caps) { const bool hasPointer = caps & WL_SEAT_CAPABILITY_POINTER; if (hasPointer && !m_pointer.pointer) { @@ -108,7 +108,7 @@ void LinuxWaylandPlatformInput::capabilities(wl_seat *seat, uint32_t caps) } } -void LinuxWaylandPlatformInput::name(wl_seat *seat, const char *name) +void LinuxWaylandPlatformInput::name(wl_seat * /*seat*/, const char *name) { m_name = name; } @@ -218,7 +218,7 @@ void LinuxWaylandPlatformInput::destroyTouch() m_touch.touch = nullptr; } -void LinuxWaylandPlatformInput::pointerEnter(wl_pointer *pointer, uint32_t serial, wl_surface *surface, wl_fixed_t x, wl_fixed_t y) +void LinuxWaylandPlatformInput::pointerEnter(wl_pointer * /*pointer*/, uint32_t serial, wl_surface *surface, wl_fixed_t x, wl_fixed_t y) { m_pointer.pos = { wl_fixed_to_int(x), wl_fixed_to_int(y) }; m_pointer.lastSerial = serial; @@ -272,7 +272,7 @@ void LinuxWaylandPlatformInput::pointerLock() } } -void LinuxWaylandPlatformInput::pointerLeave(wl_pointer *pointer, uint32_t serial, wl_surface *surface) +void LinuxWaylandPlatformInput::pointerLeave(wl_pointer * /*pointer*/, uint32_t serial, wl_surface * /*surface*/) { if (m_version >= WL_POINTER_FRAME_SINCE_VERSION) { m_pointer.accumulatedEvent.focus = nullptr; @@ -284,7 +284,7 @@ void LinuxWaylandPlatformInput::pointerLeave(wl_pointer *pointer, uint32_t seria m_pointer.lastSerial = serial; } -void LinuxWaylandPlatformInput::pointerMotion(wl_pointer *pointer, uint32_t time, wl_fixed_t x, wl_fixed_t y) +void LinuxWaylandPlatformInput::pointerMotion(wl_pointer * /*pointer*/, uint32_t time, wl_fixed_t x, wl_fixed_t y) { m_pointer.pos = { wl_fixed_to_int(x), wl_fixed_to_int(y) }; if (m_version >= WL_POINTER_FRAME_SINCE_VERSION) { @@ -295,7 +295,7 @@ void LinuxWaylandPlatformInput::pointerMotion(wl_pointer *pointer, uint32_t time } } -void LinuxWaylandPlatformInput::pointerButton(wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) +void LinuxWaylandPlatformInput::pointerButton(wl_pointer * /*pointer*/, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { const MouseButton btn = [=]() { switch (button) { @@ -319,7 +319,7 @@ void LinuxWaylandPlatformInput::pointerButton(wl_pointer *pointer, uint32_t seri m_pointer.lastSerial = serial; } -void LinuxWaylandPlatformInput::pointerAxis(wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value) +void LinuxWaylandPlatformInput::pointerAxis(wl_pointer * /*pointer*/, uint32_t time, uint32_t axis, wl_fixed_t value) { const double delta = -wl_fixed_to_double(value); const int32_t xDelta = axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ? int32_t(delta) : 0; @@ -333,7 +333,7 @@ void LinuxWaylandPlatformInput::pointerAxis(wl_pointer *pointer, uint32_t time, } } -void LinuxWaylandPlatformInput::pointerFrame(wl_pointer *pointer) +void LinuxWaylandPlatformInput::pointerFrame(wl_pointer * /*pointer*/) { auto &ev = m_pointer.accumulatedEvent; if (ev.focusChange && ev.focus) { @@ -374,8 +374,8 @@ void LinuxWaylandPlatformInput::pointerAxisDiscrete(wl_pointer *pointer, uint32_ { } -void LinuxWaylandPlatformInput::pointerRelativeMotionV1(zwp_relative_pointer_v1 *pointer, uint32_t utimeHi, uint32_t utimeLow, - wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dxUnaccel, wl_fixed_t dyUnaccel) +void LinuxWaylandPlatformInput::pointerRelativeMotionV1(zwp_relative_pointer_v1 * /*pointer*/, uint32_t utimeHi, uint32_t utimeLow, + wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t /*dxUnaccel*/, wl_fixed_t /*dyUnaccel*/) { const Position pos{ wl_fixed_to_int(dx), wl_fixed_to_int(dy) }; const uint64_t utime = uint64_t(utimeHi) << 32 | utimeLow; @@ -389,7 +389,7 @@ void LinuxWaylandPlatformInput::pointerRelativeMotionV1(zwp_relative_pointer_v1 } } -void LinuxWaylandPlatformInput::keyboardKeymap(wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size) +void LinuxWaylandPlatformInput::keyboardKeymap(wl_keyboard * /*keyboard*/, uint32_t format, int fd, uint32_t size) { if (m_keyboard.keymap) { xkb_state_unref(m_keyboard.state); @@ -417,20 +417,20 @@ void LinuxWaylandPlatformInput::keyboardKeymap(wl_keyboard *keyboard, uint32_t f m_keyboard.state = xkb_state_new(m_keyboard.keymap); } -void LinuxWaylandPlatformInput::keyboardEnter(wl_keyboard *keyboard, uint32_t serial, wl_surface *surface, wl_array *keys) +void LinuxWaylandPlatformInput::keyboardEnter(wl_keyboard * /*keyboard*/, uint32_t serial, wl_surface *surface, wl_array * /*keys*/) { m_keyboard.focus = LinuxWaylandPlatformWindow::fromSurface(surface); m_keyboard.serial = serial; } -void LinuxWaylandPlatformInput::keyboardLeave(wl_keyboard *keyboard, uint32_t serial, wl_surface *surface) +void LinuxWaylandPlatformInput::keyboardLeave(wl_keyboard * /*keyboard*/, uint32_t /*serial*/, wl_surface * /*surface*/) { m_keyboard.focus = nullptr; m_keyboard.repeat.timer.running = false; m_keyboard.serial = 0; } -void LinuxWaylandPlatformInput::keybordKey(wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) +void LinuxWaylandPlatformInput::keybordKey(wl_keyboard * /*keyboard*/, uint32_t /*serial*/, uint32_t time, uint32_t key, uint32_t state) { if (!m_keyboard.state) { return; @@ -466,7 +466,7 @@ void LinuxWaylandPlatformInput::keybordKey(wl_keyboard *keyboard, uint32_t seria } } -void LinuxWaylandPlatformInput::keyboardModifiers(wl_keyboard *keyboard, uint32_t serial, uint32_t depressed, +void LinuxWaylandPlatformInput::keyboardModifiers(wl_keyboard * /*keyboard*/, uint32_t /*serial*/, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { if (m_keyboard.state) { @@ -474,7 +474,7 @@ void LinuxWaylandPlatformInput::keyboardModifiers(wl_keyboard *keyboard, uint32_ } } -void LinuxWaylandPlatformInput::keyboardRepeatInfo(wl_keyboard *keyboard, int32_t rate, int32_t delay) +void LinuxWaylandPlatformInput::keyboardRepeatInfo(wl_keyboard * /*keyboard*/, int32_t rate, int32_t delay) { m_keyboard.repeat.delay = delay; m_keyboard.repeat.rate = 1000 / rate; @@ -507,7 +507,7 @@ void LinuxWaylandPlatformInput::keyboardSendKeyPress(uint32_t time, bool isRepea } } -void LinuxWaylandPlatformInput::touchDown(wl_touch *touch, uint32_t serial, uint32_t time, +void LinuxWaylandPlatformInput::touchDown(wl_touch * /*touch*/, uint32_t /*serial*/, uint32_t time, wl_surface *surface, int32_t id, wl_fixed_t x, wl_fixed_t y) { // We don't support touch yet, so just use the first touch point as mouse input @@ -523,7 +523,7 @@ void LinuxWaylandPlatformInput::touchDown(wl_touch *touch, uint32_t serial, uint m_touch.focus->handleMousePress(time, MouseButton::LeftButton, int16_t(m_touch.points[0].pos.x), int16_t(m_touch.points[0].pos.y)); } -void LinuxWaylandPlatformInput::touchUp(wl_touch *touch, uint32_t serial, uint32_t time, int32_t id) +void LinuxWaylandPlatformInput::touchUp(wl_touch * /*touch*/, uint32_t /*serial*/, uint32_t time, int32_t id) { if (id != m_touch.points[0].id) { return; @@ -533,7 +533,7 @@ void LinuxWaylandPlatformInput::touchUp(wl_touch *touch, uint32_t serial, uint32 m_touch.points.clear(); } -void LinuxWaylandPlatformInput::touchMotion(wl_touch *touch, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y) +void LinuxWaylandPlatformInput::touchMotion(wl_touch * /*touch*/, uint32_t time, int32_t id, wl_fixed_t /*x*/, wl_fixed_t /*y*/) { if (id != m_touch.points[0].id) { return; @@ -547,7 +547,7 @@ void LinuxWaylandPlatformInput::touchFrame(wl_touch *touch) { } -void LinuxWaylandPlatformInput::touchCancel(wl_touch *touch) +void LinuxWaylandPlatformInput::touchCancel(wl_touch * /*touch*/) { if (!m_touch.points.empty()) { m_touch.focus->handleMouseRelease(m_touch.time, MouseButton::LeftButton, int16_t(m_touch.points[0].pos.x), int16_t(m_touch.points[0].pos.y)); diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp index 431c3e1..946011f 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_integration.cpp @@ -170,7 +170,7 @@ void LinuxWaylandPlatformIntegration::global(wl_registry *registry, uint32_t id, } } -void LinuxWaylandPlatformIntegration::globalRemove(wl_registry *registry, uint32_t id) +void LinuxWaylandPlatformIntegration::globalRemove(wl_registry * /*registry*/, uint32_t id) { auto findSeat = [this](uint32_t id) { return std::find_if(m_inputs.begin(), m_inputs.end(), [id](const auto &input) { return input->seatId() == id; }); diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_output.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_output.cpp index 1daeef9..6363c45 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_output.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_output.cpp @@ -46,8 +46,8 @@ LinuxWaylandPlatformOutput *LinuxWaylandPlatformOutput::fromOutput(wl_output *ou } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) -void LinuxWaylandPlatformOutput::geometry(wl_output *output, int32_t x, int32_t y, int32_t physicalWidth, int32_t physicalHeight, - int32_t subpixel, const char *make, const char *model, int32_t transform) +void LinuxWaylandPlatformOutput::geometry(wl_output * /*output*/, int32_t /*x*/, int32_t /*y*/, int32_t /*physicalWidth*/, int32_t /*physicalHeight*/, + int32_t /*subpixel*/, const char *make, const char *model, int32_t /*transform*/) { m_make = make; m_model = model; @@ -62,7 +62,7 @@ void LinuxWaylandPlatformOutput::done(wl_output *output) { } -void LinuxWaylandPlatformOutput::scale(wl_output *output, int32_t factor) +void LinuxWaylandPlatformOutput::scale(wl_output * /*output*/, int32_t factor) { m_scaleFactor = factor; } diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp index 0710c38..09aff09 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp @@ -230,7 +230,7 @@ void LinuxWaylandPlatformWindow::handleTextInput(const std::string &str) CoreApplication::instance()->sendEvent(m_window, &ev); } -void LinuxWaylandPlatformWindow::enter(wl_surface *surface, wl_output *output) +void LinuxWaylandPlatformWindow::enter(wl_surface * /*surface*/, wl_output *output) { auto o = LinuxWaylandPlatformOutput::fromOutput(output); m_enteredOutputs.push_back(o); @@ -238,7 +238,7 @@ void LinuxWaylandPlatformWindow::enter(wl_surface *surface, wl_output *output) updateScaleFactor(); } -void LinuxWaylandPlatformWindow::leave(wl_surface *surface, wl_output *output) +void LinuxWaylandPlatformWindow::leave(wl_surface * /*surface*/, wl_output *output) { auto o = LinuxWaylandPlatformOutput::fromOutput(output); auto it = std::find(m_enteredOutputs.begin(), m_enteredOutputs.end(), o); @@ -255,21 +255,21 @@ void LinuxWaylandPlatformWindow::configure(xdg_surface *xdgSurface, uint32_t ser xdg_surface_ack_configure(xdgSurface, serial); } -void LinuxWaylandPlatformWindow::configureToplevel(xdg_toplevel *toplevel, int32_t width, int32_t height, wl_array *states) +void LinuxWaylandPlatformWindow::configureToplevel(xdg_toplevel * /*toplevel*/, int32_t width, int32_t height, wl_array * /*states*/) { if (width != 0 && height != 0) { handleResize(width, height); } } -void LinuxWaylandPlatformWindow::close(xdg_toplevel *toplevel) +void LinuxWaylandPlatformWindow::close(xdg_toplevel * /*toplevel*/) { SPDLOG_LOGGER_DEBUG(m_platformIntegration->logger(), "Window closed by user"); window()->visible = false; } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) -void LinuxWaylandPlatformWindow::configureBounds(xdg_toplevel *toplevel, int32_t width, int32_t height) +void LinuxWaylandPlatformWindow::configureBounds(xdg_toplevel * /*toplevel*/, int32_t width, int32_t height) { int32_t w = int32_t(window()->width()); int32_t h = int32_t(window()->height()); diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.cpp b/src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.cpp index 1995334..eaf6865 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_integration.cpp @@ -122,6 +122,7 @@ bool LinuxXcbPlatformIntegration::initializeXkbExtension() void LinuxXcbPlatformIntegration::dumpScreenInfo(xcb_screen_t *screen) { + KD_UNUSED(screen); // for release builds, debug log isn't compiled in SPDLOG_DEBUG("Information about screen {}", screen->root); SPDLOG_DEBUG(" width.........: {}", screen->width_in_pixels); SPDLOG_DEBUG(" height........: {}", screen->height_in_pixels); diff --git a/src/KDGui/window.cpp b/src/KDGui/window.cpp index cfd8558..f1e70e9 100644 --- a/src/KDGui/window.cpp +++ b/src/KDGui/window.cpp @@ -224,6 +224,7 @@ void Window::resizeEvent(ResizeEvent *ev) void Window::mousePressEvent(MousePressEvent *ev) { + KD_UNUSED(ev); // for release builds, debug log isn't compiled in SPDLOG_LOGGER_DEBUG(m_logger, "{}() buttons = {} at pos = ({}, {})", __FUNCTION__, @@ -234,6 +235,7 @@ void Window::mousePressEvent(MousePressEvent *ev) void Window::mouseReleaseEvent(MouseReleaseEvent *ev) { + KD_UNUSED(ev); // for release builds, debug log isn't compiled in SPDLOG_LOGGER_DEBUG(m_logger, "{}() buttons = {} at pos = ({}, {})", __FUNCTION__, @@ -244,6 +246,7 @@ void Window::mouseReleaseEvent(MouseReleaseEvent *ev) void Window::mouseMoveEvent(MouseMoveEvent *ev) { + KD_UNUSED(ev); // for release builds, debug log isn't compiled in SPDLOG_LOGGER_DEBUG(m_logger, "{}() buttons = {} at pos = ({}, {})", __FUNCTION__, @@ -254,6 +257,7 @@ void Window::mouseMoveEvent(MouseMoveEvent *ev) void Window::mouseWheelEvent(MouseWheelEvent *ev) { + KD_UNUSED(ev); // for release builds, debug log isn't compiled in SPDLOG_LOGGER_DEBUG(m_logger, "{}() xDelta = {} yDelta = {}", __FUNCTION__, @@ -263,10 +267,12 @@ void Window::mouseWheelEvent(MouseWheelEvent *ev) void Window::keyPressEvent(KeyPressEvent *ev) { + KD_UNUSED(ev); // for release builds, debug log isn't compiled in SPDLOG_LOGGER_DEBUG(m_logger, "{}() key = {}", __FUNCTION__, ev->key()); } void Window::keyReleaseEvent(KeyReleaseEvent *ev) { + KD_UNUSED(ev); // for release builds, debug log isn't compiled in SPDLOG_LOGGER_DEBUG(m_logger, "{}() key = {}", __FUNCTION__, ev->key()); } From 6d0f5d363b088bdf25b585b8ee11457af95b08cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:41 +0200 Subject: [PATCH 19/27] Fix misc-use-anonymous-namespace warning --- src/KDGui/gui_application.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/KDGui/gui_application.cpp b/src/KDGui/gui_application.cpp index ba90c28..372d20d 100644 --- a/src/KDGui/gui_application.cpp +++ b/src/KDGui/gui_application.cpp @@ -27,13 +27,14 @@ using namespace KDGui; +namespace { #if defined(PLATFORM_LINUX) -static std::unique_ptr createLinuxIntegration() +std::unique_ptr createLinuxIntegration() { bool prefersXcb = false; // TODO(doc): document this behavior - if (const char *preferredPlatform = std::getenv("KDGUI_PLATFORM")) { //NOLINT(concurrency-mt-unsafe) + if (const char *preferredPlatform = std::getenv("KDGUI_PLATFORM")) { // NOLINT(concurrency-mt-unsafe) prefersXcb = std::string_view{ preferredPlatform } == "xcb"; } @@ -46,7 +47,7 @@ static std::unique_ptr createLinuxIntegra } #endif -static std::unique_ptr createPlatformIntegration() +std::unique_ptr createPlatformIntegration() { #if defined(ANDROID) return std::make_unique(); @@ -59,6 +60,7 @@ static std::unique_ptr createPlatformIntegration #endif return {}; } +} // namespace GuiApplication::GuiApplication(std::unique_ptr &&platformIntegration) : CoreApplication(platformIntegration ? std::move(platformIntegration) : createPlatformIntegration()) From 270b683090eee5b36124855fe2318defe838d204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:42 +0200 Subject: [PATCH 20/27] Bump KDBindings ref This fixes some issues with exceptions in constructors. --- cmake/dependencies.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index f517d8f..8586b5d 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -74,7 +74,8 @@ if(NOT TARGET KDAB::KDBindings) fetchcontent_declare( KDBindings GIT_REPOSITORY https://github.com/KDAB/KDBindings.git - GIT_TAG 4c4d36489b60a3ae5ce17a3dc0b6b7cbf43a9afa # v1.1.0-beta.2 + GIT_TAG aab1cfd289296972ef32124f749e3b565b634535 # main as of 2024-07-17, needed for noexcept + # in destructors USES_TERMINAL_DOWNLOAD YES USES_TERMINAL_UPDATE YES ) fetchcontent_makeavailable(KDBindings) From 818c648ba55f38665683aaf0e4982cbc0bcbf7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:43 +0200 Subject: [PATCH 21/27] Fix readability-simplify-boolean-expr --- src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp index 0a12ed9..f72e80a 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp @@ -106,7 +106,7 @@ bool LinuxXcbPlatformWindow::create() 0, 0, 0, 0); xcb_free_pixmap(connection, pixmap); - if (window()->cursorEnabled.get() == false) + if (!window()->cursorEnabled.get()) disableCursor(); xcb_flush(connection); From aaa7f626f8b2f2bfa037642c84d5aa05625eda01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:43 +0200 Subject: [PATCH 22/27] Fix modernize-use-auto warning --- .../linux/wayland/linux_wayland_platform_window.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp index 09aff09..7b3d3cf 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.cpp @@ -271,8 +271,8 @@ void LinuxWaylandPlatformWindow::close(xdg_toplevel * /*toplevel*/) // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void LinuxWaylandPlatformWindow::configureBounds(xdg_toplevel * /*toplevel*/, int32_t width, int32_t height) { - int32_t w = int32_t(window()->width()); - int32_t h = int32_t(window()->height()); + auto w = int32_t(window()->width()); + auto h = int32_t(window()->height()); if (width != 0 && width < w) { w = width; } @@ -295,7 +295,7 @@ void LinuxWaylandPlatformWindow::updateScaleFactor() // use the highest scale factor of all the outputs this window is visible on float factor = 1; for (auto *output : m_enteredOutputs) { - const float outputScaleFactor = float(output->scaleFactor()); + const auto outputScaleFactor = float(output->scaleFactor()); if (outputScaleFactor > factor) { factor = outputScaleFactor; } From 78e03dce7a9ebb84568b4d9cf045149f75607ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:44 +0200 Subject: [PATCH 23/27] Fix modernize-use-nullptr warning --- .../platform/linux/wayland/linux_wayland_platform_input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp index 516e964..9736e20 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp @@ -403,7 +403,7 @@ void LinuxWaylandPlatformInput::keyboardKeymap(wl_keyboard * /*keyboard*/, uint3 return; } - char *map = static_cast(mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0)); + char *map = static_cast(mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0)); if (!map) { SPDLOG_LOGGER_ERROR(m_integration->logger(), "mmapping the keymap fd failed!"); close(fd); From 5a41b7bf2e7d72e23afd065c647b356680ebbd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:44 +0200 Subject: [PATCH 24/27] Fix readability-make-member-function-const warning --- .../platform/linux/wayland/linux_wayland_platform_input.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp index 9736e20..e5d1e42 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_input.cpp @@ -466,6 +466,7 @@ void LinuxWaylandPlatformInput::keybordKey(wl_keyboard * /*keyboard*/, uint32_t } } +// NOLINTNEXTLINE(readability-make-member-function-const) void LinuxWaylandPlatformInput::keyboardModifiers(wl_keyboard * /*keyboard*/, uint32_t /*serial*/, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { From 7bacedca42809566da54ebc66e05f3e3b74b1212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Tue, 23 Jul 2024 17:26:45 +0200 Subject: [PATCH 25/27] Fix readability-inconsistent-declaration-parameter-name By fixing a typo. --- .../platform/linux/wayland/linux_wayland_platform_window.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h index fc8bca7..6d5b9bd 100644 --- a/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h +++ b/src/KDGui/platform/linux/wayland/linux_wayland_platform_window.h @@ -30,7 +30,7 @@ class LinuxWaylandPlatformOutput; class KDGUI_API LinuxWaylandPlatformWindow : public AbstractPlatformWindow { public: - explicit LinuxWaylandPlatformWindow(LinuxWaylandPlatformIntegration *platformIntegraton, + explicit LinuxWaylandPlatformWindow(LinuxWaylandPlatformIntegration *platformIntegration, Window *window); LinuxWaylandPlatformWindow() = delete; From 5468592b4cea4de78d664a7c6c87364ead58c790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Wed, 24 Jul 2024 14:23:43 +0200 Subject: [PATCH 26/27] Use std::array in linux_xcb_platform_window.cpp This way we have less NOLINT exceptions. --- .../linux/xcb/linux_xcb_platform_window.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp index f72e80a..57f0f70 100644 --- a/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp +++ b/src/KDGui/platform/linux/xcb/linux_xcb_platform_window.cpp @@ -42,8 +42,7 @@ bool LinuxXcbPlatformWindow::create() m_xcbWindow = xcb_generate_id(connection); const uint32_t mask = XCB_CW_EVENT_MASK; - // NOLINTNEXTLINE(modernize-avoid-c-arrays) - const uint32_t values[1] = { + const std::array values = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | @@ -62,7 +61,7 @@ bool LinuxXcbPlatformWindow::create() XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */ screen->root_visual, /* visual */ mask, - values); + values.data()); const auto title = m_window->title.get(); xcb_change_property( @@ -170,8 +169,8 @@ void LinuxXcbPlatformWindow::disableCursor() // Hide the cursor const auto connection = m_platformIntegration->connection(); - uint32_t values[] = { m_hiddenCursor }; // NOLINT(modernize-avoid-c-arrays) - xcb_change_window_attributes(connection, m_xcbWindow, XCB_CURSOR, &values); + const std::array values = { m_hiddenCursor }; + xcb_change_window_attributes(connection, m_xcbWindow, XCB_CURSOR, values.data()); // Move cursor to centre of the window const auto windowSize = queryWindowSize(); @@ -209,8 +208,8 @@ void LinuxXcbPlatformWindow::enableCursor() int16_t(m_cursorRestorePosition.x), int16_t(m_cursorRestorePosition.y)); // Reset the default cursor (inherit from parent window) - uint32_t values[] = { 0 }; // NOLINT(modernize-avoid-c-arrays) - xcb_change_window_attributes(connection, m_xcbWindow, XCB_CURSOR, &values); + const std::array values = { 0 }; + xcb_change_window_attributes(connection, m_xcbWindow, XCB_CURSOR, values.data()); xcb_flush(connection); } From cd9cdbbbde88e070321f7e1cc8130e996327ff4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Kosobucki?= Date: Wed, 24 Jul 2024 14:25:33 +0200 Subject: [PATCH 27/27] Remove unnecessary semicolon --- src/KDUtils/file_mapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KDUtils/file_mapper.cpp b/src/KDUtils/file_mapper.cpp index 9049e51..cfc2845 100644 --- a/src/KDUtils/file_mapper.cpp +++ b/src/KDUtils/file_mapper.cpp @@ -21,7 +21,7 @@ using WriteMap = mio::basic_mmap; struct FileMapper::Map { std::variant map; - ~Map() {}; + ~Map() { } Map(bool writeable) {