diff --git a/include/bar.hpp b/include/bar.hpp index 8236dde0..03caba47 100644 --- a/include/bar.hpp +++ b/include/bar.hpp @@ -3,6 +3,7 @@ #include #include #include "wlr-layer-shell-unstable-v1-client-protocol.h" +#include "xdg-output-unstable-v1-client-protocol.h" namespace waybar { @@ -17,9 +18,19 @@ namespace waybar { struct zwlr_layer_surface_v1 *layerSurface; std::unique_ptr output; bool visible = true; + std::string outputName; auto setWidth(uint32_t) -> void; auto toggle() -> void; private: + static void _handleLogicalPosition(void *data, + struct zxdg_output_v1 *zxdg_output_v1, int32_t x, int32_t y); + static void _handleLogicalSize(void *data, + struct zxdg_output_v1 *zxdg_output_v1, int32_t width, int32_t height); + static void _handleDone(void *data, struct zxdg_output_v1 *zxdg_output_v1); + static void _handleName(void *data, struct zxdg_output_v1 *xdg_output, + const char *name); + static void _handleDescription(void *data, + struct zxdg_output_v1 *zxdg_output_v1, const char *description); static void _handleGeometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char *make, const char *model, int32_t transform); @@ -41,6 +52,7 @@ namespace waybar { Json::Value _config; Glib::RefPtr _styleContext; Glib::RefPtr _cssProvider; + struct zxdg_output_v1 *_xdgOutput; }; } diff --git a/include/client.hpp b/include/client.hpp index 4efaa0f5..b0deb0ee 100644 --- a/include/client.hpp +++ b/include/client.hpp @@ -12,7 +12,6 @@ #include #include "wlr-layer-shell-unstable-v1-client-protocol.h" -#include "idle-client-protocol.h" #include "util/ptr_vec.hpp" @@ -32,7 +31,7 @@ namespace waybar { struct wl_display *wlDisplay; struct wl_registry *registry; struct zwlr_layer_shell_v1 *layer_shell; - struct org_kde_kwin_idle *idle_manager; + struct zxdg_output_manager_v1 *xdg_output_manager; struct wl_seat *seat; util::ptr_vec bars; diff --git a/protocol/idle.xml b/protocol/idle.xml deleted file mode 100644 index 92d9989c..00000000 --- a/protocol/idle.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - . - ]]> - - - This interface allows to monitor user idle time on a given seat. The interface - allows to register timers which trigger after no user activity was registered - on the seat for a given interval. It notifies when user activity resumes. - - This is useful for applications wanting to perform actions when the user is not - interacting with the system, e.g. chat applications setting the user as away, power - management features to dim screen, etc.. - - - - - - - - - - - - - - - - - - - - - - diff --git a/protocol/meson.build b/protocol/meson.build index b9061478..793aa13e 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -23,8 +23,8 @@ wayland_scanner_client = generator( client_protocols = [ [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], + [wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'], ['wlr-layer-shell-unstable-v1.xml'], - ['idle.xml'], ] client_protos_src = [] diff --git a/src/bar.cpp b/src/bar.cpp index 97113fa7..60e437e9 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -16,8 +16,17 @@ waybar::Bar::Bar(Client &client, std::unique_ptr &&p_output) .done = _handleDone, .scale = _handleScale, }; - + static const struct zxdg_output_v1_listener xdgOutputListener = { + .logical_position = _handleLogicalPosition, + .logical_size = _handleLogicalSize, + .done = _handleDone, + .name = _handleName, + .description = _handleDescription, + }; wl_output_add_listener(*output, &outputListener, this); + _xdgOutput = + zxdg_output_manager_v1_get_xdg_output(client.xdg_output_manager, *output); + zxdg_output_v1_add_listener(_xdgOutput, &xdgOutputListener, this); window.set_title("waybar"); window.set_decorated(false); _setupConfig(); @@ -48,6 +57,36 @@ waybar::Bar::Bar(Client &client, std::unique_ptr &&p_output) wl_surface_commit(surface); } +void waybar::Bar::_handleLogicalPosition(void *data, + struct zxdg_output_v1 *zxdg_output_v1, int32_t x, int32_t y) +{ + // Nothing here +} + +void waybar::Bar::_handleLogicalSize(void *data, + struct zxdg_output_v1 *zxdg_output_v1, int32_t width, int32_t height) +{ + // Nothing here +} + +void waybar::Bar::_handleDone(void *data, struct zxdg_output_v1 *zxdg_output_v1) +{ + // Nothing here +} + +void waybar::Bar::_handleName(void *data, struct zxdg_output_v1 *xdg_output, + const char *name) +{ + auto o = reinterpret_cast(data); + o->outputName = name; +} + +void waybar::Bar::_handleDescription(void *data, + struct zxdg_output_v1 *zxdg_output_v1, const char *description) +{ + // Nothing here +} + void waybar::Bar::_handleGeometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char *make, const char *model, int32_t transform) diff --git a/src/client.cpp b/src/client.cpp index b44e29a5..0f4a6a1d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -50,13 +50,15 @@ void waybar::Client::_handle_global(void *data, struct wl_registry *registry, *output = (struct wl_output *)wl_registry_bind(registry, name, &wl_output_interface, version); o->bars.emplace_back(*o, std::move(output)); - } else if (!strcmp(interface, org_kde_kwin_idle_interface.name)) { - o->idle_manager = (org_kde_kwin_idle *)wl_registry_bind(registry, name, - &org_kde_kwin_idle_interface, version); } else if (!strcmp(interface, wl_seat_interface.name)) { o->seat = (struct wl_seat *)wl_registry_bind(registry, name, &wl_seat_interface, version); - } + } else if (!strcmp(interface, zxdg_output_manager_v1_interface.name) + && version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) { + o->xdg_output_manager = + (struct zxdg_output_manager_v1 *)wl_registry_bind(registry, name, + &zxdg_output_manager_v1_interface, ZXDG_OUTPUT_V1_NAME_SINCE_VERSION); + } } void waybar::Client::_handle_global_remove(void *data, diff --git a/src/modules/workspaces.cpp b/src/modules/workspaces.cpp index 195f97f3..27e91f9e 100644 --- a/src/modules/workspaces.cpp +++ b/src/modules/workspaces.cpp @@ -22,6 +22,7 @@ waybar::modules::Workspaces::Workspaces(Bar &bar) auto waybar::modules::Workspaces::update() -> void { + if (_bar.outputName.empty()) return; Json::Value workspaces = _getWorkspaces(); bool needReorder = false; for (auto it = _buttons.begin(); it != _buttons.end(); ++it) { @@ -34,7 +35,7 @@ auto waybar::modules::Workspaces::update() -> void } for (auto node : workspaces) { auto it = _buttons.find(node["num"].asInt()); - if (it == _buttons.end()) { + if (it == _buttons.end() && _bar.outputName == node["output"].asString()) { _addWorkspace(node); needReorder = true; } else {