22
33use crate :: {
44 config:: { Action , Config , KeyModifiers , KeyPattern } ,
5- input:: gestures:: { GestureState , SwipeAction } ,
5+ input:: gestures:: GestureState ,
66 shell:: {
77 focus:: {
88 target:: { KeyboardFocusTarget , PointerFocusTarget } ,
@@ -26,7 +26,11 @@ use crate::{
2626 } ,
2727} ;
2828use calloop:: { timer:: Timer , RegistrationToken } ;
29- use cosmic_comp_config:: { workspace:: WorkspaceLayout , TileBehavior } ;
29+ use cosmic_comp_config:: {
30+ input:: { GestureCommand , GestureConfig } ,
31+ workspace:: WorkspaceLayout ,
32+ TileBehavior ,
33+ } ;
3034use cosmic_config:: ConfigSet ;
3135use smithay:: {
3236 backend:: input:: {
@@ -1091,47 +1095,89 @@ impl State {
10911095 . for_device ( & event. device ( ) )
10921096 . cloned ( ) ;
10931097 if let Some ( seat) = maybe_seat {
1094- let mut activate_action: Option < SwipeAction > = None ;
1098+ let mut activate_action: Option < GestureCommand > = None ;
10951099 if let Some ( ref mut gesture_state) = self . common . gesture_state {
10961100 let first_update = gesture_state. update (
10971101 event. delta ( ) ,
10981102 Duration :: from_millis ( event. time_msec ( ) as u64 ) ,
10991103 ) ;
11001104 // Decide on action if first update
11011105 if first_update {
1102- activate_action = match gesture_state. fingers {
1103- 3 => None , // TODO: 3 finger gestures
1104- 4 => {
1105- if self . common . config . cosmic_conf . workspaces . workspace_layout
1106- == WorkspaceLayout :: Horizontal
1107- {
1108- match gesture_state. direction {
1109- Some ( Direction :: Left ) => {
1110- Some ( SwipeAction :: NextWorkspace )
1111- }
1112- Some ( Direction :: Right ) => {
1113- Some ( SwipeAction :: PrevWorkspace )
1114- }
1115- _ => None , // TODO: Other actions
1106+ let target_config = match gesture_state. fingers {
1107+ 3 => self
1108+ . common
1109+ . config
1110+ . cosmic_conf
1111+ . input_touchpad_gestures
1112+ . three_finger
1113+ . clone ( ) ,
1114+ 4 => self
1115+ . common
1116+ . config
1117+ . cosmic_conf
1118+ . input_touchpad_gestures
1119+ . four_finger
1120+ . clone ( ) ,
1121+ 5 => self
1122+ . common
1123+ . config
1124+ . cosmic_conf
1125+ . input_touchpad_gestures
1126+ . five_finger
1127+ . clone ( ) ,
1128+ _ => None ,
1129+ } ;
1130+
1131+ activate_action = match target_config {
1132+ Some ( GestureConfig :: WorkspaceDependent ( config) ) => {
1133+ match (
1134+ self . common . config . cosmic_conf . workspaces . workspace_layout ,
1135+ gesture_state. direction ,
1136+ ) {
1137+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Down ) ) => {
1138+ config. action_forward . clone ( )
11161139 }
1117- } else {
1118- match gesture_state. direction {
1119- Some ( Direction :: Up ) => Some ( SwipeAction :: NextWorkspace ) ,
1120- Some ( Direction :: Down ) => {
1121- Some ( SwipeAction :: PrevWorkspace )
1122- }
1123- _ => None , // TODO: Other actions
1140+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Up ) ) => {
1141+ config. action_backward . clone ( )
11241142 }
1143+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Right ) ) => {
1144+ config. action_side_1 . clone ( )
1145+ }
1146+ ( WorkspaceLayout :: Vertical , Some ( Direction :: Left ) ) => {
1147+ config. action_side_2 . clone ( )
1148+ }
1149+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Down ) ) => {
1150+ config. action_side_1 . clone ( )
1151+ }
1152+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Up ) ) => {
1153+ config. action_side_2 . clone ( )
1154+ }
1155+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Right ) ) => {
1156+ config. action_forward . clone ( )
1157+ }
1158+ ( WorkspaceLayout :: Horizontal , Some ( Direction :: Left ) ) => {
1159+ config. action_backward . clone ( )
1160+ }
1161+ _ => None ,
11251162 }
11261163 }
1127- _ => None ,
1164+ Some ( GestureConfig :: Directional ( config) ) => {
1165+ match gesture_state. direction {
1166+ Some ( Direction :: Up ) => config. action_up . clone ( ) ,
1167+ Some ( Direction :: Down ) => config. action_down . clone ( ) ,
1168+ Some ( Direction :: Right ) => config. action_right . clone ( ) ,
1169+ Some ( Direction :: Left ) => config. action_left . clone ( ) ,
1170+ None => None ,
1171+ }
1172+ }
1173+ None => None ,
11281174 } ;
1129-
1130- gesture_state. action = activate_action;
1175+ gesture_state. action = activate_action. clone ( ) ;
11311176 }
11321177
11331178 match gesture_state. action {
1134- Some ( SwipeAction :: NextWorkspace ) | Some ( SwipeAction :: PrevWorkspace ) => {
1179+ Some ( GestureCommand :: WorkspaceForward )
1180+ | Some ( GestureCommand :: WorkspaceBackward ) => {
11351181 self . common . shell . write ( ) . unwrap ( ) . update_workspace_delta (
11361182 & seat. active_output ( ) ,
11371183 gesture_state. delta ,
@@ -1150,15 +1196,15 @@ impl State {
11501196 ) ;
11511197 }
11521198 match activate_action {
1153- Some ( SwipeAction :: NextWorkspace ) => {
1199+ Some ( GestureCommand :: WorkspaceForward ) => {
11541200 let _ = to_next_workspace (
11551201 & mut * self . common . shell . write ( ) . unwrap ( ) ,
11561202 & seat,
11571203 true ,
11581204 & mut self . common . workspace_state . update ( ) ,
11591205 ) ;
11601206 }
1161- Some ( SwipeAction :: PrevWorkspace ) => {
1207+ Some ( GestureCommand :: WorkspaceBackward ) => {
11621208 let _ = to_previous_workspace (
11631209 & mut * self . common . shell . write ( ) . unwrap ( ) ,
11641210 & seat,
@@ -1182,7 +1228,8 @@ impl State {
11821228 if let Some ( seat) = maybe_seat {
11831229 if let Some ( ref gesture_state) = self . common . gesture_state {
11841230 match gesture_state. action {
1185- Some ( SwipeAction :: NextWorkspace ) | Some ( SwipeAction :: PrevWorkspace ) => {
1231+ Some ( GestureCommand :: WorkspaceForward )
1232+ | Some ( GestureCommand :: WorkspaceBackward ) => {
11861233 let velocity = gesture_state. velocity ( ) ;
11871234 let norm_velocity =
11881235 if self . common . config . cosmic_conf . workspaces . workspace_layout
0 commit comments