summaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/bind.c8
-rw-r--r--sway/commands/focus.c18
-rw-r--r--sway/commands/input/xkb_switch_layout.c1
-rw-r--r--sway/commands/move.c16
-rw-r--r--sway/commands/output/background.c12
-rw-r--r--sway/commands/seat/cursor.c4
-rw-r--r--sway/config/output.c12
-rw-r--r--sway/criteria.c60
-rw-r--r--sway/desktop/desktop.c9
-rw-r--r--sway/desktop/layer_shell.c54
-rw-r--r--sway/desktop/output.c13
-rw-r--r--sway/desktop/render.c2
-rw-r--r--sway/desktop/surface.c2
-rw-r--r--sway/desktop/xdg_shell.c120
-rw-r--r--sway/desktop/xwayland.c30
-rw-r--r--sway/input/cursor.c149
-rw-r--r--sway/input/input-manager.c4
-rw-r--r--sway/input/keyboard.c12
-rw-r--r--sway/input/seat.c33
-rw-r--r--sway/input/seatop_default.c8
-rw-r--r--sway/input/seatop_down.c4
-rw-r--r--sway/input/switch.c20
-rw-r--r--sway/input/tablet.c6
-rw-r--r--sway/input/text_input.c2
-rw-r--r--sway/ipc-json.c5
-rw-r--r--sway/main.c58
-rw-r--r--sway/meson.build3
-rw-r--r--sway/server.c7
-rw-r--r--sway/sway.5.scd10
-rw-r--r--sway/tree/arrange.c25
-rw-r--r--sway/tree/container.c26
-rw-r--r--sway/tree/output.c8
-rw-r--r--sway/tree/root.c2
-rw-r--r--sway/tree/view.c1
34 files changed, 413 insertions, 331 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index 25be415e..26c99e63 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -47,7 +47,7 @@ static bool binding_switch_compare(struct sway_switch_binding *binding_a,
if (binding_a->type != binding_b->type) {
return false;
}
- if (binding_a->state != binding_b->state) {
+ if (binding_a->trigger != binding_b->trigger) {
return false;
}
if ((binding_a->flags & BINDING_LOCKED) !=
@@ -551,11 +551,11 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
"unknown switch %s)", bindtype, split->items[0]);
}
if (strcmp(split->items[1], "on") == 0) {
- binding->state = WLR_SWITCH_STATE_ON;
+ binding->trigger = SWAY_SWITCH_TRIGGER_ON;
} else if (strcmp(split->items[1], "off") == 0) {
- binding->state = WLR_SWITCH_STATE_OFF;
+ binding->trigger = SWAY_SWITCH_TRIGGER_OFF;
} else if (strcmp(split->items[1], "toggle") == 0) {
- binding->state = WLR_SWITCH_STATE_TOGGLE;
+ binding->trigger = SWAY_SWITCH_TRIGGER_TOGGLE;
} else {
free_switch_binding(binding);
return cmd_results_new(CMD_FAILURE,
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index b8d28480..facd82de 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -54,7 +54,7 @@ static bool get_direction_from_next_prev(struct sway_container *container,
} else {
return false;
}
-
+
return true;
}
@@ -285,7 +285,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws,
}
} else {
return cmd_results_new(CMD_FAILURE,
- "Failed to find a %s container in workspace",
+ "Failed to find a %s container in workspace.",
floating ? "floating" : "tiling");
}
return cmd_results_new(CMD_SUCCESS, NULL);
@@ -295,7 +295,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
int argc, char **argv) {
if (!argc) {
return cmd_results_new(CMD_INVALID,
- "Expected 'focus output <direction|name>'");
+ "Expected 'focus output <direction|name>'.");
}
char *identifier = join_args(argv, argc);
struct sway_output *output = output_by_name_or_id(identifier);
@@ -305,13 +305,13 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
if (!parse_direction(identifier, &direction)) {
free(identifier);
return cmd_results_new(CMD_INVALID,
- "There is no output with that name");
+ "There is no output with that name.");
}
struct sway_workspace *ws = seat_get_focused_workspace(seat);
if (!ws) {
free(identifier);
return cmd_results_new(CMD_FAILURE,
- "No focused workspace to base directions off of");
+ "No focused workspace to base directions off of.");
}
output = output_get_in_direction(ws->output, direction);
@@ -375,10 +375,14 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
struct sway_seat *seat = config->handler_context.seat;
if (node->type < N_WORKSPACE) {
return cmd_results_new(CMD_FAILURE,
- "Command 'focus' cannot be used above the workspace level");
+ "Command 'focus' cannot be used above the workspace level.");
}
- if (argc == 0 && container) {
+ if (argc == 0) {
+ if (!container) {
+ return cmd_results_new(CMD_FAILURE, "No container to focus was specified.");
+ }
+
if (container_is_scratchpad_hidden_or_child(container)) {
root_scratchpad_show(container);
}
diff --git a/sway/commands/input/xkb_switch_layout.c b/sway/commands/input/xkb_switch_layout.c
index d6548a68..3be37daf 100644
--- a/sway/commands/input/xkb_switch_layout.c
+++ b/sway/commands/input/xkb_switch_layout.c
@@ -1,5 +1,6 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
+#include <wlr/interfaces/wlr_keyboard.h>
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/input-manager.h"
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 1a05a7a6..0d0d9727 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -788,15 +788,15 @@ static struct cmd_results *cmd_move_to_position_pointer(
struct wlr_output *output = wlr_output_layout_output_at(
root->output_layout, cursor->x, cursor->y);
if (output) {
- struct wlr_box *box =
- wlr_output_layout_get_box(root->output_layout, output);
- lx = fmax(lx, box->x);
- ly = fmax(ly, box->y);
- if (lx + container->pending.width > box->x + box->width) {
- lx = box->x + box->width - container->pending.width;
+ struct wlr_box box;
+ wlr_output_layout_get_box(root->output_layout, output, &box);
+ lx = fmax(lx, box.x);
+ ly = fmax(ly, box.y);
+ if (lx + container->pending.width > box.x + box.width) {
+ lx = box.x + box.width - container->pending.width;
}
- if (ly + container->pending.height > box->y + box->height) {
- ly = box->y + box->height - container->pending.height;
+ if (ly + container->pending.height > box.y + box.height) {
+ ly = box.y + box.height - container->pending.height;
}
}
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c
index 68ee9fe1..67f212ff 100644
--- a/sway/commands/output/background.c
+++ b/sway/commands/output/background.c
@@ -102,19 +102,19 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
}
char *conf_path = dirname(conf);
- char *rel_path = src;
- src = malloc(strlen(conf_path) + strlen(src) + 2);
- if (!src) {
- free(rel_path);
+ char *real_src = malloc(strlen(conf_path) + strlen(src) + 2);
+ if (!real_src) {
+ free(src);
free(conf);
sway_log(SWAY_ERROR, "Unable to allocate memory");
return cmd_results_new(CMD_FAILURE,
"Unable to allocate resources");
}
- sprintf(src, "%s/%s", conf_path, rel_path);
- free(rel_path);
+ snprintf(real_src, strlen(conf_path) + strlen(src) + 2, "%s/%s", conf_path, src);
+ free(src);
free(conf);
+ src = real_src;
}
bool can_access = access(src, F_OK) != -1;
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c
index 749235eb..504a9f5e 100644
--- a/sway/commands/seat/cursor.c
+++ b/sway/commands/seat/cursor.c
@@ -111,8 +111,8 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor,
: WLR_AXIS_ORIENTATION_HORIZONTAL;
double delta = (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_LEFT)
? -1 : 1;
- struct wlr_event_pointer_axis event = {
- .device = NULL,
+ struct wlr_pointer_axis_event event = {
+ .pointer = NULL,
.time_msec = 0,
.source = WLR_AXIS_SOURCE_WHEEL,
.orientation = orientation,
diff --git a/sway/config/output.c b/sway/config/output.c
index fa509252..88514ac0 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -546,12 +546,12 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
}
// Update output->{lx, ly, width, height}
- struct wlr_box *output_box =
- wlr_output_layout_get_box(root->output_layout, wlr_output);
- output->lx = output_box->x;
- output->ly = output_box->y;
- output->width = output_box->width;
- output->height = output_box->height;
+ struct wlr_box output_box;
+ wlr_output_layout_get_box(root->output_layout, wlr_output, &output_box);
+ output->lx = output_box.x;
+ output->ly = output_box.y;
+ output->width = output_box.width;
+ output->height = output_box.height;
if (!output->enabled) {
output_enable(output);
diff --git a/sway/criteria.c b/sway/criteria.c
index d2a5566f..94751c5f 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -3,7 +3,8 @@
#include <stdio.h>
#include <stdbool.h>
#include <strings.h>
-#include <pcre.h>
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
#include "sway/criteria.h"
#include "sway/tree/container.h"
#include "sway/config.h"
@@ -40,17 +41,19 @@ bool criteria_is_empty(struct criteria *criteria) {
char *error = NULL;
// Returns error string on failure or NULL otherwise.
-static bool generate_regex(pcre **regex, char *value) {
- const char *reg_err;
- int offset;
-
- *regex = pcre_compile(value, PCRE_UTF8 | PCRE_UCP, &reg_err, &offset, NULL);
+static bool generate_regex(pcre2_code **regex, char *value) {
+ int errorcode;
+ PCRE2_SIZE offset;
+ *regex = pcre2_compile((PCRE2_SPTR)value, PCRE2_ZERO_TERMINATED, PCRE2_UTF | PCRE2_UCP, &errorcode, &offset, NULL);
if (!*regex) {
+ PCRE2_UCHAR buffer[256];
+ pcre2_get_error_message(errorcode, buffer, sizeof(buffer));
+
const char *fmt = "Regex compilation for '%s' failed: %s";
- int len = strlen(fmt) + strlen(value) + strlen(reg_err) - 3;
+ int len = strlen(fmt) + strlen(value) + strlen((char*) buffer) - 3;
error = malloc(len);
- snprintf(error, len, fmt, value, reg_err);
+ snprintf(error, len, fmt, value, buffer);
return false;
}
@@ -66,7 +69,7 @@ static bool pattern_create(struct pattern **pattern, char *value) {
if (strcmp(value, "__focused__") == 0) {
(*pattern)->match_type = PATTERN_FOCUSED;
} else {
- (*pattern)->match_type = PATTERN_PCRE;
+ (*pattern)->match_type = PATTERN_PCRE2;
if (!generate_regex(&(*pattern)->regex, value)) {
return false;
};
@@ -77,7 +80,7 @@ static bool pattern_create(struct pattern **pattern, char *value) {
static void pattern_destroy(struct pattern *pattern) {
if (pattern) {
if (pattern->regex) {
- pcre_free(pattern->regex);
+ pcre2_code_free(pattern->regex);
}
free(pattern);
}
@@ -99,8 +102,11 @@ void criteria_destroy(struct criteria *criteria) {
free(criteria);
}
-static int regex_cmp(const char *item, const pcre *regex) {
- return pcre_exec(regex, NULL, item, strlen(item), 0, 0, NULL, 0);
+static int regex_cmp(const char *item, const pcre2_code *regex) {
+ pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(regex, NULL);
+ int result = pcre2_match(regex, (PCRE2_SPTR)item, strlen(item), 0, 0, match_data, NULL);
+ pcre2_match_data_free(match_data);
+ return result;
}
#if HAVE_XWAYLAND
@@ -155,7 +161,7 @@ static bool criteria_matches_container(struct criteria *criteria,
bool exists = false;
struct sway_container *con = container;
for (int i = 0; i < con->marks->length; ++i) {
- if (regex_cmp(con->marks->items[i], criteria->con_mark->regex) == 0) {
+ if (regex_cmp(con->marks->items[i], criteria->con_mark->regex) >= 0) {
exists = true;
break;
}
@@ -192,8 +198,8 @@ static bool criteria_matches_view(struct criteria *criteria,
return false;
}
break;
- case PATTERN_PCRE:
- if (regex_cmp(title, criteria->title->regex) != 0) {
+ case PATTERN_PCRE2:
+ if (regex_cmp(title, criteria->title->regex) < 0) {
return false;
}
break;
@@ -212,8 +218,8 @@ static bool criteria_matches_view(struct criteria *criteria,
return false;
}
break;
- case PATTERN_PCRE:
- if (regex_cmp(shell, criteria->shell->regex) != 0) {
+ case PATTERN_PCRE2:
+ if (regex_cmp(shell, criteria->shell->regex) < 0) {
return false;
}
break;
@@ -232,8 +238,8 @@ static bool criteria_matches_view(struct criteria *criteria,
return false;
}
break;
- case PATTERN_PCRE:
- if (regex_cmp(app_id, criteria->app_id->regex) != 0) {
+ case PATTERN_PCRE2:
+ if (regex_cmp(app_id, criteria->app_id->regex) < 0) {
return false;
}
break;
@@ -264,8 +270,8 @@ static bool criteria_matches_view(struct criteria *criteria,
return false;
}
break;
- case PATTERN_PCRE:
- if (regex_cmp(class, criteria->class->regex) != 0) {
+ case PATTERN_PCRE2:
+ if (regex_cmp(class, criteria->class->regex) < 0) {
return false;
}
break;
@@ -284,8 +290,8 @@ static bool criteria_matches_view(struct criteria *criteria,
return false;
}
break;
- case PATTERN_PCRE:
- if (regex_cmp(instance, criteria->instance->regex) != 0) {
+ case PATTERN_PCRE2:
+ if (regex_cmp(instance, criteria->instance->regex) < 0) {
return false;
}
break;
@@ -304,8 +310,8 @@ static bool criteria_matches_view(struct criteria *criteria,
return false;
}
break;
- case PATTERN_PCRE:
- if (regex_cmp(window_role, criteria->window_role->regex) != 0) {
+ case PATTERN_PCRE2:
+ if (regex_cmp(window_role, criteria->window_role->regex) < 0) {
return false;
}
break;
@@ -363,8 +369,8 @@ static bool criteria_matches_view(struct criteria *criteria,
return false;
}
break;
- case PATTERN_PCRE:
- if (regex_cmp(ws->name, criteria->workspace->regex) != 0) {
+ case PATTERN_PCRE2:
+ if (regex_cmp(ws->name, criteria->workspace->regex) < 0) {
return false;
}
break;
diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c
index ec45d80a..c8d4502c 100644
--- a/sway/desktop/desktop.c
+++ b/sway/desktop/desktop.c
@@ -6,10 +6,11 @@ void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
- struct wlr_box *output_box = wlr_output_layout_get_box(
- root->output_layout, output->wlr_output);
- output_damage_surface(output, lx - output_box->x,
- ly - output_box->y, surface, whole);
+ struct wlr_box output_box;
+ wlr_output_layout_get_box(root->output_layout,
+ output->wlr_output, &output_box);
+ output_damage_surface(output, lx - output_box.x,
+ ly - output_box.y, surface, whole);
}
}
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 27e457f1..159f3336 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -5,6 +5,7 @@
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output.h>
+#include <wlr/types/wlr_subcompositor.h>
#include "log.h"
#include "sway/desktop/transaction.h"
#include "sway/input/cursor.h"
@@ -270,10 +271,6 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) {
wl_resource_get_client(sway_layer->layer_surface->resource);
bool set_focus = seat->exclusive_client == client;
- wl_list_remove(&sway_layer->output_destroy.link);
- wl_list_remove(&sway_layer->link);
- wl_list_init(&sway_layer->link);
-
if (set_focus) {
struct sway_layer_surface *layer =
find_mapped_layer_by_client(client, sway_layer->layer_surface->output);
@@ -282,7 +279,6 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) {
}
}
- sway_layer->layer_surface->output = NULL;
wlr_layer_surface_v1_destroy(sway_layer->layer_surface);
}
@@ -291,10 +287,7 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
wl_container_of(listener, layer, surface_commit);
struct wlr_layer_surface_v1 *layer_surface = layer->layer_surface;
struct wlr_output *wlr_output = layer_surface->output;
- if (wlr_output == NULL) {
- return;
- }
-
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
struct sway_output *output = wlr_output->data;
struct wlr_box old_extent = layer->extent;
@@ -341,13 +334,8 @@ static void unmap(struct sway_layer_surface *sway_layer) {
cursor_rebase_all();
struct wlr_output *wlr_output = sway_layer->layer_surface->output;
- if (wlr_output == NULL) {
- return;
- }
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
struct sway_output *output = wlr_output->data;
- if (output == NULL) {
- return;
- }
output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
sway_layer->layer_surface->surface, true);
}
@@ -375,22 +363,24 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&sway_layer->surface_commit.link);
wl_list_remove(&sway_layer->new_popup.link);
wl_list_remove(&sway_layer->new_subsurface.link);
- if (sway_layer->layer_surface->output != NULL) {
- struct sway_output *output = sway_layer->layer_surface->output->data;
- if (output != NULL) {
- arrange_layers(output);
- transaction_commit_dirty();
- }
- wl_list_remove(&sway_layer->output_destroy.link);
- sway_layer->layer_surface->output = NULL;
- }
+
+ struct wlr_output *wlr_output = sway_layer->layer_surface->output;
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
+ struct sway_output *output = wlr_output->data;
+ arrange_layers(output);
+ transaction_commit_dirty();
+ wl_list_remove(&sway_layer->output_destroy.link);
+ sway_layer->layer_surface->output = NULL;
+
free(sway_layer);
}
static void handle_map(struct wl_listener *listener, void *data) {
struct sway_layer_surface *sway_layer = wl_container_of(listener,
sway_layer, map);
- struct sway_output *output = sway_layer->layer_surface->output->data;
+ struct wlr_output *wlr_output = sway_layer->layer_surface->output;
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
+ struct sway_output *output = wlr_output->data;
output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
sway_layer->layer_surface->surface, true);
wlr_surface_send_enter(sway_layer->layer_surface->surface,
@@ -408,9 +398,7 @@ static void subsurface_damage(struct sway_layer_subsurface *subsurface,
bool whole) {
struct sway_layer_surface *layer = subsurface->layer_surface;
struct wlr_output *wlr_output = layer->layer_surface->output;
- if (!wlr_output) {
- return;
- }
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
struct sway_output *output = wlr_output->data;
int ox = subsurface->wlr_subsurface->current.x + layer->geo.x;
int oy = subsurface->wlr_subsurface->current.y + layer->geo.y;
@@ -513,6 +501,7 @@ static void popup_damage(struct sway_layer_popup *layer_popup, bool whole) {
}
}
struct wlr_output *wlr_output = layer->layer_surface->output;
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
struct sway_output *output = wlr_output->data;
output_damage_surface(output, ox, oy, surface, whole);
}
@@ -521,6 +510,7 @@ static void popup_handle_map(struct wl_listener *listener, void *data) {
struct sway_layer_popup *popup = wl_container_of(listener, popup, map);
struct sway_layer_surface *layer = popup_get_layer(popup);
struct wlr_output *wlr_output = layer->layer_surface->output;
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
wlr_surface_send_enter(popup->wlr_popup->base->surface, wlr_output);
popup_damage(popup, true);
}
@@ -550,7 +540,9 @@ static void popup_unconstrain(struct sway_layer_popup *popup) {
struct sway_layer_surface *layer = popup_get_layer(popup);
struct wlr_xdg_popup *wlr_popup = popup->wlr_popup;
- struct sway_output *output = layer->layer_surface->output->data;
+ struct wlr_output *wlr_output = layer->layer_surface->output;
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
+ struct sway_output *output = wlr_output->data;
// the output box expressed in the coordinate system of the toplevel parent
// of the popup
@@ -642,6 +634,10 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
sway_log(SWAY_ERROR,
"no output to auto-assign layer surface '%s' to",
layer_surface->namespace);
+ // Note that layer_surface->output can be NULL
+ // here, but none of our destroy callbacks are
+ // registered yet so we don't have to make them
+ // handle that case.
wlr_layer_surface_v1_destroy(layer_surface);
return;
}
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 68f095c0..dd2eaf08 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -14,7 +14,7 @@
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.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 "config.h"
#include "log.h"
@@ -737,14 +737,15 @@ static void update_output_manager_config(struct sway_server *server) {
}
struct wlr_output_configuration_head_v1 *config_head =
wlr_output_configuration_head_v1_create(config, output->wlr_output);
- struct wlr_box *output_box = wlr_output_layout_get_box(
- root->output_layout, output->wlr_output);
+ struct wlr_box output_box;
+ wlr_output_layout_get_box(root->output_layout,
+ output->wlr_output, &output_box);
// We mark the output enabled even if it is switched off by DPMS
config_head->state.enabled = output->current_mode != NULL && output->enabled;
config_head->state.mode = output->current_mode;
- if (output_box) {
- config_head->state.x = output_box->x;
- config_head->state.y = output_box->y;
+ if (!wlr_box_empty(&output_box)) {
+ config_head->state.x = output_box.x;
+ config_head->state.y = output_box.y;
}
}
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index c088c936..02397c05 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -12,7 +12,7 @@
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output_layout.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 "log.h"
#include "config.h"
diff --git a/sway/desktop/surface.c b/sway/desktop/surface.c
index 767b2045..1d7b536d 100644
--- a/sway/desktop/surface.c
+++ b/sway/desktop/surface.c
@@ -1,7 +1,7 @@
#define _POSIX_C_SOURCE 200112L
#include <stdlib.h>
#include <time.h>
-#include <wlr/types/wlr_surface.h>
+#include <wlr/types/wlr_compositor.h>
#include "sway/server.h"
#include "sway/surface.h"
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 5fae8296..51168f4c 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -24,11 +24,11 @@ static const struct sway_view_child_impl popup_impl;
static void popup_get_view_coords(struct sway_view_child *child,
int *sx, int *sy) {
struct sway_xdg_popup *popup = (struct sway_xdg_popup *)child;
- struct wlr_xdg_surface *surface = popup->wlr_xdg_surface;
+ struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_popup;
- wlr_xdg_popup_get_toplevel_coords(surface->popup,
- surface->popup->geometry.x - surface->current.geometry.x,
- surface->popup->geometry.y - surface->current.geometry.y,
+ wlr_xdg_popup_get_toplevel_coords(wlr_popup,
+ wlr_popup->geometry.x - wlr_popup->base->current.geometry.x,
+ wlr_popup->geometry.y - wlr_popup->base->current.geometry.y,
sx, sy);
}
@@ -65,7 +65,7 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
static void popup_unconstrain(struct sway_xdg_popup *popup) {
struct sway_view *view = popup->child.view;
- struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup;
+ struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_popup;
struct sway_output *output = view->container->pending.workspace->output;
@@ -91,7 +91,7 @@ static struct sway_xdg_popup *popup_create(
return NULL;
}
view_child_init(&popup->child, &popup_impl, view, xdg_surface->surface);
- popup->wlr_xdg_surface = xdg_surface;
+ popup->wlr_xdg_popup = xdg_surface->popup;
wl_signal_add(&xdg_surface->events.new_popup, &popup->new_popup);
popup->new_popup.notify = popup_handle_new_popup;
@@ -119,7 +119,7 @@ static struct sway_xdg_shell_view *xdg_shell_view_from_view(
static void get_constraints(struct sway_view *view, double *min_width,
double *max_width, double *min_height, double *max_height) {
struct wlr_xdg_toplevel_state *state =
- &view->wlr_xdg_surface->toplevel->current;
+ &view->wlr_xdg_toplevel->current;
*min_width = state->min_width > 0 ? state->min_width : DBL_MIN;
*max_width = state->max_width > 0 ? state->max_width : DBL_MAX;
*min_height = state->min_height > 0 ? state->min_height : DBL_MIN;
@@ -133,9 +133,9 @@ static const char *get_string_prop(struct sway_view *view,
}
switch (prop) {
case VIEW_PROP_TITLE:
- return view->wlr_xdg_surface->toplevel->title;
+ return view->wlr_xdg_toplevel->title;
case VIEW_PROP_APP_ID:
- return view->wlr_xdg_surface->toplevel->app_id;
+ return view->wlr_xdg_toplevel->app_id;
default:
return NULL;
}
@@ -148,50 +148,45 @@ static uint32_t configure(struct sway_view *view, double lx, double ly,
if (xdg_shell_view == NULL) {
return 0;
}
- return wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
+ return wlr_xdg_toplevel_set_size(view->wlr_xdg_toplevel,
+ width, height);
}
static void set_activated(struct sway_view *view, bool activated) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
- struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
- if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
- wlr_xdg_toplevel_set_activated(surface, activated);
- }
+ wlr_xdg_toplevel_set_activated(view->wlr_xdg_toplevel, activated);
}
static void set_tiled(struct sway_view *view, bool tiled) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
- struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
enum wlr_edges edges = WLR_EDGE_NONE;
if (tiled) {
edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP |
WLR_EDGE_BOTTOM;
}
- wlr_xdg_toplevel_set_tiled(surface, edges);
+ wlr_xdg_toplevel_set_tiled(view->wlr_xdg_toplevel, edges);
}
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
- struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
- wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
+ wlr_xdg_toplevel_set_fullscreen(view->wlr_xdg_toplevel, fullscreen);
}
static void set_resizing(struct sway_view *view, bool resizing) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
- struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
- wlr_xdg_toplevel_set_resizing(surface, resizing);
+ wlr_xdg_toplevel_set_resizing(view->wlr_xdg_toplevel, resizing);
}
static bool wants_floating(struct sway_view *view) {
- struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_surface->toplevel;
+ struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_toplevel;
struct wlr_xdg_toplevel_state *state = &toplevel->current;
return (state->min_width != 0 && state->min_height != 0
&& (state->min_width == state->max_width
@@ -204,7 +199,7 @@ static void for_each_surface(struct sway_view *view,
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
- wlr_xdg_surface_for_each_surface(view->wlr_xdg_surface, iterator,
+ wlr_xdg_surface_for_each_surface(view->wlr_xdg_toplevel->base, iterator,
user_data);
}
@@ -213,8 +208,8 @@ static void for_each_popup_surface(struct sway_view *view,
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
- wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_surface, iterator,
- user_data);
+ wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_toplevel->base,
+ iterator, user_data);
}
static bool is_transient_for(struct sway_view *child,
@@ -222,12 +217,12 @@ static bool is_transient_for(struct sway_view *child,
if (xdg_shell_view_from_view(child) == NULL) {
return false;
}
- struct wlr_xdg_surface *surface = child->wlr_xdg_surface;
- while (surface && surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
- if (surface->toplevel->parent == ancestor->wlr_xdg_surface) {
+ struct wlr_xdg_toplevel *toplevel = child->wlr_xdg_toplevel;
+ while (toplevel) {
+ if (toplevel->parent == ancestor->wlr_xdg_toplevel) {
return true;
}
- surface = surface->toplevel->parent;
+ toplevel = toplevel->parent;
}
return false;
}
@@ -236,17 +231,13 @@ static void _close(struct sway_view *view) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
- struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
- if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL
- && surface->toplevel) {
- wlr_xdg_toplevel_send_close(surface);
- }
+ wlr_xdg_toplevel_send_close(view->wlr_xdg_toplevel);
}
static void close_popups(struct sway_view *view) {
struct wlr_xdg_popup *popup, *tmp;
- wl_list_for_each_safe(popup, tmp, &view->wlr_xdg_surface->popups, link) {
- wlr_xdg_popup_destroy(popup->base);
+ wl_list_for_each_safe(popup, tmp, &view->wlr_xdg_toplevel->base->popups, link) {
+ wlr_xdg_popup_destroy(popup);
}
}
@@ -280,7 +271,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
struct sway_xdg_shell_view *xdg_shell_view =
wl_container_of(listener, xdg_shell_view, commit);
struct sway_view *view = &xdg_shell_view->view;
- struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
+ struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_toplevel->base;
struct wlr_box new_geo;
wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
@@ -337,23 +328,17 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
struct sway_xdg_shell_view *xdg_shell_view =
wl_container_of(listener, xdg_shell_view, request_fullscreen);
- struct wlr_xdg_toplevel_set_fullscreen_event *e = data;
- struct wlr_xdg_surface *xdg_surface =
- xdg_shell_view->view.wlr_xdg_surface;
+ struct wlr_xdg_toplevel *toplevel = xdg_shell_view->view.wlr_xdg_toplevel;
struct sway_view *view = &xdg_shell_view->view;
- if (!sway_assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL,
- "xdg_shell requested fullscreen of surface with role %i",
- xdg_surface->role)) {
- return;
- }
- if (!xdg_surface->mapped) {
+ if (!toplevel->base->mapped) {
return;
}
struct sway_container *container = view->container;
- if (e->fullscreen && e->output && e->output->data) {
- struct sway_output *output = e->output->data;
+ struct wlr_xdg_toplevel_requested *req = &toplevel->requested;
+ if (req->fullscreen && req->fullscreen_output && req->fullscreen_output->data) {
+ struct sway_output *output = req->fullscreen_output->data;
struct sway_workspace *ws = output_get_active_workspace(output);
if (ws && !container_is_scratchpad_hidden(container) &&
container->pending.workspace != ws) {
@@ -365,7 +350,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
}
}
- container_set_fullscreen(container, e->fullscreen);
+ container_set_fullscreen(container, req->fullscreen);
arrange_root();
transaction_commit_dirty();
@@ -375,7 +360,8 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
struct sway_xdg_shell_view *xdg_shell_view =
wl_container_of(listener, xdg_shell_view, request_move);
struct sway_view *view = &xdg_shell_view->view;
- if (!container_is_floating(view->container)) {
+ if (!container_is_floating(view->container) ||
+ view->container->pending.fullscreen_mode) {
return;
}
struct wlr_xdg_toplevel_move_event *e = data;
@@ -423,13 +409,13 @@ static void handle_map(struct wl_listener *listener, void *data) {
struct sway_xdg_shell_view *xdg_shell_view =
wl_container_of(listener, xdg_shell_view, map);
struct sway_view *view = &xdg_shell_view->view;
- struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
+ struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_toplevel;
- view->natural_width = view->wlr_xdg_surface->current.geometry.width;
- view->natural_height = view->wlr_xdg_surface->current.geometry.height;
+ view->natural_width = toplevel->base->current.geometry.width;
+ view->natural_height = toplevel->base->current.geometry.height;
if (!view->natural_width && !view->natural_height) {
- view->natural_width = view->wlr_xdg_surface->surface->current.width;
- view->natural_height = view->wlr_xdg_surface->surface->current.height;
+ view->natural_width = toplevel->base->surface->current.width;
+ view->natural_height = toplevel->base->surface->current.height;
}
bool csd = false;
@@ -440,44 +426,44 @@ static void handle_map(struct wl_listener *listener, void *data) {
csd = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
} else {
struct sway_server_decoration *deco =
- decoration_from_surface(xdg_surface->surface);
+ decoration_from_surface(toplevel->base->surface);
csd = !deco || deco->wlr_server_decoration->mode ==
WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
}
- view_map(view, view->wlr_xdg_surface->surface,
- xdg_surface->toplevel->requested.fullscreen,
- xdg_surface->toplevel->requested.fullscreen_output,
+ view_map(view, toplevel->base->surface,
+ toplevel->requested.fullscreen,
+ toplevel->requested.fullscreen_output,
csd);
transaction_commit_dirty();
xdg_shell_view->commit.notify = handle_commit;
- wl_signal_add(&xdg_surface->surface->events.commit,
+ wl_signal_add(&toplevel->base->surface->events.commit,
&xdg_shell_view->commit);
xdg_shell_view->new_popup.notify = handle_new_popup;
- wl_signal_add(&xdg_surface->events.new_popup,
+ wl_signal_add(&toplevel->base->events.new_popup,
&xdg_shell_view->new_popup);
xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen;
- wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen,
+ wl_signal_add(&toplevel->events.request_fullscreen,
&xdg_shell_view->request_fullscreen);
xdg_shell_view->request_move.notify = handle_request_move;
- wl_signal_add(&xdg_surface->toplevel->events.request_move,
+ wl_signal_add(&toplevel->events.request_move,
&xdg_shell_view->request_move);
xdg_shell_view->request_resize.notify = handle_request_resize;
- wl_signal_add(&xdg_surface->toplevel->events.request_resize,
+ wl_signal_add(&toplevel->events.request_resize,
&xdg_shell_view->request_resize);
xdg_shell_view->set_title.notify = handle_set_title;
- wl_signal_add(&xdg_surface->toplevel->events.set_title,
+ wl_signal_add(&toplevel->events.set_title,
&xdg_shell_view->set_title);
xdg_shell_view->set_app_id.notify = handle_set_app_id;
- wl_signal_add(&xdg_surface->toplevel->events.set_app_id,
+ wl_signal_add(&toplevel->events.set_app_id,
&xdg_shell_view->set_app_id);
}
@@ -491,7 +477,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&xdg_shell_view->destroy.link);
wl_list_remove(&xdg_shell_view->map.link);
wl_list_remove(&xdg_shell_view->unmap.link);
- view->wlr_xdg_surface = NULL;
+ view->wlr_xdg_toplevel = NULL;
if (view->xdg_decoration) {
view->xdg_decoration->view = NULL;
}
@@ -522,7 +508,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
}
view_init(&xdg_shell_view->view, SWAY_VIEW_XDG_SHELL, &view_impl);
- xdg_shell_view->view.wlr_xdg_surface = xdg_surface;
+ xdg_shell_view->view.wlr_xdg_toplevel = xdg_surface->toplevel;
xdg_shell_view->map.notify = handle_map;
wl_signal_add(&xdg_surface->events.map, &xdg_shell_view->map);
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 40288f97..7c5dde53 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -6,6 +6,7 @@
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
#include <wlr/xwayland.h>
+#include <xcb/xcb_icccm.h>
#include "log.h"
#include "sway/desktop.h"
#include "sway/desktop/transaction.h"
@@ -121,6 +122,20 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
}
}
+static void unmanaged_handle_request_activate(struct wl_listener *listener, void *data) {
+ struct wlr_xwayland_surface *xsurface = data;
+ if (!xsurface->mapped) {
+ return;
+ }
+ struct sway_seat *seat = input_manager_current_seat();
+ struct sway_container *focus = seat_get_focused_container(seat);
+ if (focus && focus->view && focus->view->pid != xsurface->pid) {
+ return;
+ }
+
+ seat_set_focus_surface(seat, xsurface->surface, false);
+}
+
static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
struct sway_xwayland_unmanaged *surface =
wl_container_of(listener, surface, destroy);
@@ -129,6 +144,7 @@ static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&surface->unmap.link);
wl_list_remove(&surface->destroy.link);
wl_list_remove(&surface->override_redirect.link);
+ wl_list_remove(&surface->request_activate.link);
free(surface);
}
@@ -176,6 +192,8 @@ static struct sway_xwayland_unmanaged *create_unmanaged(
surface->destroy.notify = unmanaged_handle_destroy;
wl_signal_add(&xsurface->events.set_override_redirect, &surface->override_redirect);
surface->override_redirect.notify = unmanaged_handle_override_redirect;
+ wl_signal_add(&xsurface->events.request_activate, &surface->request_activate);
+ surface->request_activate.notify = unmanaged_handle_request_activate;
return surface;
}
@@ -294,7 +312,7 @@ static bool wants_floating(struct sway_view *view) {
}
}
- struct wlr_xwayland_surface_size_hints *size_hints = surface->size_hints;
+ xcb_size_hints_t *size_hints = surface->size_hints;
if (size_hints != NULL &&
size_hints->min_width > 0 && size_hints->min_height > 0 &&
(size_hints->max_width == size_hints->min_width ||
@@ -348,7 +366,7 @@ static void destroy(struct sway_view *view) {
static void get_constraints(struct sway_view *view, double *min_width,
double *max_width, double *min_height, double *max_height) {
struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
- struct wlr_xwayland_surface_size_hints *size_hints = surface->size_hints;
+ xcb_size_hints_t *size_hints = surface->size_hints;
if (size_hints == NULL) {
*min_width = DBL_MIN;
@@ -577,7 +595,8 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
if (!xsurface->mapped) {
return;
}
- if (!container_is_floating(view->container)) {
+ if (!container_is_floating(view->container) ||
+ view->container->pending.fullscreen_mode) {
return;
}
struct sway_seat *seat = input_manager_current_seat();
@@ -666,14 +685,15 @@ static void handle_set_hints(struct wl_listener *listener, void *data) {
if (!xsurface->mapped) {
return;
}
- if (!xsurface->hints_urgency && view->urgent_timer) {
+ const bool hints_urgency = xcb_icccm_wm_hints_get_urgency(xsurface->hints);
+ if (!hints_urgency && view->urgent_timer) {
// The view is in the timeout period. We'll ignore the request to
// unset urgency so that the view remains urgent until the timer clears
// it.
return;
}
if (view->allow_request_urgent) {
- view_set_urgent(view, (bool)xsurface->hints_urgency);
+ view_set_urgent(view, hints_urgency);
}
}
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 6fddee90..0b2f03a2 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -386,28 +386,29 @@ static void pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
static void handle_pointer_motion_relative(
struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, motion);
- struct wlr_event_pointer_motion *e = data;
- cursor_handle_activity_from_device(cursor, e->device);
+ struct wlr_pointer_motion_event *e = data;
+ cursor_handle_activity_from_device(cursor, &e->pointer->base);
- pointer_motion(cursor, e->time_msec, e->device, e->delta_x, e->delta_y,
- e->unaccel_dx, e->unaccel_dy);
+ pointer_motion(cursor, e->time_msec, &e->pointer->base, e->delta_x,
+ e->delta_y, e->unaccel_dx, e->unaccel_dy);
}
static void handle_pointer_motion_absolute(
struct wl_listener *listener, void *data) {
struct sway_cursor *cursor =
wl_container_of(listener, cursor, motion_absolute);
- struct wlr_event_pointer_motion_absolute *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_motion_absolute_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
double lx, ly;
- wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
+ wlr_cursor_absolute_to_layout_coords(cursor->cursor, &event->pointer->base,
event->x, event->y, &lx, &ly);
double dx = lx - cursor->cursor->x;
double dy = ly - cursor->cursor->y;
- pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy);
+ pointer_motion(cursor, event->time_msec, &event->pointer->base, dx, dy,
+ dx, dy);
}
void dispatch_cursor_button(struct sway_cursor *cursor,
@@ -422,7 +423,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
static void handle_pointer_button(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, button);
- struct wlr_event_pointer_button *event = data;
+ struct wlr_pointer_button_event *event = data;
if (event->state == WLR_BUTTON_PRESSED) {
cursor->pressed_button_count++;
@@ -434,20 +435,20 @@ static void handle_pointer_button(struct wl_listener *listener, void *data) {
}
}
- cursor_handle_activity_from_device(cursor, event->device);
- dispatch_cursor_button(cursor, event->device,
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
+ dispatch_cursor_button(cursor, &event->pointer->base,
event->time_msec, event->button, event->state);
}
void dispatch_cursor_axis(struct sway_cursor *cursor,
- struct wlr_event_pointer_axis *event) {
+ struct wlr_pointer_axis_event *event) {
seatop_pointer_axis(cursor->seat, event);
}
static void handle_pointer_axis(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
- struct wlr_event_pointer_axis *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_axis_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
dispatch_cursor_axis(cursor, event);
}
@@ -458,8 +459,8 @@ static void handle_pointer_frame(struct wl_listener *listener, void *data) {
static void handle_touch_down(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down);
- struct wlr_event_touch_down *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_touch_down_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->touch->base);
cursor_hide(cursor);
struct sway_seat *seat = cursor->seat;
@@ -467,7 +468,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
struct wlr_surface *surface = NULL;
double lx, ly;
- wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
+ wlr_cursor_absolute_to_layout_coords(cursor->cursor, &event->touch->base,
event->x, event->y, &lx, &ly);
double sx, sy;
struct sway_node *focused_node = node_at_coords(seat, lx, ly, &surface, &sx, &sy);
@@ -495,24 +496,25 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
double dx, dy;
dx = lx - cursor->cursor->x;
dy = ly - cursor->cursor->y;
- pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy);
- dispatch_cursor_button(cursor, event->device, event->time_msec,
+ pointer_motion(cursor, event->time_msec, &event->touch->base, dx, dy,
+ dx, dy);
+ dispatch_cursor_button(cursor, &event->touch->base, event->time_msec,
BTN_LEFT, WLR_BUTTON_PRESSED);
}
}
static void handle_touch_up(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up);
- struct wlr_event_touch_up *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_touch_up_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->touch->base);
struct wlr_seat *wlr_seat = cursor->seat->wlr_seat;
if (cursor->simulating_pointer_from_touch) {
if (cursor->pointer_touch_id == cursor->seat->touch_id) {
cursor->pointer_touch_up = true;
- dispatch_cursor_button(cursor, event->device, event->time_msec,
- BTN_LEFT, WLR_BUTTON_RELEASED);
+ dispatch_cursor_button(cursor, &event->touch->base,
+ event->time_msec, BTN_LEFT, WLR_BUTTON_RELEASED);
}
} else {
wlr_seat_touch_notify_up(wlr_seat, event->time_msec, event->touch_id);
@@ -522,15 +524,15 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
static void handle_touch_motion(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor =
wl_container_of(listener, cursor, touch_motion);
- struct wlr_event_touch_motion *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_touch_motion_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->touch->base);
struct sway_seat *seat = cursor->seat;
struct wlr_seat *wlr_seat = seat->wlr_seat;
struct wlr_surface *surface = NULL;
double lx, ly;
- wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
+ wlr_cursor_absolute_to_layout_coords(cursor->cursor, &event->touch->base,
event->x, event->y, &lx, &ly);
double sx, sy;
node_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy);
@@ -552,7 +554,8 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
double dx, dy;
dx = lx - cursor->cursor->x;
dy = ly - cursor->cursor->y;
- pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy);
+ pointer_motion(cursor, event->time_msec, &event->touch->base,
+ dx, dy, dx, dy);
}
} else if (surface) {
wlr_seat_touch_notify_motion(wlr_seat, event->time_msec,
@@ -591,14 +594,15 @@ static void apply_mapping_from_region(struct wlr_input_device *device,
double x1 = region->x1, x2 = region->x2;
double y1 = region->y1, y2 = region->y2;
- if (region->mm) {
- if (device->width_mm == 0 || device->height_mm == 0) {
+ if (region->mm && device->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
+ struct wlr_tablet *tablet = device->tablet;
+ if (tablet->width_mm == 0 || tablet->height_mm == 0) {
return;
}
- x1 /= device->width_mm;
- x2 /= device->width_mm;
- y1 /= device->height_mm;
- y2 /= device->height_mm;
+ x1 /= tablet->width_mm;
+ x2 /= tablet->width_mm;
+ y1 /= tablet->height_mm;
+ y2 /= tablet->height_mm;
}
*x = apply_mapping_from_coord(x1, x2, *x);
@@ -660,8 +664,8 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor,
static void handle_tool_axis(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis);
- struct wlr_event_tablet_tool_axis *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_tablet_tool_axis_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->tablet->base);
struct sway_tablet_tool *sway_tool = event->tool->data;
if (!sway_tool) {
@@ -716,8 +720,8 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
static void handle_tool_tip(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip);
- struct wlr_event_tablet_tool_tip *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_tablet_tool_tip_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->tablet->base);
struct sway_tablet_tool *sway_tool = event->tool->data;
struct wlr_tablet_v2_tablet *tablet_v2 = sway_tool->tablet->tablet_v2;
@@ -732,7 +736,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
if (cursor->simulating_pointer_from_tool_tip &&
event->state == WLR_TABLET_TOOL_TIP_UP) {
cursor->simulating_pointer_from_tool_tip = false;
- dispatch_cursor_button(cursor, event->device, event->time_msec,
+ dispatch_cursor_button(cursor, &event->tablet->base, event->time_msec,
BTN_LEFT, WLR_BUTTON_RELEASED);
wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
} else if (!surface || !wlr_surface_accepts_tablet_v2(tablet_v2, surface)) {
@@ -744,8 +748,8 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
WLR_TABLET_TOOL_TIP_UP);
} else {
cursor->simulating_pointer_from_tool_tip = true;
- dispatch_cursor_button(cursor, event->device, event->time_msec,
- BTN_LEFT, WLR_BUTTON_PRESSED);
+ dispatch_cursor_button(cursor, &event->tablet->base,
+ event->time_msec, BTN_LEFT, WLR_BUTTON_PRESSED);
wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
}
} else {
@@ -767,12 +771,13 @@ static struct sway_tablet *get_tablet_for_device(struct sway_cursor *cursor,
static void handle_tool_proximity(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor =
wl_container_of(listener, cursor, tool_proximity);
- struct wlr_event_tablet_tool_proximity *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_tablet_tool_proximity_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->tablet->base);
struct wlr_tablet_tool *tool = event->tool;
if (!tool->data) {
- struct sway_tablet *tablet = get_tablet_for_device(cursor, event->device);
+ struct sway_tablet *tablet = get_tablet_for_device(cursor,
+ &event->tablet->base);
if (!tablet) {
sway_log(SWAY_ERROR, "no tablet for tablet tool");
return;
@@ -797,8 +802,8 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) {
static void handle_tool_button(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button);
- struct wlr_event_tablet_tool_button *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_tablet_tool_button_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->tablet->base);
struct sway_tablet_tool *sway_tool = event->tool->data;
if (!sway_tool) {
@@ -819,14 +824,14 @@ static void handle_tool_button(struct wl_listener *listener, void *data) {
switch (event->state) {
case WLR_BUTTON_PRESSED:
if (cursor->tool_buttons == 0) {
- dispatch_cursor_button(cursor, event->device,
+ dispatch_cursor_button(cursor, &event->tablet->base,
event->time_msec, BTN_RIGHT, event->state);
}
cursor->tool_buttons++;
break;
case WLR_BUTTON_RELEASED:
if (cursor->tool_buttons == 1) {
- dispatch_cursor_button(cursor, event->device,
+ dispatch_cursor_button(cursor, &event->tablet->base,
event->time_msec, BTN_RIGHT, event->state);
}
cursor->tool_buttons--;
@@ -926,8 +931,8 @@ static void handle_request_pointer_set_cursor(struct wl_listener *listener,
static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_begin);
- struct wlr_event_pointer_pinch_begin *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_pinch_begin_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_pinch_begin(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->fingers);
@@ -936,8 +941,8 @@ static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data)
static void handle_pointer_pinch_update(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_update);
- struct wlr_event_pointer_pinch_update *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_pinch_update_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_pinch_update(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->dx, event->dy,
@@ -947,8 +952,8 @@ static void handle_pointer_pinch_update(struct wl_listener *listener, void *data
static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, pinch_end);
- struct wlr_event_pointer_pinch_end *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_pinch_end_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_pinch_end(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->cancelled);
@@ -957,8 +962,8 @@ static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) {
static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_begin);
- struct wlr_event_pointer_swipe_begin *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_swipe_begin_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_swipe_begin(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->fingers);
@@ -967,8 +972,8 @@ static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data)
static void handle_pointer_swipe_update(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_update);
- struct wlr_event_pointer_swipe_update *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_swipe_update_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_swipe_update(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->dx, event->dy);
@@ -977,13 +982,33 @@ static void handle_pointer_swipe_update(struct wl_listener *listener, void *data
static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_end);
- struct wlr_event_pointer_swipe_end *event = data;
- cursor_handle_activity_from_device(cursor, event->device);
+ struct wlr_pointer_swipe_end_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
wlr_pointer_gestures_v1_send_swipe_end(
cursor->pointer_gestures, cursor->seat->wlr_seat,
event->time_msec, event->cancelled);
}
+static void handle_pointer_hold_begin(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor = wl_container_of(
+ listener, cursor, hold_begin);
+ struct wlr_pointer_hold_begin_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
+ wlr_pointer_gestures_v1_send_hold_begin(
+ cursor->pointer_gestures, cursor->seat->wlr_seat,
+ event->time_msec, event->fingers);
+}
+
+static void handle_pointer_hold_end(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor = wl_container_of(
+ listener, cursor, hold_end);
+ struct wlr_pointer_hold_end_event *event = data;
+ cursor_handle_activity_from_device(cursor, &event->pointer->base);
+ wlr_pointer_gestures_v1_send_hold_end(
+ cursor->pointer_gestures, cursor->seat->wlr_seat,
+ event->time_msec, event->cancelled);
+}
+
static void handle_image_surface_destroy(struct wl_listener *listener,
void *data) {
struct sway_cursor *cursor =
@@ -1061,6 +1086,8 @@ void sway_cursor_destroy(struct sway_cursor *cursor) {
wl_list_remove(&cursor->swipe_begin.link);
wl_list_remove(&cursor->swipe_update.link);
wl_list_remove(&cursor->swipe_end.link);
+ wl_list_remove(&cursor->hold_begin.link);
+ wl_list_remove(&cursor->hold_end.link);
wl_list_remove(&cursor->motion.link);
wl_list_remove(&cursor->motion_absolute.link);
wl_list_remove(&cursor->button.link);
@@ -1117,6 +1144,10 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
wl_signal_add(&wlr_cursor->events.swipe_update, &cursor->swipe_update);
cursor->swipe_end.notify = handle_pointer_swipe_end;
wl_signal_add(&wlr_cursor->events.swipe_end, &cursor->swipe_end);
+ cursor->hold_begin.notify = handle_pointer_hold_begin;
+ wl_signal_add(&wlr_cursor->events.hold_begin, &cursor->hold_begin);
+ cursor->hold_end.notify = handle_pointer_hold_end;
+ wl_signal_add(&wlr_cursor->events.hold_end, &cursor->hold_end);
// input events
wl_signal_add(&wlr_cursor->events.motion, &cursor->motion);
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index f04a8ce0..8538d97c 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -377,7 +377,7 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) {
struct sway_input_manager *input_manager =
wl_container_of(listener, input_manager, virtual_keyboard_new);
struct wlr_virtual_keyboard_v1 *keyboard = data;
- struct wlr_input_device *device = &keyboard->input_device;
+ struct wlr_input_device *device = &keyboard->keyboard.base;
// TODO: Amend protocol to allow NULL seat
struct sway_seat *seat = keyboard->seat ?
@@ -410,7 +410,7 @@ void handle_virtual_pointer(struct wl_listener *listener, void *data) {
wl_container_of(listener, input_manager, virtual_pointer_new);
struct wlr_virtual_pointer_v1_new_pointer_event *event = data;
struct wlr_virtual_pointer_v1 *pointer = event->new_pointer;
- struct wlr_input_device *device = &pointer->input_device;
+ struct wlr_input_device *device = &pointer->pointer.base;
struct sway_seat *seat = event->suggested_seat ?
input_manager_sway_seat_from_wlr_seat(event->suggested_seat) :
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index f258ac7d..1aa30655 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -401,7 +401,7 @@ static struct wlr_input_method_keyboard_grab_v2 *keyboard_get_im_grab(
}
static void handle_key_event(struct sway_keyboard *keyboard,
- struct wlr_event_keyboard_key *event) {
+ struct wlr_keyboard_key_event *event) {
struct sway_seat *seat = keyboard->seat_device->sway_seat;
struct wlr_seat *wlr_seat = seat->wlr_seat;
struct wlr_input_device *wlr_device =
@@ -517,7 +517,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
&keyboard->state_pressed_sent, event->keycode,
event->state, keyinfo.keycode, 0);
if (pressed_sent) {
- wlr_seat_set_keyboard(wlr_seat, wlr_device);
+ wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
event->keycode, event->state);
handled = true;
@@ -542,7 +542,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
update_shortcut_state(
&keyboard->state_pressed_sent, event->keycode, event->state,
keyinfo.keycode, 0);
- wlr_seat_set_keyboard(wlr_seat, wlr_device);
+ wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
event->keycode, event->state);
}
@@ -670,7 +670,7 @@ static void handle_modifier_event(struct sway_keyboard *keyboard) {
&wlr_device->keyboard->modifiers);
} else {
struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat;
- wlr_seat_set_keyboard(wlr_seat, wlr_device);
+ wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
wlr_seat_keyboard_notify_modifiers(wlr_seat,
&wlr_device->keyboard->modifiers);
}
@@ -950,7 +950,7 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
goto cleanup;
}
sway_group->seat_device->input_device->wlr_device =
- sway_group->wlr_group->input_device;
+ &sway_group->wlr_group->keyboard.base;
if (!sway_keyboard_create(seat, sway_group->seat_device)) {
sway_log(SWAY_ERROR, "Failed to allocate sway_keyboard for group");
@@ -1086,7 +1086,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
}
struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat;
- wlr_seat_set_keyboard(seat, wlr_device);
+ wlr_seat_set_keyboard(seat, wlr_device->keyboard);
wl_list_remove(&keyboard->keyboard_key.link);
wl_signal_add(&wlr_device->keyboard->events.key, &keyboard->keyboard_key);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index ce933b66..85179dc7 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -11,6 +11,7 @@
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_tablet_v2.h>
+#include <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include "config.h"
#include "list.h"
@@ -42,6 +43,7 @@ static void seat_device_destroy(struct sway_seat_device *seat_device) {
sway_keyboard_destroy(seat_device->keyboard);
sway_tablet_destroy(seat_device->tablet);
sway_tablet_pad_destroy(seat_device->tablet_pad);
+ sway_switch_destroy(seat_device->switch_device);
wlr_cursor_detach_input_device(seat_device->sway_seat->cursor->cursor,
seat_device->input_device->wlr_device);
wl_list_remove(&seat_device->link);
@@ -245,7 +247,7 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) {
seat_node_destroy(seat_node);
// If an unmanaged or layer surface is focused when an output gets
// disabled and an empty workspace on the output was focused by the
- // seat, the seat needs to refocus it's focus inactive to update the
+ // seat, the seat needs to refocus its focus inactive to update the
// value of seat->workspace.
if (seat->workspace == node->sway_workspace) {
struct sway_node *node = seat_get_focus_inactive(seat, &root->node);
@@ -378,8 +380,8 @@ void drag_icon_update_position(struct sway_drag_icon *icon) {
case WLR_DRAG_GRAB_KEYBOARD:
return;
case WLR_DRAG_GRAB_KEYBOARD_POINTER:
- icon->x = cursor->x;
- icon->y = cursor->y;
+ icon->x = cursor->x + wlr_icon->surface->sx;
+ icon->y = cursor->y + wlr_icon->surface->sy;
break;
case WLR_DRAG_GRAB_KEYBOARD_TOUCH:;
struct wlr_touch_point *point =
@@ -387,8 +389,8 @@ void drag_icon_update_position(struct sway_drag_icon *icon) {
if (point == NULL) {
return;
}
- icon->x = seat->touch_x;
- icon->y = seat->touch_y;
+ icon->x = seat->touch_x + wlr_icon->surface->sx;
+ icon->y = seat->touch_y + wlr_icon->surface->sy;
}
drag_icon_damage_whole(icon);
@@ -724,14 +726,25 @@ static void seat_apply_input_config(struct sway_seat *seat,
ic == NULL ? MAPPED_TO_DEFAULT : ic->mapped_to;
switch (mapped_to) {
- case MAPPED_TO_DEFAULT:
+ case MAPPED_TO_DEFAULT:;
/*
* If the wlroots backend provides an output name, use that.
*
- * Otherwise, try to map built-in touch and tablet tool devices to the
+ * Otherwise, try to map built-in touch and pointer devices to the
* built-in output.
*/
- mapped_to_output = sway_device->input_device->wlr_device->output_name;
+ struct wlr_input_device *dev = sway_device->input_device->wlr_device;
+ switch (dev->type) {
+ case WLR_INPUT_DEVICE_POINTER:
+ mapped_to_output = dev->pointer->output_name;
+ break;
+ case WLR_INPUT_DEVICE_TOUCH:
+ mapped_to_output = dev->touch->output_name;
+ break;
+ default:
+ mapped_to_output = NULL;
+ break;
+ }
if (mapped_to_output == NULL && is_touch_or_tablet_tool(sway_device) &&
sway_libinput_device_is_builtin(sway_device->input_device)) {
mapped_to_output = get_builtin_output_name();
@@ -800,7 +813,7 @@ static void seat_configure_keyboard(struct sway_seat *seat,
}
sway_keyboard_configure(seat_device->keyboard);
wlr_seat_set_keyboard(seat->wlr_seat,
- seat_device->input_device->wlr_device);
+ seat_device->input_device->wlr_device->keyboard);
struct sway_node *focus = seat_get_focus(seat);
if (focus && node_is_view(focus)) {
// force notify reenter to pick up the new configuration
@@ -1561,7 +1574,7 @@ void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec) {
}
void seatop_pointer_axis(struct sway_seat *seat,
- struct wlr_event_pointer_axis *event) {
+ struct wlr_pointer_axis_event *event) {
if (seat->seatop_impl->pointer_axis) {
seat->seatop_impl->pointer_axis(seat, event);
}
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index 4320a3b4..15d1ca8b 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -474,7 +474,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
seat_set_focus(seat, node);
}
- // If moving a container by it's title bar, use a threshold for the drag
+ // If moving a container by its title bar, use a threshold for the drag
if (!mod_pressed && config->tiling_drag_threshold > 0) {
seatop_begin_move_tiling_threshold(seat, cont);
} else {
@@ -645,7 +645,7 @@ static void handle_tablet_tool_motion(struct sway_seat *seat,
* Functions used by handle_pointer_axis /
*--------------------------------------*/
-static uint32_t wl_axis_to_button(struct wlr_event_pointer_axis *event) {
+static uint32_t wl_axis_to_button(struct wlr_pointer_axis_event *event) {
switch (event->orientation) {
case WLR_AXIS_ORIENTATION_VERTICAL:
return event->delta < 0 ? SWAY_SCROLL_UP : SWAY_SCROLL_DOWN;
@@ -658,9 +658,9 @@ static uint32_t wl_axis_to_button(struct wlr_event_pointer_axis *event) {
}
static void handle_pointer_axis(struct sway_seat *seat,
- struct wlr_event_pointer_axis *event) {
+ struct wlr_pointer_axis_event *event) {
struct sway_input_device *input_device =
- event->device ? event->device->data : NULL;
+ event->pointer ? event->pointer->base.data : NULL;
struct input_config *ic =
input_device ? input_device_get_config(input_device) : NULL;
struct sway_cursor *cursor = seat->cursor;
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c
index ecc34fea..b40773d0 100644
--- a/sway/input/seatop_down.c
+++ b/sway/input/seatop_down.c
@@ -18,9 +18,9 @@ struct seatop_down_event {
};
static void handle_pointer_axis(struct sway_seat *seat,
- struct wlr_event_pointer_axis *event) {
+ struct wlr_pointer_axis_event *event) {
struct sway_input_device *input_device =
- event->device ? event->device->data : NULL;
+ event->pointer ? event->pointer->base.data : NULL;
struct input_config *ic =
input_device ? input_device_get_config(input_device) : NULL;
float scroll_factor =
diff --git a/sway/input/switch.c b/sway/input/switch.c
index 9ea87a1a..af5a2385 100644
--- a/sway/input/switch.c
+++ b/sway/input/switch.c
@@ -19,6 +19,19 @@ struct sway_switch *sway_switch_create(struct sway_seat *seat,
return switch_device;
}
+static bool sway_switch_trigger_test(enum sway_switch_trigger trigger,
+ enum wlr_switch_state state) {
+ switch (trigger) {
+ case SWAY_SWITCH_TRIGGER_ON:
+ return state == WLR_SWITCH_STATE_ON;
+ case SWAY_SWITCH_TRIGGER_OFF:
+ return state == WLR_SWITCH_STATE_OFF;
+ case SWAY_SWITCH_TRIGGER_TOGGLE:
+ return true;
+ }
+ abort(); // unreachable
+}
+
static void execute_binding(struct sway_switch *sway_switch) {
struct sway_seat* seat = sway_switch->seat_device->sway_seat;
bool input_inhibited = seat->exclusive_client != NULL;
@@ -30,11 +43,10 @@ static void execute_binding(struct sway_switch *sway_switch) {
if (binding->type != sway_switch->type) {
continue;
}
- if (binding->state != WLR_SWITCH_STATE_TOGGLE &&
- binding->state != sway_switch->state) {
+ if (!sway_switch_trigger_test(binding->trigger, sway_switch->state)) {
continue;
}
- if (config->reloading && (binding->state == WLR_SWITCH_STATE_TOGGLE
+ if (config->reloading && (binding->trigger == SWAY_SWITCH_TRIGGER_TOGGLE
|| (binding->flags & BINDING_RELOAD) == 0)) {
continue;
}
@@ -65,7 +77,7 @@ static void execute_binding(struct sway_switch *sway_switch) {
static void handle_switch_toggle(struct wl_listener *listener, void *data) {
struct sway_switch *sway_switch =
wl_container_of(listener, sway_switch, switch_toggle);
- struct wlr_event_switch_toggle *event = data;
+ struct wlr_switch_toggle_event *event = data;
struct sway_seat *seat = sway_switch->seat_device->sway_seat;
seat_idle_notify_activity(seat, IDLE_SOURCE_SWITCH);
diff --git a/sway/input/tablet.c b/sway/input/tablet.c
index 26e86e36..db2f93ec 100644
--- a/sway/input/tablet.c
+++ b/sway/input/tablet.c
@@ -196,7 +196,7 @@ static void handle_tablet_pad_attach(struct wl_listener *listener,
static void handle_tablet_pad_ring(struct wl_listener *listener, void *data) {
struct sway_tablet_pad *pad = wl_container_of(listener, pad, ring);
- struct wlr_event_tablet_pad_ring *event = data;
+ struct wlr_tablet_pad_ring_event *event = data;
if (!pad->current_surface) {
return;
@@ -210,7 +210,7 @@ static void handle_tablet_pad_ring(struct wl_listener *listener, void *data) {
static void handle_tablet_pad_strip(struct wl_listener *listener, void *data) {
struct sway_tablet_pad *pad = wl_container_of(listener, pad, strip);
- struct wlr_event_tablet_pad_strip *event = data;
+ struct wlr_tablet_pad_strip_event *event = data;
if (!pad->current_surface) {
return;
@@ -224,7 +224,7 @@ static void handle_tablet_pad_strip(struct wl_listener *listener, void *data) {
static void handle_tablet_pad_button(struct wl_listener *listener, void *data) {
struct sway_tablet_pad *pad = wl_container_of(listener, pad, button);
- struct wlr_event_tablet_pad_button *event = data;
+ struct wlr_tablet_pad_button_event *event = data;
if (!pad->current_surface) {
return;
diff --git a/sway/input/text_input.c b/sway/input/text_input.c
index b8c19c17..58911c2d 100644
--- a/sway/input/text_input.c
+++ b/sway/input/text_input.c
@@ -77,8 +77,6 @@ static void handle_im_grab_keyboard(struct wl_listener *listener, void *data) {
struct wlr_keyboard *active_keyboard = wlr_seat_get_keyboard(relay->seat->wlr_seat);
wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab,
active_keyboard);
- wlr_input_method_keyboard_grab_v2_send_modifiers(keyboard_grab,
- &active_keyboard->modifiers);
wl_signal_add(&keyboard_grab->events.destroy,
&relay->input_method_keyboard_grab_destroy);
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 1b64f86e..8357ae04 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -980,6 +980,11 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
struct wlr_keyboard *keyboard = device->wlr_device->keyboard;
struct xkb_keymap *keymap = keyboard->keymap;
struct xkb_state *state = keyboard->xkb_state;
+
+ json_object_object_add(object, "repeat_delay",
+ json_object_new_int(keyboard->repeat_info.delay));
+ json_object_object_add(object, "repeat_rate",
+ json_object_new_int(keyboard->repeat_info.rate));
json_object *layouts_arr = json_object_new_array();
json_object_object_add(object, "xkb_layout_names", layouts_arr);
diff --git a/sway/main.c b/sway/main.c
index b6f8a8bf..78974e22 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -240,35 +240,35 @@ static void handle_wlr_log(enum wlr_log_importance importance,
_sway_vlog(convert_wlr_log_importance(importance), sway_fmt, args);
}
+static const struct option long_options[] = {
+ {"help", no_argument, NULL, 'h'},
+ {"config", required_argument, NULL, 'c'},
+ {"validate", no_argument, NULL, 'C'},
+ {"debug", no_argument, NULL, 'd'},
+ {"version", no_argument, NULL, 'v'},
+ {"verbose", no_argument, NULL, 'V'},
+ {"get-socketpath", no_argument, NULL, 'p'},
+ {"unsupported-gpu", no_argument, NULL, 'u'},
+ {0, 0, 0, 0}
+};
+
+static const char usage[] =
+ "Usage: sway [options] [command]\n"
+ "\n"
+ " -h, --help Show help message and quit.\n"
+ " -c, --config <config> Specify a config file.\n"
+ " -C, --validate Check the validity of the config file, then exit.\n"
+ " -d, --debug Enables full logging, including debug information.\n"
+ " -v, --version Show the version number and quit.\n"
+ " -V, --verbose Enables more verbose logging.\n"
+ " --get-socketpath Gets the IPC socket path and prints it, then exits.\n"
+ "\n";
+
int main(int argc, char **argv) {
- static int verbose = 0, debug = 0, validate = 0, allow_unsupported_gpu = 0;
-
- static const struct option long_options[] = {
- {"help", no_argument, NULL, 'h'},
- {"config", required_argument, NULL, 'c'},
- {"validate", no_argument, NULL, 'C'},
- {"debug", no_argument, NULL, 'd'},
- {"version", no_argument, NULL, 'v'},
- {"verbose", no_argument, NULL, 'V'},
- {"get-socketpath", no_argument, NULL, 'p'},
- {"unsupported-gpu", no_argument, NULL, 'u'},
- {0, 0, 0, 0}
- };
+ static bool verbose = false, debug = false, validate = false, allow_unsupported_gpu = false;
char *config_path = NULL;
- const char* usage =
- "Usage: sway [options] [command]\n"
- "\n"
- " -h, --help Show help message and quit.\n"
- " -c, --config <config> Specify a config file.\n"
- " -C, --validate Check the validity of the config file, then exit.\n"
- " -d, --debug Enables full logging, including debug information.\n"
- " -v, --version Show the version number and quit.\n"
- " -V, --verbose Enables more verbose logging.\n"
- " --get-socketpath Gets the IPC socket path and prints it, then exits.\n"
- "\n";
-
int c;
while (1) {
int option_index = 0;
@@ -286,23 +286,23 @@ int main(int argc, char **argv) {
config_path = strdup(optarg);
break;
case 'C': // validate
- validate = 1;
+ validate = true;
break;
case 'd': // debug
- debug = 1;
+ debug = true;
break;
case 'D': // extended debug options
enable_debug_flag(optarg);
break;
case 'u':
- allow_unsupported_gpu = 1;
+ allow_unsupported_gpu = true;
break;
case 'v': // version
printf("sway version " SWAY_VERSION "\n");
exit(EXIT_SUCCESS);
break;
case 'V': // verbose
- verbose = 1;
+ verbose = true;
break;
case 'p': ; // --get-socketpath
if (getenv("SWAYSOCK")) {
diff --git a/sway/meson.build b/sway/meson.build
index 8eab31a2..4ccb2ba1 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -213,13 +213,14 @@ sway_deps = [
libudev,
math,
pango,
- pcre,
+ pcre2,
glesv2,
pixman,
server_protos,
wayland_server,
wlroots,
xkbcommon,
+ xcb_icccm,
]
if have_xwayland
diff --git a/sway/server.c b/sway/server.c
index f50a0987..9bfcffaf 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -24,6 +24,7 @@
#include <wlr/types/wlr_relative_pointer_v1.h>
#include <wlr/types/wlr_screencopy_v1.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_viewporter.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,
&server->compositor_new_surface);
+ wlr_subcompositor_create(server->wl_display);
+
server->data_device_manager =
wlr_data_device_manager_create(server->wl_display);
@@ -210,8 +213,8 @@ bool server_init(struct sway_server *server) {
// Avoid using "wayland-0" as display socket
char name_candidate[16];
- for (int i = 1; i <= 32; ++i) {
- sprintf(name_candidate, "wayland-%d", 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) {
server->socket = strdup(name_candidate);
break;
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 641d0925..168761e1 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -620,11 +620,11 @@ The default colors are:
after switching between workspaces.
*focus_on_window_activation* smart|urgent|focus|none
- This option determines what to do when an xwayland client requests
- window activation. If set to _urgent_, the urgent state will be set
- for that window. If set to _focus_, the window will become focused.
- If set to _smart_, the window will become focused only if it is already
- visible, otherwise the urgent state will be set. Default is _urgent_.
+ This option determines what to do when a client requests window activation.
+ If set to _urgent_, the urgent state will be set for that window. If set to
+ _focus_, the window will become focused. If set to _smart_, the window will
+ become focused only if it is already visible, otherwise the urgent state
+ will be set. Default is _urgent_.
*focus_wrapping* yes|no|force|workspace
This option determines what to do when attempting to focus over the edge
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index 4aa82c35..9c1a11e5 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -311,12 +311,13 @@ void arrange_output(struct sway_output *output) {
if (config->reloading) {
return;
}
- const struct wlr_box *output_box = wlr_output_layout_get_box(
- root->output_layout, output->wlr_output);
- output->lx = output_box->x;
- output->ly = output_box->y;
- output->width = output_box->width;
- output->height = output_box->height;
+ struct wlr_box output_box;
+ wlr_output_layout_get_box(root->output_layout,
+ output->wlr_output, &output_box);
+ output->lx = output_box.x;
+ output->ly = output_box.y;
+ output->width = output_box.width;
+ output->height = output_box.height;
for (int i = 0; i < output->workspaces->length; ++i) {
struct sway_workspace *workspace = output->workspaces->items[i];
@@ -328,12 +329,12 @@ void arrange_root(void) {
if (config->reloading) {
return;
}
- const struct wlr_box *layout_box =
- wlr_output_layout_get_box(root->output_layout, NULL);
- root->x = layout_box->x;
- root->y = layout_box->y;
- root->width = layout_box->width;
- root->height = layout_box->height;
+ struct wlr_box layout_box;
+ wlr_output_layout_get_box(root->output_layout, NULL, &layout_box);
+ root->x = layout_box.x;
+ root->y = layout_box.y;
+ root->width = layout_box.width;
+ root->height = layout_box.height;
if (root->fullscreen_global) {
struct sway_container *fs = root->fullscreen_global;
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 79e04ec0..09766ce5 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -9,6 +9,7 @@
#include <wayland-server-core.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_output_layout.h>
+#include <wlr/types/wlr_subcompositor.h>
#include <wlr/render/drm_format_set.h>
#include "linux-dmabuf-unstable-v1-protocol.h"
#include "cairo_util.h"
@@ -193,7 +194,7 @@ static struct sway_container *surface_at_view(struct sway_container *con, double
#endif
case SWAY_VIEW_XDG_SHELL:
_surface = wlr_xdg_surface_surface_at(
- view->wlr_xdg_surface,
+ view->wlr_xdg_toplevel->base,
view_sx, view_sy, &_sx, &_sy);
break;
}
@@ -694,12 +695,13 @@ void floating_calculate_constraints(int *min_width, int *max_width,
*min_height = config->floating_minimum_height;
}
- struct wlr_box *box = wlr_output_layout_get_box(root->output_layout, NULL);
+ struct wlr_box box;
+ wlr_output_layout_get_box(root->output_layout, NULL, &box);
if (config->floating_maximum_width == -1) { // no maximum
*max_width = INT_MAX;
} else if (config->floating_maximum_width == 0) { // automatic
- *max_width = box->width;
+ *max_width = box.width;
} else {
*max_width = config->floating_maximum_width;
}
@@ -707,7 +709,7 @@ void floating_calculate_constraints(int *min_width, int *max_width,
if (config->floating_maximum_height == -1) { // no maximum
*max_height = INT_MAX;
} else if (config->floating_maximum_height == 0) { // automatic
- *max_height = box->height;
+ *max_height = box.height;
} else {
*max_height = config->floating_maximum_height;
}
@@ -739,9 +741,9 @@ void container_floating_resize_and_center(struct sway_container *con) {
return;
}
- struct wlr_box *ob = wlr_output_layout_get_box(root->output_layout,
- ws->output->wlr_output);
- if (!ob) {
+ struct wlr_box ob;
+ wlr_output_layout_get_box(root->output_layout, ws->output->wlr_output, &ob);
+ if (wlr_box_empty(&ob)) {
// On NOOP output. Will be called again when moved to an output
con->pending.x = 0;
con->pending.y = 0;
@@ -753,8 +755,8 @@ void container_floating_resize_and_center(struct sway_container *con) {
floating_natural_resize(con);
if (!con->view) {
if (con->pending.width > ws->width || con->pending.height > ws->height) {
- con->pending.x = ob->x + (ob->width - con->pending.width) / 2;
- con->pending.y = ob->y + (ob->height - con->pending.height) / 2;
+ con->pending.x = ob.x + (ob.width - con->pending.width) / 2;
+ con->pending.y = ob.y + (ob.height - con->pending.height) / 2;
} else {
con->pending.x = ws->x + (ws->width - con->pending.width) / 2;
con->pending.y = ws->y + (ws->height - con->pending.height) / 2;
@@ -762,8 +764,8 @@ void container_floating_resize_and_center(struct sway_container *con) {
} else {
if (con->pending.content_width > ws->width
|| con->pending.content_height > ws->height) {
- con->pending.content_x = ob->x + (ob->width - con->pending.content_width) / 2;
- con->pending.content_y = ob->y + (ob->height - con->pending.content_height) / 2;
+ con->pending.content_x = ob.x + (ob.width - con->pending.content_width) / 2;
+ con->pending.content_y = ob.y + (ob.height - con->pending.content_height) / 2;
} else {
con->pending.content_x = ws->x + (ws->width - con->pending.content_width) / 2;
con->pending.content_y = ws->y + (ws->height - con->pending.content_height) / 2;
@@ -1704,7 +1706,7 @@ static void update_marks_texture(struct sway_container *con,
for (int i = 0; i < con->marks->length; ++i) {
char *mark = con->marks->items[i];
if (mark[0] != '_') {
- sprintf(part, "[%s]", mark);
+ snprintf(part, len + 1, "[%s]", mark);
strcat(buffer, part);
}
}
diff --git a/sway/tree/output.c b/sway/tree/output.c
index ad8d2482..52826c91 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -301,10 +301,10 @@ struct sway_output *output_get_in_direction(struct sway_output *reference,
if (!sway_assert(direction, "got invalid direction: %d", direction)) {
return NULL;
}
- struct wlr_box *output_box =
- wlr_output_layout_get_box(root->output_layout, reference->wlr_output);
- int lx = output_box->x + output_box->width / 2;
- int ly = output_box->y + output_box->height / 2;
+ struct wlr_box output_box;
+ wlr_output_layout_get_box(root->output_layout, reference->wlr_output, &output_box);
+ int lx = output_box.x + output_box.width / 2;
+ int ly = output_box.y + output_box.height / 2;
struct wlr_output *wlr_adjacent = wlr_output_layout_adjacent_output(
root->output_layout, direction, reference->wlr_output, lx, ly);
if (!wlr_adjacent) {
diff --git a/sway/tree/root.c b/sway/tree/root.c
index 73f3993c..8508e9eb 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -209,7 +209,7 @@ static pid_t get_parent_pid(pid_t child) {
FILE *stat = NULL;
size_t buf_size = 0;
- sprintf(file_name, "/proc/%d/stat", child);
+ snprintf(file_name, sizeof(file_name), "/proc/%d/stat", child);
if ((stat = fopen(file_name, "r"))) {
if (getline(&buffer, &buf_size, stat) != -1) {
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 8b7061ba..176be8af 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -6,6 +6,7 @@
#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_server_decoration.h>
+#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include "config.h"
#if HAVE_XWAYLAND