File tree Expand file tree Collapse file tree 8 files changed +17
-20
lines changed
Expand file tree Collapse file tree 8 files changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ You can find its changes [documented below](#070---2021-01-01).
5656- Lens implemented for tuples of Lenses of length 2-8, Tuple2 removed ([ #1654 ] by [ @Maan2003 ] )
5757- Window size and positioning code is now in display points ([ #1713 ] by [ @jneem ] )
5858- Update look and feel of controls when disabled ([ #1717 ] by [ @xarvic ] )
59+ - Change the signature of ` add_idle_callback ` ([ #1787 ] by [ @jneem ] )
5960
6061### Deprecated
6162
@@ -722,6 +723,7 @@ Last release without a changelog :(
722723[ #1761 ] : https://github.com/linebender/druid/pull/1761
723724[ #1764 ] : https://github.com/linebender/druid/pull/1764
724725[ #1772 ] : https://github.com/linebender/druid/pull/1772
726+ [ #1787 ] : https://github.com/linebender/druid/pull/1787
725727
726728[ Unreleased ] : https://github.com/linebender/druid/compare/v0.7.0...master
727729[ 0.7.0 ] : https://github.com/linebender/druid/compare/v0.6.0...v0.7.0
Original file line number Diff line number Diff line change 1414
1515//! Common functions used by the backends
1616
17- use std:: any:: Any ;
1817use std:: cell:: Cell ;
1918use std:: num:: NonZeroU64 ;
2019use std:: sync:: atomic:: { AtomicU64 , Ordering } ;
@@ -23,6 +22,7 @@ use std::time::Duration;
2322use instant:: Instant ;
2423
2524use crate :: kurbo:: Point ;
25+ use crate :: WinHandler ;
2626
2727// This is the default timing on windows.
2828const MULTI_CLICK_INTERVAL : Duration = Duration :: from_millis ( 500 ) ;
@@ -52,11 +52,11 @@ pub fn strip_access_key(raw_menu_text: &str) -> String {
5252
5353/// A trait for implementing the boxed callback hack.
5454pub ( crate ) trait IdleCallback : Send {
55- fn call ( self : Box < Self > , a : & dyn Any ) ;
55+ fn call ( self : Box < Self > , a : & mut dyn WinHandler ) ;
5656}
5757
58- impl < F : FnOnce ( & dyn Any ) + Send > IdleCallback for F {
59- fn call ( self : Box < F > , a : & dyn Any ) {
58+ impl < F : FnOnce ( & mut dyn WinHandler ) + Send > IdleCallback for F {
59+ fn call ( self : Box < F > , a : & mut dyn WinHandler ) {
6060 ( * self ) ( a)
6161 }
6262}
Original file line number Diff line number Diff line change 1414
1515//! GTK window creation and management.
1616
17- use std:: any:: Any ;
1817use std:: cell:: { Cell , RefCell } ;
1918use std:: convert:: { TryFrom , TryInto } ;
2019use std:: ffi:: c_void;
@@ -1206,7 +1205,7 @@ impl IdleHandle {
12061205 /// priority than other UI events, but that's not necessarily the case.
12071206 pub fn add_idle_callback < F > ( & self , callback : F )
12081207 where
1209- F : FnOnce ( & dyn Any ) + Send + ' static ,
1208+ F : FnOnce ( & mut dyn WinHandler ) + Send + ' static ,
12101209 {
12111210 let mut queue = self . idle_queue . lock ( ) . unwrap ( ) ;
12121211 if let Some ( state) = self . state . upgrade ( ) {
@@ -1239,7 +1238,7 @@ fn run_idle(state: &Arc<WindowState>) -> glib::source::Continue {
12391238
12401239 for item in queue {
12411240 match item {
1242- IdleKind :: Callback ( it) => it. call ( handler. as_any ( ) ) ,
1241+ IdleKind :: Callback ( it) => it. call ( handler) ,
12431242 IdleKind :: Token ( it) => handler. idle ( it) ,
12441243 }
12451244 }
Original file line number Diff line number Diff line change 1616
1717#![ allow( non_snake_case) ]
1818
19- use std:: any:: Any ;
2019use std:: ffi:: c_void;
2120use std:: mem;
2221use std:: sync:: { Arc , Mutex , Weak } ;
@@ -904,7 +903,7 @@ extern "C" fn run_idle(this: &mut Object, _: Sel) {
904903 ) ;
905904 for item in queue {
906905 match item {
907- IdleKind :: Callback ( it) => it. call ( view_state. handler . as_any ( ) ) ,
906+ IdleKind :: Callback ( it) => it. call ( & mut * view_state. handler ) ,
908907 IdleKind :: Token ( it) => {
909908 view_state. handler . as_mut ( ) . idle ( it) ;
910909 }
@@ -1404,7 +1403,7 @@ impl IdleHandle {
14041403 /// priority than other UI events, but that's not necessarily the case.
14051404 pub fn add_idle_callback < F > ( & self , callback : F )
14061405 where
1407- F : FnOnce ( & dyn Any ) + Send + ' static ,
1406+ F : FnOnce ( & mut dyn WinHandler ) + Send + ' static ,
14081407 {
14091408 self . add_idle ( IdleKind :: Callback ( Box :: new ( callback) ) ) ;
14101409 }
Original file line number Diff line number Diff line change 1414
1515//! Web window creation and management.
1616
17- use std:: any:: Any ;
1817use std:: cell:: { Cell , RefCell } ;
1918use std:: ffi:: OsString ;
2019use std:: rc:: { Rc , Weak } ;
@@ -142,7 +141,7 @@ impl WindowState {
142141 let mut queue = self . idle_queue . lock ( ) . expect ( "process_idle_queue" ) ;
143142 for item in queue. drain ( ..) {
144143 match item {
145- IdleKind :: Callback ( cb) => cb. call ( & self . handler ) ,
144+ IdleKind :: Callback ( cb) => cb. call ( & mut * * self . handler . borrow_mut ( ) ) ,
146145 IdleKind :: Token ( tok) => self . handler . borrow_mut ( ) . idle ( tok) ,
147146 }
148147 }
@@ -686,7 +685,7 @@ impl IdleHandle {
686685 /// Add an idle handler, which is called (once) when the main thread is idle.
687686 pub fn add_idle_callback < F > ( & self , callback : F )
688687 where
689- F : FnOnce ( & dyn Any ) + Send + ' static ,
688+ F : FnOnce ( & mut dyn WinHandler ) + Send + ' static ,
690689 {
691690 let mut queue = self . queue . lock ( ) . expect ( "IdleHandle::add_idle queue" ) ;
692691 queue. push ( IdleKind :: Callback ( Box :: new ( callback) ) ) ;
Original file line number Diff line number Diff line change 1616
1717#![ allow( non_snake_case, clippy:: cast_lossless) ]
1818
19- use std:: any:: Any ;
2019use std:: cell:: { Cell , RefCell } ;
2120use std:: mem;
2221use std:: panic:: Location ;
@@ -1226,7 +1225,7 @@ impl WndProc for MyWndProc {
12261225 let queue = self . handle . borrow ( ) . take_idle_queue ( ) ;
12271226 for callback in queue {
12281227 match callback {
1229- IdleKind :: Callback ( it) => it. call ( s. handler . as_any ( ) ) ,
1228+ IdleKind :: Callback ( it) => it. call ( & mut * s. handler ) ,
12301229 IdleKind :: Token ( token) => s. handler . idle ( token) ,
12311230 }
12321231 }
@@ -2173,7 +2172,7 @@ impl IdleHandle {
21732172 /// which means it won't be scheduled if the window is closed.
21742173 pub fn add_idle_callback < F > ( & self , callback : F )
21752174 where
2176- F : FnOnce ( & dyn Any ) + Send + ' static ,
2175+ F : FnOnce ( & mut dyn WinHandler ) + Send + ' static ,
21772176 {
21782177 let mut queue = self . queue . lock ( ) . unwrap ( ) ;
21792178 if queue. is_empty ( ) {
Original file line number Diff line number Diff line change 1414
1515//! X11 window creation and window management.
1616
17- use std:: any:: Any ;
1817use std:: cell:: { Cell , RefCell } ;
1918use std:: collections:: BinaryHeap ;
2019use std:: convert:: { TryFrom , TryInto } ;
@@ -1147,7 +1146,7 @@ impl Window {
11471146 for callback in queue {
11481147 match callback {
11491148 IdleKind :: Callback ( f) => {
1150- f. call ( handler. as_any ( ) ) ;
1149+ f. call ( handler) ;
11511150 }
11521151 IdleKind :: Token ( tok) => {
11531152 handler. idle ( tok) ;
@@ -1424,7 +1423,7 @@ impl IdleHandle {
14241423
14251424 pub fn add_idle_callback < F > ( & self , callback : F )
14261425 where
1427- F : FnOnce ( & dyn Any ) + Send + ' static ,
1426+ F : FnOnce ( & mut dyn WinHandler ) + Send + ' static ,
14281427 {
14291428 self . queue
14301429 . lock ( )
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ impl IdleHandle {
9797 /// priority than other UI events, but that's not necessarily the case.
9898 pub fn add_idle < F > ( & self , callback : F )
9999 where
100- F : FnOnce ( & dyn Any ) + Send + ' static ,
100+ F : FnOnce ( & mut dyn WinHandler ) + Send + ' static ,
101101 {
102102 self . 0 . add_idle_callback ( callback)
103103 }
You can’t perform that action at this time.
0 commit comments