From 64fa80f8b20099b2b30647d38ba23969f8b210b1 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Fri, 22 Oct 2021 15:05:47 +0200 Subject: [PATCH] Remove unneccessary waylandFlush() calls --- src/bar.cpp | 2 -- src/common.hpp | 2 -- src/main.cpp | 9 +++++---- src/shm_buffer.cpp | 1 - 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/bar.cpp b/src/bar.cpp index 5aa0f1f..15ae220 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -30,7 +30,6 @@ Bar::~Bar() { wl_surface_destroy(_surface); zwlr_layer_surface_v1_destroy(_layerSurface); - waylandFlush(); } void Bar::layerSurfaceConfigure(uint32_t serial, uint32_t width, uint32_t height) @@ -56,5 +55,4 @@ void Bar::render() wl_surface_attach(_surface, _bufs->buffer(), 0, 0); wl_surface_commit(_surface); _bufs->flip(); - waylandFlush(); } diff --git a/src/common.hpp b/src/common.hpp index 3f35766..9e8149e 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -5,8 +5,6 @@ #include #include "wlr-layer-shell-unstable-v1-client-protocol.h" -void waylandFlush(); - extern wl_display *display; extern wl_compositor *compositor; extern wl_shm *shm; diff --git a/src/main.cpp b/src/main.cpp index 0e3bafd..1a9537f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,6 +14,7 @@ #include "common.hpp" #include "bar.hpp" +static void waylandFlush(); static void waylandWriteReady(); static void requireGlobal(const void *p, const char *name); @@ -27,7 +28,6 @@ static xdg_wm_base *xdgWmBase; static const struct xdg_wm_base_listener xdgWmBaseListener = { [](void*, xdg_wm_base *sender, uint32_t serial) { xdg_wm_base_pong(sender, serial); - waylandFlush(); } }; @@ -38,7 +38,6 @@ static void onReady() requireGlobal(shm, "wl_shm"); requireGlobal(wlrLayerShell, "zwlr_layer_shell_v1"); std::ignore = new Bar(nullptr); - waylandFlush(); } struct HandleGlobalHelper { @@ -98,9 +97,11 @@ int main(int argc, char **argv) displayWriteNotifier = new QSocketNotifier(wl_display_get_fd(display), QSocketNotifier::Write); displayWriteNotifier->setEnabled(false); QObject::connect(displayWriteNotifier, &QSocketNotifier::activated, waylandWriteReady); - waylandFlush(); - return app.exec(); + while (true) { + waylandFlush(); + app.processEvents(QEventLoop::WaitForMoreEvents); + } } void waylandFlush() diff --git a/src/shm_buffer.cpp b/src/shm_buffer.cpp index 5d5a916..5c7c7ee 100644 --- a/src/shm_buffer.cpp +++ b/src/shm_buffer.cpp @@ -34,7 +34,6 @@ ShmBuffer::~ShmBuffer() for (auto i=0; i