Implement surface-suspension-v1

This commit is contained in:
Simon Ser 2021-06-16 20:52:40 +02:00
parent 75a4122f7a
commit 3562b9d303
3 changed files with 33 additions and 0 deletions

View file

@ -90,6 +90,8 @@ struct sway_server {
struct wlr_xdg_activation_v1 *xdg_activation_v1; struct wlr_xdg_activation_v1 *xdg_activation_v1;
struct wl_listener xdg_activation_v1_request_activate; struct wl_listener xdg_activation_v1_request_activate;
struct wlr_surface_suspension_manager_v1 *surface_suspension_manager_v1;
// The timeout for transactions, after which a transaction is applied // The timeout for transactions, after which a transaction is applied
// regardless of readiness. // regardless of readiness.
size_t txn_timeout_ms; size_t txn_timeout_ms;

View file

@ -22,6 +22,7 @@
#include <wlr/types/wlr_relative_pointer_v1.h> #include <wlr/types/wlr_relative_pointer_v1.h>
#include <wlr/types/wlr_screencopy_v1.h> #include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/types/wlr_server_decoration.h> #include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_surface_suspension_v1.h>
#include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_tablet_v2.h>
#include <wlr/types/wlr_viewporter.h> #include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xcursor_manager.h>
@ -166,6 +167,9 @@ bool server_init(struct sway_server *server) {
wl_signal_add(&server->xdg_activation_v1->events.request_activate, wl_signal_add(&server->xdg_activation_v1->events.request_activate,
&server->xdg_activation_v1_request_activate); &server->xdg_activation_v1_request_activate);
server->surface_suspension_manager_v1 =
wlr_surface_suspension_manager_v1_create(server->wl_display);
// Avoid using "wayland-0" as display socket // Avoid using "wayland-0" as display socket
char name_candidate[16]; char name_candidate[16];
for (int i = 1; i <= 32; ++i) { for (int i = 1; i <= 32; ++i) {

View file

@ -5,6 +5,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <strings.h> #include <strings.h>
#include <wlr/types/wlr_surface_suspension_v1.h>
#include "stringop.h" #include "stringop.h"
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
#include "sway/input/cursor.h" #include "sway/input/cursor.h"
@ -561,6 +562,23 @@ struct sway_workspace *workspace_output_prev(
return workspace_output_prev_next_impl(current->output, -1, create); return workspace_output_prev_next_impl(current->output, -1, create);
} }
static void set_surface_suspended_iterator(struct wlr_surface *surface,
int x, int y, void *data) {
bool *suspended = data;
wlr_surface_suspension_manager_v1_set_suspended(
server.surface_suspension_manager_v1, surface, *suspended);
}
static void set_container_suspended(struct sway_container *container,
void *data) {
if (!container->view || container_is_floating(container)) {
return;
}
view_for_each_surface(container->view,
set_surface_suspended_iterator, data);
}
bool workspace_switch(struct sway_workspace *workspace, bool workspace_switch(struct sway_workspace *workspace,
bool no_auto_back_and_forth) { bool no_auto_back_and_forth) {
struct sway_seat *seat = input_manager_current_seat(); struct sway_seat *seat = input_manager_current_seat();
@ -589,6 +607,15 @@ bool workspace_switch(struct sway_workspace *workspace,
} }
seat_set_focus(seat, next); seat_set_focus(seat, next);
arrange_workspace(workspace); arrange_workspace(workspace);
if (active_ws) {
bool suspended = true;
workspace_for_each_container(active_ws, set_container_suspended, &suspended);
}
bool suspended = false;
workspace_for_each_container(workspace, set_container_suspended, &suspended);
return true; return true;
} }