Skip to content

Commit

Permalink
Always respect XDG configure size regardless of state (#321)
Browse files Browse the repository at this point in the history
The previous logic was ignoring most of the toplevel configure events unless the window was maximized or was being resized. This pull-request removes that check in order to always respect the size suggested by the compositor.

This is particularly important for tiling compositors (e.g.: sway) where the window can be arbitrarily resized by the compositor even when it's not maximized (e.g.: when it's part of a tiled layout). The screen recordings below show some comparison videos of the old and new behavior.

Signed-off-by: Valentin Hăloiu <[email protected]>
  • Loading branch information
vially authored Jan 4, 2023
1 parent ce3a7f5 commit a03e186
Showing 1 changed file with 3 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,36 +91,14 @@ const xdg_toplevel_listener ELinuxWindowWayland::kXdgToplevelListener = {
int32_t width,
int32_t height,
wl_array* states) {
auto is_maximized = false;
auto is_resizing = false;
uint32_t* state = static_cast<uint32_t*>(states->data);
for (auto i = 0; i < states->size; i++) {
switch (*state) {
case XDG_TOPLEVEL_STATE_MAXIMIZED:
is_maximized = true;
break;
case XDG_TOPLEVEL_STATE_RESIZING:
is_resizing = true;
break;
case XDG_TOPLEVEL_STATE_ACTIVATED:
case XDG_TOPLEVEL_STATE_FULLSCREEN:
default:
break;
}
state++;
}

auto self = reinterpret_cast<ELinuxWindowWayland*>(data);
if (self->current_rotation_ == 90 || self->current_rotation_ == 270) {
std::swap(width, height);
}

int32_t next_width = 0;
int32_t next_height = 0;
if (is_maximized || is_resizing) {
next_width = width;
next_height = height;
} else if (self->restore_window_required_) {
int32_t next_width = width;
int32_t next_height = height;
if (self->restore_window_required_) {
self->restore_window_required_ = false;
next_width = self->restore_window_width_;
next_height = self->restore_window_height_;
Expand Down

0 comments on commit a03e186

Please sign in to comment.