upstream update: merge sway 1.8.1 (#111)

This commit is contained in:
Erik Reider 2023-02-14 16:51:29 +01:00 committed by GitHub
parent 3efd3b558f
commit e78fc3364b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 100 additions and 24 deletions

View file

@ -2,7 +2,7 @@
### CHANGE THESE VARIABLES BEFORE RELEASE: ### CHANGE THESE VARIABLES BEFORE RELEASE:
# Change to current Sway base version! # Change to current Sway base version!
%global SwayBaseVersion 1.8 %global SwayBaseVersion 1.8.1
# Change to current SwayFX tag! # Change to current SwayFX tag!
%global Tag 0.1.1 %global Tag 0.1.1

View file

@ -63,7 +63,7 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad);
void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad); void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad);
void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad,
struct wlr_surface *surface); struct wlr_surface *surface);
#endif #endif

View file

@ -33,10 +33,10 @@ struct cmd_results *cmd_font(int argc, char **argv) {
return cmd_results_new(CMD_FAILURE, "Invalid font family."); return cmd_results_new(CMD_FAILURE, "Invalid font family.");
} }
const gint size = pango_font_description_get_size(font_description); const PangoFontMask flags = pango_font_description_get_set_fields(font_description);
if (size == 0) { if ((flags & PANGO_FONT_MASK_SIZE) == 0) {
pango_font_description_free(font_description); pango_font_description_free(font_description);
return cmd_results_new(CMD_FAILURE, "Invalid font size."); return cmd_results_new(CMD_FAILURE, "Font size not given.");
} }
if (config->font_description != NULL) { if (config->font_description != NULL) {

View file

@ -1022,6 +1022,7 @@ static void output_manager_apply(struct sway_server *server,
oc->y = config_head->state.y; oc->y = config_head->state.y;
oc->transform = config_head->state.transform; oc->transform = config_head->state.transform;
oc->scale = config_head->state.scale; oc->scale = config_head->state.scale;
oc->adaptive_sync = config_head->state.adaptive_sync_enabled;
if (test_only) { if (test_only) {
ok &= test_output_config(oc, output); ok &= test_output_config(oc, output);

View file

@ -1399,6 +1399,41 @@ void output_render(struct sway_output *output, struct timespec *when,
goto renderer_end; goto renderer_end;
} }
if (server.session_lock.locked) {
float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f};
if (server.session_lock.lock == NULL) {
// abandoned lock -> red BG
clear_color[0] = 1.f;
}
int nrects;
pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
for (int i = 0; i < nrects; ++i) {
scissor_output(wlr_output, &rects[i]);
fx_renderer_clear(clear_color);
}
if (server.session_lock.lock != NULL) {
struct render_data data = {
.damage = damage,
.deco_data = get_undecorated_decoration_data(),
};
struct wlr_session_lock_surface_v1 *lock_surface;
wl_list_for_each(lock_surface, &server.session_lock.lock->surfaces, link) {
if (lock_surface->output != wlr_output) {
continue;
}
if (!lock_surface->mapped) {
continue;
}
output_surface_for_each_surface(output, lock_surface->surface,
0.0, 0.0, render_surface_iterator, &data);
}
}
goto renderer_end;
}
if (output_has_opaque_overlay_layer_surface(output)) { if (output_has_opaque_overlay_layer_surface(output)) {
goto render_overlay; goto render_overlay;
} }

View file

@ -97,6 +97,24 @@ struct sway_node *node_at_coords(
double ox = lx, oy = ly; double ox = lx, oy = ly;
wlr_output_layout_output_coords(root->output_layout, wlr_output, &ox, &oy); wlr_output_layout_output_coords(root->output_layout, wlr_output, &ox, &oy);
if (server.session_lock.locked) {
if (server.session_lock.lock == NULL) {
return NULL;
}
struct wlr_session_lock_surface_v1 *lock_surf;
wl_list_for_each(lock_surf, &server.session_lock.lock->surfaces, link) {
if (lock_surf->output != wlr_output) {
continue;
}
*surface = wlr_surface_surface_at(lock_surf->surface, ox, oy, sx, sy);
if (*surface != NULL) {
return NULL;
}
}
return NULL;
}
// layer surfaces on the overlay layer are rendered on top // layer surfaces on the overlay layer are rendered on top
if ((*surface = layer_surface_at(output, if ((*surface = layer_surface_at(output,
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
@ -1322,6 +1340,10 @@ static void warp_to_constraint_cursor_hint(struct sway_cursor *cursor) {
double sy = constraint->current.cursor_hint.y; double sy = constraint->current.cursor_hint.y;
struct sway_view *view = view_from_wlr_surface(constraint->surface); struct sway_view *view = view_from_wlr_surface(constraint->surface);
if (!view) {
return;
}
struct sway_container *con = view->container; struct sway_container *con = view->container;
double lx = sx + con->pending.content_x - view->geometry.x; double lx = sx + con->pending.content_x - view->geometry.x;

View file

@ -176,11 +176,11 @@ static void seat_keyboard_notify_enter(struct sway_seat *seat,
state->pressed_keycodes, state->npressed, &keyboard->modifiers); state->pressed_keycodes, state->npressed, &keyboard->modifiers);
} }
static void seat_tablet_pads_notify_enter(struct sway_seat *seat, static void seat_tablet_pads_set_focus(struct sway_seat *seat,
struct wlr_surface *surface) { struct wlr_surface *surface) {
struct sway_seat_device *seat_device; struct sway_seat_device *seat_device;
wl_list_for_each(seat_device, &seat->devices, link) { wl_list_for_each(seat_device, &seat->devices, link) {
sway_tablet_pad_notify_enter(seat_device->tablet_pad, surface); sway_tablet_pad_set_focus(seat_device->tablet_pad, surface);
} }
} }
@ -204,7 +204,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
#endif #endif
seat_keyboard_notify_enter(seat, view->surface); seat_keyboard_notify_enter(seat, view->surface);
seat_tablet_pads_notify_enter(seat, view->surface); seat_tablet_pads_set_focus(seat, view->surface);
sway_input_method_relay_set_focus(&seat->im_relay, view->surface); sway_input_method_relay_set_focus(&seat->im_relay, view->surface);
struct wlr_pointer_constraint_v1 *constraint = struct wlr_pointer_constraint_v1 *constraint =
@ -1080,9 +1080,20 @@ void seat_configure_xcursor(struct sway_seat *seat) {
bool seat_is_input_allowed(struct sway_seat *seat, bool seat_is_input_allowed(struct sway_seat *seat,
struct wlr_surface *surface) { struct wlr_surface *surface) {
if (server.session_lock.locked) {
if (server.session_lock.lock == NULL) {
return false;
}
struct wlr_session_lock_surface_v1 *lock_surf;
wl_list_for_each(lock_surf, &server.session_lock.lock->surfaces, link) {
if (lock_surf->surface == surface) {
return true;
}
}
return false;
}
struct wl_client *client = wl_resource_get_client(surface->resource); struct wl_client *client = wl_resource_get_client(surface->resource);
return seat->exclusive_client == client || return seat->exclusive_client == client || seat->exclusive_client == NULL;
(seat->exclusive_client == NULL && !server.session_lock.locked);
} }
static void send_unfocus(struct sway_container *con, void *data) { static void send_unfocus(struct sway_container *con, void *data) {
@ -1313,7 +1324,7 @@ void seat_set_focus_surface(struct sway_seat *seat,
} }
sway_input_method_relay_set_focus(&seat->im_relay, surface); sway_input_method_relay_set_focus(&seat->im_relay, surface);
seat_tablet_pads_notify_enter(seat, surface); seat_tablet_pads_set_focus(seat, surface);
} }
void seat_set_focus_layer(struct sway_seat *seat, void seat_set_focus_layer(struct sway_seat *seat,

View file

@ -334,14 +334,10 @@ static void handle_pad_tablet_surface_destroy(struct wl_listener *listener,
struct sway_tablet_pad *tablet_pad = struct sway_tablet_pad *tablet_pad =
wl_container_of(listener, tablet_pad, surface_destroy); wl_container_of(listener, tablet_pad, surface_destroy);
wlr_tablet_v2_tablet_pad_notify_leave(tablet_pad->tablet_v2_pad, sway_tablet_pad_set_focus(tablet_pad, NULL);
tablet_pad->current_surface);
wl_list_remove(&tablet_pad->surface_destroy.link);
wl_list_init(&tablet_pad->surface_destroy.link);
tablet_pad->current_surface = NULL;
} }
void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad,
struct wlr_surface *surface) { struct wlr_surface *surface) {
if (!tablet_pad || !tablet_pad->tablet) { if (!tablet_pad || !tablet_pad->tablet) {
return; return;
@ -360,7 +356,8 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad,
tablet_pad->current_surface = NULL; tablet_pad->current_surface = NULL;
} }
if (!wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) { if (surface == NULL ||
!wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) {
return; return;
} }
@ -368,7 +365,6 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad,
tablet_pad->tablet->tablet_v2, surface); tablet_pad->tablet->tablet_v2, surface);
tablet_pad->current_surface = surface; tablet_pad->current_surface = surface;
wl_list_remove(&tablet_pad->surface_destroy.link);
tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy; tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy;
wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy); wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy);
} }

View file

@ -558,7 +558,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
struct wlr_box window_box = { struct wlr_box window_box = {
c->pending.content_x - c->pending.x, c->pending.content_x - c->pending.x,
(c->current.border == B_PIXEL) ? c->current.border_thickness : 0, (c->current.border == B_PIXEL) ? c->pending.content_y - c->pending.y : 0,
c->pending.content_width, c->pending.content_width,
c->pending.content_height c->pending.content_height
}; };

View file

@ -32,6 +32,7 @@ static void handle_surface_map(struct wl_listener *listener, void *data) {
if (server.session_lock.focused == NULL) { if (server.session_lock.focused == NULL) {
set_lock_focused_surface(surf->surface); set_lock_focused_surface(surf->surface);
} }
wlr_surface_send_enter(surf->surface, surf->output->wlr_output);
output_damage_whole(surf->output); output_damage_whole(surf->output);
} }

View file

@ -23,6 +23,7 @@ sway_sources = files(
'desktop/transaction.c', 'desktop/transaction.c',
'desktop/xdg_shell.c', 'desktop/xdg_shell.c',
'desktop/launcher.c', 'desktop/launcher.c',
'input/input-manager.c', 'input/input-manager.c',
'input/cursor.c', 'input/cursor.c',
'input/keyboard.c', 'input/keyboard.c',

View file

@ -76,6 +76,11 @@ bool server_init(struct sway_server *server) {
return false; return false;
} }
if (!server->backend) {
sway_log(SWAY_ERROR, "Unable to create backend");
return false;
}
server->wlr_renderer = wlr_renderer_autocreate(server->backend); server->wlr_renderer = wlr_renderer_autocreate(server->backend);
if (!server->wlr_renderer) { if (!server->wlr_renderer) {
sway_log(SWAY_ERROR, "Failed to create wlr_renderer"); sway_log(SWAY_ERROR, "Failed to create wlr_renderer");

View file

@ -337,8 +337,9 @@ node and will have the following properties:
this, but borders are included. this, but borders are included.
|- window_rect |- window_rect
: object : object
: The geometry of the contents inside the node. The window decorations are : The geometry of the content inside the node. These coordinates are relative
excluded from this calculation, but borders are included. to the node itself. Window decorations and borders are outside the
_window_rect_
|- deco_rect |- deco_rect
: object : object
: The geometry of the decorations for the node relative to the parent node : The geometry of the decorations for the node relative to the parent node

View file

@ -119,7 +119,7 @@ must be separated by one space. For example:
Enables or disables the specified output (all outputs are enabled by Enables or disables the specified output (all outputs are enabled by
default). default).
As opposed to the _power_ command, the output will loose its current As opposed to the _power_ command, the output will lose its current
workspace and windows. workspace and windows.
*output* <name> toggle *output* <name> toggle

View file

@ -377,6 +377,7 @@ void view_request_activate(struct sway_view *view) {
case FOWA_SMART: case FOWA_SMART:
if (workspace_is_visible(ws)) { if (workspace_is_visible(ws)) {
seat_set_focus_container(seat, view->container); seat_set_focus_container(seat, view->container);
container_raise_floating(view->container);
} else { } else {
view_set_urgent(view, true); view_set_urgent(view, true);
} }
@ -386,10 +387,12 @@ void view_request_activate(struct sway_view *view) {
break; break;
case FOWA_FOCUS: case FOWA_FOCUS:
seat_set_focus_container(seat, view->container); seat_set_focus_container(seat, view->container);
container_raise_floating(view->container);
break; break;
case FOWA_NONE: case FOWA_NONE:
break; break;
} }
transaction_commit_dirty();
} }
void view_set_csd_from_server(struct sway_view *view, bool enabled) { void view_set_csd_from_server(struct sway_view *view, bool enabled) {

View file

@ -292,7 +292,7 @@ static uint32_t render_status_block(struct render_context *ctx,
} }
double offset = 0; double offset = 0;
if (strncmp(block->align, "left", 5) == 0) { if (strncmp(block->align, "left", 4) == 0) {
offset = x_pos; offset = x_pos;
} else if (strncmp(block->align, "right", 5) == 0) { } else if (strncmp(block->align, "right", 5) == 0) {
offset = x_pos + width - text_width; offset = x_pos + width - text_width;