transaction: Note if instructions are server requests

On server request, we need to send configure events to inform the client
of the new intended size. If the client changes size itself, sending a
configure event will only cause problems.

Use transaction_commit_dirty_client to distinguish between the two
transaction causes.
This commit is contained in:
Kenny Levinsen 2021-02-21 18:18:35 +01:00 committed by Simon Ser
parent 66343839b1
commit 35b9a41720
4 changed files with 26 additions and 6 deletions

View file

@ -28,6 +28,12 @@ struct sway_view;
*/ */
void transaction_commit_dirty(void); void transaction_commit_dirty(void);
/*
* Same as transaction_commit_dirty, but signalling that this is a
* client-initiated change has already taken effect.
*/
void transaction_commit_dirty_client(void);
/** /**
* Notify the transaction system that a view is ready for the new layout. * Notify the transaction system that a view is ready for the new layout.
* *

View file

@ -35,6 +35,7 @@ struct sway_transaction_instruction {
struct sway_container_state container_state; struct sway_container_state container_state;
}; };
uint32_t serial; uint32_t serial;
bool server_request;
bool waiting; bool waiting;
}; };
@ -165,7 +166,7 @@ static void copy_container_state(struct sway_container *container,
} }
static void transaction_add_node(struct sway_transaction *transaction, static void transaction_add_node(struct sway_transaction *transaction,
struct sway_node *node) { struct sway_node *node, bool server_request) {
struct sway_transaction_instruction *instruction = NULL; struct sway_transaction_instruction *instruction = NULL;
// Check if we have an instruction for this node already, in which case we // Check if we have an instruction for this node already, in which case we
@ -188,9 +189,12 @@ static void transaction_add_node(struct sway_transaction *transaction,
} }
instruction->transaction = transaction; instruction->transaction = transaction;
instruction->node = node; instruction->node = node;
instruction->server_request = server_request;
list_add(transaction->instructions, instruction); list_add(transaction->instructions, instruction);
node->ntxnrefs++; node->ntxnrefs++;
} else if (server_request) {
instruction->server_request = true;
} }
switch (node->type) { switch (node->type) {
@ -364,6 +368,9 @@ static bool should_configure(struct sway_node *node,
if (node->destroying) { if (node->destroying) {
return false; return false;
} }
if (!instruction->server_request) {
return false;
}
struct sway_container_state *cstate = &node->sway_container->current; struct sway_container_state *cstate = &node->sway_container->current;
struct sway_container_state *istate = &instruction->container_state; struct sway_container_state *istate = &instruction->container_state;
#if HAVE_XWAYLAND #if HAVE_XWAYLAND
@ -522,7 +529,7 @@ void transaction_notify_view_ready_immediately(struct sway_view *view) {
} }
} }
void transaction_commit_dirty(void) { static void _transaction_commit_dirty(bool server_request) {
if (!server.dirty_nodes->length) { if (!server.dirty_nodes->length) {
return; return;
} }
@ -536,10 +543,18 @@ void transaction_commit_dirty(void) {
for (int i = 0; i < server.dirty_nodes->length; ++i) { for (int i = 0; i < server.dirty_nodes->length; ++i) {
struct sway_node *node = server.dirty_nodes->items[i]; struct sway_node *node = server.dirty_nodes->items[i];
transaction_add_node(server.pending_transaction, node); transaction_add_node(server.pending_transaction, node, server_request);
node->dirty = false; node->dirty = false;
} }
server.dirty_nodes->length = 0; server.dirty_nodes->length = 0;
transaction_commit_pending(); transaction_commit_pending();
} }
void transaction_commit_dirty(void) {
_transaction_commit_dirty(true);
}
void transaction_commit_dirty_client(void) {
_transaction_commit_dirty(false);
}

View file

@ -298,8 +298,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
if (container_is_floating(view->container)) { if (container_is_floating(view->container)) {
view_update_size(view); view_update_size(view);
transaction_commit_dirty(); transaction_commit_dirty_client();
transaction_notify_view_ready_immediately(view);
} else { } else {
view_center_surface(view); view_center_surface(view);
} }

View file

@ -413,7 +413,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
if (container_is_floating(view->container)) { if (container_is_floating(view->container)) {
view_update_size(view); view_update_size(view);
transaction_commit_dirty(); transaction_commit_dirty_client();
} else { } else {
view_center_surface(view); view_center_surface(view);
} }