@@ -5,6 +5,7 @@ use std::sync::{Arc, Mutex, Weak};
5
5
use std:: time:: Duration ;
6
6
7
7
use ahash:: HashSet ;
8
+ use dpi:: { PhysicalPosition , Position } ;
8
9
use sctk:: compositor:: { CompositorState , Region , SurfaceData , SurfaceDataExt } ;
9
10
use sctk:: reexports:: client:: backend:: ObjectId ;
10
11
use sctk:: reexports:: client:: protocol:: wl_seat:: WlSeat ;
@@ -76,7 +77,7 @@ pub struct WindowState {
76
77
/// Queue handle.
77
78
pub queue_handle : QueueHandle < WinitState > ,
78
79
79
- /// State that differes based on being an XDG shell or a WLR layer shell
80
+ /// State that differs based on being an XDG shell or a WLR layer shell
80
81
shell_specific : ShellSpecificState ,
81
82
82
83
/// Theme variant.
@@ -85,9 +86,6 @@ pub struct WindowState {
85
86
/// The current window title.
86
87
title : String ,
87
88
88
- /// Whether the frame is resizable.
89
- resizable : bool ,
90
-
91
89
// NOTE: we can't use simple counter, since it's racy when seat getting destroyed and new
92
90
// is created, since add/removed stuff could be delivered a bit out of order.
93
91
/// Seats that has keyboard focus on that window.
@@ -226,7 +224,6 @@ impl WindowState {
226
224
pointer_constraints,
227
225
pointers : Default :: default ( ) ,
228
226
queue_handle : queue_handle. clone ( ) ,
229
- resizable : true ,
230
227
scale_factor : 1. ,
231
228
shm : winit_state. shm . wl_shm ( ) . clone ( ) ,
232
229
custom_cursor_pool : winit_state. custom_cursor_pool . clone ( ) ,
@@ -269,11 +266,10 @@ impl WindowState {
269
266
} ,
270
267
size : initial_size. to_logical ( 1.0 ) ,
271
268
selected_cursor : Default :: default ( ) ,
272
- decorate : true ,
269
+ decorate : false ,
273
270
frame_callback_state : FrameCallbackState :: None ,
274
271
seat_focus : Default :: default ( ) ,
275
272
has_pending_move : None ,
276
- resizable : true ,
277
273
custom_cursor_pool : winit_state. custom_cursor_pool . clone ( ) ,
278
274
initial_size : Some ( initial_size) ,
279
275
text_inputs : Vec :: new ( ) ,
@@ -733,6 +729,27 @@ impl WindowState {
733
729
}
734
730
}
735
731
732
+ #[ inline]
733
+ pub fn outer_position ( & self ) -> Result < PhysicalPosition < i32 > , RequestError > {
734
+ Err ( NotSupportedError :: new ( "window position information is not available on xdg Wayland" )
735
+ . into ( ) )
736
+ }
737
+
738
+ pub fn set_outer_position ( & self , position : Position ) {
739
+ let position = position. to_logical ( self . scale_factor ) ;
740
+
741
+ match & self . shell_specific {
742
+ ShellSpecificState :: Xdg { .. } => {
743
+ warn ! ( "Change window position is not available on xdg Wayland" , )
744
+ } ,
745
+ // XXX just works for LayerShell
746
+ // Probably we can save this change to get in the `outer_position` function
747
+ ShellSpecificState :: WlrLayer { surface, .. } => {
748
+ surface. set_margin ( position. y , 0 , 0 , position. x )
749
+ } ,
750
+ }
751
+ }
752
+
736
753
/// Get the outer size of the window.
737
754
#[ inline]
738
755
pub fn outer_size ( & self ) -> LogicalSize < u32 > {
@@ -862,7 +879,8 @@ impl WindowState {
862
879
outer_size. height as i32 ,
863
880
) ;
864
881
865
- // Update the target viewport, this is used if and only if fractional scaling is in use.
882
+ // Update the target viewport, this is used if and only if fractional scaling is in
883
+ // use.
866
884
if let Some ( viewport) = viewport. as_ref ( ) {
867
885
// Set inner size without the borders.
868
886
viewport. set_destination ( self . size . width as _ , self . size . height as _ ) ;
0 commit comments