Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events are broken when opening multiple windows #727

Closed
wolfiestyle opened this issue Feb 18, 2016 · 6 comments
Closed

Events are broken when opening multiple windows #727

wolfiestyle opened this issue Feb 18, 2016 · 6 comments

Comments

@wolfiestyle
Copy link

If you open and poll events for multiple windows, they are received by a random window, instead of the one where currently the event is happening. That means if I open two windows called foo and bar, if I move the mouse inside foo, then bar will randomly receive mouse movement events too.

Included sample code for both glium and glutin versions: https://gist.github.com/darkstalker/e1059220502a29913752

@tomaka tomaka added the bug label Feb 18, 2016
@tomaka
Copy link
Contributor

tomaka commented Feb 18, 2016

On which platform is this?

@wolfiestyle
Copy link
Author

Linux x86_64, under x11

@tomaka tomaka added the A-x11 label Feb 18, 2016
@wolfiestyle
Copy link
Author

This is probably because it's using a function that receives events for all the windows [1] instead of using something like XCheckWindowEvent (i guess). Duno how this is handled on other platforms.
Anyway I think this per-window event paradigm is incorrect, since it would require multiple event loops for an app with multiple windows, and doing that requires polling since wait_events blocks. It would be better to have a single wait_events loop for the entire application and the iterator returning a (Window, Event) pair to know where it happened. The current design is "ok" only for single window applications.

[1] https://github.com/tomaka/glutin/blob/master/src/api/x11/window.rs#L184

@elinorbgr
Copy link
Contributor

My 2 cents: I had this issue for wayland: the events for the whole application must be retrieved in the same place. So I've set up some global logic for dispatching the events to internal event queues for each window: https://github.com/tomaka/glutin/blob/master/src/api/wayland/context.rs#L152-L188

The caveat of this regarding glutin design, is that wait_events will stop blocking at the first dispatched event to any window, and thus can return None. Don't know if it is a problem actually...

@wolfiestyle
Copy link
Author

This looks like a design flaw in glutin for me. Probably it was designed for single window apps (like games). But I'm trying to write a widget toolkit, and this doesn't fit my needs. Looks like i'll have to fallback to raw Xlib :c

@tomaka
Copy link
Contributor

tomaka commented Nov 3, 2016

Closing for rust-windowing/winit#68

@tomaka tomaka closed this as completed Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants