@@ -25,6 +25,7 @@ pub enum Message {
25
25
ShowActiveWindowHint ( bool ) ,
26
26
ShowMaximizeButton ( bool ) ,
27
27
ShowMinimizeButton ( bool ) ,
28
+ SetEdgeSnapThreshold ( u32 ) ,
28
29
}
29
30
30
31
pub struct Page {
@@ -36,6 +37,7 @@ pub struct Page {
36
37
focus_delay_text : String ,
37
38
cursor_follows_focus : bool ,
38
39
show_active_hint : bool ,
40
+ edge_snap_threshold : u32 ,
39
41
}
40
42
41
43
impl Default for Page {
@@ -76,6 +78,15 @@ impl Default for Page {
76
78
} )
77
79
. unwrap_or ( true ) ;
78
80
81
+ let edge_snap_threshold = comp_config
82
+ . get ( "edge_snap_threshold" )
83
+ . inspect_err ( |err| {
84
+ if !matches ! ( err, cosmic_config:: Error :: NoConfigDirectory ) {
85
+ error ! ( ?err, "Failed to read config 'edge_snap_threshold'" )
86
+ }
87
+ } )
88
+ . unwrap_or ( 0 ) ;
89
+
79
90
Page {
80
91
super_key_selections : vec ! [
81
92
fl!( "super-key" , "launcher" ) ,
@@ -90,6 +101,7 @@ impl Default for Page {
90
101
focus_delay_text : format ! ( "{focus_follows_cursor_delay}" ) ,
91
102
cursor_follows_focus,
92
103
show_active_hint,
104
+ edge_snap_threshold,
93
105
}
94
106
}
95
107
}
@@ -168,6 +180,12 @@ impl Page {
168
180
error ! ( ?err, "Failed to set config 'active_hint'" ) ;
169
181
}
170
182
}
183
+ Message :: SetEdgeSnapThreshold ( value) => {
184
+ self . edge_snap_threshold = value;
185
+ if let Err ( err) = self . comp_config . set ( "edge_snap_threshold" , value) {
186
+ error ! ( ?err, "Failed to set config 'edge_snap_threshold'" ) ;
187
+ }
188
+ }
171
189
}
172
190
}
173
191
}
@@ -179,7 +197,7 @@ impl page::Page<crate::pages::Message> for Page {
179
197
sections : & mut SlotMap < section:: Entity , Section < crate :: pages:: Message > > ,
180
198
) -> Option < page:: Content > {
181
199
Some ( vec ! [
182
- sections. insert( super_key_action ( ) ) ,
200
+ sections. insert( window_management ( ) ) ,
183
201
sections. insert( window_controls( ) ) ,
184
202
sections. insert( focus_navigation( ) ) ,
185
203
] )
@@ -197,7 +215,7 @@ impl page::Page<crate::pages::Message> for Page {
197
215
198
216
impl page:: AutoBind < crate :: pages:: Message > for Page { }
199
217
200
- pub fn super_key_action ( ) -> Section < crate :: pages:: Message > {
218
+ pub fn window_management ( ) -> Section < crate :: pages:: Message > {
201
219
let mut descriptions = Slab :: new ( ) ;
202
220
203
221
let super_key = descriptions. insert ( fl ! ( "super-key" ) ) ;
@@ -206,6 +224,8 @@ pub fn super_key_action() -> Section<crate::pages::Message> {
206
224
let _applications = descriptions. insert ( fl ! ( "super-key" , "applications" ) ) ;
207
225
let _disable = descriptions. insert ( fl ! ( "super-key" , "disable" ) ) ;
208
226
227
+ let edge_gravity = descriptions. insert ( fl ! ( "edge-gravity" ) ) ;
228
+
209
229
Section :: default ( )
210
230
. descriptions ( descriptions)
211
231
. view :: < Page > ( move |_binder, page, section| {
@@ -220,6 +240,12 @@ pub fn super_key_action() -> Section<crate::pages::Message> {
220
240
Message :: SuperKey ,
221
241
) ) ,
222
242
)
243
+ . add ( settings:: item (
244
+ & descriptions[ edge_gravity] ,
245
+ toggler ( page. edge_snap_threshold != 0 ) . on_toggle ( |is_enabled| {
246
+ Message :: SetEdgeSnapThreshold ( if is_enabled { 10 } else { 0 } )
247
+ } ) ,
248
+ ) )
223
249
. apply ( Element :: from)
224
250
. map ( crate :: pages:: Message :: WindowManagement )
225
251
} )
0 commit comments