@@ -101,6 +101,7 @@ fn main() {
101
101
themed_pointer : None ,
102
102
set_cursor : false ,
103
103
cursor_icon : CursorIcon :: Crosshair ,
104
+ hide_titlebar : false ,
104
105
} ;
105
106
106
107
// We don't draw immediately, the configure will notify us when to first draw.
@@ -137,6 +138,8 @@ struct SimpleWindow {
137
138
themed_pointer : Option < ThemedPointer > ,
138
139
set_cursor : bool ,
139
140
cursor_icon : CursorIcon ,
141
+
142
+ hide_titlebar : bool ,
140
143
}
141
144
142
145
impl CompositorHandler for SimpleWindow {
@@ -251,7 +254,7 @@ impl WindowHandler for SimpleWindow {
251
254
self . compositor_state . clone ( ) ,
252
255
self . subcompositor_state . clone ( ) ,
253
256
qh. clone ( ) ,
254
- FrameConfig :: auto ( ) ,
257
+ FrameConfig :: auto ( ) . hide_titlebar ( self . hide_titlebar ) ,
255
258
)
256
259
. expect ( "failed to create client side decorations frame." ) ;
257
260
frame. set_title ( self . title . clone ( ) ) ;
@@ -447,7 +450,45 @@ impl PointerHandler for SimpleWindow {
447
450
}
448
451
} else if pressed {
449
452
println ! ( "Press {:x} @ {:?}" , button, event. position) ;
450
- self . shift = self . shift . xor ( Some ( 0 ) ) ;
453
+
454
+ if button == 0x111 {
455
+ self . hide_titlebar = !self . hide_titlebar ;
456
+
457
+ if let Some ( frame) = self . window_frame . as_mut ( ) {
458
+ // FrameConfig::auto() is not free, this shouldn't be called here
459
+ let config = FrameConfig :: auto ( ) ;
460
+
461
+ if self . hide_titlebar {
462
+ frame. set_config ( config. hide_titlebar ( true ) ) ;
463
+ self . window . xdg_surface ( ) . set_window_geometry (
464
+ 0 ,
465
+ 0 ,
466
+ self . width . get ( ) as i32 ,
467
+ self . height . get ( ) as i32 ,
468
+ ) ;
469
+ } else {
470
+ let ( width, height) = ( self . width , self . height ) ;
471
+
472
+ frame. set_config ( config. hide_titlebar ( false ) ) ;
473
+ frame. resize ( width, height) ;
474
+
475
+ let ( x, y) = frame. location ( ) ;
476
+ let outer_size = frame. add_borders ( width. get ( ) , height. get ( ) ) ;
477
+ self . window . xdg_surface ( ) . set_window_geometry (
478
+ x,
479
+ y,
480
+ outer_size. 0 as i32 ,
481
+ outer_size. 1 as i32 ,
482
+ ) ;
483
+
484
+ // Update new width and height;
485
+ self . width = width;
486
+ self . height = height;
487
+ }
488
+ }
489
+ } else {
490
+ self . shift = self . shift . xor ( Some ( 0 ) ) ;
491
+ }
451
492
}
452
493
}
453
494
Axis {
0 commit comments