Merge branch 'master' into workspace-movement

This commit is contained in:
Alex Janka 2024-07-22 12:17:36 +10:00
commit 23910437c4
18 changed files with 132 additions and 709 deletions

View file

@ -1,29 +0,0 @@
name: Check git build for Arch.
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
arch-build-git:
container: archlinux:latest
runs-on: ubuntu-latest
steps:
# It is necessary to checkout into sub-directory, because of some weird ownership problems cause by using containers
- name: Check out sources
uses: actions/checkout@v3
with:
fetch-depth: 0
path: swayfx
- name: Git makepkg build and check
id: makepkg
uses: edlanglois/pkgbuild-action@v1
with:
pkgdir: ./swayfx/build-scripts/aur-git

View file

@ -1,29 +0,0 @@
name: Check stable build for Arch.
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
arch-build-stable:
container: archlinux:latest
runs-on: ubuntu-latest
steps:
# It is necessary to checkout into sub-directory, because of some weird ownership problems cause by using containers
- name: Check out sources
uses: actions/checkout@v3
with:
fetch-depth: 0
path: swayfx
- name: Stable makepkg build and check
id: makepkg
uses: edlanglois/pkgbuild-action@v1
with:
pkgdir: ./swayfx/build-scripts/aur

View file

@ -1,51 +0,0 @@
name: Check build for Fedora.
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
fedora-build:
container: fedora:latest
runs-on: ubuntu-latest
steps:
- name: Install tooling for source RPM build
run: |
dnf -y install @development-tools @rpm-development-tools
dnf -y install rpkg git
dnf -y install 'dnf-command(builddep)'
# It is necessary to checkout into sub-directory, because of some weird ownership problems cause by using containers
- name: Check out sources
uses: actions/checkout@v3
with:
fetch-depth: 0
path: swayfx
- name: Copy spec into root dir
run: |
cd swayfx
cp ./build-scripts/swayfx.rpkg.spec ./
- name: Generate spec
run: |
cd swayfx
mkdir specs
rpkg spec --source --outdir specs
- name: Install build dependencies
run: |
cd swayfx
dnf -y builddep ./specs/swayfx.rpkg.spec
- name: Local build
run: |
cd swayfx
mkdir -p out
rpkg local --out `pwd`/out

View file

@ -1,86 +0,0 @@
name: Package for Fedora Copr repo
on:
release:
types: [published]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
fedora-copr:
container: fedora:latest
runs-on: ubuntu-latest
steps:
- name: Install API token for copr-cli
env:
# To generate a new token: https://copr.fedorainfracloud.org/api/.
API_LOGIN: ${{ secrets.COPR_API_LOGIN }}
API_USERNAME: ${{ secrets.COPR_API_USERNAME }}
API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }}
run: |
mkdir -p "$HOME/.config"
# To generate a new token: https://copr.fedorainfracloud.org/api/.
echo "[copr-cli]" >> "$HOME/.config/copr"
echo "login = $API_LOGIN" >> "$HOME/.config/copr"
echo "username = $API_USERNAME" >> "$HOME/.config/copr"
echo "token = $API_TOKEN_CONTENT" >> "$HOME/.config/copr"
echo "copr_url = https://copr.fedorainfracloud.org" >> "$HOME/.config/copr"
- name: Install tooling for source RPM build
run: |
dnf -y install @development-tools @rpm-development-tools copr-cli rpkg git 'dnf-command(builddep)'
# It is necessary to checkout into sub-directory, because of some weird ownership problems cause by using containers
- name: Check out sources
uses: actions/checkout@v3
with:
fetch-depth: 0
path: swayfx
- name: Check out the latest tag
run: |
cp ./swayfx/build-scripts/swayfx.rpkg.spec ./
cd swayfx
git stash save "Action stashing changes"
latestTag=$(git describe --abbrev=0 --tags)
git checkout $latestTag
- name: Copy master spec into root dir
run: |
cd swayfx
cp ../swayfx.rpkg.spec ./
- name: Generate spec
run: |
cd swayfx
mkdir specs
rpkg spec --source --outdir specs
- name: Install build dependencies
run: |
cd swayfx
dnf -y builddep ./specs/swayfx.rpkg.spec
- name: Local build
run: |
cd swayfx
mkdir -p out
rpkg local --out `pwd`/out
- name: Test if installation of package is successful
run: |
cd swayfx/out
packages=(`rpmspec -q --nodebuginfo --qf \
"./%{ARCH}/%{Name}-%{Version}-%{Release}.%{ARCH}.rpm\n" \
../specs/swayfx.rpkg.spec`)
for i in "${packages[@]}"; do
dnf -y install "$i"
done
- name: Submit the build to copr
run: |
cd swayfx
rpkg -v copr-build -w ${{ secrets.COPR_REPO_NAME }}

View file

@ -1,16 +0,0 @@
# sway does not set DISPLAY/WAYLAND_DISPLAY in the systemd user environment
# See FS#63021
# Adapted from xorg's 50-systemd-user.sh, which achieves a similar goal.
# Upstream refuses to set XDG_CURRENT_DESKTOP so we have to.
exec systemctl --user set-environment XDG_CURRENT_DESKTOP=sway
exec systemctl --user import-environment DISPLAY \
SWAYSOCK \
WAYLAND_DISPLAY \
XDG_CURRENT_DESKTOP
exec hash dbus-update-activation-environment 2>/dev/null && \
dbus-update-activation-environment --systemd DISPLAY \
SWAYSOCK \
XDG_CURRENT_DESKTOP=sway \
WAYLAND_DISPLAY

View file

@ -1,83 +0,0 @@
# Maintainer: Erik Reider <erik.reider@protonmail.com>
_pkgname=swayfx
pkgname="$_pkgname-git"
pkgver=r7023.9cd02fc4
pkgrel=5
license=("MIT")
pkgdesc="SwayFX: Sway, but with eye candy!"
makedepends=(
"git"
"meson"
"scdoc"
"wayland-protocols"
)
depends=(
"cairo"
"gdk-pixbuf2"
"libevdev.so"
"libinput"
"libjson-c.so"
"libudev.so"
"libwayland-server.so"
"libwlroots.so=11"
"libxcb"
"libxkbcommon.so"
"pango"
"pcre2"
"ttf-font"
)
optdepends=(
"alacritty: Terminal emulator used by the default config"
"dmenu: Application launcher"
"grim: Screenshot utility"
"i3status: Status line"
"mako: Lightweight notification daemon"
"slurp: Select a region"
"swayidle: Idle management daemon"
"swaylock: Screen locker"
"wallutils: Timed wallpapers"
"waybar: Highly customizable bar"
"xdg-desktop-portal-gtk: Default xdg-desktop-portal for file picking"
"xdg-desktop-portal-wlr: xdg-desktop-portal backend"
)
backup=(etc/sway/config)
arch=("i686" "x86_64")
url="https://github.com/WillPower3309/swayfx"
source=("${pkgname%-*}::git+${url}.git"
50-systemd-user.conf
sway-portals.conf)
sha512sums=(
"SKIP"
"d5f9aadbb4bbef067c31d4c8c14dad220eb6f3e559e9157e20e1e3d47faf2f77b9a15e52519c3ffc53dc8a5202cb28757b81a4b3b0cc5dd50a4ddc49e03fe06e"
"790741df028822bf4d83170dea57e1c63f7d7938cf31969e4cd347b0fc07330322b603c9ec0091b7a3f425132bed9dee6f261074cc273555120858beaaaf5da1")
provides=("sway" "swayfx")
conflicts=("sway" "swayfx")
options=(debug)
install=sway.install
pkgver() {
cd "$_pkgname"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
build() {
export PKG_CONFIG_PATH='/usr/lib/wlroots0.16/pkgconfig'
arch-meson \
-Dwerror=false \
-Dsd-bus-provider=libsystemd \
"$_pkgname" build
meson compile -C build
}
package() {
install -Dm644 50-systemd-user.conf -t "$pkgdir/etc/sway/config.d/"
install -Dm644 sway-portals.conf "$pkgdir/usr/share/xdg-desktop-portal/sway-portals.conf"
DESTDIR="$pkgdir" meson install -C build
cd "$_pkgname"
install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
for util in autoname-workspaces.py inactive-windows-transparency.py grimshot; do
install -Dm755 "contrib/$util" -t "$pkgdir/usr/share/$pkgname/scripts"
done
}

View file

@ -1,6 +0,0 @@
[preferred]
# Use xdg-desktop-portal-gtk for every portal interface...
default=gtk
# ... except for the ScreenCast and Screenshot
org.freedesktop.impl.portal.ScreenCast=wlr
org.freedesktop.impl.portal.Screenshot=wlr

View file

@ -1,31 +0,0 @@
post_install() {
cat << EOD
Sway requires additional setup for privilege escalation. Without this setup,
sway will fail to start with session activation permission failures. Choose one
of the two available options (In alphabetical, not recommended, order):
1. polkit: This will make sway "just work" right after installation but may be
a weightier solution than desired.
2. seatd: Already required as a sway dependency, this is a lighter-weight
solution but requires some user configuration: Enabling the service,
adding your user to the "seat" group, then logging out/in again.
Either option should provide the same functionality/stability. Refer to the
Sway wiki page for information.
EOD
}
post_upgrade() {
cat << EOD
Sway's necessary privileges can now be obtained through seatd as well as the
incumbent polkit package. As such, polkit has been relegated to an optional
dependency.
Note that using seatd instead of polkit means that a user must be a part of the
"seat" group: Otherwise, the user will not be able to achieve the appropriate
privileged actions.
For more information, refer to the Sway wiki page.
EOD
}

View file

@ -1,16 +0,0 @@
# sway does not set DISPLAY/WAYLAND_DISPLAY in the systemd user environment
# See FS#63021
# Adapted from xorg's 50-systemd-user.sh, which achieves a similar goal.
# Upstream refuses to set XDG_CURRENT_DESKTOP so we have to.
exec systemctl --user set-environment XDG_CURRENT_DESKTOP=sway
exec systemctl --user import-environment DISPLAY \
SWAYSOCK \
WAYLAND_DISPLAY \
XDG_CURRENT_DESKTOP
exec hash dbus-update-activation-environment 2>/dev/null && \
dbus-update-activation-environment --systemd DISPLAY \
SWAYSOCK \
XDG_CURRENT_DESKTOP=sway \
WAYLAND_DISPLAY

View file

@ -1,78 +0,0 @@
# Maintainer: Erik Reider <erik.reider@protonmail.com>
_pkgname=swayfx
pkgname="$_pkgname"
pkgver=0.3.2
pkgrel=5
license=("MIT")
pkgdesc="SwayFX: Sway, but with eye candy!"
makedepends=(
"git"
"meson"
"scdoc"
"wayland-protocols"
)
depends=(
"cairo"
"gdk-pixbuf2"
"libevdev.so"
"libinput"
"libjson-c.so"
"libudev.so"
"libwayland-server.so"
"libwlroots.so=11"
"libxcb"
"libxkbcommon.so"
"pango"
"pcre2"
"ttf-font"
)
optdepends=(
"alacritty: Terminal emulator used by the default config"
"dmenu: Application launcher"
"grim: Screenshot utility"
"i3status: Status line"
"mako: Lightweight notification daemon"
"slurp: Select a region"
"swayidle: Idle management daemon"
"swaylock: Screen locker"
"wallutils: Timed wallpapers"
"waybar: Highly customizable bar"
"xdg-desktop-portal-gtk: Default xdg-desktop-portal for file picking"
"xdg-desktop-portal-wlr: xdg-desktop-portal backend"
)
backup=(etc/sway/config)
arch=("i686" "x86_64")
url="https://github.com/WillPower3309/swayfx"
source=("${_pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/$pkgver.tar.gz"
50-systemd-user.conf
sway-portals.conf)
sha512sums=(
"SKIP"
"d5f9aadbb4bbef067c31d4c8c14dad220eb6f3e559e9157e20e1e3d47faf2f77b9a15e52519c3ffc53dc8a5202cb28757b81a4b3b0cc5dd50a4ddc49e03fe06e"
"790741df028822bf4d83170dea57e1c63f7d7938cf31969e4cd347b0fc07330322b603c9ec0091b7a3f425132bed9dee6f261074cc273555120858beaaaf5da1")
provides=("sway" "swayfx")
conflicts=("sway" "swayfx")
options=(debug)
install=sway.install
build() {
export PKG_CONFIG_PATH='/usr/lib/wlroots0.16/pkgconfig'
arch-meson \
-Dwerror=false \
-Dsd-bus-provider=libsystemd \
"${_pkgname}-${pkgver}" build
meson compile -C build
}
package() {
install -Dm644 50-systemd-user.conf -t "$pkgdir/etc/sway/config.d/"
install -Dm644 sway-portals.conf "$pkgdir/usr/share/xdg-desktop-portal/sway-portals.conf"
DESTDIR="$pkgdir" meson install -C build
cd "${_pkgname}-${pkgver}"
install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
for util in autoname-workspaces.py inactive-windows-transparency.py grimshot; do
install -Dm755 "contrib/$util" -t "$pkgdir/usr/share/$pkgname/scripts"
done
}

View file

@ -1,6 +0,0 @@
[preferred]
# Use xdg-desktop-portal-gtk for every portal interface...
default=gtk
# ... except for the ScreenCast and Screenshot
org.freedesktop.impl.portal.ScreenCast=wlr
org.freedesktop.impl.portal.Screenshot=wlr

View file

@ -1,31 +0,0 @@
post_install() {
cat << EOD
Sway requires additional setup for privilege escalation. Without this setup,
sway will fail to start with session activation permission failures. Choose one
of the two available options (In alphabetical, not recommended, order):
1. polkit: This will make sway "just work" right after installation but may be
a weightier solution than desired.
2. seatd: Already required as a sway dependency, this is a lighter-weight
solution but requires some user configuration: Enabling the service,
adding your user to the "seat" group, then logging out/in again.
Either option should provide the same functionality/stability. Refer to the
Sway wiki page for information.
EOD
}
post_upgrade() {
cat << EOD
Sway's necessary privileges can now be obtained through seatd as well as the
incumbent polkit package. As such, polkit has been relegated to an optional
dependency.
Note that using seatd instead of polkit means that a user must be a part of the
"seat" group: Otherwise, the user will not be able to achieve the appropriate
privileged actions.
For more information, refer to the Sway wiki page.
EOD
}

View file

@ -1,158 +0,0 @@
# vim: syntax=spec
### CHANGE THESE VARIABLES BEFORE RELEASE:
# Change to current Sway base version!
%global SwayBaseVersion 1.8.1
# Change to current SwayFX tag!
%global Tag 0.3.2
Name: {{{ git_dir_name }}}
Version: %{Tag}
Release: 2%{?dist}
Summary: SwayFX: Sway, but with eye candy!
License: MIT
URL: https://github.com/WillPower3309/swayfx
VCS: {{{ git_dir_vcs }}}
Source: {{{ git_dir_pack }}}
Source101: sway-portals.conf
BuildRequires: gcc-c++
BuildRequires: gnupg2
BuildRequires: meson >= 0.60.0
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(gdk-pixbuf-2.0)
BuildRequires: pkgconfig(glesv2)
BuildRequires: pkgconfig(json-c) >= 0.13
BuildRequires: pkgconfig(libdrm)
BuildRequires: pkgconfig(libevdev)
BuildRequires: pkgconfig(libinput) >= 1.21.0
BuildRequires: pkgconfig(libpcre2-8)
BuildRequires: pkgconfig(libsystemd) >= 239
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(pango)
BuildRequires: pkgconfig(pangocairo)
BuildRequires: pkgconfig(pixman-1)
BuildRequires: pkgconfig(scdoc)
BuildRequires: pkgconfig(wayland-client)
BuildRequires: pkgconfig(wayland-cursor)
BuildRequires: pkgconfig(wayland-server) >= 1.21.0
BuildRequires: pkgconfig(wayland-protocols) >= 1.24
BuildRequires: (pkgconfig(wlroots) >= 0.16.0 with pkgconfig(wlroots) < 0.17)
BuildRequires: pkgconfig(xcb)
BuildRequires: pkgconfig(xcb-icccm)
BuildRequires: pkgconfig(xkbcommon)
# Dmenu is the default launcher in sway
Recommends: dmenu
# In addition, xargs is recommended for use in such a launcher arrangement
Recommends: findutils
# Install configs and scripts for better integration with systemd user session
Recommends: sway-systemd
Requires: swaybg
Recommends: swayidle
Recommends: swaylock
# By default the Fedora background is used
Recommends: desktop-backgrounds-compat
# Lack of graphical drivers may hurt the common use case
Recommends: mesa-dri-drivers
# Minimal installation doesn't include Qt Wayland backend
Recommends: (qt5-qtwayland if qt5-qtbase-gui)
Recommends: (qt6-qtwayland if qt6-qtbase-gui)
# dmenu (as well as rxvt any many others) requires XWayland on Sway
Requires: xorg-x11-server-Xwayland
# Sway binds the terminal shortcut to one specific terminal. In our case foot
Recommends: foot
# grim is the recommended way to take screenshots on sway 1.0+
Recommends: grim
%{?systemd_requires}
Conflicts: sway
Provides: sway = %{SwayBaseVersion}
%description
SwayFX: Sway, but with eye candy!
# The artwork is heavy and we don't use it with our default config
%package wallpapers
Summary: Wallpapers for Sway
BuildArch: noarch
License: CC0
%description wallpapers
Wallpaper collection provided with Sway
%package -n grimshot
Summary: Helper for screenshots within sway
Requires: grim
Requires: jq
Requires: slurp
Requires: /usr/bin/wl-copy
Recommends: /usr/bin/notify-send
%description -n grimshot
Grimshot is an easy to use screenshot tool for sway. It relies on grim,
slurp and jq to do the heavy lifting, and mostly provides an easy to use
interface.
%prep
{{{ git_dir_setup_macro }}}
%build
%meson \
-Dsd-bus-provider=libsystemd \
-Dwerror=false
%meson_build
%install
%meson_install
# Set Fedora background as default background
sed -i "s|^output \* bg .*|output * bg /usr/share/backgrounds/default.png fill|" %{buildroot}%{_sysconfdir}/sway/config
# Create directory for extra config snippets
install -d -m755 -pv %{buildroot}%{_sysconfdir}/sway/config.d
# Install portals.conf for xdg-desktop-portal
install -D -m644 -pv %{SOURCE101} %{buildroot}%{_datadir}/xdg-desktop-portal/sway-portals.conf
# install python scripts from contrib
install -D -m644 -pv -t %{buildroot}%{_datadir}/sway/contrib contrib/*.py
# install contrib/grimshot tool
scdoc <contrib/grimshot.1.scd >%{buildroot}%{_mandir}/man1/grimshot.1
install -D -m755 -pv contrib/grimshot %{buildroot}%{_bindir}/grimshot
%files
%license LICENSE
%doc README.md
%dir %{_sysconfdir}/sway
%dir %{_sysconfdir}/sway/config.d
%config(noreplace) %{_sysconfdir}/sway/config
%{_mandir}/man1/sway*
%{_mandir}/man5/*
%{_mandir}/man7/*
%{_bindir}/sway
%{_bindir}/swaybar
%{_bindir}/swaymsg
%{_bindir}/swaynag
%{_datadir}/sway
%{_datadir}/wayland-sessions/sway.desktop
%dir %{_datadir}/xdg-desktop-portal
%{_datadir}/xdg-desktop-portal/sway-portals.conf
%{bash_completions_dir}/sway*
%{fish_completions_dir}/sway*.fish
%{zsh_completions_dir}/_sway*
%files wallpapers
%license assets/LICENSE
%{_datadir}/backgrounds/sway
%files -n grimshot
%{_bindir}/grimshot
%{_mandir}/man1/grimshot.1*
# Changelog will be empty until you make first annotated Git tag.
%changelog
{{{ git_dir_changelog }}}

View file

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1713349283,
"narHash": "sha256-2bjFu3+1zPWZPPGqF+7rumTvEwmdBHBhjPva/AMSruQ=",
"lastModified": 1715037484,
"narHash": "sha256-OUt8xQFmBU96Hmm4T9tOWTu4oCswCzoVl+pxSq/kiFc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2e359fb3162c85095409071d131e08252d91a14f",
"rev": "ad7efee13e0d216bf29992311536fce1d3eefbef",
"type": "github"
},
"original": {
@ -43,11 +43,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1713495445,
"narHash": "sha256-dMvGkhjt72NznwI57HLR+Oc6QMctf16W4zI1XYuwnZI=",
"lastModified": 1715160751,
"narHash": "sha256-S8m7phTU7QYgAq4B0hjH5WdtTjHDcNVhYfPFdhbty+A=",
"owner": "wlrfx",
"repo": "scenefx",
"rev": "5ada125a56012923c47fcf3d049fab32eb7104ff",
"rev": "2ec3505248e819191c37cb831197629f373326fb",
"type": "github"
},
"original": {

View file

@ -14,7 +14,7 @@
let
mkPackage = pkgs: {
swayfx-unwrapped =
(pkgs.swayfx-unwrapped.override { wlroots_0_16 = pkgs.wlroots_0_17; }).overrideAttrs
(pkgs.swayfx-unwrapped.override { wlroots = pkgs.wlroots_0_17; }).overrideAttrs
(old: {
version = "0.4.0-git";
src = pkgs.lib.cleanSource ./.;

View file

@ -97,6 +97,7 @@ static const struct cmd_handler handlers[] = {
{ "no_focus", cmd_no_focus },
{ "output", cmd_output },
{ "popup_during_fullscreen", cmd_popup_during_fullscreen },
{ "primary_selection", cmd_primary_selection },
{ "seat", cmd_seat },
{ "set", cmd_set },
{ "shadow_blur_radius", cmd_shadow_blur_radius },

View file

@ -45,17 +45,27 @@ static void handle_render(struct sway_seat *seat, struct fx_render_context *ctx)
memcpy(&box, &e->drop_box, sizeof(struct wlr_box));
scale_box(&box, ctx->output->wlr_output->scale);
// Render blur
pixman_region32_t opaque_region;
pixman_region32_init(&opaque_region);
struct decoration_data deco_data = get_undecorated_decoration_data();
deco_data.blur = e->con->blur_enabled;
deco_data.corner_radius = e->con->corner_radius;
struct wlr_fbox src_box = {0};
render_blur(ctx, NULL, &src_box, &box, false, &opaque_region, deco_data);
pixman_region32_fini(&opaque_region);
deco_data.corner_radius = e->con->corner_radius * ctx->output->wlr_output->scale;
render_rounded_rect(ctx, &box, color, e->con->corner_radius * ctx->output->wlr_output->scale, ALL);
// Render blur
if (deco_data.blur && color[3] < 1.0f) {
pixman_region32_t opaque_region;
pixman_region32_init(&opaque_region);
struct wlr_fbox src_box = {0};
struct wlr_box blur_box;
memcpy(&blur_box, &e->drop_box, sizeof(struct wlr_box));
// The render_blur function doesn't use root-relative coordinates
blur_box.x -= ctx->output->lx;
blur_box.y -= ctx->output->ly;
scale_box(&blur_box, ctx->output->wlr_output->scale);
render_blur(ctx, NULL, &src_box, &blur_box, false, &opaque_region, deco_data);
pixman_region32_fini(&opaque_region);
}
render_rounded_rect(ctx, &box, color, deco_data.corner_radius, ALL);
}
}

View file

@ -63,33 +63,38 @@
#define SWAY_LAYER_SHELL_VERSION 4
#if WLR_HAS_DRM_BACKEND
static void handle_drm_lease_request(struct wl_listener *listener, void *data) {
static void handle_drm_lease_request(struct wl_listener *listener, void *data)
{
/* We only offer non-desktop outputs, but in the future we might want to do
* more logic here. */
struct wlr_drm_lease_request_v1 *req = data;
struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req);
if (!lease) {
if (!lease)
{
sway_log(SWAY_ERROR, "Failed to grant lease request");
wlr_drm_lease_request_v1_reject(req);
}
}
#endif
static bool is_privileged(const struct wl_global *global) {
static bool is_privileged(const struct wl_global *global)
{
#if WLR_HAS_DRM_BACKEND
if (server.drm_lease_manager != NULL) {
if (server.drm_lease_manager != NULL)
{
struct wlr_drm_lease_device_v1 *drm_lease_dev;
wl_list_for_each(drm_lease_dev, &server.drm_lease_manager->devices, link) {
if (drm_lease_dev->global == global) {
wl_list_for_each(drm_lease_dev, &server.drm_lease_manager->devices, link)
{
if (drm_lease_dev->global == global)
{
return true;
}
}
}
#endif
return
global == server.output_manager_v1->global ||
return global == server.output_manager_v1->global ||
global == server.output_power_manager_v1->global ||
global == server.input_method->global ||
global == server.foreign_toplevel_manager->global ||
@ -107,10 +112,12 @@ static bool is_privileged(const struct wl_global *global) {
}
static bool filter_global(const struct wl_client *client,
const struct wl_global *global, void *data) {
const struct wl_global *global, void *data)
{
#if HAVE_XWAYLAND
struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
if (xwayland && global == xwayland->shell_v1->global) {
if (xwayland && global == xwayland->shell_v1->global)
{
return xwayland->server != NULL && client == xwayland->server->client;
}
#endif
@ -120,14 +127,16 @@ static bool filter_global(const struct wl_client *client,
const struct wlr_security_context_v1_state *security_context =
wlr_security_context_manager_v1_lookup_client(
server.security_context_manager_v1, (struct wl_client *)client);
if (is_privileged(global)) {
if (is_privileged(global))
{
return security_context == NULL;
}
return true;
}
bool server_init(struct sway_server *server) {
bool server_init(struct sway_server *server)
{
sway_log(SWAY_DEBUG, "Initializing Wayland server");
server->wl_display = wl_display_create();
server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
@ -135,20 +144,23 @@ bool server_init(struct sway_server *server) {
wl_display_set_global_filter(server->wl_display, filter_global, NULL);
server->backend = wlr_backend_autocreate(server->wl_display, &server->session);
if (!server->backend) {
if (!server->backend)
{
sway_log(SWAY_ERROR, "Unable to create backend");
return false;
}
server->renderer = fx_renderer_create(server->backend);
if (!server->renderer) {
if (!server->renderer)
{
sway_log(SWAY_ERROR, "Failed to create fx_renderer");
return false;
}
wlr_renderer_init_wl_shm(server->renderer, server->wl_display);
if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL) {
if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL)
{
wlr_drm_create(server->wl_display, server->renderer);
server->linux_dmabuf_v1 = wlr_linux_dmabuf_v1_create_with_renderer(
server->wl_display, 4, server->renderer);
@ -156,7 +168,8 @@ bool server_init(struct sway_server *server) {
server->allocator = wlr_allocator_autocreate(server->backend,
server->renderer);
if (!server->allocator) {
if (!server->allocator)
{
sway_log(SWAY_ERROR, "Failed to create allocator");
return false;
}
@ -256,13 +269,16 @@ bool server_init(struct sway_server *server) {
sway_session_lock_init();
#if WLR_HAS_DRM_BACKEND
server->drm_lease_manager=
server->drm_lease_manager =
wlr_drm_lease_v1_manager_create(server->wl_display, server->backend);
if (server->drm_lease_manager) {
if (server->drm_lease_manager)
{
server->drm_lease_request.notify = handle_drm_lease_request;
wl_signal_add(&server->drm_lease_manager->events.request,
&server->drm_lease_request);
} else {
}
else
{
sway_log(SWAY_DEBUG, "Failed to create wlr_drm_lease_device_v1");
sway_log(SWAY_INFO, "VR will not be available");
}
@ -302,26 +318,32 @@ bool server_init(struct sway_server *server) {
// Avoid using "wayland-0" as display socket
char name_candidate[16];
for (unsigned int i = 1; i <= 32; ++i) {
for (unsigned int i = 1; i <= 32; ++i)
{
snprintf(name_candidate, sizeof(name_candidate), "wayland-%u", i);
if (wl_display_add_socket(server->wl_display, name_candidate) >= 0) {
if (wl_display_add_socket(server->wl_display, name_candidate) >= 0)
{
server->socket = strdup(name_candidate);
break;
}
}
if (!server->socket) {
if (!server->socket)
{
sway_log(SWAY_ERROR, "Unable to open wayland socket");
wlr_backend_destroy(server->backend);
return false;
}
server->headless_backend = wlr_headless_backend_create(server->wl_display);
if (!server->headless_backend) {
if (!server->headless_backend)
{
sway_log(SWAY_ERROR, "Failed to create secondary headless backend");
wlr_backend_destroy(server->backend);
return false;
} else {
}
else
{
wlr_multi_backend_add(server->backend, server->headless_backend);
}
@ -331,7 +353,8 @@ bool server_init(struct sway_server *server) {
root->fallback_output = output_create(wlr_output);
// This may have been set already via -Dtxn-timeout
if (!server->txn_timeout_ms) {
if (!server->txn_timeout_ms)
{
server->txn_timeout_ms = 200;
}
@ -343,7 +366,8 @@ bool server_init(struct sway_server *server) {
return true;
}
void server_fini(struct sway_server *server) {
void server_fini(struct sway_server *server)
{
// TODO: free sway-specific resources
#if HAVE_XWAYLAND
wlr_xwayland_destroy(server->xwayland.wlr_xwayland);
@ -353,18 +377,23 @@ void server_fini(struct sway_server *server) {
list_free(server->dirty_nodes);
}
bool server_start(struct sway_server *server) {
bool server_start(struct sway_server *server)
{
#if HAVE_XWAYLAND
if (config->xwayland != XWAYLAND_MODE_DISABLED) {
if (config->xwayland != XWAYLAND_MODE_DISABLED)
{
sway_log(SWAY_DEBUG, "Initializing Xwayland (lazy=%d)",
config->xwayland == XWAYLAND_MODE_LAZY);
server->xwayland.wlr_xwayland =
wlr_xwayland_create(server->wl_display, server->compositor,
config->xwayland == XWAYLAND_MODE_LAZY);
if (!server->xwayland.wlr_xwayland) {
if (!server->xwayland.wlr_xwayland)
{
sway_log(SWAY_ERROR, "Failed to start Xwayland");
unsetenv("DISPLAY");
} else {
}
else
{
wl_signal_add(&server->xwayland.wlr_xwayland->events.new_surface,
&server->xwayland_surface);
server->xwayland_surface.notify = handle_xwayland_surface;
@ -379,13 +408,15 @@ bool server_start(struct sway_server *server) {
}
#endif
if (config->primary_selection) {
if (config->primary_selection)
{
wlr_primary_selection_v1_device_manager_create(server->wl_display);
}
sway_log(SWAY_INFO, "Starting backend on wayland display '%s'",
server->socket);
if (!wlr_backend_start(server->backend)) {
if (!wlr_backend_start(server->backend))
{
sway_log(SWAY_ERROR, "Failed to start backend");
wlr_backend_destroy(server->backend);
return false;
@ -394,7 +425,8 @@ bool server_start(struct sway_server *server) {
return true;
}
void server_run(struct sway_server *server) {
void server_run(struct sway_server *server)
{
sway_log(SWAY_INFO, "Running compositor on wayland display '%s'",
server->socket);
wl_display_run(server->wl_display);