@@ -13,16 +13,14 @@ use std::slice;
13
13
use std:: sync:: { Arc , Mutex , Weak } ;
14
14
use std:: time:: Instant ;
15
15
16
+ use gtk:: gdk:: ffi:: GdkKeymapKey ;
16
17
use gtk:: gdk_pixbuf:: Colorspace :: Rgb ;
17
18
use gtk:: gdk_pixbuf:: Pixbuf ;
18
- use gtk:: glib:: source:: Continue ;
19
19
use gtk:: glib:: translate:: FromGlib ;
20
+ use gtk:: glib:: { ControlFlow , Propagation } ;
20
21
use gtk:: prelude:: * ;
21
- use gtk:: traits:: SettingsExt ;
22
22
use gtk:: { AccelGroup , ApplicationWindow , DrawingArea } ;
23
23
24
- use gdk_sys:: GdkKeymapKey ;
25
-
26
24
use anyhow:: anyhow;
27
25
use cairo:: Surface ;
28
26
use gtk:: gdk:: {
@@ -416,7 +414,7 @@ impl WindowBuilder {
416
414
. connect_enter_notify_event ( |widget, _| {
417
415
widget. grab_focus ( ) ;
418
416
419
- Inhibit ( true )
417
+ Propagation :: Stop
420
418
} ) ;
421
419
422
420
// Set the minimum size
@@ -528,7 +526,7 @@ impl WindowBuilder {
528
526
}
529
527
}
530
528
531
- Inhibit ( false )
529
+ Propagation :: Proceed
532
530
} ) ) ;
533
531
534
532
win_state. drawing_area . connect_screen_changed (
@@ -584,7 +582,7 @@ impl WindowBuilder {
584
582
} ) ;
585
583
}
586
584
587
- Inhibit ( true )
585
+ Propagation :: Stop
588
586
} ) ) ;
589
587
590
588
win_state. drawing_area . connect_button_release_event ( clone ! ( handle => move |_widget, event| {
@@ -611,7 +609,7 @@ impl WindowBuilder {
611
609
} ) ;
612
610
}
613
611
614
- Inhibit ( true )
612
+ Propagation :: Stop
615
613
} ) ) ;
616
614
617
615
win_state. drawing_area . connect_motion_notify_event (
@@ -632,7 +630,7 @@ impl WindowBuilder {
632
630
state. with_handler( |h| h. mouse_move( & mouse_event) ) ;
633
631
}
634
632
635
- Inhibit ( true )
633
+ Propagation :: Stop
636
634
} ) ,
637
635
) ;
638
636
@@ -642,7 +640,7 @@ impl WindowBuilder {
642
640
state. with_handler( |h| h. mouse_leave( ) ) ;
643
641
}
644
642
645
- Inhibit ( true )
643
+ Propagation :: Stop
646
644
} ) ,
647
645
) ;
648
646
@@ -698,7 +696,7 @@ impl WindowBuilder {
698
696
}
699
697
}
700
698
701
- Inhibit ( true )
699
+ Propagation :: Stop
702
700
} ) ) ;
703
701
704
702
win_state
@@ -716,7 +714,7 @@ impl WindowBuilder {
716
714
) ;
717
715
}
718
716
719
- Inhibit ( true )
717
+ Propagation :: Stop
720
718
} ) ) ;
721
719
722
720
win_state
@@ -734,7 +732,7 @@ impl WindowBuilder {
734
732
) ;
735
733
}
736
734
737
- Inhibit ( true )
735
+ Propagation :: Stop
738
736
} ) ) ;
739
737
740
738
win_state
@@ -743,7 +741,7 @@ impl WindowBuilder {
743
741
if let Some ( state) = handle. state. upgrade( ) {
744
742
state. with_handler( |h| h. got_focus( ) ) ;
745
743
}
746
- Inhibit ( true )
744
+ Propagation :: Stop
747
745
} ) ) ;
748
746
749
747
win_state
@@ -752,17 +750,20 @@ impl WindowBuilder {
752
750
if let Some ( state) = handle. state. upgrade( ) {
753
751
state. with_handler( |h| h. lost_focus( ) ) ;
754
752
}
755
- Inhibit ( true )
753
+ Propagation :: Stop
756
754
} ) ) ;
757
755
758
756
win_state
759
757
. window
760
758
. connect_delete_event ( clone ! ( handle => move |_widget, _ev| {
761
759
if let Some ( state) = handle. state. upgrade( ) {
762
760
state. with_handler( |h| h. request_close( ) ) ;
763
- Inhibit ( !state. closing. get( ) )
761
+ match state. closing. get( ) {
762
+ true => Propagation :: Proceed ,
763
+ false => Propagation :: Stop ,
764
+ }
764
765
} else {
765
- Inhibit ( false )
766
+ Propagation :: Proceed
766
767
}
767
768
} ) ) ;
768
769
@@ -1218,9 +1219,9 @@ impl WindowHandle {
1218
1219
if let Some ( state) = self . state . upgrade ( ) {
1219
1220
gtk:: glib:: timeout_add ( interval, move || {
1220
1221
if state. with_handler ( |h| h. timer ( token) ) . is_some ( ) {
1221
- return Continue ( false ) ;
1222
+ return ControlFlow :: Break ;
1222
1223
}
1223
- Continue ( true )
1224
+ ControlFlow :: Continue
1224
1225
} ) ;
1225
1226
}
1226
1227
token
@@ -1379,7 +1380,7 @@ impl IdleHandle {
1379
1380
}
1380
1381
}
1381
1382
1382
- fn run_idle ( state : & Arc < WindowState > ) -> Continue {
1383
+ fn run_idle ( state : & Arc < WindowState > ) -> ControlFlow {
1383
1384
util:: assert_main_thread ( ) ;
1384
1385
let result = state. with_handler ( |handler| {
1385
1386
let queue: Vec < _ > = std:: mem:: take ( & mut state. idle_queue . lock ( ) . unwrap ( ) ) ;
@@ -1401,7 +1402,7 @@ fn run_idle(state: &Arc<WindowState>) -> Continue {
1401
1402
let timeout = Duration :: from_millis ( 16 ) ;
1402
1403
gtk:: glib:: timeout_add ( timeout, move || run_idle ( & state) ) ;
1403
1404
}
1404
- Continue ( false )
1405
+ ControlFlow :: Break
1405
1406
}
1406
1407
1407
1408
fn make_gdk_cursor ( cursor : & Cursor , gdk_window : & Window ) -> Option < gtk:: gdk:: Cursor > {
@@ -1501,7 +1502,7 @@ fn make_key_event(key: &EventKey, repeat: bool, state: KeyState) -> KeyEvent {
1501
1502
let keyval = key. keyval ( ) ;
1502
1503
let hardware_keycode = key. hardware_keycode ( ) ;
1503
1504
1504
- let keycode = hardware_keycode_to_keyval ( hardware_keycode) . unwrap_or_else ( || keyval. clone ( ) ) ;
1505
+ let keycode = hardware_keycode_to_keyval ( hardware_keycode) . unwrap_or ( keyval) ;
1505
1506
1506
1507
let text = keyval. to_unicode ( ) ;
1507
1508
let mods = get_modifiers ( key. state ( ) ) ;
@@ -1535,14 +1536,14 @@ fn make_key_event(key: &EventKey, repeat: bool, state: KeyState) -> KeyEvent {
1535
1536
/// keyval with the lowest group and level
1536
1537
fn hardware_keycode_to_keyval ( keycode : u16 ) -> Option < keycodes:: RawKey > {
1537
1538
unsafe {
1538
- let keymap = gdk_sys :: gdk_keymap_get_default ( ) ;
1539
+ let keymap = gtk :: gdk :: ffi :: gdk_keymap_get_default ( ) ;
1539
1540
1540
1541
let mut nkeys = 0 ;
1541
1542
let mut keys: * mut GdkKeymapKey = ptr:: null_mut ( ) ;
1542
1543
let mut keyvals: * mut c_uint = ptr:: null_mut ( ) ;
1543
1544
1544
1545
// call into gdk to retrieve the keyvals and keymap keys
1545
- gdk_sys :: gdk_keymap_get_entries_for_keycode (
1546
+ gtk :: gdk :: ffi :: gdk_keymap_get_entries_for_keycode (
1546
1547
keymap,
1547
1548
c_uint:: from ( keycode) ,
1548
1549
& mut keys as * mut * mut GdkKeymapKey ,
@@ -1563,8 +1564,8 @@ fn hardware_keycode_to_keyval(keycode: u16) -> Option<keycodes::RawKey> {
1563
1564
} ) ;
1564
1565
1565
1566
// notify glib to free the allocated arrays
1566
- glib_sys :: g_free ( keyvals as * mut c_void ) ;
1567
- glib_sys :: g_free ( keys as * mut c_void ) ;
1567
+ gtk :: glib :: ffi :: g_free ( keyvals as * mut c_void ) ;
1568
+ gtk :: glib :: ffi :: g_free ( keys as * mut c_void ) ;
1568
1569
1569
1570
resolved_keyval
1570
1571
} else {
0 commit comments