@@ -11,8 +11,9 @@ use crate::{
11
11
utils:: prelude:: * ,
12
12
wayland:: {
13
13
handlers:: screencopy:: { submit_buffer, FrameHolder , SessionData } ,
14
- protocols:: screencopy:: {
15
- FailureReason , Frame as ScreencopyFrame , Session as ScreencopySession ,
14
+ protocols:: {
15
+ screencopy:: { FailureReason , Frame as ScreencopyFrame , Session as ScreencopySession } ,
16
+ workspace:: WorkspaceUpdateGuard ,
16
17
} ,
17
18
} ,
18
19
} ;
@@ -76,6 +77,7 @@ use smithay::{
76
77
relative_pointer:: RelativePointerManagerState ,
77
78
seat:: WaylandFocus ,
78
79
shm:: { shm_format_to_fourcc, with_buffer_contents} ,
80
+ xdg_activation:: XdgActivationState ,
79
81
} ,
80
82
} ;
81
83
use tracing:: { error, info, trace, warn} ;
@@ -202,7 +204,7 @@ pub fn init_backend(
202
204
state. backend . kms ( ) . input_devices . remove ( device. name ( ) ) ;
203
205
}
204
206
state. process_input_event ( event, true ) ;
205
- for output in state. common . shell . outputs ( ) {
207
+ for output in state. common . shell . read ( ) . unwrap ( ) . outputs ( ) {
206
208
if let Err ( err) = state. backend . kms ( ) . schedule_render (
207
209
& state. common . event_loop_handle ,
208
210
output,
@@ -326,9 +328,13 @@ pub fn init_backend(
326
328
state. common . config . read_outputs (
327
329
& mut state. common . output_configuration_state ,
328
330
& mut state. backend ,
329
- & mut state. common . shell ,
331
+ & mut state. common . shell . write ( ) . unwrap ( ) ,
330
332
& state. common . event_loop_handle ,
333
+ & mut state. common . workspace_state . update ( ) ,
334
+ & state. common . xdg_activation_state ,
331
335
) ;
336
+ state. common . refresh ( ) ;
337
+
332
338
for surface in state
333
339
. backend
334
340
. kms ( )
@@ -339,7 +345,7 @@ pub fn init_backend(
339
345
surface. scheduled = false ;
340
346
surface. pending = false ;
341
347
}
342
- for output in state. common . shell . outputs ( ) {
348
+ for output in state. common . shell . read ( ) . unwrap ( ) . outputs ( ) {
343
349
if let Err ( err) = state. backend . kms ( ) . schedule_render (
344
350
& state. common . event_loop_handle ,
345
351
output,
@@ -601,7 +607,7 @@ impl State {
601
607
602
608
let outputs = device. enumerate_surfaces ( ) ?. added ; // There are no removed outputs on newly added devices
603
609
let mut wl_outputs = Vec :: new ( ) ;
604
- let mut w = self . common . shell . global_space ( ) . size . w ;
610
+ let mut w = self . common . shell . read ( ) . unwrap ( ) . global_space ( ) . size . w ;
605
611
{
606
612
let backend = self . backend . kms ( ) ;
607
613
backend
@@ -701,9 +707,12 @@ impl State {
701
707
self . common . config . read_outputs (
702
708
& mut self . common . output_configuration_state ,
703
709
& mut self . backend ,
704
- & mut self . common . shell ,
710
+ & mut * self . common . shell . write ( ) . unwrap ( ) ,
705
711
& self . common . event_loop_handle ,
712
+ & mut self . common . workspace_state . update ( ) ,
713
+ & self . common . xdg_activation_state ,
706
714
) ;
715
+ self . common . refresh ( ) ;
707
716
708
717
Ok ( ( ) )
709
718
}
@@ -720,7 +729,7 @@ impl State {
720
729
let backend = self . backend . kms ( ) ;
721
730
if let Some ( device) = backend. devices . get_mut ( & drm_node) {
722
731
let changes = device. enumerate_surfaces ( ) ?;
723
- let mut w = self . common . shell . global_space ( ) . size . w ;
732
+ let mut w = self . common . shell . read ( ) . unwrap ( ) . global_space ( ) . size . w ;
724
733
for crtc in changes. removed {
725
734
if let Some ( pos) = device
726
735
. non_desktop_connectors
@@ -831,18 +840,23 @@ impl State {
831
840
self . common
832
841
. output_configuration_state
833
842
. add_heads ( outputs_added. iter ( ) ) ;
834
- self . common . config . read_outputs (
835
- & mut self . common . output_configuration_state ,
836
- & mut self . backend ,
837
- & mut self . common . shell ,
838
- & self . common . event_loop_handle ,
839
- ) ;
840
- // Don't remove the outputs, before potentially new ones have been initialized.
841
- // reading a new config means outputs might become enabled, that were previously disabled.
842
- // If we have 0 outputs at some point, we won't quit, but shell doesn't know where to move
843
- // windows and workspaces to.
844
- for output in outputs_removed {
845
- self . common . shell . remove_output ( & output) ;
843
+ {
844
+ self . common . config . read_outputs (
845
+ & mut self . common . output_configuration_state ,
846
+ & mut self . backend ,
847
+ & mut * self . common . shell . write ( ) . unwrap ( ) ,
848
+ & self . common . event_loop_handle ,
849
+ & mut self . common . workspace_state . update ( ) ,
850
+ & self . common . xdg_activation_state ,
851
+ ) ;
852
+ self . common . refresh ( ) ;
853
+ // Don't remove the outputs, before potentially new ones have been initialized.
854
+ // reading a new config means outputs might become enabled, that were previously disabled.
855
+ // If we have 0 outputs at some point, we won't quit, but shell doesn't know where to move
856
+ // windows and workspaces to.
857
+ for output in outputs_removed {
858
+ self . common . remove_output ( & output) ;
859
+ }
846
860
}
847
861
848
862
{
@@ -889,14 +903,17 @@ impl State {
889
903
890
904
if self . backend . kms ( ) . session . is_active ( ) {
891
905
for output in outputs_removed {
892
- self . common . shell . remove_output ( & output) ;
906
+ self . common . remove_output ( & output) ;
893
907
}
894
908
self . common . config . read_outputs (
895
909
& mut self . common . output_configuration_state ,
896
910
& mut self . backend ,
897
- & mut self . common . shell ,
911
+ & mut * self . common . shell . write ( ) . unwrap ( ) ,
898
912
& self . common . event_loop_handle ,
913
+ & mut self . common . workspace_state . update ( ) ,
914
+ & self . common . xdg_activation_state ,
899
915
) ;
916
+ self . common . refresh ( ) ;
900
917
} else {
901
918
self . common . output_configuration_state . update ( ) ;
902
919
}
@@ -1178,30 +1195,33 @@ impl Surface {
1178
1195
) ;
1179
1196
}
1180
1197
1181
- let ( previous_workspace, workspace) = state. shell . workspaces . active ( & self . output ) ;
1182
- let ( previous_idx, idx) = state. shell . workspaces . active_num ( & self . output ) ;
1183
- let previous_workspace = previous_workspace
1184
- . zip ( previous_idx)
1185
- . map ( |( ( w, start) , idx) | ( w. handle , idx, start) ) ;
1186
- let workspace = ( workspace. handle , idx) ;
1187
-
1188
- let mut elements = workspace_elements (
1189
- Some ( & render_node) ,
1190
- & mut renderer,
1191
- & state. shell ,
1192
- & state. config ,
1193
- & state. theme ,
1194
- state. clock . now ( ) ,
1195
- & self . output ,
1196
- previous_workspace,
1197
- workspace,
1198
- CursorMode :: All ,
1199
- & mut Some ( & mut self . fps ) ,
1200
- false ,
1201
- )
1202
- . map_err ( |err| {
1203
- anyhow:: format_err!( "Failed to accumulate elements for rendering: {:?}" , err)
1204
- } ) ?;
1198
+ let mut elements = {
1199
+ let shell = state. shell . read ( ) . unwrap ( ) ;
1200
+ let ( previous_workspace, workspace) = shell. workspaces . active ( & self . output ) ;
1201
+ let ( previous_idx, idx) = shell. workspaces . active_num ( & self . output ) ;
1202
+ let previous_workspace = previous_workspace
1203
+ . zip ( previous_idx)
1204
+ . map ( |( ( w, start) , idx) | ( w. handle , idx, start) ) ;
1205
+ let workspace = ( workspace. handle , idx) ;
1206
+
1207
+ workspace_elements (
1208
+ Some ( & render_node) ,
1209
+ & mut renderer,
1210
+ & * shell,
1211
+ & state. config ,
1212
+ & state. theme ,
1213
+ state. clock . now ( ) ,
1214
+ & self . output ,
1215
+ previous_workspace,
1216
+ workspace,
1217
+ CursorMode :: All ,
1218
+ & mut Some ( & mut self . fps ) ,
1219
+ false ,
1220
+ )
1221
+ . map_err ( |err| {
1222
+ anyhow:: format_err!( "Failed to accumulate elements for rendering: {:?}" , err)
1223
+ } ) ?
1224
+ } ;
1205
1225
self . fps . elements ( ) ;
1206
1226
1207
1227
let frames: Vec < (
@@ -1490,6 +1510,8 @@ impl KmsState {
1490
1510
shell : & mut Shell ,
1491
1511
test_only : bool ,
1492
1512
loop_handle : & LoopHandle < ' _ , State > ,
1513
+ workspace_state : & mut WorkspaceUpdateGuard < ' _ , State > ,
1514
+ xdg_activation_state : & XdgActivationState ,
1493
1515
) -> Result < ( ) , anyhow:: Error > {
1494
1516
let recreated = if let Some ( device) = self
1495
1517
. devices
@@ -1509,7 +1531,12 @@ impl KmsState {
1509
1531
1510
1532
if !output_config. enabled {
1511
1533
if !test_only {
1512
- shell. remove_output ( output) ;
1534
+ shell. workspaces . remove_output (
1535
+ output,
1536
+ shell. seats . iter ( ) ,
1537
+ workspace_state,
1538
+ xdg_activation_state,
1539
+ ) ;
1513
1540
if surface. surface . take ( ) . is_some ( ) {
1514
1541
// just drop it
1515
1542
surface. pending = false ;
@@ -1608,7 +1635,9 @@ impl KmsState {
1608
1635
surface. surface = Some ( target) ;
1609
1636
true
1610
1637
} ;
1611
- shell. add_output ( output) ;
1638
+ shell
1639
+ . workspaces
1640
+ . add_output ( output, workspace_state, xdg_activation_state) ;
1612
1641
res
1613
1642
} else {
1614
1643
false
@@ -1748,7 +1777,7 @@ impl KmsState {
1748
1777
& surface. output ,
1749
1778
backend. primary_node ,
1750
1779
target_node,
1751
- & common. shell ,
1780
+ & * common. shell . read ( ) . unwrap ( ) ,
1752
1781
) ;
1753
1782
1754
1783
let result = if render_node != target_node {
0 commit comments