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:: {
@@ -1121,52 +1125,92 @@ impl State {
11211125 }
11221126 InputEvent :: GestureSwipeUpdate { event, .. } => {
11231127 if let Some ( seat) = self . common . seat_with_device ( & event. device ( ) ) . cloned ( ) {
1124- let mut activate_action: Option < SwipeAction > = None ;
1128+ let mut activate_action: Option < GestureCommand > = None ;
11251129 if let Some ( ref mut gesture_state) = self . common . gesture_state {
11261130 let first_update = gesture_state. update (
11271131 event. delta ( ) ,
11281132 Duration :: from_millis ( event. time_msec ( ) as u64 ) ,
11291133 ) ;
11301134 // Decide on action if first update
11311135 if first_update {
1132- activate_action = match gesture_state. fingers {
1133- 3 => None , // TODO: 3 finger gestures
1134- 4 => {
1135- if self . common . config . cosmic_conf . workspaces . workspace_layout
1136- == WorkspaceLayout :: Horizontal
1137- {
1138- match gesture_state. direction {
1139- Some ( Direction :: Left ) => {
1140- Some ( SwipeAction :: NextWorkspace )
1141- }
1142- Some ( Direction :: Right ) => {
1143- Some ( SwipeAction :: PrevWorkspace )
1144- }
1145- _ => None , // TODO: Other actions
1136+ let target_config = match gesture_state. fingers {
1137+ 3 => self
1138+ . common
1139+ . config
1140+ . cosmic_conf
1141+ . input_touchpad_gestures
1142+ . three_finger
1143+ . clone ( ) ,
1144+ 4 => self
1145+ . common
1146+ . config
1147+ . cosmic_conf
1148+ . input_touchpad_gestures
1149+ . four_finger
1150+ . clone ( ) ,
1151+ 5 => self
1152+ . common
1153+ . config
1154+ . cosmic_conf
1155+ . input_touchpad_gestures
1156+ . five_finger
1157+ . clone ( ) ,
1158+ _ => None ,
1159+ } ;
1160+
1161+ activate_action = match target_config {
1162+ Some ( GestureConfig :: WorkspaceDependent ( config) ) => {
1163+ match (
1164+ self . common . config . cosmic_conf . workspaces . workspace_layout ,
1165+ gesture_state. direction ,
1166+ ) {
1167+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Down ) ) => {
1168+ config. action_forward . clone ( )
11461169 }
1147- } else {
1148- match gesture_state. direction {
1149- Some ( Direction :: Up ) => Some ( SwipeAction :: NextWorkspace ) ,
1150- Some ( Direction :: Down ) => {
1151- Some ( SwipeAction :: PrevWorkspace )
1152- }
1153- _ => None , // TODO: Other actions
1170+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Up ) ) => {
1171+ config. action_backward . clone ( )
1172+ }
1173+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Right ) ) => {
1174+ config. action_side_1 . clone ( )
1175+ }
1176+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Left ) ) => {
1177+ config. action_side_2 . clone ( )
1178+ }
1179+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Down ) ) => {
1180+ config. action_side_1 . clone ( )
1181+ }
1182+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Up ) ) => {
1183+ config. action_side_2 . clone ( )
1184+ }
1185+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Right ) ) => {
1186+ config. action_forward . clone ( )
1187+ }
1188+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Left ) ) => {
1189+ config. action_backward . clone ( )
11541190 }
1191+ _ => None ,
11551192 }
11561193 }
1157- _ => None ,
1194+ Some ( GestureConfig :: Directional ( config) ) => {
1195+ match gesture_state. direction {
1196+ Some ( Direction :: Up ) => config. action_up . clone ( ) ,
1197+ Some ( Direction :: Down ) => config. action_down . clone ( ) ,
1198+ Some ( Direction :: Right ) => config. action_right . clone ( ) ,
1199+ Some ( Direction :: Left ) => config. action_left . clone ( ) ,
1200+ None => None ,
1201+ }
1202+ }
1203+ None => None ,
11581204 } ;
1159-
1160- gesture_state. action = activate_action;
1205+ gesture_state. action = activate_action. clone ( ) ;
11611206 }
11621207
11631208 match gesture_state. action {
1164- Some ( SwipeAction :: NextWorkspace ) | Some ( SwipeAction :: PrevWorkspace ) => {
1165- self . common . shell . update_workspace_delta (
1166- & seat. active_output ( ) ,
1167- gesture_state. delta ,
1168- )
1169- }
1209+ Some ( GestureCommand :: WorkspaceForward )
1210+ | Some ( GestureCommand :: WorkspaceBackward ) => self
1211+ . common
1212+ . shell
1213+ . update_workspace_delta ( & seat. active_output ( ) , gesture_state. delta ) ,
11701214 _ => { }
11711215 }
11721216 } else {
@@ -1180,10 +1224,10 @@ impl State {
11801224 ) ;
11811225 }
11821226 match activate_action {
1183- Some ( SwipeAction :: NextWorkspace ) => {
1227+ Some ( GestureCommand :: WorkspaceForward ) => {
11841228 let _ = self . to_next_workspace ( & seat, true ) ;
11851229 }
1186- Some ( SwipeAction :: PrevWorkspace ) => {
1230+ Some ( GestureCommand :: WorkspaceBackward ) => {
11871231 let _ = self . to_previous_workspace ( & seat, true ) ;
11881232 }
11891233 _ => { }
@@ -1194,7 +1238,8 @@ impl State {
11941238 if let Some ( seat) = self . common . seat_with_device ( & event. device ( ) ) . cloned ( ) {
11951239 if let Some ( ref gesture_state) = self . common . gesture_state {
11961240 match gesture_state. action {
1197- Some ( SwipeAction :: NextWorkspace ) | Some ( SwipeAction :: PrevWorkspace ) => {
1241+ Some ( GestureCommand :: WorkspaceForward )
1242+ | Some ( GestureCommand :: WorkspaceBackward ) => {
11981243 let velocity = gesture_state. velocity ( ) ;
11991244 let norm_velocity =
12001245 if self . common . config . cosmic_conf . workspaces . workspace_layout
0 commit comments