From bb60e68b9d39cb21b195cbd156d05b0987fc653f Mon Sep 17 00:00:00 2001 From: Till Smejkal Date: Thu, 3 Dec 2020 21:52:20 +0100 Subject: [PATCH 1/3] Update to the latest version of the foreign toplevel manager protocol There was an update the of the toplevel manager protocol. Unfortunately, there are no new interesting updates with regard to the taskbar implementation. Nonetheless, update the protocol xml files to the latest version so that the implementation is up-to-date. While being there, also change the debug warning that is shown when there is a version mismatch between the server and client version of the protocol. --- ...lr-foreign-toplevel-management-unstable-v1.xml | 15 +++++++++++++-- src/modules/wlr/taskbar.cpp | 13 +++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/protocol/wlr-foreign-toplevel-management-unstable-v1.xml b/protocol/wlr-foreign-toplevel-management-unstable-v1.xml index a97738f..1081337 100644 --- a/protocol/wlr-foreign-toplevel-management-unstable-v1.xml +++ b/protocol/wlr-foreign-toplevel-management-unstable-v1.xml @@ -25,7 +25,7 @@ THIS SOFTWARE. - + The purpose of this protocol is to enable the creation of taskbars and docks by providing them with a list of opened applications and @@ -68,7 +68,7 @@ - + A zwlr_foreign_toplevel_handle_v1 object represents an opened toplevel window. Each app may have multiple opened toplevels. @@ -255,5 +255,16 @@ actually changes, this will be indicated by the state event. + + + + + + This event is emitted whenever the parent of the toplevel changes. + + No event is emitted when the parent handle is destroyed by the client. + + + diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index bdc980c..0a42ca1 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -187,6 +187,12 @@ static void tl_handle_done(void *data, struct zwlr_foreign_toplevel_handle_v1 *h return static_cast(data)->handle_done(); } +static void tl_handle_parent(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, + struct zwlr_foreign_toplevel_handle_v1 *parent) +{ + /* This is explicitly left blank */ +} + static void tl_handle_closed(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle) { return static_cast(data)->handle_closed(); @@ -200,6 +206,7 @@ static const struct zwlr_foreign_toplevel_handle_v1_listener toplevel_handle_imp .state = tl_handle_state, .done = tl_handle_done, .closed = tl_handle_closed, + .parent = tl_handle_parent, }; Task::Task(const waybar::Bar &bar, const Json::Value &config, Taskbar *tbar, @@ -661,9 +668,11 @@ void Taskbar::register_manager(struct wl_registry *registry, uint32_t name, uint spdlog::warn("Register foreign toplevel manager again although already existing!"); return; } - if (version < ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN_SINCE_VERSION) { - spdlog::warn("Using different foreign toplevel manager protocol version: {}", version); + if (version < ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_SET_FULLSCREEN_SINCE_VERSION) { + spdlog::warn("Foreign toplevel manager server does not have the appropriate version." + " To be able to use all features, you need at least version 2, but server is version {}", version); } + // limit version to a highest supported by the client protocol file version = std::min(version, zwlr_foreign_toplevel_manager_v1_interface.version); From 18f129a7128ee7a3991fba316fe956c455177360 Mon Sep 17 00:00:00 2001 From: Till Smejkal Date: Fri, 4 Dec 2020 08:04:02 +0100 Subject: [PATCH 2/3] Spit out a warning when trying to set/unset fullscreen without server supporting it Previously we only checked when connecting to the server whether it had the minimum required version but didn't act accordingly in the various functions that use the functionality of later versions. If there were a server in the wild, that actually would not have this functionality, there would have been a crash. Fix this by checking the version before using the functionality and gracefully abort it. --- src/modules/wlr/taskbar.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index 0a42ca1..e70ad9c 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -546,6 +546,11 @@ void Task::activate() void Task::fullscreen(bool set) { + if (zwlr_foreign_toplevel_handle_v1_get_version(handle_) < ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_SET_FULLSCREEN_SINCE_VERSION) { + spdlog::warn("Foreign toplevel manager server does not support for set/unset fullscreen."); + return; + } + if (set) zwlr_foreign_toplevel_handle_v1_set_fullscreen(handle_, nullptr); else From 68b6136989bf102b30a05b7b1964c44bca59a57b Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 4 Dec 2020 00:38:18 -0800 Subject: [PATCH 3/3] fix(sway/workspaces): ignore emulated scroll events GDK Wayland backend can emit two events for mouse scroll: one is a GDK_SCROLL_SMOOTH and the other one is an emulated scroll event with direction. We only receive emulated events on a window, thus it is not possible to handle these in a module and stop propagation. Ignoring emulated events should be safe since those are duplicates of smooth scroll events anyways. Fixes #386 --- src/modules/sway/workspaces.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index 8d78bf5..d0c2463 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -291,6 +291,12 @@ std::string Workspaces::getIcon(const std::string &name, const Json::Value &node } bool Workspaces::handleScroll(GdkEventScroll *e) { + if (gdk_event_get_pointer_emulated((GdkEvent *)e)) { + /** + * Ignore emulated scroll events on window + */ + return false; + } auto dir = AModule::getScrollDir(e); if (dir == SCROLL_DIR::NONE) { return true;