aboutsummaryrefslogtreecommitdiff
path: root/sway/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/desktop.c18
-rw-r--r--sway/desktop/output.c51
-rw-r--r--sway/desktop/render.c51
-rw-r--r--sway/desktop/transaction.c118
-rw-r--r--sway/desktop/xdg_shell.c20
-rw-r--r--sway/desktop/xdg_shell_v6.c21
-rw-r--r--sway/desktop/xwayland.c34
7 files changed, 189 insertions, 124 deletions
diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c
index 6575519d..72650397 100644
--- a/sway/desktop/desktop.c
+++ b/sway/desktop/desktop.c
@@ -22,3 +22,21 @@ void desktop_damage_whole_container(struct sway_container *con) {
}
}
}
+
+void desktop_damage_box(struct wlr_box *box) {
+ for (int i = 0; i < root_container.children->length; ++i) {
+ struct sway_container *cont = root_container.children->items[i];
+ output_damage_box(cont->sway_output, box);
+ }
+}
+
+void desktop_damage_view(struct sway_view *view) {
+ desktop_damage_whole_container(view->swayc);
+ struct wlr_box box = {
+ .x = view->swayc->current.view_x - view->geometry.x,
+ .y = view->swayc->current.view_y - view->geometry.y,
+ .width = view->surface->current.width,
+ .height = view->surface->current.height,
+ };
+ desktop_damage_box(&box);
+}
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 66747a3f..3d8bbff5 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -144,15 +144,16 @@ void output_view_for_each_surface(struct sway_output *output,
.user_iterator = iterator,
.user_data = user_data,
.output = output,
- .ox = view->swayc->current.view_x - output->swayc->current.swayc_x,
- .oy = view->swayc->current.view_y - output->swayc->current.swayc_y,
+ .ox = view->swayc->current.view_x - output->swayc->current.swayc_x
+ - view->geometry.x,
+ .oy = view->swayc->current.view_y - output->swayc->current.swayc_y
+ - view->geometry.y,
.width = view->swayc->current.view_width,
.height = view->swayc->current.view_height,
.rotation = 0, // TODO
};
- view_for_each_surface(view,
- output_for_each_surface_iterator, &data);
+ view_for_each_surface(view, output_for_each_surface_iterator, &data);
}
void output_view_for_each_popup(struct sway_output *output,
@@ -162,8 +163,10 @@ void output_view_for_each_popup(struct sway_output *output,
.user_iterator = iterator,
.user_data = user_data,
.output = output,
- .ox = view->swayc->current.view_x - output->swayc->current.swayc_x,
- .oy = view->swayc->current.view_y - output->swayc->current.swayc_y,
+ .ox = view->swayc->current.view_x - output->swayc->current.swayc_x
+ - view->geometry.x,
+ .oy = view->swayc->current.view_y - output->swayc->current.swayc_y
+ - view->geometry.y,
.width = view->swayc->current.view_width,
.height = view->swayc->current.view_height,
.rotation = 0, // TODO
@@ -303,44 +306,33 @@ struct send_frame_done_data {
static void send_frame_done_container_iterator(struct sway_container *con,
void *_data) {
- struct send_frame_done_data *data = _data;
- if (!sway_assert(con->type == C_VIEW, "expected a view")) {
+ if (con->type != C_VIEW) {
return;
}
-
if (!view_is_visible(con->sway_view)) {
return;
}
+ struct send_frame_done_data *data = _data;
output_view_for_each_surface(data->output, con->sway_view,
send_frame_done_iterator, data->when);
}
-static void send_frame_done_container(struct sway_output *output,
- struct sway_container *con, struct timespec *when) {
- struct send_frame_done_data data = {
- .output = output,
- .when = when,
- };
- container_descendants(con, C_VIEW,
- send_frame_done_container_iterator, &data);
-}
-
static void send_frame_done(struct sway_output *output, struct timespec *when) {
if (output_has_opaque_overlay_layer_surface(output)) {
goto send_frame_overlay;
}
+ struct send_frame_done_data data = {
+ .output = output,
+ .when = when,
+ };
struct sway_container *workspace = output_get_active_workspace(output);
if (workspace->current.ws_fullscreen) {
- if (workspace->current.ws_fullscreen->type == C_VIEW) {
- output_view_for_each_surface(output,
- workspace->current.ws_fullscreen->sway_view,
- send_frame_done_iterator, when);
- } else {
- send_frame_done_container(output, workspace->current.ws_fullscreen,
- when);
- }
+ send_frame_done_container_iterator(
+ workspace->current.ws_fullscreen, &data);
+ container_for_each_child(workspace->current.ws_fullscreen,
+ send_frame_done_container_iterator, &data);
#ifdef HAVE_XWAYLAND
send_frame_done_unmanaged(output,
&root_container.sway_root->xwayland_unmanaged, when);
@@ -351,9 +343,8 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) {
send_frame_done_layer(output,
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], when);
- send_frame_done_container(output, workspace, when);
- send_frame_done_container(output, workspace->sway_workspace->floating,
- when);
+ workspace_for_each_container(workspace,
+ send_frame_done_container_iterator, &data);
#ifdef HAVE_XWAYLAND
send_frame_done_unmanaged(output,
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index cdac9c72..5cf8abc0 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -193,9 +193,11 @@ static void render_view_toplevels(struct sway_view *view,
.alpha = alpha,
};
// Render all toplevels without descending into popups
- output_surface_for_each_surface(output, view->surface,
- view->swayc->current.view_x - output->wlr_output->lx,
- view->swayc->current.view_y - output->wlr_output->ly,
+ double ox =
+ view->swayc->current.view_x - output->wlr_output->lx - view->geometry.x;
+ double oy =
+ view->swayc->current.view_y - output->wlr_output->ly - view->geometry.y;
+ output_surface_for_each_surface(output, view->surface, ox, oy,
render_surface_iterator, &data);
}
@@ -227,8 +229,10 @@ static void render_saved_view(struct sway_view *view,
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,
+ .x = view->swayc->current.view_x - output->swayc->current.swayc_x -
+ view->saved_geometry.x,
+ .y = view->swayc->current.view_y - output->swayc->current.swayc_y -
+ view->saved_geometry.y,
.width = view->saved_buffer_width,
.height = view->saved_buffer_height,
};
@@ -266,7 +270,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
render_view_toplevels(view, output, damage, view->swayc->alpha);
}
- if (view->using_csd) {
+ if (view->swayc->current.using_csd) {
return;
}
@@ -585,7 +589,7 @@ static void render_container_simple(struct sway_output *output,
marks_texture = view->marks_unfocused;
}
- if (!view->using_csd) {
+ if (!view->swayc->current.using_csd) {
if (state->border == B_NORMAL) {
render_titlebar(output, damage, child, state->swayc_x,
state->swayc_y, state->swayc_width, colors,
@@ -750,8 +754,6 @@ static void render_container(struct sway_output *output,
case L_TABBED:
render_container_tabbed(output, damage, con, parent_focused);
break;
- case L_FLOATING:
- sway_assert(false, "Didn't expect to see floating here");
}
}
@@ -777,7 +779,7 @@ static void render_floating_container(struct sway_output *soutput,
marks_texture = view->marks_unfocused;
}
- if (!view->using_csd) {
+ if (!view->swayc->current.using_csd) {
if (con->current.border == B_NORMAL) {
render_titlebar(soutput, damage, con, con->current.swayc_x,
con->current.swayc_y, con->current.swayc_width, colors,
@@ -802,8 +804,7 @@ static void render_floating(struct sway_output *soutput,
if (!workspace_is_visible(ws)) {
continue;
}
- list_t *floating =
- ws->current.ws_floating->current.children;
+ list_t *floating = ws->current.ws_floating;
for (int k = 0; k < floating->length; ++k) {
struct sway_container *floater = floating->items[k];
render_floating_container(soutput, damage, floater);
@@ -812,8 +813,6 @@ static void render_floating(struct sway_output *soutput,
}
}
-const char *damage_debug = NULL;
-
void output_render(struct sway_output *output, struct timespec *when,
pixman_region32_t *damage) {
struct wlr_output *wlr_output = output->wlr_output;
@@ -827,21 +826,17 @@ void output_render(struct sway_output *output, struct timespec *when,
wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height);
- bool damage_whole_before_swap = false;
if (!pixman_region32_not_empty(damage)) {
// Output isn't damaged but needs buffer swap
goto renderer_end;
}
- if (damage_debug != NULL) {
- if (strcmp(damage_debug, "highlight") == 0) {
- wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1});
- damage_whole_before_swap = true;
- } else if (strcmp(damage_debug, "rerender") == 0) {
- int width, height;
- wlr_output_transformed_resolution(wlr_output, &width, &height);
- pixman_region32_union_rect(damage, damage, 0, 0, width, height);
- }
+ if (debug.damage == DAMAGE_HIGHLIGHT) {
+ wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1});
+ } else if (debug.damage == DAMAGE_RERENDER) {
+ int width, height;
+ wlr_output_transformed_resolution(wlr_output, &width, &height);
+ pixman_region32_union_rect(damage, damage, 0, 0, width, height);
}
struct sway_container *workspace = output_get_active_workspace(output);
@@ -915,12 +910,12 @@ render_overlay:
render_drag_icons(output, damage, &root_container.sway_root->drag_icons);
renderer_end:
- if (root_container.sway_root->debug_tree) {
+ if (debug.render_tree) {
+ wlr_renderer_scissor(renderer, NULL);
wlr_render_texture(renderer, root_container.sway_root->debug_tree,
- wlr_output->transform_matrix, 0, 0, 1);
+ wlr_output->transform_matrix, 0, 40, 1);
}
-
- if (damage_whole_before_swap || root_container.sway_root->debug_tree) {
+ if (debug.damage == DAMAGE_HIGHLIGHT) {
int width, height;
wlr_output_transformed_resolution(wlr_output, &width, &height);
pixman_region32_union_rect(damage, damage, 0, 0, width, height);
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index c08730ce..f82e5ef2 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -1,11 +1,13 @@
#define _POSIX_C_SOURCE 200809L
#include <errno.h>
+#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wlr/types/wlr_buffer.h>
#include "sway/debug.h"
+#include "sway/desktop.h"
#include "sway/desktop/idle_inhibit_v1.h"
#include "sway/desktop/transaction.h"
#include "sway/output.h"
@@ -15,26 +17,12 @@
#include "list.h"
#include "log.h"
-/**
- * How long we should wait for views to respond to the configure before giving
- * up and applying the transaction anyway.
- */
-int txn_timeout_ms = 200;
-
-/**
- * If enabled, sway will always wait for the transaction timeout before
- * applying it, rather than applying it when the views are ready. This allows us
- * to observe the rendered state while a transaction is in progress.
- */
-bool txn_debug = false;
-
struct sway_transaction {
struct wl_event_source *timer;
list_t *instructions; // struct sway_transaction_instruction *
size_t num_waiting;
size_t num_configures;
uint32_t con_ids; // Bitwise XOR of view container IDs
- struct timespec create_time;
struct timespec commit_time;
};
@@ -52,9 +40,6 @@ static struct sway_transaction *transaction_create() {
return NULL;
}
transaction->instructions = create_list();
- if (server.debug_txn_timings) {
- clock_gettime(CLOCK_MONOTONIC, &transaction->create_time);
- }
return transaction;
}
@@ -107,10 +92,12 @@ static void copy_pending_state(struct sway_container *container,
state->border_left = view->border_left;
state->border_right = view->border_right;
state->border_bottom = view->border_bottom;
+ state->using_csd = view->using_csd;
} else if (container->type == C_WORKSPACE) {
state->ws_fullscreen = container->sway_workspace->fullscreen;
- state->ws_floating = container->sway_workspace->floating;
+ state->ws_floating = create_list();
state->children = create_list();
+ list_cat(state->ws_floating, container->sway_workspace->floating);
list_cat(state->children, container->children);
} else {
state->children = create_list();
@@ -147,19 +134,14 @@ static void transaction_add_container(struct sway_transaction *transaction,
*/
static void transaction_apply(struct sway_transaction *transaction) {
wlr_log(WLR_DEBUG, "Applying transaction %p", transaction);
- if (server.debug_txn_timings) {
+ if (debug.txn_timings) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
- struct timespec *create = &transaction->create_time;
struct timespec *commit = &transaction->commit_time;
- float ms_arranging = (commit->tv_sec - create->tv_sec) * 1000 +
- (commit->tv_nsec - create->tv_nsec) / 1000000.0;
- float ms_waiting = (now.tv_sec - commit->tv_sec) * 1000 +
+ float ms = (now.tv_sec - commit->tv_sec) * 1000 +
(now.tv_nsec - commit->tv_nsec) / 1000000.0;
- float ms_total = ms_arranging + ms_waiting;
- wlr_log(WLR_DEBUG, "Transaction %p: %.1fms arranging, %.1fms waiting, "
- "%.1fms total (%.1f frames if 60Hz)", transaction,
- ms_arranging, ms_waiting, ms_total, ms_total / (1000.0f / 60));
+ wlr_log(WLR_DEBUG, "Transaction %p: %.1fms waiting "
+ "(%.1f frames if 60Hz)", transaction, ms, ms / (1000.0f / 60));
}
// Apply the instruction state to the container's current state
@@ -168,25 +150,17 @@ static void transaction_apply(struct sway_transaction *transaction) {
transaction->instructions->items[i];
struct sway_container *container = instruction->container;
- // Damage the old and new locations
- struct wlr_box old_box = {
- .x = container->current.swayc_x,
- .y = container->current.swayc_y,
- .width = container->current.swayc_width,
- .height = container->current.swayc_height,
- };
- struct wlr_box new_box = {
- .x = instruction->state.swayc_x,
- .y = instruction->state.swayc_y,
- .width = instruction->state.swayc_width,
- .height = instruction->state.swayc_height,
- };
- for (int j = 0; j < root_container.current.children->length; ++j) {
- struct sway_container *output = root_container.current.children->items[j];
- if (output->sway_output) {
- output_damage_box(output->sway_output, &old_box);
- output_damage_box(output->sway_output, &new_box);
- }
+ // Damage the old location
+ desktop_damage_whole_container(container);
+ if (container->type == C_VIEW && container->sway_view->saved_buffer) {
+ struct sway_view *view = container->sway_view;
+ struct wlr_box box = {
+ .x = container->current.view_x - view->saved_geometry.x,
+ .y = container->current.view_y - view->saved_geometry.y,
+ .width = view->saved_buffer_width,
+ .height = view->saved_buffer_height,
+ };
+ desktop_damage_box(&box);
}
// There are separate children lists for each instruction state, the
@@ -195,15 +169,35 @@ static void transaction_apply(struct sway_transaction *transaction) {
// Any child containers which are being deleted will be cleaned up in
// transaction_destroy().
list_free(container->current.children);
+ list_free(container->current.ws_floating);
memcpy(&container->current, &instruction->state,
sizeof(struct sway_container_state));
if (container->type == C_VIEW && container->sway_view->saved_buffer) {
- view_remove_saved_buffer(container->sway_view);
+ if (!container->destroying || container->ntxnrefs == 1) {
+ view_remove_saved_buffer(container->sway_view);
+ }
+ }
+
+ // Damage the new location
+ desktop_damage_whole_container(container);
+ if (container->type == C_VIEW && container->sway_view->surface) {
+ struct sway_view *view = container->sway_view;
+ struct wlr_surface *surface = view->surface;
+ struct wlr_box box = {
+ .x = container->current.view_x - view->geometry.x,
+ .y = container->current.view_y - view->geometry.y,
+ .width = surface->current.width,
+ .height = surface->current.height,
+ };
+ desktop_damage_box(&box);
}
container->instruction = NULL;
+ if (container->type == C_CONTAINER || container->type == C_VIEW) {
+ container_discover_outputs(container);
+ }
}
}
@@ -294,31 +288,38 @@ static void transaction_commit(struct sway_transaction *transaction) {
struct timespec when;
wlr_surface_send_frame_done(con->sway_view->surface, &when);
}
- if (con->type == C_VIEW) {
+ if (con->type == C_VIEW && !con->sway_view->saved_buffer) {
view_save_buffer(con->sway_view);
+ memcpy(&con->sway_view->saved_geometry, &con->sway_view->geometry,
+ sizeof(struct wlr_box));
}
con->instruction = instruction;
}
transaction->num_configures = transaction->num_waiting;
- if (server.debug_txn_timings) {
+ if (debug.txn_timings) {
clock_gettime(CLOCK_MONOTONIC, &transaction->commit_time);
}
+ if (debug.noatomic) {
+ transaction->num_waiting = 0;
+ } else if (debug.txn_wait) {
+ // Force the transaction to time out even if all views are ready.
+ // We do this by inflating the waiting counter.
+ transaction->num_waiting += 1000000;
+ }
if (transaction->num_waiting) {
// Set up a timer which the views must respond within
transaction->timer = wl_event_loop_add_timer(server.wl_event_loop,
handle_timeout, transaction);
if (transaction->timer) {
- wl_event_source_timer_update(transaction->timer, txn_timeout_ms);
+ wl_event_source_timer_update(transaction->timer,
+ server.txn_timeout_ms);
} else {
wlr_log(WLR_ERROR, "Unable to create transaction timer (%s). "
"Some imperfect frames might be rendered.",
strerror(errno));
- handle_timeout(transaction);
+ transaction->num_waiting = 0;
}
- } else {
- wlr_log(WLR_DEBUG,
- "Transaction %p has nothing to wait for", transaction);
}
// The debug tree shows the pending/live tree. Here is a good place to
@@ -331,7 +332,7 @@ static void set_instruction_ready(
struct sway_transaction_instruction *instruction) {
struct sway_transaction *transaction = instruction->transaction;
- if (server.debug_txn_timings) {
+ if (debug.txn_timings) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
struct timespec *start = &transaction->commit_time;
@@ -342,15 +343,12 @@ static void set_instruction_ready(
transaction->num_configures - transaction->num_waiting + 1,
transaction->num_configures, ms,
instruction->container->name);
-
}
// If the transaction has timed out then its num_waiting will be 0 already.
if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) {
- if (!txn_debug) {
- wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction);
- wl_event_source_timer_update(transaction->timer, 0);
- }
+ wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction);
+ wl_event_source_timer_update(transaction->timer, 0);
}
instruction->container->instruction = NULL;
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 6a7a3f7f..aae129bd 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -7,6 +7,7 @@
#include <wlr/util/edges.h>
#include "log.h"
#include "sway/decoration.h"
+#include "sway/desktop.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/server.h"
@@ -107,7 +108,8 @@ static void get_constraints(struct sway_view *view, double *min_width,
*max_height = state->max_height > 0 ? state->max_height : DBL_MAX;
}
-static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) {
+static const char *get_string_prop(struct sway_view *view,
+ enum sway_view_prop prop) {
if (xdg_shell_view_from_view(view) == NULL) {
return NULL;
}
@@ -255,8 +257,24 @@ static void handle_commit(struct wl_listener *listener, void *data) {
}
if (view->swayc->instruction) {
+ wlr_xdg_surface_get_geometry(xdg_surface, &view->geometry);
transaction_notify_view_ready_by_serial(view,
xdg_surface->configure_serial);
+ } else {
+ struct wlr_box new_geo;
+ wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
+
+ if ((new_geo.width != view->width || new_geo.height != view->height) &&
+ container_is_floating(view->swayc)) {
+ // A floating view has unexpectedly sent a new size
+ desktop_damage_view(view);
+ view_update_size(view, new_geo.width, new_geo.height);
+ memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
+ desktop_damage_view(view);
+ transaction_commit_dirty();
+ } else {
+ memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
+ }
}
view_damage_from(view);
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 5b3c7b2b..277c53a3 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -6,6 +6,7 @@
#include <wlr/types/wlr_xdg_shell_v6.h>
#include "log.h"
#include "sway/decoration.h"
+#include "sway/desktop.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/server.h"
@@ -106,7 +107,8 @@ static void get_constraints(struct sway_view *view, double *min_width,
*max_height = state->max_height > 0 ? state->max_height : DBL_MAX;
}
-static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) {
+static const char *get_string_prop(struct sway_view *view,
+ enum sway_view_prop prop) {
if (xdg_shell_v6_view_from_view(view) == NULL) {
return NULL;
}
@@ -250,9 +252,26 @@ static void handle_commit(struct wl_listener *listener, void *data) {
if (!view->swayc) {
return;
}
+
if (view->swayc->instruction) {
+ wlr_xdg_surface_v6_get_geometry(xdg_surface_v6, &view->geometry);
transaction_notify_view_ready_by_serial(view,
xdg_surface_v6->configure_serial);
+ } else {
+ struct wlr_box new_geo;
+ wlr_xdg_surface_v6_get_geometry(xdg_surface_v6, &new_geo);
+
+ if ((new_geo.width != view->width || new_geo.height != view->height) &&
+ container_is_floating(view->swayc)) {
+ // A floating view has unexpectedly sent a new size
+ desktop_damage_view(view);
+ view_update_size(view, new_geo.width, new_geo.height);
+ memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
+ desktop_damage_view(view);
+ transaction_commit_dirty();
+ } else {
+ memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
+ }
}
view_damage_from(view);
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 14f59b9c..ce7235e4 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -277,18 +277,44 @@ static const struct sway_view_impl view_impl = {
.destroy = destroy,
};
+static void get_geometry(struct sway_view *view, struct wlr_box *box) {
+ box->x = box->y = 0;
+ if (view->surface) {
+ box->width = view->surface->current.width;
+ box->height = view->surface->current.height;
+ } else {
+ box->width = 0;
+ box->height = 0;
+ }
+}
+
static void handle_commit(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, commit);
struct sway_view *view = &xwayland_view->view;
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
- struct wlr_surface_state *surface_state = &xsurface->surface->current;
+ struct wlr_surface_state *state = &xsurface->surface->current;
if (view->swayc->instruction) {
+ get_geometry(view, &view->geometry);
transaction_notify_view_ready_by_size(view,
- surface_state->width, surface_state->height);
- } else if (container_is_floating(view->swayc)) {
- view_update_size(view, surface_state->width, surface_state->height);
+ state->width, state->height);
+ } else {
+ struct wlr_box new_geo;
+ get_geometry(view, &new_geo);
+
+ if ((new_geo.width != view->width || new_geo.height != view->height) &&
+ container_is_floating(view->swayc)) {
+ // A floating view has unexpectedly sent a new size
+ // eg. The Firefox "Save As" dialog when downloading a file
+ desktop_damage_view(view);
+ view_update_size(view, new_geo.width, new_geo.height);
+ memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
+ desktop_damage_view(view);
+ transaction_commit_dirty();
+ } else {
+ memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
+ }
}
view_damage_from(view);