feat(workspace): only show workspaces which are on same output as bar
This commit is contained in:
parent
2512d51564
commit
424ebb3c9b
|
@ -3,6 +3,7 @@
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||||
|
#include "xdg-output-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
namespace waybar {
|
namespace waybar {
|
||||||
|
|
||||||
|
@ -17,9 +18,19 @@ namespace waybar {
|
||||||
struct zwlr_layer_surface_v1 *layerSurface;
|
struct zwlr_layer_surface_v1 *layerSurface;
|
||||||
std::unique_ptr<struct wl_output *> output;
|
std::unique_ptr<struct wl_output *> output;
|
||||||
bool visible = true;
|
bool visible = true;
|
||||||
|
std::string outputName;
|
||||||
auto setWidth(uint32_t) -> void;
|
auto setWidth(uint32_t) -> void;
|
||||||
auto toggle() -> void;
|
auto toggle() -> void;
|
||||||
private:
|
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,
|
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 x, int32_t y, int32_t physical_width, int32_t physical_height,
|
||||||
int32_t subpixel, const char *make, const char *model, int32_t transform);
|
int32_t subpixel, const char *make, const char *model, int32_t transform);
|
||||||
|
@ -41,6 +52,7 @@ namespace waybar {
|
||||||
Json::Value _config;
|
Json::Value _config;
|
||||||
Glib::RefPtr<Gtk::StyleContext> _styleContext;
|
Glib::RefPtr<Gtk::StyleContext> _styleContext;
|
||||||
Glib::RefPtr<Gtk::CssProvider> _cssProvider;
|
Glib::RefPtr<Gtk::CssProvider> _cssProvider;
|
||||||
|
struct zxdg_output_v1 *_xdgOutput;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
|
||||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||||
#include "idle-client-protocol.h"
|
|
||||||
|
|
||||||
#include "util/ptr_vec.hpp"
|
#include "util/ptr_vec.hpp"
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ namespace waybar {
|
||||||
struct wl_display *wlDisplay;
|
struct wl_display *wlDisplay;
|
||||||
struct wl_registry *registry;
|
struct wl_registry *registry;
|
||||||
struct zwlr_layer_shell_v1 *layer_shell;
|
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;
|
struct wl_seat *seat;
|
||||||
util::ptr_vec<Bar> bars;
|
util::ptr_vec<Bar> bars;
|
||||||
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<protocol name="idle">
|
|
||||||
<copyright><![CDATA[
|
|
||||||
Copyright (C) 2015 Martin Gräßlin
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2.1 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
]]></copyright>
|
|
||||||
<interface name="org_kde_kwin_idle" version="1">
|
|
||||||
<description summary="User idle time manager">
|
|
||||||
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..
|
|
||||||
</description>
|
|
||||||
<request name="get_idle_timeout">
|
|
||||||
<arg name="id" type="new_id" interface="org_kde_kwin_idle_timeout"/>
|
|
||||||
<arg name="seat" type="object" interface="wl_seat"/>
|
|
||||||
<arg name="timeout" type="uint" summary="The idle timeout in msec"/>
|
|
||||||
</request>
|
|
||||||
</interface>
|
|
||||||
<interface name="org_kde_kwin_idle_timeout" version="1">
|
|
||||||
<request name="release" type="destructor">
|
|
||||||
<description summary="release the timeout object"/>
|
|
||||||
</request>
|
|
||||||
<request name="simulate_user_activity">
|
|
||||||
<description summary="Simulates user activity for this timeout, behaves just like real user activity on the seat"/>
|
|
||||||
</request>
|
|
||||||
<event name="idle">
|
|
||||||
<description summary="Triggered when there has not been any user activity in the requested idle time interval"/>
|
|
||||||
</event>
|
|
||||||
<event name="resumed">
|
|
||||||
<description summary="Triggered on the first user activity after an idle event"/>
|
|
||||||
</event>
|
|
||||||
</interface>
|
|
||||||
</protocol>
|
|
|
@ -23,8 +23,8 @@ wayland_scanner_client = generator(
|
||||||
|
|
||||||
client_protocols = [
|
client_protocols = [
|
||||||
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
|
[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'],
|
['wlr-layer-shell-unstable-v1.xml'],
|
||||||
['idle.xml'],
|
|
||||||
]
|
]
|
||||||
|
|
||||||
client_protos_src = []
|
client_protos_src = []
|
||||||
|
|
41
src/bar.cpp
41
src/bar.cpp
|
@ -16,8 +16,17 @@ waybar::Bar::Bar(Client &client, std::unique_ptr<struct wl_output *> &&p_output)
|
||||||
.done = _handleDone,
|
.done = _handleDone,
|
||||||
.scale = _handleScale,
|
.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);
|
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_title("waybar");
|
||||||
window.set_decorated(false);
|
window.set_decorated(false);
|
||||||
_setupConfig();
|
_setupConfig();
|
||||||
|
@ -48,6 +57,36 @@ waybar::Bar::Bar(Client &client, std::unique_ptr<struct wl_output *> &&p_output)
|
||||||
wl_surface_commit(surface);
|
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<waybar::Bar *>(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,
|
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 x, int32_t y, int32_t physical_width, int32_t physical_height,
|
||||||
int32_t subpixel, const char *make, const char *model, int32_t transform)
|
int32_t subpixel, const char *make, const char *model, int32_t transform)
|
||||||
|
|
|
@ -50,13 +50,15 @@ void waybar::Client::_handle_global(void *data, struct wl_registry *registry,
|
||||||
*output = (struct wl_output *)wl_registry_bind(registry, name,
|
*output = (struct wl_output *)wl_registry_bind(registry, name,
|
||||||
&wl_output_interface, version);
|
&wl_output_interface, version);
|
||||||
o->bars.emplace_back(*o, std::move(output));
|
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)) {
|
} else if (!strcmp(interface, wl_seat_interface.name)) {
|
||||||
o->seat = (struct wl_seat *)wl_registry_bind(registry, name,
|
o->seat = (struct wl_seat *)wl_registry_bind(registry, name,
|
||||||
&wl_seat_interface, version);
|
&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,
|
void waybar::Client::_handle_global_remove(void *data,
|
||||||
|
|
|
@ -22,6 +22,7 @@ waybar::modules::Workspaces::Workspaces(Bar &bar)
|
||||||
|
|
||||||
auto waybar::modules::Workspaces::update() -> void
|
auto waybar::modules::Workspaces::update() -> void
|
||||||
{
|
{
|
||||||
|
if (_bar.outputName.empty()) return;
|
||||||
Json::Value workspaces = _getWorkspaces();
|
Json::Value workspaces = _getWorkspaces();
|
||||||
bool needReorder = false;
|
bool needReorder = false;
|
||||||
for (auto it = _buttons.begin(); it != _buttons.end(); ++it) {
|
for (auto it = _buttons.begin(); it != _buttons.end(); ++it) {
|
||||||
|
@ -34,7 +35,7 @@ auto waybar::modules::Workspaces::update() -> void
|
||||||
}
|
}
|
||||||
for (auto node : workspaces) {
|
for (auto node : workspaces) {
|
||||||
auto it = _buttons.find(node["num"].asInt());
|
auto it = _buttons.find(node["num"].asInt());
|
||||||
if (it == _buttons.end()) {
|
if (it == _buttons.end() && _bar.outputName == node["output"].asString()) {
|
||||||
_addWorkspace(node);
|
_addWorkspace(node);
|
||||||
needReorder = true;
|
needReorder = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue