transaction: validate X transaction completions by geometry, not size

Xwayland views are aware of their coordinates, so validating transaction
completions should take into account the reported coordinates of the
view. Prior to this commit they didn't, and matching dimensions would
suffice to validate the transaction.

Also introduced `transaction_notify_view_ready_immediately` to support
the fix from d0f7e0f without jumping through hoops to figure out the
geometry of an `xdg_shell` view.
This commit is contained in:
Tudor Brindus 2020-10-18 16:26:01 -04:00 committed by Simon Ser
parent 5bd6a5ce3f
commit 8355884fbd
4 changed files with 26 additions and 11 deletions

View file

@ -38,11 +38,17 @@ void transaction_notify_view_ready_by_serial(struct sway_view *view,
/** /**
* Notify the transaction system that a view is ready for the new layout, but * 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. * identifying the instruction by geometry rather than by serial.
* *
* This is used by xwayland views, as they don't have serials. * This is used by xwayland views, as they don't have serials.
*/ */
void transaction_notify_view_ready_by_size(struct sway_view *view, void transaction_notify_view_ready_by_geometry(struct sway_view *view,
int width, int height); double x, double y, int width, int height);
/**
* Unconditionally notify the transaction system that a view is ready for the
* new layout.
*/
void transaction_notify_view_ready_immediately(struct sway_view *view);
#endif #endif

View file

@ -510,17 +510,27 @@ void transaction_notify_view_ready_by_serial(struct sway_view *view,
} }
} }
void transaction_notify_view_ready_by_size(struct sway_view *view, void transaction_notify_view_ready_by_geometry(struct sway_view *view,
int width, int height) { double x, double y, int width, int height) {
struct sway_transaction_instruction *instruction = struct sway_transaction_instruction *instruction =
view->container->node.instruction; view->container->node.instruction;
if (instruction != NULL && if (instruction != NULL &&
(int)instruction->container_state.content_x == (int)x &&
(int)instruction->container_state.content_y == (int)y &&
instruction->container_state.content_width == width && instruction->container_state.content_width == width &&
instruction->container_state.content_height == height) { instruction->container_state.content_height == height) {
set_instruction_ready(instruction); set_instruction_ready(instruction);
} }
} }
void transaction_notify_view_ready_immediately(struct sway_view *view) {
struct sway_transaction_instruction *instruction =
view->container->node.instruction;
if (instruction != NULL) {
set_instruction_ready(instruction);
}
}
void transaction_commit_dirty(void) { void transaction_commit_dirty(void) {
if (!server.dirty_nodes->length) { if (!server.dirty_nodes->length) {
return; return;

View file

@ -302,8 +302,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));
desktop_damage_view(view); desktop_damage_view(view);
transaction_commit_dirty(); transaction_commit_dirty();
transaction_notify_view_ready_by_size(view, transaction_notify_view_ready_immediately(view);
new_geo.width, new_geo.height);
} else { } else {
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
} }

View file

@ -401,8 +401,8 @@ static void handle_commit(struct wl_listener *listener, void *data) {
if (view->container->node.instruction) { if (view->container->node.instruction) {
get_geometry(view, &view->geometry); get_geometry(view, &view->geometry);
transaction_notify_view_ready_by_size(view, transaction_notify_view_ready_by_geometry(view,
state->width, state->height); xsurface->x, xsurface->y, state->width, state->height);
} else { } else {
struct wlr_box new_geo; struct wlr_box new_geo;
get_geometry(view, &new_geo); get_geometry(view, &new_geo);
@ -418,8 +418,8 @@ 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));
desktop_damage_view(view); desktop_damage_view(view);
transaction_commit_dirty(); transaction_commit_dirty();
transaction_notify_view_ready_by_size(view, transaction_notify_view_ready_by_geometry(view,
new_geo.width, new_geo.height); xsurface->x, xsurface->y, new_geo.width, new_geo.height);
} else { } else {
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
} }