Skip to content

Commit

Permalink
chore: bump sctk to use master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
kchibisov committed Mar 25, 2023
1 parent 0faaae6 commit a2a1259
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ libc = "0.2.64"
mio = { version = "0.8", features = ["os-ext"], optional = true }
percent-encoding = { version = "2.0", optional = true }
fnv = { version = "1.0.3", optional = true }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/kchibisov/client-toolkit", branch = "winit-update", optional = true }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", optional = true }
sctk-adwaita = { git = "https://github.com/kchibisov/sctk-adwaita", branch = "update-wayland-rs-030", default_features = false, optional = true }
wayland-client = { version = "0.30.0", optional = true }
wayland-backend = { version = "0.1.0", default_features = false, features = ["client_system"], optional = true }
Expand Down
42 changes: 24 additions & 18 deletions src/platform_impl/linux/wayland/window/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! The state of the window, which is shared with the event-loop.
use std::mem::ManuallyDrop;
use std::num::NonZeroU32;
use std::sync::{Arc, Weak};

use log::warn;
Expand Down Expand Up @@ -193,24 +194,30 @@ impl WindowState {
self.frame = None;
}

// TODO refactor SCTK to use bitflags.
let stateless = Self::is_stateless(&configure);

let new_size = if let Some(frame) = self.frame.as_mut() {
// Configure the window states.
frame.configure_state(&configure.states);
frame.update_state(configure.state);

match configure.new_size {
Some((width, height)) => frame.subtract_borders(width, height).into(),
None if stateless => self.stateless_size,
None => self.size,
(Some(width), Some(height)) => {
let (width, height) = frame.subtract_borders(width, height);
(
width.map(|w| w.get()).unwrap_or(1),
height.map(|h| h.get()).unwrap_or(1),
)
.into()
}
(_, _) if stateless => self.stateless_size,
_ => self.size,
}
} else {
configure.new_size.map(Into::into).unwrap_or(if stateless {
self.stateless_size
} else {
self.size
})
match configure.new_size {
(Some(width), Some(height)) => (width.get(), height.get()).into(),
_ if stateless => self.stateless_size,
_ => self.size,
}
};

// XXX Set the configure before doing a resize.
Expand All @@ -222,13 +229,9 @@ impl WindowState {
new_size
}

#[inline]
fn is_stateless(configure: &WindowConfigure) -> bool {
!(configure.is_maximized()
|| configure.is_fullscreen()
|| configure.is_tiled_left()
|| configure.is_tiled_right()
|| configure.is_tiled_top()
|| configure.is_tiled_bottom())
!(configure.is_maximized() || configure.is_fullscreen() || configure.is_tiled())
}

/// Start interacting drag resize.
Expand Down Expand Up @@ -273,7 +276,7 @@ impl WindowState {
FrameAction::Maximize => self.window.set_maximized(),
FrameAction::UnMaximize => self.window.unset_maximized(),
FrameAction::Close => WinitState::queue_close(updates, window_id),
FrameAction::Move => self.window.r#move(seat, serial),
FrameAction::Move => self.window.move_(seat, serial),
FrameAction::Resize(edge) => self.window.resize(seat, serial, edge),
FrameAction::ShowMenu(x, y) => self.window.show_window_menu(seat, serial, (x, y)),
};
Expand Down Expand Up @@ -496,7 +499,10 @@ impl WindowState {
let ((x, y), outer_size) = if let Some(frame) = self.frame.as_mut() {
// Resize only visible frame.
if !frame.is_hidden() {
frame.resize(self.size.width, self.size.height);
frame.resize(
NonZeroU32::new(self.size.width).unwrap(),
NonZeroU32::new(self.size.height).unwrap(),
);
}

(
Expand Down

0 comments on commit a2a1259

Please sign in to comment.