aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2025-07-10 16:44:48 +0200
committerFurkan Sahin <furkan-dev@proton.me>2025-07-10 16:44:48 +0200
commit70b0dcbbd44e92857bab34797cd817f4ac58943c (patch)
treec52d30ebb219fe04836fd547d9d59b43721ebb01
parent1e3706fced46bf6b13640891452ddcffb897ad37 (diff)
Wire up xdg-toplevel-tag-v1
-rw-r--r--include/sway/server.h2
-rw-r--r--include/sway/tree/view.h6
-rw-r--r--sway/desktop/xdg_shell.c16
-rw-r--r--sway/server.c9
-rw-r--r--sway/tree/view.c7
5 files changed, 39 insertions, 1 deletions
diff --git a/include/sway/server.h b/include/sway/server.h
index 72bccd70..f50d48f0 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -119,6 +119,8 @@ struct sway_server {
struct wl_listener xdg_activation_v1_request_activate;
struct wl_listener xdg_activation_v1_new_token;
+ struct wl_listener xdg_toplevel_tag_manager_v1_set_tag;
+
struct wl_listener request_set_cursor_shape;
struct wlr_tearing_control_manager_v1 *tearing_control_v1;
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 6151a023..ae81c5bb 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -25,6 +25,7 @@ enum sway_view_type {
enum sway_view_prop {
VIEW_PROP_TITLE,
VIEW_PROP_APP_ID,
+ VIEW_PROP_TAG,
VIEW_PROP_CLASS,
VIEW_PROP_INSTANCE,
VIEW_PROP_WINDOW_TYPE,
@@ -128,6 +129,7 @@ struct sway_xdg_shell_view {
struct sway_view view;
struct wlr_scene_tree *image_capture_tree;
+ char *tag;
struct wl_listener commit;
struct wl_listener request_move;
@@ -236,6 +238,8 @@ const char *view_get_sandbox_app_id(struct sway_view *view);
const char *view_get_sandbox_instance_id(struct sway_view *view);
+const char *view_get_tag(struct sway_view *view);
+
const char *view_get_shell(struct sway_view *view);
void view_get_constraints(struct sway_view *view, double *min_width,
@@ -360,4 +364,6 @@ void view_send_frame_done(struct sway_view *view);
bool view_can_tear(struct sway_view *view);
+void xdg_toplevel_tag_manager_v1_handle_set_tag(struct wl_listener *listener, void *data);
+
#endif
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 3852806e..db09e91d 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_xdg_shell.h>
+#include <wlr/types/wlr_xdg_toplevel_tag_v1.h>
#include <wlr/util/edges.h>
#include "log.h"
#include "sway/decoration.h"
@@ -157,7 +158,8 @@ static void get_constraints(struct sway_view *view, double *min_width,
static const char *get_string_prop(struct sway_view *view,
enum sway_view_prop prop) {
- if (xdg_shell_view_from_view(view) == NULL) {
+ struct sway_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view);
+ if (xdg_shell_view == NULL) {
return NULL;
}
switch (prop) {
@@ -165,6 +167,8 @@ static const char *get_string_prop(struct sway_view *view,
return view->wlr_xdg_toplevel->title;
case VIEW_PROP_APP_ID:
return view->wlr_xdg_toplevel->app_id;
+ case VIEW_PROP_TAG:
+ return xdg_shell_view->tag;
default:
return NULL;
}
@@ -265,6 +269,7 @@ static void destroy(struct sway_view *view) {
if (xdg_shell_view == NULL) {
return;
}
+ free(xdg_shell_view->tag);
free(xdg_shell_view);
}
@@ -581,3 +586,12 @@ void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data) {
xdg_toplevel->base->data = xdg_shell_view;
}
+
+void xdg_toplevel_tag_manager_v1_handle_set_tag(struct wl_listener *listener, void *data) {
+ const struct wlr_xdg_toplevel_tag_manager_v1_set_tag_event *event = data;
+ struct sway_view *view = view_from_wlr_xdg_surface(event->toplevel->base);
+ struct sway_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view);
+ free(xdg_shell_view->tag);
+ xdg_shell_view->tag = strdup(event->tag);
+ view_execute_criteria(view);
+}
diff --git a/sway/server.c b/sway/server.c
index fb620432..8615066e 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -49,6 +49,7 @@
#include <wlr/types/wlr_xdg_foreign_v1.h>
#include <wlr/types/wlr_xdg_foreign_v2.h>
#include <wlr/types/wlr_xdg_output_v1.h>
+#include <wlr/types/wlr_xdg_toplevel_tag_v1.h>
#include <xf86drm.h>
#include "config.h"
#include "list.h"
@@ -439,6 +440,13 @@ bool server_init(struct sway_server *server) {
wl_signal_add(&server->xdg_activation_v1->events.new_token,
&server->xdg_activation_v1_new_token);
+ struct wlr_xdg_toplevel_tag_manager_v1 *xdg_toplevel_tag_manager_v1 =
+ wlr_xdg_toplevel_tag_manager_v1_create(server->wl_display, 1);
+ server->xdg_toplevel_tag_manager_v1_set_tag.notify =
+ xdg_toplevel_tag_manager_v1_handle_set_tag;
+ wl_signal_add(&xdg_toplevel_tag_manager_v1->events.set_tag,
+ &server->xdg_toplevel_tag_manager_v1_set_tag);
+
struct wlr_cursor_shape_manager_v1 *cursor_shape_manager =
wlr_cursor_shape_manager_v1_create(server->wl_display, 1);
server->request_set_cursor_shape.notify = handle_request_set_cursor_shape;
@@ -536,6 +544,7 @@ void server_fini(struct sway_server *server) {
wl_list_remove(&server->tearing_control_new_object.link);
wl_list_remove(&server->xdg_activation_v1_request_activate.link);
wl_list_remove(&server->xdg_activation_v1_new_token.link);
+ wl_list_remove(&server->xdg_toplevel_tag_manager_v1_set_tag.link);
wl_list_remove(&server->request_set_cursor_shape.link);
wl_list_remove(&server->new_foreign_toplevel_capture_request.link);
input_manager_finish(server->input);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 7bf185fe..61aa5377 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -190,6 +190,13 @@ const char *view_get_sandbox_instance_id(struct sway_view *view) {
return security_context ? security_context->instance_id : NULL;
}
+const char *view_get_tag(struct sway_view *view) {
+ if (view->impl->get_string_prop) {
+ return view->impl->get_string_prop(view, VIEW_PROP_TAG);
+ }
+ return NULL;
+}
+
const char *view_get_shell(struct sway_view *view) {
switch(view->type) {
case SWAY_VIEW_XDG_SHELL: