From 08782c7889c922f116323218803aebecabccb935 Mon Sep 17 00:00:00 2001 From: Marco Trevisan Date: Fri, 24 Nov 2023 01:37:59 +0100 Subject: [PATCH 1/2] snap: Run as native wayland client if possible The new electron versions support wayland natively, this implies that mailspring can use the native rendering when in a wayland desktop environment, bringing various benefits including a better rendering in high DPI displays. To enable this electron still requires some flags, so add a wrapper launcher that is used to enable them unless wayland isn't explicitly disabled. --- snap/launcher | 9 +++++++++ snap/snapcraft.yaml | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 snap/launcher diff --git a/snap/launcher b/snap/launcher new file mode 100644 index 0000000000..f9337a2107 --- /dev/null +++ b/snap/launcher @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ -n "$WAYLAND_DISPLAY" ] && \ + [ "${DISABLE_WAYLAND:-0}" = 0 ] && \ + [ "${GDK_BACKEND:-wayland}" = "wayland" ]; then + args="--enable-features=WaylandWindowDecorations --ozone-platform=wayland --use-gl=desktop" +fi + +exec "$SNAP/usr/bin/mailspring" $args "${@}" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 016b4daa79..8074b736a3 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -19,6 +19,8 @@ parts: override-build: | cp -a "$CRAFT_PART_SRC"/* "$CRAFT_PART_INSTALL" craftctl default + install -m 755 ${CRAFT_PROJECT_DIR}/snap/launcher \ + -D ${CRAFT_PART_INSTALL}/bin/mailspring.launcher -v sed -i 's|Icon=mailspring|Icon=/usr/share/pixmaps/mailspring\.png|' \ $CRAFT_PART_INSTALL/usr/share/applications/Mailspring.desktop prime: @@ -44,7 +46,7 @@ parts: apps: mailspring: - command: usr/bin/mailspring --no-sandbox + command: bin/mailspring.launcher --no-sandbox common-id: mailspring desktop: usr/share/applications/Mailspring.desktop extensions: [gnome] @@ -53,8 +55,6 @@ apps: # Correct the TMPDIR path for Chromium Framework/Electron to # ensure libappindicator has readable resources. TMPDIR: $XDG_RUNTIME_DIR - # Fallback to XWayland if running in a Wayland session. - DISABLE_WAYLAND: 1 plugs: - avahi-observe - browser-support @@ -69,3 +69,4 @@ apps: - pulseaudio - unity7 - x11 + - wayland From 7bb2912aaac013df34717c88891e4549a68f4a1b Mon Sep 17 00:00:00 2001 From: Marco Trevisan Date: Sat, 25 Nov 2023 02:11:59 +0100 Subject: [PATCH 2/2] snap: Make native wayland client support configurable Make possible for users to enable the native wayland client by using snap set mailspring wayland-native=true By default mailspring will use xwayland, but the support can be toggled by users with the said command. --- snap/hooks/configure | 7 +++++++ snap/launcher | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 snap/hooks/configure diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100644 index 0000000000..75f3aad439 --- /dev/null +++ b/snap/hooks/configure @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -eu + +wayland_native="$(snapctl get wayland-native)" +if [[ -z "$wayland_native" ]]; then + snapctl set wayland-native=false +fi diff --git a/snap/launcher b/snap/launcher index f9337a2107..dc97ff46cf 100644 --- a/snap/launcher +++ b/snap/launcher @@ -1,8 +1,8 @@ #!/bin/sh -if [ -n "$WAYLAND_DISPLAY" ] && \ - [ "${DISABLE_WAYLAND:-0}" = 0 ] && \ - [ "${GDK_BACKEND:-wayland}" = "wayland" ]; then +if [ "${DISABLE_WAYLAND:-0}" = 0 ] && \ + [ "${GDK_BACKEND:-wayland}" = "wayland" ] && \ + [ "$(snapctl get wayland-native)" = "true" ]; then args="--enable-features=WaylandWindowDecorations --ozone-platform=wayland --use-gl=desktop" fi