Compare commits

...

30 commits

Author SHA1 Message Date
Simon Ser 3b1effdfa5 build: bump version to 1.6.1 2021-06-24 18:26:29 +02:00
Kenny Levinsen b21913e11d ci: Test wlroots static linking
(cherry picked from commit 4df9f49dc1)
2021-06-24 18:21:29 +02:00
Kenny Levinsen 04f75e6acc input: Move get_current_time_msec in from util
get_current_time_msec is only used in cursor.c, so we can move it in and
make it static. This is primarily intended to avoid a symbol collision
with wlroots, which we unfortunately do not have a good solution for
yet.

(cherry picked from commit 80315217f7)
2021-06-24 18:21:29 +02:00
Bill Doyle ae55861548 Only defer seat attachment during initial startup
Deferred commands are only run once, during sway startup. This means
that deferring seat attachment based on whether we are reading the
config prevents devices from being reattached to the correct seat during
a config reload. Instead, only defer if the config is not yet active.

Fixes #6048.

(cherry picked from commit cad6e59b93)
2021-06-24 18:21:29 +02:00
Ronan Pigott f49356ebf0 view: commit transactions for foreign toplevel requests
(cherry picked from commit 5a73dc1bc2)
2021-06-24 18:21:29 +02:00
Issam E. Maghni 2b0765b464 cairo: Replace <cairo/cairo.h> by <cairo.h>
For full context, read
https://gitlab.freedesktop.org/cairo/cairo/-/issues/479
TL;DR, cairo’s pc file adds `/cairo` to CFLAGS.
So namespace cairo shouldn’t be used.

(cherry picked from commit d45623c2db)
2021-06-24 18:21:29 +02:00
Rouven Czerwinski f0dd271ccf view: handle case where map_ws is NULL
When a criteria places the view into the scratchpad, map_ws is NULL and
trying to access map_ws->fullscreen will result in SIGSEGFAULT with:

  #0  0x0000000000455327 in should_focus (view=0x15a6a70) at ../sway/tree/view.c:604
          prev_con = 0x0
          len = <optimized out>
          seat = 0x12233c0
          prev_ws = 0x1264c80
          map_ws = 0x0
          criterias = <optimized out>
          seat = <optimized out>
          prev_con = <optimized out>
          prev_ws = <optimized out>
          map_ws = <optimized out>
          criterias = <optimized out>
          len = <optimized out>
          num_children = <optimized out>
  #1  view_map (view=view@entry=0x15a6a70, wlr_surface=0x15a5cb0, fullscreen=<optimized out>, fullscreen_output=<optimized out>, decoration=<optimized out>) at ../sway/tree/view.c:809
          __PRETTY_FUNCTION__ = "view_map"
          ws = <optimized out>
          seat = <optimized out>
          node = <optimized out>
          target_sibling = <optimized out>
          container = 0x1625400
          set_focus = <optimized out>
          app_id = <optimized out>
          class = <optimized out>
  #2  0x0000000000423a7e in handle_map (listener=0x15a6c78, data=<optimized out>) at ../sway/desktop/xdg_shell.c:454
          xdg_shell_view = 0x15a6a70
          view = 0x15a6a70
          xdg_surface = 0x15a6620
          csd = <optimized out>
  #3  0x00007f508bd3674c in wlr_signal_emit_safe (signal=signal@entry=0x15a6718, data=data@entry=0x15a6620) at ../subprojects/wlroots/util/signal.c:29
          pos = 0x15a6c78
          l = 0x15a6c78
          cursor = {link = {prev = 0x15a6c78, next = 0x7fff53d58190}, notify = 0x7f508bd366c0 <handle_noop>}
          end = {link = {prev = 0x7fff53d58170, next = 0x15a6718}, notify = 0x7f508bd366c0 <handle_noop>}
  #4  0x00007f508bd15b29 in handle_xdg_surface_commit (wlr_surface=<optimized out>) at ../subprojects/wlroots/types/xdg_shell/wlr_xdg_surface.c:384
          surface = 0x15a6620
  #5  0x00007f508bd2e981 in surface_commit_state (surface=surface@entry=0x15a5cb0, next=next@entry=0x15a5e18) at ../subprojects/wlroots/types/wlr_surface.c:455
          __PRETTY_FUNCTION__ = "surface_commit_state"
          invalid_buffer = <optimized out>
          subsurface = 0x15a6038
  #6  0x00007f508bd2f53b in surface_commit_pending (surface=0x15a5cb0) at ../subprojects/wlroots/types/wlr_surface.c:474
          next_seq = 3
          next_seq = <optimized out>
  #7  surface_commit (client=<optimized out>, resource=<optimized out>) at ../subprojects/wlroots/types/wlr_surface.c:542
          surface = 0x15a5cb0
          subsurface = <optimized out>

If map_ws is NULL we assume the view is places into the scratchpad and
return false as well.

(cherry picked from commit 30e400c0a3)
2021-06-24 18:21:29 +02:00
Ronan Pigott d33f4957ce workspace: reap empty parents when adding tiles
(cherry picked from commit c12169953a)
2021-06-24 18:21:29 +02:00
Kenny Levinsen 2660c0c1bc desktop/render: Pass explicit clip box to render
render_surface_iterator previously deduced the clip box from an optional
container passed with render data. This causes problems when offsets in
view geometry need to be compensated for in the clip dimensions.

Instead, prepare the clip box in render_view_toplevels where the offsets
are being applied, and compensate for them immediately.

A similar compensation is applied to render_saved_view.

Closes: https://github.com/swaywm/sway/issues/6223
(cherry picked from commit 4e6f515253)
2021-06-24 18:21:29 +02:00
Kenny Levinsen ee4e4bb50f Remove usage of surface->sx|sy
These coordinates contain the all-time accumulated buffer attach point,
which is a way to perform incremental client-side initiated movement of
windows, intended as a way to maintain logical window positioning while
compensating for layout changes such as folding in a left side panel.

This value is not useful for implementing this feature, and break things
if they ever become non-zero. Their inclusion in calculations also tend
to cause confusion.

Remove usage of these coordinates, removing the ability for clients to
move themselves. This may again be supported if a better API is made
available from wlroots.

(cherry picked from commit 7ec9d07fc5)
2021-06-24 18:21:29 +02:00
Tudor Brindus b51721901d tree/view: don't give focus to views mapped under fullscreen views
Fixes #6211.

(cherry picked from commit 80128d23ba)
2021-06-24 18:21:29 +02:00
Dominique Martinet fc1cce9348 view_destroy: fix use-after-free with subsurface_destroy
remove view from its own unmap event listener so when subsurfaces
link try to remove themselves they won't run into it.

This fixes the following ASAN use-after-free error on a build slightly
modified to instrument wl_list operations:
==71705==ERROR: AddressSanitizer: heap-use-after-free on address 0x6160000829a0 at pc 0x000000508eb7 bp 0x7ffec8fd8030 sp 0x7ffec8fd8028
WRITE of size 8 at 0x6160000829a0 thread T0
    #0 0x508eb6 in wl_list_remove ../common/list.c:181
    #1 0x4f4998 in view_child_destroy ../sway/tree/view.c:1131
    #2 0x4f38fa in subsurface_handle_destroy ../sway/tree/view.c:946
    #3 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29
    #4 0x7fda5072f0dd in subsurface_destroy ../types/wlr_surface.c:649
    #5 0x7fda507312c4 in subsurface_handle_surface_destroy ../types/wlr_surface.c:1094
    #6 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29
    #7 0x7fda5072f305 in surface_handle_resource_destroy ../types/wlr_surface.c:677
    #8 0x7fda508180ce in destroy_resource (/lib64/libwayland-server.so.0+0xc0ce)
    #9 0x7fda508187f2 in wl_client_destroy (/lib64/libwayland-server.so.0+0xc7f2)
    #10 0x7fda50818e5f in wl_client_connection_data (/lib64/libwayland-server.so.0+0xce5f)
    #11 0x7fda50818219 in wl_event_loop_dispatch (/lib64/libwayland-server.so.0+0xc219)
    #12 0x7fda50818984 in wl_display_run (/lib64/libwayland-server.so.0+0xc984)
    #13 0x43122c in server_run ../sway/server.c:254
    #14 0x42f47c in main ../sway/main.c:433
    #15 0x7fda503cab74 in __libc_start_main (/lib64/libc.so.6+0x27b74)
    #16 0x40f6fd in _start (/opt/wayland/bin/sway+0x40f6fd)

0x6160000829a0 is located 288 bytes inside of 592-byte region [0x616000082880,0x616000082ad0)
freed by thread T0 here:
    #0 0x7fda50f01a27 in free (/lib64/libasan.so.6+0xaea27)
    #1 0x4532d8 in destroy ../sway/desktop/xdg_shell.c:262
    #2 0x4ed17b in view_destroy ../sway/tree/view.c:67
    #3 0x4ed300 in view_begin_destroy ../sway/tree/view.c:83
    #4 0x454a3f in handle_destroy ../sway/desktop/xdg_shell.c:507
    #5 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29
    #6 0x7fda506e2c87 in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:481
    #7 0x7fda506e3018 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:516
    #8 0x7fda506dfbe5 in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71
    #9 0x7fda508180ce in destroy_resource (/lib64/libwayland-server.so.0+0xc0ce)

previously allocated by thread T0 here:
    #0 0x7fda50f01ed7 in calloc (/lib64/libasan.so.6+0xaeed7)
    #1 0x454bc8 in handle_xdg_shell_surface ../sway/desktop/xdg_shell.c:528
    #2 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7fda506e2363 in handle_xdg_surface_commit ../types/xdg_shell/wlr_xdg_surface.c:378
    #4 0x7fda5072e368 in surface_commit_state ../types/wlr_surface.c:455
    #5 0x7fda5072e51d in surface_commit_pending ../types/wlr_surface.c:474
    #6 0x7fda5072ea58 in surface_commit ../types/wlr_surface.c:542
    #7 0x7fda4fb3ac03 in ffi_call_unix64 (/lib64/libffi.so.6+0x6c03)

Fixes #5168

(cherry picked from commit 8529141150)
2021-06-24 18:21:29 +02:00
Simon Ser 9bd664175d Avoid creating zero-sized textures for marks
Same as 6327f1b361 ("Avoid creating zero-sized textures for titlebars")
but for marks.

(cherry picked from commit e3e99d961d)
2021-06-24 18:21:29 +02:00
Simon Ser 7d6b23a0be Avoid creating zero-sized textures for titlebars
Creating a zero-sized wlr_texture is incorrect.

(cherry picked from commit 6327f1b361)
2021-06-24 18:21:29 +02:00
Michael Weiser 599874a158 Prevent use-after-free on first bar subcommand error
If any error is encountered during execution of the first subcommand of
a freshly created bar configuration, parsing apparently is to be aborted
and the current bar config is freed. The pointer to that memory is left
dangling though, leading to a use-after-free on successive bar
subcommands. This quite reliably ends in a crash like so:

sway -c reproducer.config
00:00:00.083 [sway/config.c:865] Error on line 2 'foo bar': Unknown/invalid command 'foo' (s)
free(): double free detected in tcache 2
00:00:00.608 [swaynag/swaynag.c:451] failed to register with the wayland display
Aborted (core dumped)

Minimal reproducer config:
bar {
        foo bar
        position top
}

Other messages:
malloc(): unaligned fastbin chunk detected
double free or corruption (fasttop)

The invalid command has to be the first for a newly created bar config.
Removing the command or switching order so it's not the first one masks
the problem.

Prevent this from occuring by resetting the pointer to NULL after
freeing the memory.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
(cherry picked from commit 730efbc89c)
2021-06-24 18:21:29 +02:00
fwsmit a50039af77 desktop/layer_shell: fix centering for opposing anchors
(cherry picked from commit 8106f01c17)
2021-06-24 18:21:29 +02:00
Simon Ser 80e4efdb33 ci: stick to wlroots 0.14.0 2021-06-24 18:10:01 +02:00
Simon Ser 0d1231a6d1 Iterate over subsurfaces below the parent surface
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/2948

(cherry picked from commit 3162766eef)
2021-06-24 18:10:01 +02:00
Tobias Langendorf 1766ae3f44 remove usage of wlr_texture_get_size
update for wlroots 6369f7093178f0d66414eb67c312a403bfbb84a4

(cherry picked from commit 12e223e797)
2021-06-24 18:10:01 +02:00
Kenny Levinsen d9de8d90a9 meson: libseat is no longer optional
See: https://github.com/swaywm/wlroots/pull/2839
(cherry picked from commit 4e77bc2935)
2021-06-24 18:10:01 +02:00
Kenny Levinsen 8dc08792c8 ci: Install libseat
(cherry picked from commit fcfe52de29)
2021-06-24 18:10:01 +02:00
Simon Ser 9bdb0ead6e Log wlroots version on startup
Can be useful to make sure a bugfix is included. In the future maybe
the wlroots version string could include a commit hash when built
from source, too.

(cherry picked from commit 78fc9d0d2d)
2021-06-24 18:10:01 +02:00
Simon Ser 62e3ca671d Remove WLR_HAS_XDG_FOREIGN checks
References: https://github.com/swaywm/wlroots/pull/2833
(cherry picked from commit 1a72049c04)
2021-06-24 18:10:01 +02:00
Simon Ser d2d1461855 build: stop checking for logind
wlroots has removed its logind session backend [1]. It now relies
on libseat only.

[1]: https://github.com/swaywm/wlroots/pull/2786

(cherry picked from commit e49a98fcb3)
2021-06-24 18:10:01 +02:00
Simon Ser 4246cfaea8 build: update wlroots dependency version to 0.14.x
The latest commit of Sway always requires the latest commit of
wlroots.

(cherry picked from commit 7a68a28475)
2021-06-24 18:10:01 +02:00
Simon Ser be4b92c6b1 build: bump version to 1.6 2021-04-07 21:44:21 +02:00
Ronan Pigott 98696fa0e6 output: damage whole output when exiting scanout
(cherry picked from commit 62fbf33ce2)
2021-04-07 21:43:26 +02:00
Simon Ser 8a49a296f6 build: bump to version v1.6-rc3 2021-03-31 19:12:46 +02:00
Simon Ser 83202d40e2 ci: add xcb-util-wm dependency for wlroots
This is now a mandatory dependency for wlroots.

(cherry picked from commit 276a37a605)
2021-03-31 19:12:17 +02:00
columbarius 8f5c546fca config: allow whitespaces in config path
(cherry picked from commit 1d62d6bfa0)
2021-03-31 19:12:17 +02:00
29 changed files with 166 additions and 102 deletions

View file

@ -6,6 +6,7 @@ packages:
- json-c-dev
- libevdev-dev
- libinput-dev
- libseat-dev
- libxcb-dev
- libxkbcommon-dev
- mesa-dev
@ -16,10 +17,11 @@ packages:
- wayland-dev
- wayland-protocols
- xcb-util-image-dev
- xcb-util-wm-dev
- xwayland
sources:
- https://github.com/swaywm/sway
- https://github.com/swaywm/wlroots
- https://github.com/swaywm/wlroots#0.14.0
tasks:
- wlroots: |
cd wlroots
@ -36,3 +38,10 @@ tasks:
cd sway
meson configure build -Dxwayland=disabled
ninja -C build
- build-static: |
cd sway
mkdir subprojects
ln -s ../../wlroots subprojects/wlroots
rm -rf build
meson build --default-library=static --force-fallback-for=wlroots
ninja -C build

View file

@ -13,10 +13,12 @@ packages:
- wayland
- wayland-protocols
- xcb-util-image
- xcb-util-wm
- xorg-xwayland
- seatd
sources:
- https://github.com/swaywm/sway
- https://github.com/swaywm/wlroots
- https://github.com/swaywm/wlroots#0.14.0
tasks:
- wlroots: |
cd wlroots

View file

@ -19,13 +19,14 @@ packages:
- devel/libudev-devd
- graphics/libdrm
- graphics/mesa-libs
- sysutils/seatd
- x11/libinput
- x11/libX11
- x11/pixman
- x11/xcb-util-wm
sources:
- https://github.com/swaywm/sway
- https://github.com/swaywm/wlroots
- https://github.com/swaywm/wlroots#0.14.0
tasks:
- setup: |
cd sway

View file

@ -1,6 +1,6 @@
#define _POSIX_C_SOURCE 200809
#include <assert.h>
#include <cairo/cairo.h>
#include <cairo.h>
#include <fcntl.h>
#include <pango/pangocairo.h>
#include <stdio.h>

View file

@ -1,6 +1,6 @@
#include <assert.h>
#include "background-image.h"
#include "cairo.h"
#include "cairo_util.h"
#include "log.h"
#if HAVE_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>

View file

@ -1,6 +1,6 @@
#include <stdint.h>
#include <cairo/cairo.h>
#include "cairo.h"
#include <cairo.h>
#include "cairo_util.h"
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
cairo_set_source_rgba(cairo,

View file

@ -1,4 +1,4 @@
#include <cairo/cairo.h>
#include <cairo.h>
#include <pango/pangocairo.h>
#include <stdarg.h>
#include <stdbool.h>
@ -6,7 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cairo.h"
#include "cairo_util.h"
#include "log.h"
#include "stringop.h"

View file

@ -10,12 +10,6 @@
#include "log.h"
#include "util.h"
uint32_t get_current_time_msec(void) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return now.tv_sec * 1000 + now.tv_nsec / 1000000;
}
int wrap(int i, int max) {
return ((i % max) + max) % max;
}

View file

@ -1,6 +1,6 @@
#ifndef _SWAY_BACKGROUND_IMAGE_H
#define _SWAY_BACKGROUND_IMAGE_H
#include "cairo.h"
#include "cairo_util.h"
enum background_mode {
BACKGROUND_MODE_STRETCH,

View file

@ -1,8 +1,8 @@
#ifndef _SWAY_CAIRO_H
#define _SWAY_CAIRO_H
#ifndef _SWAY_CAIRO_UTIL_H
#define _SWAY_CAIRO_UTIL_H
#include "config.h"
#include <stdint.h>
#include <cairo/cairo.h>
#include <cairo.h>
#include <wayland-client-protocol.h>
void cairo_set_source_u32(cairo_t *cairo, uint32_t color);

View file

@ -3,7 +3,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <cairo/cairo.h>
#include <cairo.h>
#include <pango/pangocairo.h>
/**

View file

@ -1,6 +1,6 @@
#ifndef _SWAY_BUFFERS_H
#define _SWAY_BUFFERS_H
#include <cairo/cairo.h>
#include <cairo.h>
#include <pango/pangocairo.h>
#include <stdbool.h>
#include <stdint.h>

View file

@ -29,12 +29,6 @@ enum movement_unit parse_movement_unit(const char *unit);
int parse_movement_amount(int argc, char **argv,
struct movement_amount *amount);
/**
* Get the current time, in milliseconds.
*/
uint32_t get_current_time_msec(void);
/**
* Wrap i into the range [0, max]
*/

View file

@ -1,7 +1,7 @@
project(
'sway',
'c',
version: '1.6-rc2',
version: '1.6.1',
license: 'MIT',
meson_version: '>=0.53.0',
default_options: [
@ -61,7 +61,7 @@ math = cc.find_library('m')
rt = cc.find_library('rt')
# Try first to find wlroots as a subproject, then as a system dependency
wlroots_version = ['>=0.12.0', '<0.13.0']
wlroots_version = ['>=0.14.0', '<0.15.0']
wlroots_proj = subproject(
'wlroots',
default_options: ['examples=false'],
@ -76,9 +76,6 @@ endif
wlroots_features = {
'xwayland': false,
'systemd': false,
'elogind': false,
'libseat': false,
}
foreach name, _ : wlroots_features
var_name = 'have_' + name.underscorify()
@ -318,7 +315,3 @@ summary({
'man-pages': scdoc.found(),
}, bool_yn: true)
if not wlroots_features['systemd'] and not wlroots_features['elogind'] and not wlroots_features['libseat']
warning('The sway binary must be setuid when compiled without (e)logind or libseat')
warning('You must do this manually post-install: chmod a+s /path/to/sway')
endif

View file

@ -116,6 +116,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
if (res && res->status != CMD_SUCCESS) {
if (id) {
free_bar_config(config->current_bar);
config->current_bar = NULL;
id = NULL;
}
return res;

View file

@ -12,7 +12,7 @@ struct cmd_results *seat_cmd_attach(int argc, char **argv) {
if (!config->handler_context.seat_config) {
return cmd_results_new(CMD_FAILURE, "No seat defined");
}
if (config->reading) {
if (!config->active) {
return cmd_results_new(CMD_DEFER, NULL);
}

View file

@ -26,7 +26,7 @@
#include "sway/tree/arrange.h"
#include "sway/tree/root.h"
#include "sway/tree/workspace.h"
#include "cairo.h"
#include "cairo_util.h"
#include "pango.h"
#include "stringop.h"
#include "list.h"
@ -338,35 +338,60 @@ static bool file_exists(const char *path) {
return path && access(path, R_OK) != -1;
}
static char *get_config_path(void) {
static const char *config_paths[] = {
"$HOME/.sway/config",
"$XDG_CONFIG_HOME/sway/config",
"$HOME/.i3/config",
"$XDG_CONFIG_HOME/i3/config",
SYSCONFDIR "/sway/config",
SYSCONFDIR "/i3/config",
};
char *config_home = getenv("XDG_CONFIG_HOME");
if (!config_home || !*config_home) {
config_paths[1] = "$HOME/.config/sway/config";
config_paths[3] = "$HOME/.config/i3/config";
static char *config_path(const char *prefix, const char *config_folder) {
if (!prefix || !prefix[0] || !config_folder || !config_folder[0]) {
return NULL;
}
for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) {
wordexp_t p;
if (wordexp(config_paths[i], &p, WRDE_UNDEF) == 0) {
char *path = strdup(p.we_wordv[0]);
wordfree(&p);
if (file_exists(path)) {
const char *filename = "config";
size_t size = 3 + strlen(prefix) + strlen(config_folder) + strlen(filename);
char *path = calloc(size, sizeof(char));
snprintf(path, size, "%s/%s/%s", prefix, config_folder, filename);
return path;
}
free(path);
}
static char *get_config_path(void) {
char *path = NULL;
const char *home = getenv("HOME");
size_t size_fallback = 1 + strlen(home) + strlen("/.config");
char *config_home_fallback = calloc(size_fallback, sizeof(char));
snprintf(config_home_fallback, size_fallback, "%s/.config", home);
const char *config_home = getenv("XDG_CONFIG_HOME");
if (config_home == NULL || config_home[0] == '\0') {
config_home = config_home_fallback;
}
return NULL;
struct config_path {
const char *prefix;
const char *config_folder;
};
struct config_path config_paths[] = {
{ .prefix = home, .config_folder = ".sway"},
{ .prefix = config_home, .config_folder = "sway"},
{ .prefix = home, .config_folder = ".i3"},
{ .prefix = config_home, .config_folder = "i3"},
{ .prefix = SYSCONFDIR, .config_folder = "sway"},
{ .prefix = SYSCONFDIR, .config_folder = "i3"}
};
size_t num_config_paths = sizeof(config_paths)/sizeof(config_paths[0]);
for (size_t i = 0; i < num_config_paths; i++) {
path = config_path(config_paths[i].prefix, config_paths[i].config_folder);
if (!path) {
continue;
}
if (file_exists(path)) {
break;
}
free(path);
path = NULL;
}
free(config_home_fallback);
return path;
}
static bool load_config(const char *path, struct sway_config *config,

View file

@ -115,9 +115,10 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list,
// Horizontal axis
const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
| ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
if ((state->anchor & both_horiz) && box.width == 0) {
if (box.width == 0) {
box.x = bounds.x;
box.width = bounds.width;
} else if ((state->anchor & both_horiz) == both_horiz) {
box.x = bounds.x + ((bounds.width / 2) - (box.width / 2));
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) {
box.x = bounds.x;
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) {
@ -128,9 +129,10 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list,
// Vertical axis
const uint32_t both_vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP
| ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
if ((state->anchor & both_vert) && box.height == 0) {
if (box.height == 0) {
box.y = bounds.y;
box.height = bounds.height;
} else if ((state->anchor & both_vert) == both_vert) {
box.y = bounds.y + ((bounds.height / 2) - (box.height / 2));
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) {
box.y = bounds.y;
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) {
@ -139,17 +141,23 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list,
box.y = bounds.y + ((bounds.height / 2) - (box.height / 2));
}
// Margin
if ((state->anchor & both_horiz) == both_horiz) {
if (box.width == 0) {
box.x += state->margin.left;
box.width -= state->margin.left + state->margin.right;
box.width = bounds.width -
(state->margin.left + state->margin.right);
} else if ((state->anchor & both_horiz) == both_horiz) {
// don't apply margins
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) {
box.x += state->margin.left;
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) {
box.x -= state->margin.right;
}
if ((state->anchor & both_vert) == both_vert) {
if (box.height == 0) {
box.y += state->margin.top;
box.height -= state->margin.top + state->margin.bottom;
box.height = bounds.height -
(state->margin.top + state->margin.bottom);
} else if ((state->anchor & both_vert) == both_vert) {
// don't apply margins
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) {
box.y += state->margin.top;
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) {

View file

@ -99,8 +99,8 @@ static bool get_surface_box(struct surface_iterator_data *data,
int sw = surface->current.width;
int sh = surface->current.height;
double _sx = sx + surface->sx;
double _sy = sy + surface->sy;
double _sx = sx;
double _sy = sy;
rotate_child_position(&_sx, &_sy, sw, sh, data->width, data->height,
data->rotation);
@ -553,6 +553,7 @@ static int output_repaint_timer_handler(void *data) {
if (last_scanned_out && !scanned_out) {
sway_log(SWAY_DEBUG, "Stopping fullscreen view scan out on %s",
output->wlr_output->name);
output_damage_whole(output);
}
last_scanned_out = scanned_out;

View file

@ -32,7 +32,7 @@
struct render_data {
pixman_region32_t *damage;
float alpha;
struct sway_container *container;
struct wlr_box *clip_box;
};
/**
@ -160,10 +160,10 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view
wlr_output->transform_matrix);
struct wlr_box dst_box = *_box;
struct sway_container *container = data->container;
if (container != NULL) {
dst_box.width = fmin(dst_box.width, container->current.content_width - surface->sx);
dst_box.height = fmin(dst_box.height, container->current.content_height - surface->sy);
struct wlr_box *clip_box = data->clip_box;
if (clip_box != NULL) {
dst_box.width = fmin(dst_box.width, clip_box->width);
dst_box.height = fmin(dst_box.height, clip_box->height);
}
scale_box(&dst_box, wlr_output->scale);
@ -265,8 +265,13 @@ static void render_view_toplevels(struct sway_view *view,
.damage = damage,
.alpha = alpha,
};
struct wlr_box clip_box;
if (!container_is_current_floating(view->container)) {
data.container = view->container;
// As we pass the geometry offsets to the surface iterator, we will
// need to account for the offsets in the clip dimensions.
clip_box.width = view->container->current.content_width + view->geometry.x;
clip_box.height = view->container->current.content_height + view->geometry.y;
data.clip_box = &clip_box;
}
// Render all toplevels without descending into popups
double ox = view->container->surface_x -
@ -332,10 +337,10 @@ static void render_saved_view(struct sway_view *view,
if (!floating) {
dst_box.width = fmin(dst_box.width,
view->container->current.content_width -
(saved_buf->x - view->container->current.content_x));
(saved_buf->x - view->container->current.content_x) + view->saved_geometry.x);
dst_box.height = fmin(dst_box.height,
view->container->current.content_height -
(saved_buf->y - view->container->current.content_y));
(saved_buf->y - view->container->current.content_y) + view->saved_geometry.y);
}
scale_box(&dst_box, wlr_output->scale);
@ -488,9 +493,10 @@ static void render_titlebar(struct sway_output *output,
int ob_marks_x = 0; // output-buffer-local
int ob_marks_width = 0; // output-buffer-local
if (config->show_marks && marks_texture) {
struct wlr_box texture_box;
wlr_texture_get_size(marks_texture,
&texture_box.width, &texture_box.height);
struct wlr_box texture_box = {
.width = marks_texture->width,
.height = marks_texture->height,
};
ob_marks_width = texture_box.width;
// The marks texture might be shorter than the config->font_height, in
@ -541,9 +547,10 @@ static void render_titlebar(struct sway_output *output,
int ob_title_x = 0; // output-buffer-local
int ob_title_width = 0; // output-buffer-local
if (title_texture) {
struct wlr_box texture_box;
wlr_texture_get_size(title_texture,
&texture_box.width, &texture_box.height);
struct wlr_box texture_box = {
.width = title_texture->width,
.height = title_texture->height,
};
// The effective output may be NULL when con is not on any output.
// This can happen because we render all children of containers,

View file

@ -4,6 +4,7 @@
#include <libevdev/libevdev.h>
#include <linux/input-event-codes.h>
#include <errno.h>
#include <time.h>
#include <strings.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_cursor.h>
@ -31,6 +32,12 @@
#include "sway/tree/workspace.h"
#include "wlr-layer-shell-unstable-v1-protocol.h"
static uint32_t get_current_time_msec(void) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return now.tv_sec * 1000 + now.tv_nsec / 1000000;
}
static struct wlr_surface *layer_surface_at(struct sway_output *output,
struct wl_list *layer, double ox, double oy, double *sx, double *sy) {
struct sway_layer_surface *sway_layer;

View file

@ -12,6 +12,7 @@
#include <sys/un.h>
#include <unistd.h>
#include <wlr/util/log.h>
#include <wlr/version.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/server.h"
@ -344,6 +345,7 @@ int main(int argc, char **argv) {
}
sway_log(SWAY_INFO, "Sway version " SWAY_VERSION);
sway_log(SWAY_INFO, "wlroots version " WLR_VERSION_STR);
log_kernel();
log_distro();
log_env();

View file

@ -26,11 +26,9 @@
#include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#if WLR_HAS_XDG_FOREIGN
#include <wlr/types/wlr_xdg_foreign_registry.h>
#include <wlr/types/wlr_xdg_foreign_v1.h>
#include <wlr/types/wlr_xdg_foreign_v2.h>
#endif
#include <wlr/types/wlr_xdg_output_v1.h>
#include "config.h"
#include "list.h"
@ -156,12 +154,10 @@ bool server_init(struct sway_server *server) {
wlr_primary_selection_v1_device_manager_create(server->wl_display);
wlr_viewporter_create(server->wl_display);
#if WLR_HAS_XDG_FOREIGN
struct wlr_xdg_foreign_registry *foreign_registry =
wlr_xdg_foreign_registry_create(server->wl_display);
wlr_xdg_foreign_v1_create(server->wl_display, foreign_registry);
wlr_xdg_foreign_v2_create(server->wl_display, foreign_registry);
#endif
// Avoid using "wayland-0" as display socket
char name_candidate[16];

View file

@ -7,7 +7,7 @@
#include <strings.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_output_layout.h>
#include "cairo.h"
#include "cairo_util.h"
#include "pango.h"
#include "sway/config.h"
#include "sway/desktop.h"
@ -531,6 +531,10 @@ static void update_title_texture(struct sway_container *con,
cairo_surface_destroy(dummy_surface);
cairo_destroy(c);
if (width == 0 || height == 0) {
return;
}
cairo_surface_t *surface = cairo_image_surface_create(
CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cairo = cairo_create(surface);
@ -1620,6 +1624,10 @@ static void update_marks_texture(struct sway_container *con,
"%s", buffer);
cairo_destroy(c);
if (width == 0 || height == 0) {
return;
}
cairo_surface_t *surface = cairo_image_surface_create(
CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cairo = cairo_create(surface);

View file

@ -56,6 +56,7 @@ void view_destroy(struct sway_view *view) {
"(might have a pending transaction?)")) {
return;
}
wl_list_remove(&view->events.unmap.listener_list);
if (!wl_list_empty(&view->saved_buffers)) {
view_remove_saved_buffer(view);
}
@ -599,6 +600,11 @@ static bool should_focus(struct sway_view *view) {
return true;
}
// View opened "under" fullscreen view should not be given focus.
if (root->fullscreen_global || !map_ws || map_ws->fullscreen) {
return false;
}
// Views can only take focus if they are mapped into the active workspace
if (prev_ws != map_ws) {
return false;
@ -638,6 +644,7 @@ static void handle_foreign_activate_request(
break;
}
}
transaction_commit_dirty();
}
static void handle_foreign_fullscreen_request(
@ -677,6 +684,7 @@ static void handle_foreign_fullscreen_request(
arrange_workspace(container->pending.workspace);
}
}
transaction_commit_dirty();
}
static void handle_foreign_close_request(
@ -806,8 +814,8 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
if (wlr_surface_is_xwayland_surface(wlr_surface)) {
struct wlr_xwayland_surface *xsurface =
wlr_xwayland_surface_from_wlr_surface(wlr_surface);
set_focus = (wlr_xwayland_icccm_input_model(xsurface) !=
WLR_ICCCM_INPUT_MODEL_NONE) && set_focus;
set_focus &= wlr_xwayland_icccm_input_model(xsurface) !=
WLR_ICCCM_INPUT_MODEL_NONE;
}
#endif
@ -818,11 +826,9 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
const char *app_id;
const char *class;
if ((app_id = view_get_app_id(view)) != NULL) {
wlr_foreign_toplevel_handle_v1_set_app_id(
view->foreign_toplevel, app_id);
wlr_foreign_toplevel_handle_v1_set_app_id(view->foreign_toplevel, app_id);
} else if ((class = view_get_class(view)) != NULL) {
wlr_foreign_toplevel_handle_v1_set_app_id(
view->foreign_toplevel, class);
wlr_foreign_toplevel_handle_v1_set_app_id(view->foreign_toplevel, class);
}
}
@ -1031,7 +1037,10 @@ static void view_child_handle_surface_destroy(struct wl_listener *listener,
static void view_init_subsurfaces(struct sway_view *view,
struct wlr_surface *surface) {
struct wlr_subsurface *subsurface;
wl_list_for_each(subsurface, &surface->subsurfaces, parent_link) {
wl_list_for_each(subsurface, &surface->subsurfaces_below, parent_link) {
view_subsurface_create(view, subsurface);
}
wl_list_for_each(subsurface, &surface->subsurfaces_above, parent_link) {
view_subsurface_create(view, subsurface);
}
}
@ -1039,7 +1048,10 @@ static void view_init_subsurfaces(struct sway_view *view,
static void view_child_init_subsurfaces(struct sway_view_child *view_child,
struct wlr_surface *surface) {
struct wlr_subsurface *subsurface;
wl_list_for_each(subsurface, &surface->subsurfaces, parent_link) {
wl_list_for_each(subsurface, &surface->subsurfaces_below, parent_link) {
view_child_subsurface_create(view_child, subsurface);
}
wl_list_for_each(subsurface, &surface->subsurfaces_above, parent_link) {
view_child_subsurface_create(view_child, subsurface);
}
}

View file

@ -794,7 +794,11 @@ void workspace_detach(struct sway_workspace *workspace) {
struct sway_container *workspace_add_tiling(struct sway_workspace *workspace,
struct sway_container *con) {
if (con->pending.workspace) {
struct sway_container *old_parent = con->pending.parent;
container_detach(con);
if (old_parent) {
container_reap_empty(old_parent);
}
}
if (config->default_layout != L_NONE) {
con = container_split(con, config->default_layout);

View file

@ -5,7 +5,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "cairo.h"
#include "cairo_util.h"
#include "pango.h"
#include "pool-buffer.h"
#include "swaybar/bar.h"

View file

@ -13,7 +13,7 @@
#include "swaybar/tray/item.h"
#include "swaybar/tray/tray.h"
#include "background-image.h"
#include "cairo.h"
#include "cairo_util.h"
#include "list.h"
#include "log.h"
#include "wlr-layer-shell-unstable-v1-client-protocol.h"

View file

@ -1,5 +1,5 @@
#include <stdint.h>
#include "cairo.h"
#include "cairo_util.h"
#include "log.h"
#include "pango.h"
#include "pool-buffer.h"