Merge branch 'master' into sway_mirror

This commit is contained in:
Alexander Courtis 2022-01-21 10:27:30 +11:00
commit 246c9a31b2
25 changed files with 126 additions and 55 deletions

View file

@ -80,6 +80,12 @@ enum movement_unit parse_movement_unit(const char *unit) {
int parse_movement_amount(int argc, char **argv, int parse_movement_amount(int argc, char **argv,
struct movement_amount *amount) { struct movement_amount *amount) {
if (!sway_assert(argc > 0, "Expected args in parse_movement_amount")) {
amount->amount = 0;
amount->unit = MOVEMENT_UNIT_INVALID;
return 0;
}
char *err; char *err;
amount->amount = (int)strtol(argv[0], &err, 10); amount->amount = (int)strtol(argv[0], &err, 10);
if (*err) { if (*err) {

View file

@ -1,4 +1,4 @@
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
struct sway_container; struct sway_container;
struct sway_view; struct sway_view;

View file

@ -4,7 +4,7 @@
#include <stdint.h> #include <stdint.h>
#include <wlr/types/wlr_pointer_constraints_v1.h> #include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/types/wlr_pointer_gestures_v1.h> #include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "config.h" #include "config.h"

View file

@ -3,7 +3,7 @@
#include <wlr/types/wlr_text_input_v3.h> #include <wlr/types/wlr_text_input_v3.h>
#include <wlr/types/wlr_input_method_v2.h> #include <wlr/types/wlr_input_method_v2.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
#include "sway/input/seat.h" #include "sway/input/seat.h"
/** /**

View file

@ -1,7 +1,7 @@
#ifndef _SWAY_LAYERS_H #ifndef _SWAY_LAYERS_H
#define _SWAY_LAYERS_H #define _SWAY_LAYERS_H
#include <stdbool.h> #include <stdbool.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_layer_shell_v1.h>
enum layer_parent { enum layer_parent {
@ -25,6 +25,8 @@ struct sway_layer_surface {
bool mapped; bool mapped;
struct wlr_box extent; struct wlr_box extent;
enum zwlr_layer_shell_v1_layer layer; enum zwlr_layer_shell_v1_layer layer;
struct wl_list subsurfaces;
}; };
struct sway_layer_popup { struct sway_layer_popup {
@ -44,6 +46,7 @@ struct sway_layer_popup {
struct sway_layer_subsurface { struct sway_layer_subsurface {
struct wlr_subsurface *wlr_subsurface; struct wlr_subsurface *wlr_subsurface;
struct sway_layer_surface *layer_surface; struct sway_layer_surface *layer_surface;
struct wl_list link;
struct wl_listener map; struct wl_listener map;
struct wl_listener unmap; struct wl_listener unmap;

View file

@ -1,6 +1,6 @@
#ifndef _SWAY_SURFACE_H #ifndef _SWAY_SURFACE_H
#define _SWAY_SURFACE_H #define _SWAY_SURFACE_H
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
struct sway_surface { struct sway_surface {
struct wlr_surface *wlr_surface; struct wlr_surface *wlr_surface;

View file

@ -2,7 +2,7 @@
#define _SWAY_CONTAINER_H #define _SWAY_CONTAINER_H
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
#include "list.h" #include "list.h"
#include "sway/tree/node.h" #include "sway/tree/node.h"

View file

@ -1,7 +1,7 @@
#ifndef _SWAY_VIEW_H #ifndef _SWAY_VIEW_H
#define _SWAY_VIEW_H #define _SWAY_VIEW_H
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
#include "config.h" #include "config.h"
#if HAVE_XWAYLAND #if HAVE_XWAYLAND
#include <wlr/xwayland.h> #include <wlr/xwayland.h>

View file

@ -35,6 +35,15 @@ if is_freebsd
add_project_arguments('-D_C11_SOURCE', language: 'c') add_project_arguments('-D_C11_SOURCE', language: 'c')
endif endif
# Execute the wlroots subproject, if any
wlroots_version = ['>=0.16.0', '<0.17.0']
subproject(
'wlroots',
default_options: ['examples=false'],
required: false,
version: wlroots_version,
)
jsonc = dependency('json-c', version: '>=0.13') jsonc = dependency('json-c', version: '>=0.13')
pcre = dependency('libpcre') pcre = dependency('libpcre')
wayland_server = dependency('wayland-server', version: '>=1.20.0') wayland_server = dependency('wayland-server', version: '>=1.20.0')
@ -42,6 +51,7 @@ wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor') wayland_cursor = dependency('wayland-cursor')
wayland_egl = dependency('wayland-egl') wayland_egl = dependency('wayland-egl')
wayland_protos = dependency('wayland-protocols', version: '>=1.24') wayland_protos = dependency('wayland-protocols', version: '>=1.24')
wlroots = dependency('wlroots', version: wlroots_version)
xkbcommon = dependency('xkbcommon') xkbcommon = dependency('xkbcommon')
cairo = dependency('cairo') cairo = dependency('cairo')
pango = dependency('pango') pango = dependency('pango')
@ -60,20 +70,6 @@ fish_comp = dependency('fish', required: false)
math = cc.find_library('m') math = cc.find_library('m')
rt = cc.find_library('rt') rt = cc.find_library('rt')
# Try first to find wlroots as a subproject, then as a system dependency
wlroots_version = ['>=0.16.0', '<0.17.0']
wlroots_proj = subproject(
'wlroots',
default_options: ['examples=false'],
required: false,
version: wlroots_version,
)
if wlroots_proj.found()
wlroots = wlroots_proj.get_variable('wlroots')
else
wlroots = dependency('wlroots', version: wlroots_version)
endif
wlroots_features = { wlroots_features = {
'xwayland': false, 'xwayland': false,
} }
@ -92,15 +88,22 @@ if get_option('sd-bus-provider') == 'auto'
if not get_option('tray').disabled() if not get_option('tray').disabled()
assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto') assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto')
endif endif
sdbus = dependency(['libsystemd', 'libelogind', 'basu'], sdbus = dependency(['libsystemd', 'libelogind'],
required: get_option('tray'), required: false,
version: '>=239', version: '>=239',
) )
if not sdbus.found()
sdbus = dependency('basu', required: false)
endif
else else
sdbus = dependency(get_option('sd-bus-provider'), required: get_option('tray')) sdbus = dependency(get_option('sd-bus-provider'), required: get_option('tray'))
endif endif
have_tray = sdbus.found() tray_deps_found = sdbus.found()
if get_option('tray').enabled() and not tray_deps_found
error('Building with -Dtray=enabled, but sd-bus has not been not found')
endif
have_tray = (not get_option('tray').disabled()) and tray_deps_found
conf_data = configuration_data() conf_data = configuration_data()
@ -156,8 +159,8 @@ add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir
version = '"@0@"'.format(meson.project_version()) version = '"@0@"'.format(meson.project_version())
git = find_program('git', native: true, required: false) git = find_program('git', native: true, required: false)
if git.found() if git.found()
git_commit = run_command([git, 'rev-parse', '--short', 'HEAD']) git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'], check: false)
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD']) git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false)
if git_commit.returncode() == 0 and git_branch.returncode() == 0 if git_commit.returncode() == 0 and git_branch.returncode() == 0
version = '"@0@-@1@ (" __DATE__ ", branch \'@2@\')"'.format( version = '"@0@-@1@ (" __DATE__ ", branch \'@2@\')"'.format(
meson.project_version(), meson.project_version(),

View file

@ -451,7 +451,8 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
return cmd_results_new(CMD_FAILURE, ""); return cmd_results_new(CMD_FAILURE, "");
} }
struct sway_node *next_focus = NULL; struct sway_node *next_focus = NULL;
if (container_is_floating(container)) { if (container_is_floating(container) &&
container->pending.fullscreen_mode == FULLSCREEN_NONE) {
next_focus = node_get_in_direction_floating(container, seat, direction); next_focus = node_get_in_direction_floating(container, seat, direction);
} else { } else {
next_focus = node_get_in_direction_tiling(container, seat, direction, descend); next_focus = node_get_in_direction_tiling(container, seat, direction, descend);

View file

@ -874,6 +874,10 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
return cmd_results_new(CMD_INVALID, "Invalid x position specified"); return cmd_results_new(CMD_INVALID, "Invalid x position specified");
} }
if (argc < 1) {
return cmd_results_new(CMD_FAILURE, expected_position_syntax);
}
struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
// Y direction // Y direction
num_consumed_args = parse_movement_amount(argc, argv, &ly); num_consumed_args = parse_movement_amount(argc, argv, &ly);

View file

@ -5,6 +5,7 @@
#include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output_damage.h> #include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_subcompositor.h>
#include "log.h" #include "log.h"
#include "sway/desktop/transaction.h" #include "sway/desktop/transaction.h"
#include "sway/input/cursor.h" #include "sway/input/cursor.h"
@ -352,6 +353,8 @@ static void unmap(struct sway_layer_surface *sway_layer) {
sway_layer->layer_surface->surface, true); sway_layer->layer_surface->surface, true);
} }
static void layer_subsurface_destroy(struct sway_layer_subsurface *subsurface);
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_layer_surface *sway_layer = struct sway_layer_surface *sway_layer =
wl_container_of(listener, sway_layer, destroy); wl_container_of(listener, sway_layer, destroy);
@ -360,6 +363,12 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
if (sway_layer->layer_surface->mapped) { if (sway_layer->layer_surface->mapped) {
unmap(sway_layer); unmap(sway_layer);
} }
struct sway_layer_subsurface *subsurface, *subsurface_tmp;
wl_list_for_each_safe(subsurface, subsurface_tmp, &sway_layer->subsurfaces, link) {
layer_subsurface_destroy(subsurface);
}
wl_list_remove(&sway_layer->link); wl_list_remove(&sway_layer->link);
wl_list_remove(&sway_layer->destroy.link); wl_list_remove(&sway_layer->destroy.link);
wl_list_remove(&sway_layer->map.link); wl_list_remove(&sway_layer->map.link);
@ -428,11 +437,8 @@ static void subsurface_handle_commit(struct wl_listener *listener, void *data) {
subsurface_damage(subsurface, false); subsurface_damage(subsurface, false);
} }
static void subsurface_handle_destroy(struct wl_listener *listener, static void layer_subsurface_destroy(struct sway_layer_subsurface *subsurface) {
void *data) { wl_list_remove(&subsurface->link);
struct sway_layer_subsurface *subsurface =
wl_container_of(listener, subsurface, destroy);
wl_list_remove(&subsurface->map.link); wl_list_remove(&subsurface->map.link);
wl_list_remove(&subsurface->unmap.link); wl_list_remove(&subsurface->unmap.link);
wl_list_remove(&subsurface->destroy.link); wl_list_remove(&subsurface->destroy.link);
@ -440,6 +446,13 @@ static void subsurface_handle_destroy(struct wl_listener *listener,
free(subsurface); free(subsurface);
} }
static void subsurface_handle_destroy(struct wl_listener *listener,
void *data) {
struct sway_layer_subsurface *subsurface =
wl_container_of(listener, subsurface, destroy);
layer_subsurface_destroy(subsurface);
}
static struct sway_layer_subsurface *create_subsurface( static struct sway_layer_subsurface *create_subsurface(
struct wlr_subsurface *wlr_subsurface, struct wlr_subsurface *wlr_subsurface,
struct sway_layer_surface *layer_surface) { struct sway_layer_surface *layer_surface) {
@ -451,6 +464,7 @@ static struct sway_layer_subsurface *create_subsurface(
subsurface->wlr_subsurface = wlr_subsurface; subsurface->wlr_subsurface = wlr_subsurface;
subsurface->layer_surface = layer_surface; subsurface->layer_surface = layer_surface;
wl_list_insert(&layer_surface->subsurfaces, &subsurface->link);
subsurface->map.notify = subsurface_handle_map; subsurface->map.notify = subsurface_handle_map;
wl_signal_add(&wlr_subsurface->events.map, &subsurface->map); wl_signal_add(&wlr_subsurface->events.map, &subsurface->map);
@ -643,6 +657,8 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
return; return;
} }
wl_list_init(&sway_layer->subsurfaces);
sway_layer->surface_commit.notify = handle_surface_commit; sway_layer->surface_commit.notify = handle_surface_commit;
wl_signal_add(&layer_surface->surface->events.commit, wl_signal_add(&layer_surface->surface->events.commit,
&sway_layer->surface_commit); &sway_layer->surface_commit);

View file

@ -14,7 +14,7 @@
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_presentation_time.h> #include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/util/region.h> #include <wlr/util/region.h>
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"

View file

@ -12,7 +12,7 @@
#include <wlr/types/wlr_output_damage.h> #include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/util/region.h> #include <wlr/util/region.h>
#include "log.h" #include "log.h"
#include "config.h" #include "config.h"

View file

@ -1,7 +1,7 @@
#define _POSIX_C_SOURCE 200112L #define _POSIX_C_SOURCE 200112L
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_compositor.h>
#include "sway/server.h" #include "sway/server.h"
#include "sway/surface.h" #include "sway/surface.h"

View file

@ -402,7 +402,7 @@ static void transaction_commit(struct sway_transaction *transaction) {
struct sway_transaction_instruction *instruction = struct sway_transaction_instruction *instruction =
transaction->instructions->items[i]; transaction->instructions->items[i];
struct sway_node *node = instruction->node; struct sway_node *node = instruction->node;
bool hidden = node_is_view(node) && bool hidden = node_is_view(node) && !node->destroying &&
!view_is_visible(node->sway_container->view); !view_is_visible(node->sway_container->view);
if (should_configure(node, instruction)) { if (should_configure(node, instruction)) {
instruction->serial = view_configure(node->sway_container->view, instruction->serial = view_configure(node->sway_container->view,

View file

@ -72,8 +72,8 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) {
// the output box expressed in the coordinate system of the toplevel parent // the output box expressed in the coordinate system of the toplevel parent
// of the popup // of the popup
struct wlr_box output_toplevel_sx_box = { struct wlr_box output_toplevel_sx_box = {
.x = output->lx - view->container->pending.content_x, .x = output->lx - view->container->pending.content_x + view->geometry.x,
.y = output->ly - view->container->pending.content_y, .y = output->ly - view->container->pending.content_y + view->geometry.y,
.width = output->width, .width = output->width,
.height = output->height, .height = output->height,
}; };

View file

@ -927,6 +927,7 @@ static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data)
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_begin); listener, cursor, pinch_begin);
struct wlr_event_pointer_pinch_begin *event = data; struct wlr_event_pointer_pinch_begin *event = data;
cursor_handle_activity_from_device(cursor, event->device);
wlr_pointer_gestures_v1_send_pinch_begin( wlr_pointer_gestures_v1_send_pinch_begin(
cursor->pointer_gestures, cursor->seat->wlr_seat, cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->fingers); event->time_msec, event->fingers);
@ -936,6 +937,7 @@ static void handle_pointer_pinch_update(struct wl_listener *listener, void *data
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_update); listener, cursor, pinch_update);
struct wlr_event_pointer_pinch_update *event = data; struct wlr_event_pointer_pinch_update *event = data;
cursor_handle_activity_from_device(cursor, event->device);
wlr_pointer_gestures_v1_send_pinch_update( wlr_pointer_gestures_v1_send_pinch_update(
cursor->pointer_gestures, cursor->seat->wlr_seat, cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->dx, event->dy, event->time_msec, event->dx, event->dy,
@ -946,6 +948,7 @@ static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_end); listener, cursor, pinch_end);
struct wlr_event_pointer_pinch_end *event = data; struct wlr_event_pointer_pinch_end *event = data;
cursor_handle_activity_from_device(cursor, event->device);
wlr_pointer_gestures_v1_send_pinch_end( wlr_pointer_gestures_v1_send_pinch_end(
cursor->pointer_gestures, cursor->seat->wlr_seat, cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->cancelled); event->time_msec, event->cancelled);
@ -955,6 +958,7 @@ static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data)
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_begin); listener, cursor, swipe_begin);
struct wlr_event_pointer_swipe_begin *event = data; struct wlr_event_pointer_swipe_begin *event = data;
cursor_handle_activity_from_device(cursor, event->device);
wlr_pointer_gestures_v1_send_swipe_begin( wlr_pointer_gestures_v1_send_swipe_begin(
cursor->pointer_gestures, cursor->seat->wlr_seat, cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->fingers); event->time_msec, event->fingers);
@ -964,6 +968,7 @@ static void handle_pointer_swipe_update(struct wl_listener *listener, void *data
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_update); listener, cursor, swipe_update);
struct wlr_event_pointer_swipe_update *event = data; struct wlr_event_pointer_swipe_update *event = data;
cursor_handle_activity_from_device(cursor, event->device);
wlr_pointer_gestures_v1_send_swipe_update( wlr_pointer_gestures_v1_send_swipe_update(
cursor->pointer_gestures, cursor->seat->wlr_seat, cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->dx, event->dy); event->time_msec, event->dx, event->dy);
@ -973,6 +978,7 @@ static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_end); listener, cursor, swipe_end);
struct wlr_event_pointer_swipe_end *event = data; struct wlr_event_pointer_swipe_end *event = data;
cursor_handle_activity_from_device(cursor, event->device);
wlr_pointer_gestures_v1_send_swipe_end( wlr_pointer_gestures_v1_send_swipe_end(
cursor->pointer_gestures, cursor->seat->wlr_seat, cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->cancelled); event->time_msec, event->cancelled);

View file

@ -51,6 +51,16 @@ static void seat_device_destroy(struct sway_seat_device *seat_device) {
static void seat_node_destroy(struct sway_seat_node *seat_node) { static void seat_node_destroy(struct sway_seat_node *seat_node) {
wl_list_remove(&seat_node->destroy.link); wl_list_remove(&seat_node->destroy.link);
wl_list_remove(&seat_node->link); wl_list_remove(&seat_node->link);
/*
* This is the only time we remove items from the focus stack without
* immediately re-adding them. If we just removed the last thing,
* mark that nothing has focus anymore.
*/
if (wl_list_empty(&seat_node->seat->focus_stack)) {
seat_node->seat->has_focus = false;
}
free(seat_node); free(seat_node);
} }
@ -1415,9 +1425,8 @@ struct sway_node *seat_get_focus(struct sway_seat *seat) {
if (!seat->has_focus) { if (!seat->has_focus) {
return NULL; return NULL;
} }
if (wl_list_empty(&seat->focus_stack)) { sway_assert(!wl_list_empty(&seat->focus_stack),
return NULL; "focus_stack is empty, but has_focus is true");
}
struct sway_seat_node *current = struct sway_seat_node *current =
wl_container_of(seat->focus_stack.next, current, link); wl_container_of(seat->focus_stack.next, current, link);
return current->node; return current->node;

View file

@ -153,6 +153,9 @@ static void log_kernel(void) {
static bool drop_permissions(void) { static bool drop_permissions(void) {
if (getuid() != geteuid() || getgid() != getegid()) { if (getuid() != geteuid() || getgid() != getegid()) {
sway_log(SWAY_ERROR, "!!! DEPRECATION WARNING: "
"SUID privilege drop will be removed in a future release, please migrate to seatd-launch");
// Set the gid and uid in the correct order. // Set the gid and uid in the correct order.
if (setgid(getgid()) != 0) { if (setgid(getgid()) != 0) {
sway_log(SWAY_ERROR, "Unable to drop root group, refusing to start"); sway_log(SWAY_ERROR, "Unable to drop root group, refusing to start");

View file

@ -24,6 +24,7 @@
#include <wlr/types/wlr_relative_pointer_v1.h> #include <wlr/types/wlr_relative_pointer_v1.h>
#include <wlr/types/wlr_screencopy_v1.h> #include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/types/wlr_server_decoration.h> #include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_tablet_v2.h>
#include <wlr/types/wlr_viewporter.h> #include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xcursor_manager.h>
@ -101,6 +102,8 @@ bool server_init(struct sway_server *server) {
wl_signal_add(&server->compositor->events.new_surface, wl_signal_add(&server->compositor->events.new_surface,
&server->compositor_new_surface); &server->compositor_new_surface);
wlr_subcompositor_create(server->wl_display);
server->data_device_manager = server->data_device_manager =
wlr_data_device_manager_create(server->wl_display); wlr_data_device_manager_create(server->wl_display);

View file

@ -9,6 +9,7 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/render/drm_format_set.h> #include <wlr/render/drm_format_set.h>
#include "linux-dmabuf-unstable-v1-protocol.h" #include "linux-dmabuf-unstable-v1-protocol.h"
#include "cairo_util.h" #include "cairo_util.h"
@ -80,10 +81,8 @@ void container_destroy(struct sway_container *con) {
wlr_texture_destroy(con->marks_urgent); wlr_texture_destroy(con->marks_urgent);
wlr_texture_destroy(con->marks_focused_tab_title); wlr_texture_destroy(con->marks_focused_tab_title);
if (con->view) { if (con->view && con->view->container == con) {
if (con->view->container == con) { con->view->container = NULL;
con->view->container = NULL;
}
if (con->view->destroying) { if (con->view->destroying) {
view_destroy(con->view); view_destroy(con->view);
} }

View file

@ -6,6 +6,7 @@
#include <wlr/types/wlr_buffer.h> #include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_server_decoration.h> #include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_xdg_decoration_v1.h> #include <wlr/types/wlr_xdg_decoration_v1.h>
#include "config.h" #include "config.h"
#if HAVE_XWAYLAND #if HAVE_XWAYLAND

View file

@ -466,6 +466,11 @@ uint32_t render_sni(cairo_t *cairo, struct swaybar_output *output, double *x,
sni->target_size = target_size; sni->target_size = target_size;
} }
// Passive
if (sni->status && sni->status[0] == 'P') {
return 0;
}
int icon_size; int icon_size;
cairo_surface_t *icon; cairo_surface_t *icon;
if (sni->icon) { if (sni->icon) {
@ -493,24 +498,36 @@ uint32_t render_sni(cairo_t *cairo, struct swaybar_output *output, double *x,
cairo_destroy(cairo_icon); cairo_destroy(cairo_icon);
} }
int padded_size = icon_size + 2*padding; double descaled_padding = (double)padding / output->scale;
*x -= padded_size; double descaled_icon_size = (double)icon_size / output->scale;
int y = floor((height - padded_size) / 2.0);
int size = descaled_icon_size + 2 * descaled_padding;
*x -= size;
int icon_y = floor((output->height - size) / 2.0);
cairo_operator_t op = cairo_get_operator(cairo); cairo_operator_t op = cairo_get_operator(cairo);
cairo_set_operator(cairo, CAIRO_OPERATOR_OVER); cairo_set_operator(cairo, CAIRO_OPERATOR_OVER);
cairo_set_source_surface(cairo, icon, *x + padding, y + padding);
cairo_rectangle(cairo, *x, y, padded_size, padded_size); cairo_matrix_t scale_matrix;
cairo_pattern_t *icon_pattern = cairo_pattern_create_for_surface(icon);
// TODO: check cairo_pattern_status for "ENOMEM"
cairo_matrix_init_scale(&scale_matrix, output->scale, output->scale);
cairo_matrix_translate(&scale_matrix, -(*x + descaled_padding), -(icon_y + descaled_padding));
cairo_pattern_set_matrix(icon_pattern, &scale_matrix);
cairo_set_source(cairo, icon_pattern);
cairo_rectangle(cairo, *x, icon_y, size, size);
cairo_fill(cairo); cairo_fill(cairo);
cairo_set_operator(cairo, op); cairo_set_operator(cairo, op);
cairo_pattern_destroy(icon_pattern);
cairo_surface_destroy(icon); cairo_surface_destroy(icon);
struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
hotspot->x = *x; hotspot->x = *x;
hotspot->y = 0; hotspot->y = 0;
hotspot->width = height; hotspot->width = size;
hotspot->height = height; hotspot->height = output->height;
hotspot->callback = icon_hotspot_callback; hotspot->callback = icon_hotspot_callback;
hotspot->destroy = free; hotspot->destroy = free;
hotspot->data = strdup(sni->watcher_id); hotspot->data = strdup(sni->watcher_id);

View file

@ -116,8 +116,8 @@ uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) {
} }
} // else display on all } // else display on all
if ((int) output->height*output->scale <= 2*config->tray_padding) { if ((int)(output->height * output->scale) <= 2 * config->tray_padding) {
return 2*config->tray_padding + 1; return (2 * config->tray_padding + 1) / output->scale;
} }
uint32_t max_height = 0; uint32_t max_height = 0;