@@ -89,6 +89,21 @@ impl<'a> Fum<'a> {
89
89
match keybind {
90
90
Keybind :: Many ( keybinds) => {
91
91
for keybind in keybinds {
92
+ if let Keybind :: WithModifier ( modifiers, keybind) = keybind {
93
+ if key. modifiers . intersects ( * modifiers) {
94
+ if key. code == keybind. into_keycode ( ) {
95
+ Action :: run ( action, self ) ?;
96
+ }
97
+ }
98
+ } else {
99
+ if key. code == keybind. into_keycode ( ) {
100
+ Action :: run ( action, self ) ?;
101
+ }
102
+ }
103
+ }
104
+ } ,
105
+ Keybind :: WithModifier ( modifiers, keybind) => {
106
+ if key. modifiers . intersects ( * modifiers) {
92
107
if key. code == keybind. into_keycode ( ) {
93
108
Action :: run ( action, self ) ?;
94
109
}
@@ -102,70 +117,92 @@ impl<'a> Fum<'a> {
102
117
}
103
118
}
104
119
} ,
105
- Event :: Mouse ( mouse) if mouse. kind == MouseEventKind :: Down ( MouseButton :: Left ) => {
106
- if let Some ( ( action, exec) ) = self . ui . click ( mouse. column , mouse. row , & self . state . buttons ) {
107
- let action = action. to_owned ( ) ;
108
- let exec = exec. to_owned ( ) ;
120
+ Event :: Mouse ( mouse) => {
121
+ match mouse. kind {
122
+ // Button click mouse left.
123
+ MouseEventKind :: Down ( MouseButton :: Left ) => {
124
+ if let Some ( ( action, _, exec) ) = self . ui . click ( mouse. column , mouse. row , & self . state . buttons ) {
125
+ let action = action. to_owned ( ) ;
126
+ let exec = exec. to_owned ( ) ;
127
+
128
+ if let Some ( action) = action {
129
+ Action :: run ( & action, self ) ?;
130
+ }
109
131
110
- if let Some ( action) = action {
111
- Action :: run ( & action, self ) ?;
112
- }
132
+ if let Some ( exec) = exec {
133
+ let parts: Vec < & str > = exec. split_whitespace ( ) . collect ( ) ;
134
+ if let Some ( command) = parts. get ( 0 ) {
135
+ let _ = Command :: new ( command) // Ignore result
136
+ . args ( & parts[ 1 ..] )
137
+ . stdout ( Stdio :: null ( ) )
138
+ . stderr ( Stdio :: null ( ) )
139
+ . spawn ( ) ;
140
+ }
141
+ }
142
+ }
143
+ } ,
144
+
145
+ // Button click mouse right.
146
+ MouseEventKind :: Down ( MouseButton :: Right ) => {
147
+ if let Some ( ( _, action_secondary, _) ) = self . ui . click ( mouse. column , mouse. row , & self . state . buttons ) {
148
+ let action_secondary = action_secondary. to_owned ( ) ;
113
149
114
- if let Some ( exec) = exec {
115
- let parts: Vec < & str > = exec. split_whitespace ( ) . collect ( ) ;
116
- if let Some ( command) = parts. get ( 0 ) {
117
- let _ = Command :: new ( command) // Ignore result
118
- . args ( & parts[ 1 ..] )
119
- . stdout ( Stdio :: null ( ) )
120
- . stderr ( Stdio :: null ( ) )
121
- . spawn ( ) ;
150
+ if let Some ( action_secondary) = action_secondary {
151
+ Action :: run ( & action_secondary, self ) ?;
152
+ }
122
153
}
123
- }
124
- }
125
- } ,
126
- Event :: Mouse ( mouse) if mouse. kind == MouseEventKind :: Drag ( MouseButton :: Left ) => {
127
- if !self . dragging && self . start_drag . is_none ( ) {
128
- self . dragging = true ;
129
- self . start_drag = Some ( Position :: new ( mouse. column , mouse. row ) ) ;
130
- }
154
+ } ,
131
155
132
- if self . dragging {
133
- self . current_drag = Some ( Position :: new ( mouse. column , mouse. row ) ) ;
134
-
135
- if let Some ( start_drag) = & self . start_drag {
136
- if let Some ( current_drag) = & self . current_drag {
137
- if let Some ( ( rect, direction, widget) ) = self . ui . drag ( start_drag, & self . state . sliders ) {
138
- let value: f64 = match direction {
139
- Direction :: Horizontal => ( ( current_drag. x as f64 - rect. x as f64 ) / rect. width as f64 ) . clamp ( 0.0 , 1.0 ) ,
140
- Direction :: Vertical => ( 1.0 - ( ( current_drag. y as f64 - rect. y as f64 ) / rect. height as f64 ) ) . clamp ( 0.0 , 1.0 )
141
- } ;
142
-
143
- match widget {
144
- SliderSource :: Progress => {
145
- let position = value * self . state . meta . length . as_secs ( ) as f64 ;
146
- if position >= self . state . meta . length . as_secs ( ) as f64 {
147
- self . dragging = false ;
148
- self . start_drag = None ;
149
- self . current_drag = None ;
150
- }
156
+ // Mouse left drag.
157
+ MouseEventKind :: Drag ( MouseButton :: Left ) => {
158
+ if !self . dragging && self . start_drag . is_none ( ) {
159
+ self . dragging = true ;
160
+ self . start_drag = Some ( Position :: new ( mouse. column , mouse. row ) ) ;
161
+ }
151
162
152
- Action :: run ( & Action :: Position ( position as u64 ) , self ) ?;
153
- } ,
154
- SliderSource :: Volume => {
155
- let volume = value * 100.0 ;
156
- Action :: run ( & Action :: Volume ( VolumeType :: Set ( volume) ) , self ) ?;
163
+ if self . dragging {
164
+ self . current_drag = Some ( Position :: new ( mouse. column , mouse. row ) ) ;
165
+
166
+ if let Some ( start_drag) = & self . start_drag {
167
+ if let Some ( current_drag) = & self . current_drag {
168
+ if let Some ( ( rect, direction, widget) ) = self . ui . drag ( start_drag, & self . state . sliders ) {
169
+ let value: f64 = match direction {
170
+ Direction :: Horizontal => ( ( current_drag. x as f64 - rect. x as f64 ) / rect. width as f64 ) . clamp ( 0.0 , 1.0 ) ,
171
+ Direction :: Vertical => ( 1.0 - ( ( current_drag. y as f64 - rect. y as f64 ) / rect. height as f64 ) ) . clamp ( 0.0 , 1.0 )
172
+ } ;
173
+
174
+ match widget {
175
+ SliderSource :: Progress => {
176
+ let position = value * self . state . meta . length . as_secs ( ) as f64 ;
177
+ if position >= self . state . meta . length . as_secs ( ) as f64 {
178
+ self . dragging = false ;
179
+ self . start_drag = None ;
180
+ self . current_drag = None ;
181
+ }
182
+
183
+ Action :: run ( & Action :: Position ( position as u64 ) , self ) ?;
184
+ } ,
185
+ SliderSource :: Volume => {
186
+ let volume = value * 100.0 ;
187
+ Action :: run ( & Action :: Volume ( VolumeType :: Set ( volume) ) , self ) ?;
188
+ }
189
+ }
157
190
}
158
191
}
159
192
}
160
193
}
161
- }
194
+ } ,
195
+
196
+ // Mouse left release.
197
+ MouseEventKind :: Up ( MouseButton :: Left ) => {
198
+ self . dragging = false ;
199
+ self . start_drag = None ;
200
+ self . current_drag = None ;
201
+ } ,
202
+
203
+ _ => { }
162
204
}
163
205
} ,
164
- Event :: Mouse ( mouse) if mouse. kind == MouseEventKind :: Up ( MouseButton :: Left ) => {
165
- self . dragging = false ;
166
- self . start_drag = None ;
167
- self . current_drag = None ;
168
- }
169
206
Event :: Resize ( _, _) => {
170
207
self . redraw = true ;
171
208
}
0 commit comments