aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sway/desktop/transaction.h13
-rw-r--r--sway/desktop/output.c8
-rw-r--r--sway/desktop/transaction.c17
3 files changed, 25 insertions, 13 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h
index fcfed297..7ab80eb8 100644
--- a/include/sway/desktop/transaction.h
+++ b/include/sway/desktop/transaction.h
@@ -52,11 +52,16 @@ 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.
+ * Get the saved texture that should be rendered for a view.
*
- * In most cases this will return the normal live texture for a view, but if the
- * view is in a transaction then it'll return a saved texture.
+ * The addresses pointed at by the width and height pointers will be populated
+ * with the surface's dimensions, which may be different to the texture's
+ * dimensions if output scaling is used.
+ *
+ * This function should only be called if it is known that the view has
+ * instructions.
*/
-struct wlr_texture *transaction_get_texture(struct sway_view *view);
+struct wlr_texture *transaction_get_saved_texture(struct sway_view *view,
+ int *width, int *height);
#endif
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 69d0bdd4..b55a3962 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -354,15 +354,17 @@ static void render_saved_view(struct sway_view *view,
struct sway_output *output, pixman_region32_t *damage, float alpha) {
struct wlr_output *wlr_output = output->wlr_output;
- struct wlr_texture *texture = transaction_get_texture(view);
+ int width, height;
+ struct wlr_texture *texture =
+ transaction_get_saved_texture(view, &width, &height);
if (!texture) {
return;
}
struct wlr_box box = {
.x = view->swayc->current.view_x - output->swayc->current.swayc_x,
.y = view->swayc->current.view_y - output->swayc->current.swayc_y,
- .width = view->swayc->current.view_width,
- .height = view->swayc->current.view_height,
+ .width = width,
+ .height = height,
};
struct wlr_box output_box = {
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index fc23ef35..7c5a9b8f 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -41,6 +41,7 @@ struct sway_transaction_instruction {
struct sway_container *container;
struct sway_container_state state;
struct wlr_buffer *saved_buffer;
+ int saved_buffer_width, saved_buffer_height;
uint32_t serial;
bool ready;
};
@@ -71,6 +72,8 @@ static void save_view_buffer(struct sway_view *view,
}
if (view->surface && wlr_surface_has_buffer(view->surface)) {
instruction->saved_buffer = wlr_buffer_ref(view->surface->buffer);
+ instruction->saved_buffer_width = view->surface->current->width;
+ instruction->saved_buffer_height = view->surface->current->height;
}
}
@@ -392,12 +395,14 @@ void transaction_notify_view_ready_by_size(struct sway_view *view,
}
}
-struct wlr_texture *transaction_get_texture(struct sway_view *view) {
- if (!view->swayc || !view->swayc->instructions->length) {
- return view->surface->buffer->texture;
- }
+struct wlr_texture *transaction_get_saved_texture(struct sway_view *view,
+ int *width, int *height) {
struct sway_transaction_instruction *instruction =
view->swayc->instructions->items[0];
- return instruction->saved_buffer ?
- instruction->saved_buffer->texture : NULL;
+ if (!instruction->saved_buffer) {
+ return NULL;
+ }
+ *width = instruction->saved_buffer_width;
+ *height = instruction->saved_buffer_height;
+ return instruction->saved_buffer->texture;
}