Repository navigation
Implement changes to RedrawRequested event - #1062
Conversation
Implements the changes described in rust-windowing#1041 for the X11 platform and for platform-independent public-facing code.
|
I've implemented the proposed changes for X11 only, inserting an I'm not sure how incomplete implementations are usually done, so please let me know if I should do something differently with this PR. |
goddessfreya
left a comment
There was a problem hiding this comment.
I'll give this a test run later this week when I finally get X11 working with glutin v0.23... so might be a while.
Anyways, until then, have a singular "Yike" :).
| if refresh { | ||
| sink.send_window_event(crate::event::WindowEvent::RedrawRequested, wid); | ||
| unimplemented!() | ||
| //sink.send_window_event(crate::event::WindowEvent::RedrawRequested, wid); |
|
Yeah, it would be a very long while... @FliegendeWurst, since you are on the testers list, would you like to test this? Please make sure the examples don't freeze, and the ordering of the events is consistent with what is proposed here: #1041 Thanks :) |
|
The 'request_redraw' example no longer compiles since the event naming changed. Other examples ('cursor', 'cursor_grab', 'transparent', 'timer', 'window_icon', 'window_run_return') still seem to work. I adjusted the 'resizable' example to print debug information on all events. You can download the full log below. It seems like the event ordering works as intended, but some events are sometimes in two separate 'event cycles' (see comments below) and in the same cycle at other times. I'm not sure that's intended. NewEvents(WaitCancelled { start: Instant { tv_sec: 3708, tv_nsec: 833814233 }, requested_resume: None })
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Motion { axis: 0, value: -23.0 } }
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Motion { axis: 1, value: -5.0 } }
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: MouseMotion { delta: (-23.0, -5.0) } }
WindowEvent { window_id: WindowId(X(WindowId(153092097))), event: CursorEntered { device_id: DeviceId(X(DeviceId(2))) } }
WindowEvent { window_id: WindowId(X(WindowId(153092097))), event: CursorMoved { device_id: DeviceId(X(DeviceId(2))), position: LogicalPosition { x: 527.0769230769231, y: 138.46153846153848 }, modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } }
WindowEvent { window_id: WindowId(X(WindowId(153092097))), event: CursorLeft { device_id: DeviceId(X(DeviceId(2))) } }
MainEventsCleared
RedrawEventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 3708, tv_nsec: 835169670 }, requested_resume: None })
WindowEvent { window_id: WindowId(X(WindowId(153092097))), event: Resized(LogicalSize { width: 525.2307692307693, height: 200.30769230769232 }) }
MainEventsCleared
RedrawRequested(WindowId(X(WindowId(153092097)))) // Redraw immediately after Resized event
RedrawEventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 3708, tv_nsec: 844635764 }, requested_resume: None })
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Motion { axis: 0, value: -67.0 } }
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Motion { axis: 1, value: 0.0 } }
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: MouseMotion { delta: (-67.0, 0.0) } }
MainEventsCleared
RedrawEventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 3708, tv_nsec: 856688181 }, requested_resume: None })
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Motion { axis: 0, value: -83.0 } }
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Motion { axis: 1, value: 3.5714285713620484 } }
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: MouseMotion { delta: (-83.0, 3.5714285713620484) } }
MainEventsCleared
RedrawEventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 3708, tv_nsec: 867070153 }, requested_resume: None })
MainEventsCleared
RedrawEventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 3708, tv_nsec: 868223645 }, requested_resume: None })
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Motion { axis: 0, value: -92.0 } }
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: Motion { axis: 1, value: 3.5714285713620484 } }
DeviceEvent { device_id: DeviceId(X(DeviceId(10))), event: MouseMotion { delta: (-92.0, 3.5714285713620484) } }
MainEventsCleared
RedrawEventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 3708, tv_nsec: 868638730 }, requested_resume: None })
WindowEvent { window_id: WindowId(X(WindowId(153092097))), event: Resized(LogicalSize { width: 493.84615384615387, height: 200.30769230769232 }) }
MainEventsCleared
// no redraw event after resized event?
RedrawEventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 3708, tv_nsec: 868749321 }, requested_resume: None })
MainEventsCleared
RedrawRequested(WindowId(X(WindowId(153092097)))) // here it is, apparently
RedrawEventsCleared |
|
Yeah, it should be on the same cycle, otherwise applications that use both Maybe we can make it so that |
|
I've fixed the example. I'm not sure what can be done about the issue of related events being split across separate event loop iterations. |
|
IIRC X11 is an asynchronous API. Perhaps we're seeing the redraw event splitting because of synchronization issues between Winit and the X11 server, roughly as so?:
That's based on my extremely rough understanding of X11's structure, so it may or may not be accurate, but I think it seems relatively plausible. Also re:@zegentzy - I'm strongly opposed to only sending |
|
@Osspial There is no guarantee that after an Referring to the docs, every X function that X clients may call says that XYZ may generate Expose events. For example, two functions of interest are:
-- XResizeWindow, emphasis mine.
-- XMoveResizeWindow, emphasis mine. There is no reason to suggest that
-- §10.9.1 Expose Events, emphasis mine. I did some googling, and I found this document:
However, that claim seems to contradict this mozilla bug here which mentions the expose event arriving before the configure one: https://bugzilla.mozilla.org/show_bug.cgi?id=1280653#c11 Fwiw, I tested this out with this small patch against master (not this PR) and found that an In fact, I could reproduce this redraw splitting on master, so this isn't even a regression from what's currently happening on master: Given that, I'm approving this PR. |
goddessfreya
left a comment
There was a problem hiding this comment.
Lgtm, just fix the examples in src/lib.rs so CI stops complaining.
|
Fixed the doctests. The remaining CI failures are on Windows and Mac. |
|
One more change, we should only issue EDIT: Rationale:
-- §10.9.1 Expose Events |
* Implement changes to `RedrawRequested` event Implements the changes described in rust-windowing#1041 for the X11 platform and for platform-independent public-facing code. * Fix `request_redraw` example * Fix examples in lib docs * Only issue `RedrawRequested` on final `Expose` event
* Implement changes to `RedrawRequested` event Implements the changes described in rust-windowing#1041 for the X11 platform and for platform-independent public-facing code. * Fix `request_redraw` example * Fix examples in lib docs * Only issue `RedrawRequested` on final `Expose` event
* Implement changes to `RedrawRequested` event Implements the changes described in #1041 for the X11 platform and for platform-independent public-facing code. * Fix `request_redraw` example * Fix examples in lib docs * Only issue `RedrawRequested` on final `Expose` event
* Implement changes to `RedrawRequested` event Implements the changes described in #1041 for the X11 platform and for platform-independent public-facing code. * Fix `request_redraw` example * Fix examples in lib docs * Only issue `RedrawRequested` on final `Expose` event
* Implement changes to `RedrawRequested` event Implements the changes described in #1041 for the X11 platform and for platform-independent public-facing code. * Fix `request_redraw` example * Fix examples in lib docs * Only issue `RedrawRequested` on final `Expose` event
* Implement changes to `RedrawRequested` event Implements the changes described in #1041 for the X11 platform and for platform-independent public-facing code. * Fix `request_redraw` example * Fix examples in lib docs * Only issue `RedrawRequested` on final `Expose` event
Implements the changes described in #1041 for the X11 platform and for
platform-independent public-facing code.
cargo fmthas been run on this branchCHANGELOG.mdif knowledge of this change could be valuable to users