33use crate :: {
44 backend:: render:: cursor:: CursorState ,
55 config:: { xkb_config_to_wl, Action , Config , KeyModifiers , KeyPattern } ,
6- input:: gestures:: { GestureState , SwipeAction } ,
6+ input:: gestures:: GestureState ,
77 shell:: {
88 focus:: {
99 target:: { KeyboardFocusTarget , PointerFocusTarget } ,
@@ -25,7 +25,11 @@ use crate::{
2525 } ,
2626} ;
2727use calloop:: { timer:: Timer , RegistrationToken } ;
28- use cosmic_comp_config:: { workspace:: WorkspaceLayout , TileBehavior } ;
28+ use cosmic_comp_config:: {
29+ input:: { GestureCommand , GestureConfig } ,
30+ workspace:: WorkspaceLayout ,
31+ TileBehavior ,
32+ } ;
2933use cosmic_config:: ConfigSet ;
3034use smithay:: {
3135 backend:: input:: {
@@ -1140,52 +1144,92 @@ impl State {
11401144 }
11411145 InputEvent :: GestureSwipeUpdate { event, .. } => {
11421146 if let Some ( seat) = self . common . seat_with_device ( & event. device ( ) ) . cloned ( ) {
1143- let mut activate_action: Option < SwipeAction > = None ;
1147+ let mut activate_action: Option < GestureCommand > = None ;
11441148 if let Some ( ref mut gesture_state) = self . common . gesture_state {
11451149 let first_update = gesture_state. update (
11461150 event. delta ( ) ,
11471151 Duration :: from_millis ( event. time_msec ( ) as u64 ) ,
11481152 ) ;
11491153 // Decide on action if first update
11501154 if first_update {
1151- activate_action = match gesture_state. fingers {
1152- 3 => None , // TODO: 3 finger gestures
1153- 4 => {
1154- if self . common . config . cosmic_conf . workspaces . workspace_layout
1155- == WorkspaceLayout :: Horizontal
1156- {
1157- match gesture_state. direction {
1158- Some ( Direction :: Left ) => {
1159- Some ( SwipeAction :: NextWorkspace )
1160- }
1161- Some ( Direction :: Right ) => {
1162- Some ( SwipeAction :: PrevWorkspace )
1163- }
1164- _ => None , // TODO: Other actions
1155+ let target_config = match gesture_state. fingers {
1156+ 3 => self
1157+ . common
1158+ . config
1159+ . cosmic_conf
1160+ . input_touchpad_gestures
1161+ . three_finger
1162+ . clone ( ) ,
1163+ 4 => self
1164+ . common
1165+ . config
1166+ . cosmic_conf
1167+ . input_touchpad_gestures
1168+ . four_finger
1169+ . clone ( ) ,
1170+ 5 => self
1171+ . common
1172+ . config
1173+ . cosmic_conf
1174+ . input_touchpad_gestures
1175+ . five_finger
1176+ . clone ( ) ,
1177+ _ => None ,
1178+ } ;
1179+
1180+ activate_action = match target_config {
1181+ Some ( GestureConfig :: WorkspaceDependent ( config) ) => {
1182+ match (
1183+ self . common . config . cosmic_conf . workspaces . workspace_layout ,
1184+ gesture_state. direction ,
1185+ ) {
1186+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Down ) ) => {
1187+ config. action_forward . clone ( )
11651188 }
1166- } else {
1167- match gesture_state. direction {
1168- Some ( Direction :: Up ) => Some ( SwipeAction :: NextWorkspace ) ,
1169- Some ( Direction :: Down ) => {
1170- Some ( SwipeAction :: PrevWorkspace )
1171- }
1172- _ => None , // TODO: Other actions
1189+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Up ) ) => {
1190+ config. action_backward . clone ( )
1191+ }
1192+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Right ) ) => {
1193+ config. action_side_1 . clone ( )
1194+ }
1195+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Left ) ) => {
1196+ config. action_side_2 . clone ( )
1197+ }
1198+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Down ) ) => {
1199+ config. action_side_1 . clone ( )
1200+ }
1201+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Up ) ) => {
1202+ config. action_side_2 . clone ( )
1203+ }
1204+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Right ) ) => {
1205+ config. action_forward . clone ( )
1206+ }
1207+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Left ) ) => {
1208+ config. action_backward . clone ( )
11731209 }
1210+ _ => None ,
11741211 }
11751212 }
1176- _ => None ,
1213+ Some ( GestureConfig :: Directional ( config) ) => {
1214+ match gesture_state. direction {
1215+ Some ( Direction :: Up ) => config. action_up . clone ( ) ,
1216+ Some ( Direction :: Down ) => config. action_down . clone ( ) ,
1217+ Some ( Direction :: Right ) => config. action_right . clone ( ) ,
1218+ Some ( Direction :: Left ) => config. action_left . clone ( ) ,
1219+ None => None ,
1220+ }
1221+ }
1222+ None => None ,
11771223 } ;
1178-
1179- gesture_state. action = activate_action;
1224+ gesture_state. action = activate_action. clone ( ) ;
11801225 }
11811226
11821227 match gesture_state. action {
1183- Some ( SwipeAction :: NextWorkspace ) | Some ( SwipeAction :: PrevWorkspace ) => {
1184- self . common . shell . update_workspace_delta (
1185- & seat. active_output ( ) ,
1186- gesture_state. delta ,
1187- )
1188- }
1228+ Some ( GestureCommand :: WorkspaceForward )
1229+ | Some ( GestureCommand :: WorkspaceBackward ) => self
1230+ . common
1231+ . shell
1232+ . update_workspace_delta ( & seat. active_output ( ) , gesture_state. delta ) ,
11891233 _ => { }
11901234 }
11911235 } else {
@@ -1199,10 +1243,10 @@ impl State {
11991243 ) ;
12001244 }
12011245 match activate_action {
1202- Some ( SwipeAction :: NextWorkspace ) => {
1246+ Some ( GestureCommand :: WorkspaceForward ) => {
12031247 let _ = self . to_next_workspace ( & seat, true ) ;
12041248 }
1205- Some ( SwipeAction :: PrevWorkspace ) => {
1249+ Some ( GestureCommand :: WorkspaceBackward ) => {
12061250 let _ = self . to_previous_workspace ( & seat, true ) ;
12071251 }
12081252 _ => { }
@@ -1213,7 +1257,8 @@ impl State {
12131257 if let Some ( seat) = self . common . seat_with_device ( & event. device ( ) ) . cloned ( ) {
12141258 if let Some ( ref gesture_state) = self . common . gesture_state {
12151259 match gesture_state. action {
1216- Some ( SwipeAction :: NextWorkspace ) | Some ( SwipeAction :: PrevWorkspace ) => {
1260+ Some ( GestureCommand :: WorkspaceForward )
1261+ | Some ( GestureCommand :: WorkspaceBackward ) => {
12171262 let velocity = gesture_state. velocity ( ) ;
12181263 let norm_velocity =
12191264 if self . common . config . cosmic_conf . workspaces . workspace_layout
0 commit comments