mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 16:36:26 +01:00
Implement atomic layout updates for xwayland views
This commit is contained in:
parent
b6a238c7b7
commit
1549fb719a
3 changed files with 40 additions and 27 deletions
|
@ -49,6 +49,15 @@ void transaction_commit(struct sway_transaction *transaction);
|
|||
*/
|
||||
void transaction_notify_view_ready(struct sway_view *view, uint32_t serial);
|
||||
|
||||
/**
|
||||
* Notify the transaction system that a view is ready for the new layout, but
|
||||
* identifying the instruction by width and height rather than by serial.
|
||||
*
|
||||
* This is used by xwayland views, as they don't have serials.
|
||||
*/
|
||||
void transaction_notify_view_ready_by_size(struct sway_view *view,
|
||||
int width, int height);
|
||||
|
||||
/**
|
||||
* Get the texture that should be rendered for a view.
|
||||
*
|
||||
|
|
|
@ -267,9 +267,7 @@ void transaction_commit(struct sway_transaction *transaction) {
|
|||
instruction->state.view_y,
|
||||
instruction->state.view_width,
|
||||
instruction->state.view_height);
|
||||
if (instruction->serial) {
|
||||
++transaction->num_waiting;
|
||||
}
|
||||
++transaction->num_waiting;
|
||||
}
|
||||
list_add(con->instructions, instruction);
|
||||
}
|
||||
|
@ -307,20 +305,8 @@ void transaction_commit(struct sway_transaction *transaction) {
|
|||
update_debug_tree();
|
||||
}
|
||||
|
||||
void transaction_notify_view_ready(struct sway_view *view, uint32_t serial) {
|
||||
// Find the instruction
|
||||
struct sway_transaction_instruction *instruction = NULL;
|
||||
for (int i = 0; i < view->swayc->instructions->length; ++i) {
|
||||
struct sway_transaction_instruction *tmp_instruction =
|
||||
view->swayc->instructions->items[i];
|
||||
if (tmp_instruction->serial == serial && !tmp_instruction->ready) {
|
||||
instruction = tmp_instruction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!instruction) {
|
||||
return;
|
||||
}
|
||||
static void set_instruction_ready(
|
||||
struct sway_transaction_instruction *instruction) {
|
||||
instruction->ready = true;
|
||||
|
||||
// If all views are ready, apply the transaction.
|
||||
|
@ -335,6 +321,30 @@ void transaction_notify_view_ready(struct sway_view *view, uint32_t serial) {
|
|||
}
|
||||
}
|
||||
|
||||
void transaction_notify_view_ready(struct sway_view *view, uint32_t serial) {
|
||||
for (int i = 0; i < view->swayc->instructions->length; ++i) {
|
||||
struct sway_transaction_instruction *instruction =
|
||||
view->swayc->instructions->items[i];
|
||||
if (instruction->serial == serial && !instruction->ready) {
|
||||
set_instruction_ready(instruction);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void transaction_notify_view_ready_by_size(struct sway_view *view,
|
||||
int width, int height) {
|
||||
for (int i = 0; i < view->swayc->instructions->length; ++i) {
|
||||
struct sway_transaction_instruction *instruction =
|
||||
view->swayc->instructions->items[i];
|
||||
if (!instruction->ready && instruction->state.view_width == width &&
|
||||
instruction->state.view_height == height) {
|
||||
set_instruction_ready(instruction);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct wlr_texture *transaction_get_texture(struct sway_view *view) {
|
||||
if (!view->swayc || !view->swayc->instructions->length) {
|
||||
return view->surface->buffer->texture;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <wlr/xwayland.h>
|
||||
#include "log.h"
|
||||
#include "sway/desktop.h"
|
||||
#include "sway/desktop/transaction.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "sway/output.h"
|
||||
|
@ -243,16 +244,9 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
struct sway_view *view = &xwayland_view->view;
|
||||
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
|
||||
|
||||
// Don't allow xwayland views to do resize or reposition themselves if
|
||||
// they're involved in a transaction. Once the transaction has finished
|
||||
// they'll apply the next time a commit happens.
|
||||
if (view->swayc && view->swayc->instructions->length) {
|
||||
if (view->swayc && container_is_floating(view->swayc)) {
|
||||
view_update_size(view, xsurface->width, xsurface->height);
|
||||
} else {
|
||||
view_update_size(view, view->swayc->width, view->swayc->height);
|
||||
}
|
||||
view_update_position(view, view->x, view->y);
|
||||
if (view->swayc->instructions->length) {
|
||||
transaction_notify_view_ready_by_size(view,
|
||||
xsurface->width, xsurface->height);
|
||||
}
|
||||
view_damage_from(view);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue