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

x11: fix WindowAttributesExtX11::with_x11_screen(), extend example #3974

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

strohel
Copy link
Contributor

@strohel strohel commented Oct 30, 2024

This is a kind of follow-up to #3973.

There's an API to programmatically specify X11 screen id (override what is determined from the DISPLAY env variable), but it doesn't work.

Setting up X Server with 2 screens and calling DISPLAY=:0 X11_SCREEN_ID=1 cargo run --example window should be equivalent to calling DISPLAY=:0.1 cargo run --example window

The latter works now (and places the window on the correct screen), but the former yields

failed to create initial window: Os(OsError { line: 620, file: "src/platform_impl/linux/x11/window.rs", error: X11Error(X11Error { error_kind: Match, error_code: 8, sequence: 219, bad_value: 1319, minor_opcode: 0, major_opcode: 1, extension_name: None, request_name: Some("CreateWindow") }) })

Here 1319 is the root window id for screen 0, which doesn't match the screen 1 that we request.

The problem is that we need to factor in the screen id when determining the parent (root) window when not explicitly set. This patch does that.

CC @bschwind @mbernat.


There is also a soft-prerequisite commit that extends the window example to make the code change more easily testable. I've done the simplest possible thing and accept the optional parameters as env variables. Let me know if that's fine.


  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

strohel added a commit to tonarino/winit that referenced this pull request Oct 31, 2024
Based on rust-windowing#3973, which should be merged first.

There's an API to programmatically specify X11 screen id (override what is determined from the `DISPLAY` env variable), but it doesn't work.

Seeting up X Server with 2 screens and calling `DISPLAY=:0 X11_SCREEN_ID=1 cargo run --example window` should be equivalent to calling `DISPLAY=:0.1 cargo run --example window`

The latter works (and places the window on the correct screen), but the former yields

`failed to create initial window: Os(OsError { line: 620, file: "src/platform_impl/linux/x11/window.rs", error: X11Error(X11Error { error_kind: Match, error_code: 8, sequence: 219, bad_value: 1319, minor_opcode: 0, major_opcode: 1, extension_name: None, request_name: Some("CreateWindow") }) })`

_Here `1319` is the root window id for screen 0, which doesn't match the screen 1 that we request._

The problem is that we need to factor in the screen id when determining the parent (root) window when not explicitly set. This patch does that.
@strohel strohel force-pushed the fix-with-x11-screen branch from b8d2c97 to bef697f Compare November 5, 2024 13:00
@strohel
Copy link
Contributor Author

strohel commented Nov 5, 2024

Gentle ping if I can get your review @notgull / @kchibisov 🙏. I've also rebased this on latest master as there was a conflict.

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@notgull
Copy link
Member

notgull commented Nov 6, 2024

Could you please squash your commits into one as per CONTRIBUTING.md?

Based on rust-windowing#3973, which should be merged first.

There's an API to programmatically specify X11 screen id (override what is determined from the `DISPLAY` env variable), but it doesn't work.

Seeting up X Server with 2 screens and calling `DISPLAY=:0 X11_SCREEN_ID=1 cargo run --example window` should be equivalent to calling `DISPLAY=:0.1 cargo run --example window`

The latter works (and places the window on the correct screen), but the former yields

`failed to create initial window: Os(OsError { line: 620, file: "src/platform_impl/linux/x11/window.rs", error: X11Error(X11Error { error_kind: Match, error_code: 8, sequence: 219, bad_value: 1319, minor_opcode: 0, major_opcode: 1, extension_name: None, request_name: Some("CreateWindow") }) })`

_Here `1319` is the root window id for screen 0, which doesn't match the screen 1 that we request._

The problem is that we need to factor in the screen id when determining the parent (root) window when not explicitly set. This patch does that.

---

Also: Extend the window example with X11_{SCREEN,VISUAL}_ID env variables
@strohel strohel force-pushed the fix-with-x11-screen branch from bef697f to f2be80e Compare November 6, 2024 08:43
@strohel
Copy link
Contributor Author

strohel commented Nov 6, 2024

Could you please squash your commits into one as per CONTRIBUTING.md?

Sure, pushed!

@notgull notgull merged commit ae4c449 into rust-windowing:master Nov 6, 2024
58 checks passed
@strohel
Copy link
Contributor Author

strohel commented Nov 22, 2024

(belated) Thanks for merging!

@kchibisov
Copy link
Member

I'll see what I can do with patch release once I have time, unless someone else won't do it.

@madsmtm madsmtm added this to the Version 0.30.6 milestone Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

5 participants