[sway] found new tray-menu patch(es)

This commit is contained in:
Gwenhael Le Moine 2024-05-06 10:57:10 +02:00
parent d45728c1b2
commit d8f68b8929
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
3 changed files with 131 additions and 32 deletions

View file

@ -3,7 +3,7 @@
# variables
GITHUB_REPO=swaywm/sway
VERSION=${VERSION:-"latest"}
BUILD=12
BUILD=13
TAG=gwh
OUTPUT=/tmp
@ -56,12 +56,12 @@ PKGNAM=${PRGNAM}
###########
# Tray-menu patch
PATCH_6249=${PATCH_6249:-"no"}
if [ "$PATCH_6249" = "yes" ]; then
[ -e "$CWD"/patches/6249-tray-menu.patch ] && mv "$CWD"/patches/6249-tray-menu.patch{,.previous}
wget -c https://patch-diff.githubusercontent.com/raw/swaywm/sway/pull/6249.patch -O "$CWD"/patches/6249-tray-menu.patch
patch -p1 < "$CWD"/patches/6249-tray-menu.patch
PKGVERSION="${PKGVERSION}_p6249"
PATCH=${PATCH:-"no"}
if [ "$PATCH" = "yes" ]; then
for p in "$CWD"/patches/*.patch; do
patch -p1 < "$p"
done
PKGVERSION="${PKGVERSION}_patched"
fi
######################

View file

@ -1,4 +1,4 @@
From 2f304ef0532a45d00b2ec2c7fc63adef0aec7607 Mon Sep 17 00:00:00 2001
From 0fc5d7aed84415a77b718ca9dc3c0b3ad2c05b02 Mon Sep 17 00:00:00 2001
From: Felix Weilbach <felix.weilbach@t-online.de>
Date: Sun, 30 May 2021 20:45:01 +0200
Subject: [PATCH] Tray: Implement dbusmenu
@ -24,12 +24,12 @@ Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
create mode 100644 swaybar/tray/dbusmenu.c
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h
index 3ad0bdf3ce..3c0b49265e 100644
index 197d219011..d0b3dc8153 100644
--- a/include/swaybar/bar.h
+++ b/include/swaybar/bar.h
@@ -31,6 +31,7 @@ struct swaybar {
struct zwlr_layer_shell_v1 *layer_shell;
@@ -33,6 +33,7 @@ struct swaybar {
struct zxdg_output_manager_v1 *xdg_output_manager;
struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
struct wl_shm *shm;
+ struct xdg_wm_base *wm_base;
@ -126,7 +126,7 @@ index d2e80a6d47..853f17cdc1 100644
struct swaybar_tray *create_tray(struct swaybar *bar);
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 5e4ebd97c9..177b870b48 100644
index 021fc3bdb5..9c83db3e54 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -29,6 +29,7 @@
@ -137,16 +137,16 @@ index 5e4ebd97c9..177b870b48 100644
void free_workspaces(struct wl_list *list) {
struct swaybar_workspace *ws, *tmp;
@@ -362,6 +363,8 @@ static void handle_global(void *data, struct wl_registry *registry,
} else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) {
bar->xdg_output_manager = wl_registry_bind(registry, name,
&zxdg_output_manager_v1_interface, 2);
@@ -365,6 +366,8 @@ static void handle_global(void *data, struct wl_registry *registry,
} else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) {
bar->cursor_shape_manager = wl_registry_bind(registry, name,
&wp_cursor_shape_manager_v1_interface, 1);
+ } else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
+ bar->wm_base = wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
}
}
@@ -534,6 +537,7 @@ void bar_teardown(struct swaybar *bar) {
@@ -539,6 +542,7 @@ void bar_teardown(struct swaybar *bar) {
#if HAVE_TRAY
destroy_tray(bar->tray);
#endif
@ -155,7 +155,7 @@ index 5e4ebd97c9..177b870b48 100644
free_outputs(&bar->unused_outputs);
free_seats(&bar->seats);
diff --git a/swaybar/input.c b/swaybar/input.c
index 8eccf5420b..4ee4915991 100644
index ada4bc8624..dfac5480f4 100644
--- a/swaybar/input.c
+++ b/swaybar/input.c
@@ -10,6 +10,10 @@
@ -169,10 +169,10 @@ index 8eccf5420b..4ee4915991 100644
void free_hotspots(struct wl_list *list) {
struct swaybar_hotspot *hotspot, *tmp;
wl_list_for_each_safe(hotspot, tmp, list, link) {
@@ -112,10 +116,23 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
}
@@ -131,10 +135,23 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
pointer->serial = serial;
update_cursor(seat);
}
update_cursor(seat);
+
+#if HAVE_TRAY
+ if (dbusmenu_pointer_enter(data, wl_pointer, serial, surface, surface_x,
@ -193,7 +193,7 @@ index 8eccf5420b..4ee4915991 100644
struct swaybar_seat *seat = data;
seat->pointer.current = NULL;
}
@@ -125,6 +142,11 @@ static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
@@ -144,6 +161,11 @@ static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
struct swaybar_seat *seat = data;
seat->pointer.x = wl_fixed_to_double(surface_x);
seat->pointer.y = wl_fixed_to_double(surface_y);
@ -205,7 +205,7 @@ index 8eccf5420b..4ee4915991 100644
}
static bool check_bindings(struct swaybar *bar, uint32_t button,
@@ -141,6 +163,7 @@ static bool check_bindings(struct swaybar *bar, uint32_t button,
@@ -160,6 +182,7 @@ static bool check_bindings(struct swaybar *bar, uint32_t button,
}
static bool process_hotspots(struct swaybar_output *output,
@ -213,7 +213,7 @@ index 8eccf5420b..4ee4915991 100644
double x, double y, uint32_t button, uint32_t state) {
bool released = state == WL_POINTER_BUTTON_STATE_RELEASED;
struct swaybar_hotspot *hotspot;
@@ -148,7 +171,7 @@ static bool process_hotspots(struct swaybar_output *output,
@@ -167,7 +190,7 @@ static bool process_hotspots(struct swaybar_output *output,
if (x >= hotspot->x && y >= hotspot->y
&& x < hotspot->x + hotspot->width
&& y < hotspot->y + hotspot->height) {
@ -222,7 +222,7 @@ index 8eccf5420b..4ee4915991 100644
button, released, hotspot->data)) {
return true;
}
@@ -161,13 +184,19 @@ static bool process_hotspots(struct swaybar_output *output,
@@ -180,13 +203,19 @@ static bool process_hotspots(struct swaybar_output *output,
static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, uint32_t time, uint32_t button, uint32_t state) {
struct swaybar_seat *seat = data;
@ -243,7 +243,7 @@ index 8eccf5420b..4ee4915991 100644
return;
}
@@ -221,7 +250,7 @@ static void process_discrete_scroll(struct swaybar_seat *seat,
@@ -240,7 +269,7 @@ static void process_discrete_scroll(struct swaybar_seat *seat,
struct swaybar_output *output, struct swaybar_pointer *pointer,
uint32_t axis, wl_fixed_t value) {
uint32_t button = wl_axis_to_button(axis, value);
@ -252,7 +252,7 @@ index 8eccf5420b..4ee4915991 100644
// (Currently hotspots don't do anything on release events, so no need to emit one)
return;
}
@@ -278,6 +307,12 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
@@ -297,6 +326,12 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
return;
}
@ -265,7 +265,7 @@ index 8eccf5420b..4ee4915991 100644
// If there's a while since the last scroll event,
// set 'value' to zero as if to reset the "virtual scroll wheel"
if (seat->axis[axis].discrete_steps == 0 &&
@@ -294,6 +329,12 @@ static void wl_pointer_frame(void *data, struct wl_pointer *wl_pointer) {
@@ -313,6 +348,12 @@ static void wl_pointer_frame(void *data, struct wl_pointer *wl_pointer) {
struct swaybar_pointer *pointer = &seat->pointer;
struct swaybar_output *output = pointer->current;
@ -278,7 +278,7 @@ index 8eccf5420b..4ee4915991 100644
if (output == NULL) {
return;
}
@@ -401,7 +442,7 @@ static void wl_touch_up(void *data, struct wl_touch *wl_touch,
@@ -420,7 +461,7 @@ static void wl_touch_up(void *data, struct wl_touch *wl_touch,
}
if (time - slot->time < 500) {
// Tap, treat it like a pointer click
@ -302,7 +302,7 @@ index e5f1811eb0..fef1ee778f 100644
swaybar_deps = [
diff --git a/swaybar/render.c b/swaybar/render.c
index ccf3656378..2385a2f46d 100644
index 1113ca44a1..7769063d0f 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -160,6 +160,7 @@ static void render_sharp_line(cairo_t *cairo, uint32_t color,
@ -323,7 +323,7 @@ index ccf3656378..2385a2f46d 100644
return HOTSPOT_PROCESS;
diff --git a/swaybar/tray/dbusmenu.c b/swaybar/tray/dbusmenu.c
new file mode 100644
index 0000000000..8821cacaec
index 0000000000..423abc425e
--- /dev/null
+++ b/swaybar/tray/dbusmenu.c
@@ -0,0 +1,1367 @@
@ -921,7 +921,7 @@ index 0000000000..8821cacaec
+ cairo_surface_destroy(recorder);
+ return;
+ }
+ int surface_x, surface_y, surface_width, surface_height;
+ int surface_x, surface_y, surface_width, surface_height = 0;
+ draw_menu_items(cairo, menu, &surface_x, &surface_y, &surface_width,
+ &surface_height, open);
+

View file

@ -0,0 +1,99 @@
From 03c14421354e54332e12f78d029dcaa9919fd161 Mon Sep 17 00:00:00 2001
From: Florian Franzen <Florian.Franzen@gmail.com>
Date: Sat, 2 Mar 2024 11:19:37 +0000
Subject: [PATCH] Tray: don't invoke dbus menu when tray is disabled
---
swaybar/input.c | 26 +++++++++++++++++---------
swaybar/tray/tray.c | 2 +-
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/swaybar/input.c b/swaybar/input.c
index dfac5480f4..54e1d5cde5 100644
--- a/swaybar/input.c
+++ b/swaybar/input.c
@@ -137,8 +137,9 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
}
#if HAVE_TRAY
- if (dbusmenu_pointer_enter(data, wl_pointer, serial, surface, surface_x,
- surface_y)) {
+ struct swaybar_config *config = seat->bar->config;
+ if (!config->tray_hidden && dbusmenu_pointer_enter(data, wl_pointer, serial,
+ surface, surface_x, surface_y)) {
return;
}
#endif
@@ -147,12 +148,14 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
static void wl_pointer_leave(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *surface) {
#if HAVE_TRAY
- if (dbusmenu_pointer_leave(data, wl_pointer, serial, surface)) {
+ struct swaybar_seat *seat = data;
+ struct swaybar_config *config = seat->bar->config;
+ if (!config->tray_hidden && dbusmenu_pointer_leave(data, wl_pointer, serial,
+ surface)) {
return;
}
#endif
- struct swaybar_seat *seat = data;
seat->pointer.current = NULL;
}
@@ -162,7 +165,9 @@ static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
seat->pointer.x = wl_fixed_to_double(surface_x);
seat->pointer.y = wl_fixed_to_double(surface_y);
#if HAVE_TRAY
- if (dbusmenu_pointer_motion(data, wl_pointer, time, surface_x, surface_y)) {
+ struct swaybar_config *config = seat->bar->config;
+ if (!config->tray_hidden && dbusmenu_pointer_motion(data, wl_pointer, time,
+ surface_x, surface_y)) {
return;
}
#endif
@@ -204,8 +209,9 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, uint32_t time, uint32_t button, uint32_t state) {
struct swaybar_seat *seat = data;
#if HAVE_TRAY
- if (dbusmenu_pointer_button(seat, wl_pointer, serial, time, button,
- state)) {
+ struct swaybar_config *config = seat->bar->config;
+ if (!config->tray_hidden && dbusmenu_pointer_button(seat, wl_pointer, serial,
+ time, button, state)) {
return;
}
#endif
@@ -327,7 +333,8 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
}
#if HAVE_TRAY
- if (dbusmenu_pointer_axis(data, wl_pointer)) {
+ struct swaybar_config *config = seat->bar->config;
+ if (!config->tray_hidden && dbusmenu_pointer_axis(data, wl_pointer)) {
return;
}
#endif
@@ -349,7 +356,8 @@ static void wl_pointer_frame(void *data, struct wl_pointer *wl_pointer) {
struct swaybar_output *output = pointer->current;
#if HAVE_TRAY
- if (dbusmenu_pointer_frame(data, wl_pointer)) {
+ struct swaybar_config *config = seat->bar->config;
+ if (!config->tray_hidden && dbusmenu_pointer_frame(data, wl_pointer)) {
return;
}
#endif
diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c
index b0545f4a70..e4a680342b 100644
--- a/swaybar/tray/tray.c
+++ b/swaybar/tray/tray.c
@@ -110,7 +110,7 @@ static int cmp_output(const void *item, const void *cmp_to) {
uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) {
struct swaybar_config *config = output->bar->config;
- if (config->tray_outputs) {
+ if (config->tray_outputs && !config->tray_hidden) {
if (list_seq_find(config->tray_outputs, cmp_output, output) == -1) {
return 0;
}