File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,20 +23,10 @@ pub enum Event {
2323 Closed ,
2424
2525 /// A window was moved.
26- Moved {
27- /// The new logical x location of the window
28- x : i32 ,
29- /// The new logical y location of the window
30- y : i32 ,
31- } ,
26+ Moved ( Point ) ,
3227
3328 /// A window was resized.
34- Resized {
35- /// The new logical width of the window
36- width : u32 ,
37- /// The new logical height of the window
38- height : u32 ,
39- } ,
29+ Resized ( Size ) ,
4030
4131 /// A window redraw was requested.
4232 ///
Original file line number Diff line number Diff line change @@ -194,6 +194,17 @@ pub fn close_events() -> Subscription<Id> {
194194 } )
195195}
196196
197+ /// Subscribes to all [`Event::Resized`] occurrences in the running application.
198+ pub fn resize_events ( ) -> Subscription < ( Id , Size ) > {
199+ event:: listen_with ( |event, _status, id| {
200+ if let crate :: core:: Event :: Window ( Event :: Resized ( size) ) = event {
201+ Some ( ( id, size) )
202+ } else {
203+ None
204+ }
205+ } )
206+ }
207+
197208/// Subscribes to all [`Event::CloseRequested`] occurences in the running application.
198209pub fn close_requests ( ) -> Subscription < Id > {
199210 event:: listen_with ( |event, _status, id| {
Original file line number Diff line number Diff line change @@ -132,10 +132,10 @@ pub fn window_event(
132132 WindowEvent :: Resized ( new_size) => {
133133 let logical_size = new_size. to_logical ( scale_factor) ;
134134
135- Some ( Event :: Window ( window:: Event :: Resized {
135+ Some ( Event :: Window ( window:: Event :: Resized ( Size {
136136 width : logical_size. width ,
137137 height : logical_size. height ,
138- } ) )
138+ } ) ) )
139139 }
140140 WindowEvent :: CloseRequested => {
141141 Some ( Event :: Window ( window:: Event :: CloseRequested ) )
@@ -277,7 +277,7 @@ pub fn window_event(
277277 let winit:: dpi:: LogicalPosition { x, y } =
278278 position. to_logical ( scale_factor) ;
279279
280- Some ( Event :: Window ( window:: Event :: Moved { x, y } ) )
280+ Some ( Event :: Window ( window:: Event :: Moved ( Point :: new ( x, y) ) ) )
281281 }
282282 _ => None ,
283283 }
You can’t perform that action at this time.
0 commit comments