Authentication-Results: mail-b.sr.ht; dkim=pass header.d=handlerug.me header.i=@handlerug.me Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by mail-b.sr.ht (Postfix) with ESMTPS id 2C62211EF37 for <~sircmpwn/visurf-devel@lists.sr.ht>; Fri, 5 Nov 2021 10:54:21 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=handlerug.me; s=key1; t=1636109657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BjxC0mBYtrIdVG3WUK/Gu0A80A4+qa84VwmtRCYYsI4=; b=xOKFg4ArwyK5gjyksByOyKARzvZIQOGHuarunZQ6Pv+t+XPlzeLG4Se+Rm+KK3vhxCBBdi eO0uGvsraQDGQolxo57E3MThNqFPdcxDEaP0fjuzIsEpqJyLrlZPnS/bGNPnfN6bDBE0hF H6TJhD2yPKaz1I9xNJS0UUP7jXMYq7o= From: Umar Getagazov To: ~sircmpwn/visurf-devel@lists.sr.ht Cc: Umar Getagazov Subject: [PATCH v2] nsvi: request server-side decorations Date: Fri, 5 Nov 2021 17:54:13 +0700 Message-Id: <20211105105413.18221-1-umar@handlerug.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: umar@handlerug.me visurf doesn't have CSD, so the code just calls set_mode without setting up a listener. This fixes occasionally disappearing SSD in sway. --- Oops, indeed, forgot to check for NULL. Fixed in this revision, sorry. frontends/visurf/Makefile | 11 ++++++++++- frontends/visurf/main.c | 4 ++++ frontends/visurf/visurf.h | 2 ++ frontends/visurf/window.c | 9 +++++++++ frontends/visurf/window.h | 1 + 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/frontends/visurf/Makefile b/frontends/visurf/Makefile index 7eda515c9..3695b96e9 100644 --- a/frontends/visurf/Makefile +++ b/frontends/visurf/Makefile @@ -35,7 +35,16 @@ $(OBJROOT)/xdg-shell.c: $(XDG_SHELL_PROTOCOL) $(OBJROOT)/xdg-shell.h $(OBJROOT)/xdg-shell.h: $(XDG_SHELL_PROTOCOL) $(WAYLAND_SCANNER) client-header $< $@ -S_WAYLAND := $(OBJROOT)/xdg-shell.c +XDG_DECORATION_PROTOCOL := \ + $(WAYLAND_PROTOCOLS)/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml + +$(OBJROOT)/xdg-decoration.c: $(XDG_DECORATION_PROTOCOL) $(OBJROOT)/xdg-decoration.h + $(WAYLAND_SCANNER) private-code $(XDG_DECORATION_PROTOCOL) $@ + +$(OBJROOT)/xdg-decoration.h: $(XDG_DECORATION_PROTOCOL) + $(WAYLAND_SCANNER) client-header $< $@ + +S_WAYLAND := $(OBJROOT)/xdg-shell.c $(OBJROOT)/xdg-decoration.c S_FRONTEND := main.c bitmap.c commands.c fetch.c getopt.c keybindings.c \ layout.c pool-buffer.c plotters.c window.c diff --git a/frontends/visurf/main.c b/frontends/visurf/main.c index be7841b2e..9ad1c54b6 100644 --- a/frontends/visurf/main.c +++ b/frontends/visurf/main.c @@ -42,6 +42,7 @@ #include "visurf/visurf.h" #include "visurf/window.h" #include "xdg-shell.h" +#include "xdg-decoration.h" char **respaths; struct nsvi_state *global_state; @@ -779,6 +780,9 @@ registry_global(void *data, struct wl_registry *wl_registry, name, &xdg_wm_base_interface, 1); xdg_wm_base_add_listener(state->xdg_wm_base, &xdg_wm_base_listener, state); + } else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) { + state->xdg_decoration_manager = wl_registry_bind(wl_registry, + name, &zxdg_decoration_manager_v1_interface, 1); } else if (strcmp(interface, wl_seat_interface.name) == 0) { state->wl_seat = wl_registry_bind(wl_registry, name, &wl_seat_interface, 7); diff --git a/frontends/visurf/visurf.h b/frontends/visurf/visurf.h index e799a811e..921cb5cb3 100644 --- a/frontends/visurf/visurf.h +++ b/frontends/visurf/visurf.h @@ -7,6 +7,7 @@ #include #include "visurf/keybindings.h" #include "xdg-shell.h" +#include "xdg-decoration.h" #include "utils/nsurl.h" enum pointer_event_mask { @@ -88,6 +89,7 @@ struct nsvi_state { struct wl_shm *wl_shm; struct wl_compositor *wl_compositor; struct xdg_wm_base *xdg_wm_base; + struct zxdg_decoration_manager_v1 *xdg_decoration_manager; struct nsvi_output *outputs; struct nsvi_window *windows; diff --git a/frontends/visurf/window.c b/frontends/visurf/window.c index d811d0f9d..185992a4f 100644 --- a/frontends/visurf/window.c +++ b/frontends/visurf/window.c @@ -24,6 +24,7 @@ #include "visurf/visurf.h" #include "visurf/window.h" #include "xdg-shell.h" +#include "xdg-decoration.h" struct pool_buffer *activebuffer; @@ -677,6 +678,14 @@ nsvi_window_create(void) &xdg_toplevel_listener, win); xdg_toplevel_set_title(win->xdg_toplevel, "visurf"); xdg_toplevel_set_app_id(win->xdg_toplevel, "visurf"); + if (global_state->xdg_decoration_manager != NULL) { + win->xdg_toplevel_decoration = + zxdg_decoration_manager_v1_get_toplevel_decoration( + global_state->xdg_decoration_manager, + win->xdg_toplevel); + zxdg_toplevel_decoration_v1_set_mode(win->xdg_toplevel_decoration, + ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + } wl_surface_commit(win->wl_surface); return win; } diff --git a/frontends/visurf/window.h b/frontends/visurf/window.h index ccdc366b0..11fb63dc8 100644 --- a/frontends/visurf/window.h +++ b/frontends/visurf/window.h @@ -65,6 +65,7 @@ struct nsvi_window { struct wl_surface *wl_surface; struct xdg_surface *xdg_surface; struct xdg_toplevel *xdg_toplevel; + struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration; struct pool_buffer buffers[2]; struct gui_window **tabs; -- 2.33.0