@@ -17,8 +17,7 @@ use super::{
17
17
window:: WindowId ,
18
18
} ;
19
19
use crate :: event:: {
20
- DeviceEvent , DeviceId as RootDeviceId , ElementState , Event , KeyEvent , RawKeyEvent , Touch ,
21
- TouchPhase , WindowEvent ,
20
+ DeviceId as RootDeviceId , ElementState , Event , KeyEvent , Touch , TouchPhase , WindowEvent ,
22
21
} ;
23
22
use crate :: event_loop:: DeviceEvents ;
24
23
use crate :: keyboard:: ModifiersState ;
@@ -140,34 +139,24 @@ impl<T> EventLoopWindowTarget<T> {
140
139
141
140
let device_id = RootDeviceId ( unsafe { DeviceId :: dummy ( ) } ) ;
142
141
143
- let device_event = runner. device_events ( ) . then_some ( Event :: DeviceEvent {
144
- device_id,
145
- event : DeviceEvent :: Key ( RawKeyEvent {
146
- physical_key,
147
- state : ElementState :: Pressed ,
148
- } ) ,
149
- } ) ;
150
-
151
142
runner. send_events (
152
- device_event
153
- . into_iter ( )
154
- . chain ( iter:: once ( Event :: WindowEvent {
155
- window_id : RootWindowId ( id) ,
156
- event : WindowEvent :: KeyboardInput {
157
- device_id,
158
- event : KeyEvent {
159
- physical_key,
160
- logical_key,
161
- text,
162
- location,
163
- state : ElementState :: Pressed ,
164
- repeat,
165
- platform_specific : KeyEventExtra ,
166
- } ,
167
- is_synthetic : false ,
143
+ iter:: once ( Event :: WindowEvent {
144
+ window_id : RootWindowId ( id) ,
145
+ event : WindowEvent :: KeyboardInput {
146
+ device_id,
147
+ event : KeyEvent {
148
+ physical_key,
149
+ logical_key,
150
+ text,
151
+ location,
152
+ state : ElementState :: Pressed ,
153
+ repeat,
154
+ platform_specific : KeyEventExtra ,
168
155
} ,
169
- } ) )
170
- . chain ( modifiers_changed) ,
156
+ is_synthetic : false ,
157
+ } ,
158
+ } )
159
+ . chain ( modifiers_changed) ,
171
160
) ;
172
161
} ,
173
162
prevent_default,
@@ -187,34 +176,24 @@ impl<T> EventLoopWindowTarget<T> {
187
176
188
177
let device_id = RootDeviceId ( unsafe { DeviceId :: dummy ( ) } ) ;
189
178
190
- let device_event = runner. device_events ( ) . then_some ( Event :: DeviceEvent {
191
- device_id,
192
- event : DeviceEvent :: Key ( RawKeyEvent {
193
- physical_key,
194
- state : ElementState :: Pressed ,
195
- } ) ,
196
- } ) ;
197
-
198
179
runner. send_events (
199
- device_event
200
- . into_iter ( )
201
- . chain ( iter:: once ( Event :: WindowEvent {
202
- window_id : RootWindowId ( id) ,
203
- event : WindowEvent :: KeyboardInput {
204
- device_id,
205
- event : KeyEvent {
206
- physical_key,
207
- logical_key,
208
- text,
209
- location,
210
- state : ElementState :: Released ,
211
- repeat,
212
- platform_specific : KeyEventExtra ,
213
- } ,
214
- is_synthetic : false ,
180
+ iter:: once ( Event :: WindowEvent {
181
+ window_id : RootWindowId ( id) ,
182
+ event : WindowEvent :: KeyboardInput {
183
+ device_id,
184
+ event : KeyEvent {
185
+ physical_key,
186
+ logical_key,
187
+ text,
188
+ location,
189
+ state : ElementState :: Released ,
190
+ repeat,
191
+ platform_specific : KeyEventExtra ,
215
192
} ,
216
- } ) )
217
- . chain ( modifiers_changed) ,
193
+ is_synthetic : false ,
194
+ } ,
195
+ } )
196
+ . chain ( modifiers_changed) ,
218
197
)
219
198
} ,
220
199
prevent_default,
@@ -311,48 +290,17 @@ impl<T> EventLoopWindowTarget<T> {
311
290
}
312
291
} ) ;
313
292
314
- runner. send_events ( modifiers. into_iter ( ) . chain ( events. flat_map (
315
- |( position, delta) | {
316
- let device_id = RootDeviceId ( DeviceId ( pointer_id) ) ;
317
-
318
- let device_events = runner. device_events ( ) . then ( || {
319
- let x_motion = ( delta. x != 0.0 ) . then_some ( Event :: DeviceEvent {
320
- device_id,
321
- event : DeviceEvent :: Motion {
322
- axis : 0 ,
323
- value : delta. x ,
324
- } ,
325
- } ) ;
326
-
327
- let y_motion = ( delta. y != 0.0 ) . then_some ( Event :: DeviceEvent {
328
- device_id,
329
- event : DeviceEvent :: Motion {
330
- axis : 1 ,
331
- value : delta. y ,
332
- } ,
333
- } ) ;
334
-
335
- x_motion. into_iter ( ) . chain ( y_motion) . chain ( iter:: once (
336
- Event :: DeviceEvent {
337
- device_id,
338
- event : DeviceEvent :: MouseMotion {
339
- delta : ( delta. x , delta. y ) ,
340
- } ,
341
- } ,
342
- ) )
343
- } ) ;
344
-
345
- device_events. into_iter ( ) . flatten ( ) . chain ( iter:: once (
346
- Event :: WindowEvent {
347
- window_id : RootWindowId ( id) ,
348
- event : WindowEvent :: CursorMoved {
349
- device_id,
350
- position,
351
- } ,
352
- } ,
353
- ) )
354
- } ,
355
- ) ) ) ;
293
+ runner. send_events ( modifiers. into_iter ( ) . chain ( events. flat_map ( |position| {
294
+ let device_id = RootDeviceId ( DeviceId ( pointer_id) ) ;
295
+
296
+ iter:: once ( Event :: WindowEvent {
297
+ window_id : RootWindowId ( id) ,
298
+ event : WindowEvent :: CursorMoved {
299
+ device_id,
300
+ position,
301
+ } ,
302
+ } )
303
+ } ) ) ) ;
356
304
}
357
305
} ,
358
306
{
@@ -413,18 +361,10 @@ impl<T> EventLoopWindowTarget<T> {
413
361
ElementState :: Released
414
362
} ;
415
363
416
- let device_event = runner. device_events ( ) . then ( || Event :: DeviceEvent {
417
- device_id,
418
- event : DeviceEvent :: Button {
419
- button : button. to_id ( ) ,
420
- state,
421
- } ,
422
- } ) ;
423
-
424
364
// A chorded button event may come in without any prior CursorMoved events,
425
365
// therefore we should send a CursorMoved event to make sure that the
426
366
// user code has the correct cursor position.
427
- runner. send_events ( modifiers. into_iter ( ) . chain ( device_event ) . chain ( [
367
+ runner. send_events ( modifiers. into_iter ( ) . chain ( [
428
368
Event :: WindowEvent {
429
369
window_id : RootWindowId ( id) ,
430
370
event : WindowEvent :: CursorMoved {
@@ -475,18 +415,11 @@ impl<T> EventLoopWindowTarget<T> {
475
415
} ) ;
476
416
477
417
let device_id: RootDeviceId = RootDeviceId ( DeviceId ( pointer_id) ) ;
478
- let device_event = runner. device_events ( ) . then ( || Event :: DeviceEvent {
479
- device_id,
480
- event : DeviceEvent :: Button {
481
- button : button. to_id ( ) ,
482
- state : ElementState :: Pressed ,
483
- } ,
484
- } ) ;
485
418
486
419
// A mouse down event may come in without any prior CursorMoved events,
487
420
// therefore we should send a CursorMoved event to make sure that the
488
421
// user code has the correct cursor position.
489
- runner. send_events ( modifiers. into_iter ( ) . chain ( device_event ) . chain ( [
422
+ runner. send_events ( modifiers. into_iter ( ) . chain ( [
490
423
Event :: WindowEvent {
491
424
window_id : RootWindowId ( id) ,
492
425
event : WindowEvent :: CursorMoved {
@@ -568,18 +501,11 @@ impl<T> EventLoopWindowTarget<T> {
568
501
} ) ;
569
502
570
503
let device_id: RootDeviceId = RootDeviceId ( DeviceId ( pointer_id) ) ;
571
- let device_event = runner. device_events ( ) . then ( || Event :: DeviceEvent {
572
- device_id,
573
- event : DeviceEvent :: Button {
574
- button : button. to_id ( ) ,
575
- state : ElementState :: Pressed ,
576
- } ,
577
- } ) ;
578
504
579
505
// A mouse up event may come in without any prior CursorMoved events,
580
506
// therefore we should send a CursorMoved event to make sure that the
581
507
// user code has the correct cursor position.
582
- runner. send_events ( modifiers. into_iter ( ) . chain ( device_event ) . chain ( [
508
+ runner. send_events ( modifiers. into_iter ( ) . chain ( [
583
509
Event :: WindowEvent {
584
510
window_id : RootWindowId ( id) ,
585
511
event : WindowEvent :: CursorMoved {
@@ -644,21 +570,16 @@ impl<T> EventLoopWindowTarget<T> {
644
570
}
645
571
} ) ;
646
572
647
- let device_event = runner. device_events ( ) . then_some ( Event :: DeviceEvent {
648
- device_id : RootDeviceId ( DeviceId ( pointer_id) ) ,
649
- event : DeviceEvent :: MouseWheel { delta } ,
650
- } ) ;
651
-
652
- runner. send_events ( modifiers_changed. into_iter ( ) . chain ( device_event) . chain (
653
- iter:: once ( Event :: WindowEvent {
573
+ runner. send_events ( modifiers_changed. into_iter ( ) . chain ( iter:: once (
574
+ Event :: WindowEvent {
654
575
window_id : RootWindowId ( id) ,
655
576
event : WindowEvent :: MouseWheel {
656
577
device_id : RootDeviceId ( DeviceId ( pointer_id) ) ,
657
578
delta,
658
579
phase : TouchPhase :: Moved ,
659
580
} ,
660
- } ) ,
661
- ) ) ;
581
+ } ,
582
+ ) ) ) ;
662
583
} ,
663
584
prevent_default,
664
585
) ;
0 commit comments