Skip to content

Commit

Permalink
feat: support to move wlr_layer_shell
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRibera committed Dec 18, 2024
1 parent f526b79 commit 41327bb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/platform_impl/linux/wayland/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,13 @@ impl CoreWindow for Window {
}

fn outer_position(&self) -> Result<PhysicalPosition<i32>, RequestError> {
Err(NotSupportedError::new("window position information is not available on Wayland")
.into())
// XXX just for LayerShell
self.window_state.lock().unwrap().outer_position()
}

fn set_outer_position(&self, _position: Position) {
// Not possible.
fn set_outer_position(&self, position: Position) {
// XXX just for LayerShell
self.window_state.lock().unwrap().set_outer_position(position);
}

fn surface_size(&self) -> PhysicalSize<u32> {
Expand Down
22 changes: 22 additions & 0 deletions src/platform_impl/linux/wayland/window/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::sync::{Arc, Mutex, Weak};
use std::time::Duration;

use ahash::HashSet;
use dpi::{PhysicalPosition, Position};
use sctk::compositor::{CompositorState, Region, SurfaceData, SurfaceDataExt};
use sctk::reexports::client::backend::ObjectId;
use sctk::reexports::client::protocol::wl_seat::WlSeat;
Expand Down Expand Up @@ -733,6 +734,27 @@ impl WindowState {
}
}

#[inline]
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, RequestError> {
Err(NotSupportedError::new("window position information is not available on xdg Wayland")
.into())
}

pub fn set_outer_position(&self, position: Position) {
let position = position.to_logical(self.scale_factor);

match &self.shell_specific {
ShellSpecificState::Xdg { .. } => {
warn!("Change window position is not available on xdg Wayland",)
},
// XXX just works for LayerShell
// Probably we can save this change to get in the `outer_position` function
ShellSpecificState::WlrLayer { surface, .. } => {
surface.set_margin(position.y, 0, 0, position.x)
},
}
}

/// Get the outer size of the window.
#[inline]
pub fn outer_size(&self) -> LogicalSize<u32> {
Expand Down

0 comments on commit 41327bb

Please sign in to comment.