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.
master
Kenny Levinsen 4 years ago committed by Simon Ser
parent 66343839b1
commit 35b9a41720

@ -28,6 +28,12 @@ struct sway_view;
*/
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.
*

@ -35,6 +35,7 @@ struct sway_transaction_instruction {
struct sway_container_state container_state;
};
uint32_t serial;
bool server_request;
bool waiting;
};
@ -165,7 +166,7 @@ static void copy_container_state(struct sway_container *container,
}
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;
// 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->node = node;
instruction->server_request = server_request;
list_add(transaction->instructions, instruction);
node->ntxnrefs++;
} else if (server_request) {
instruction->server_request = true;
}
switch (node->type) {
@ -364,6 +368,9 @@ static bool should_configure(struct sway_node *node,
if (node->destroying) {
return false;
}
if (!instruction->server_request) {
return false;
}
struct sway_container_state *cstate = &node->sway_container->current;
struct sway_container_state *istate = &instruction->container_state;
#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) {
return;
}
@ -536,10 +543,18 @@ void transaction_commit_dirty(void) {
for (int i = 0; i < server.dirty_nodes->length; ++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;
}
server.dirty_nodes->length = 0;
transaction_commit_pending();
}
void transaction_commit_dirty(void) {
_transaction_commit_dirty(true);
}
void transaction_commit_dirty_client(void) {
_transaction_commit_dirty(false);
}

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

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

Loading…
Cancel
Save