-
Notifications
You must be signed in to change notification settings - Fork 909
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] Create windows with a parent window #2246
[X11] Create windows with a parent window #2246
Conversation
egui_sdl2_gl cannot create window with parent and with OpenGL context, it's because of the specification of SDL2 itself. so I should not use egui_sdl2_gl. Now I use egui-glow (internally uses egui-winit), but this don't support parent window, but I create Pull-Request to winit upstream (rust-windowing/winit#2246). For the merging that PR, as workarround, SoyBoy uses a folk of egui-glow on my GitHub accnount.
573f967
to
b2c3199
Compare
All checks have passed! It's truly ready for review 🎊 |
bd5621d
to
ef6e8c8
Compare
This PR followed the HEAD of master. Including document updates. |
ef6e8c8
to
d36181a
Compare
d36181a
to
a517678
Compare
What does this PR stop? I’ll try to resolve that if I can. |
We don't have a maintainer for X11 atm, so there's not really anyone to neither review nor accept the PR, sadly |
Oh... It make sense. |
a517678
to
904be7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not from your PR, but maybe you could also fix these errors?
#[doc(hidden)]
is ignored on trait impl items
The code here... really, there's not much to review, besides the example.
Being able to visualise things is always nice, so I added softbuffer as a dev-dependency and modified the example. See my commits here: https://github.com/dhardy/winit/commits/with-parent-window-in-x11
That is, child windows are created at the mouse coordinates as a child of the window clicked in. Seems to work fine to me.
Maybe pull my commits into this PR? Although it's somewhat orthogonal; @madsmtm? (I also copied the softbuffer example into winit/examples
.)
CHANGELOG.md
Outdated
@@ -40,10 +40,12 @@ And please only add new entries to the top of this list, right below the `# Unre | |||
- On iOS, send `RedrawEventsCleared` even if there are no redraw events, consistent with other platforms. | |||
- **Breaking:** Replaced `Window::with_app_id` and `Window::with_class` with `Window::with_name` on `WindowBuilderExtUnix`. | |||
- On Wayland and X11, fix window not resizing with `Window::set_inner_size` after calling `Window:set_resizable(false)`. | |||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left over from a merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry. Removed!
src/platform/unix.rs
Outdated
@@ -274,6 +274,9 @@ pub trait WindowBuilderExtUnix { | |||
|
|||
#[cfg(feature = "x11")] | |||
fn with_x11_screen(self, screen_id: i32) -> Self; | |||
#[cfg(feature = "x11")] | |||
/// Build window with X11's parent window. Only relevant on X11. | |||
fn with_x11_parent(self, parent_id: usize) -> Self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other point worth making: is it possible to use the winit::WindowId
here?
For X11 only, this doesn't matter much. If this feature gets generalised to other platforms (hopefully), then it would be better to use the WindowId
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usize
is likely the wrong type to use here. X11 window IDs are u32
s, as far as I can tell (although x11-dl
's typedefs do make things confusing, and the definition of XID
in the headers wasn't fun to track down).
As of #2351, we can make a WindowId
from arbitrary u64
s, so using it instead should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other point worth making: is it possible to use the winit::WindowId here?
As of #2351, we can make a WindowId from arbitrary u64s, so using it instead should be fine.
Good idea, thanks! I'll do that.
Further note: the child windows created by this PR are limited to the area of their parent. In general, it can be useful to have child windows without this restriction (e.g. menus may extend beyond the bounds of the parent). |
Sorry I did my project... I can do this PR starting this week end maybe. |
Re adding |
Using softbuffer should resolve issues with examples on Wayland, so it should simplify testing. |
I'm personally not entirely sold on softbuffer's current API, but I think the benefits of adding it to the examples (i.e. no more complaints about windows not showing up on wayland) are worthwhile. |
Yeah, I just want to have something that puts pixels into window, I'm not recommending softbuffer in particular. |
Will there ever be a perfect fit? Moreover, I'm skeptical that using a complex hardware-accelerated API as the default for visualizations is the most reliable choice, even if GL does work basically everywhere. Given some direction I'm happy to author a different PR regarding softbuffer-in-winit, but it's simple enough that anyone here could do this. |
If you feel like it you can go for it for sure. |
aded31f
to
7dbf8fc
Compare
src/platform/x11.rs
Outdated
@@ -171,6 +172,9 @@ pub trait WindowBuilderExtX11 { | |||
fn with_x11_visual<T>(self, visual_infos: *const T) -> Self; | |||
|
|||
fn with_x11_screen(self, screen_id: i32) -> Self; | |||
#[cfg(feature = "x11")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Also remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not removed.
7dbf8fc
to
5efd863
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rebase. Should be good after that.
5efd863
to
d5b0d66
Compare
Rebased! |
src/platform/x11.rs
Outdated
@@ -171,6 +172,9 @@ pub trait WindowBuilderExtX11 { | |||
fn with_x11_visual<T>(self, visual_infos: *const T) -> Self; | |||
|
|||
fn with_x11_screen(self, screen_id: i32) -> Self; | |||
#[cfg(feature = "x11")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not removed.
src/platform/x11.rs
Outdated
@@ -171,6 +172,9 @@ pub trait WindowBuilderExtX11 { | |||
fn with_x11_visual<T>(self, visual_infos: *const T) -> Self; | |||
|
|||
fn with_x11_screen(self, screen_id: i32) -> Self; | |||
#[cfg(feature = "x11")] | |||
/// Build window with X11's parent window. Only relevant on X11. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're inside the X11 extension.
/// Build window with X11's parent window. Only relevant on X11. | |
/// Build window with parent window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! fixed.
@@ -120,7 +120,16 @@ impl UnownedWindow { | |||
pl_attribs: PlatformSpecificWindowBuilderAttributes, | |||
) -> Result<UnownedWindow, RootOsError> { | |||
let xconn = &event_loop.xconn; | |||
let root = event_loop.root; | |||
// root should be a type ffi::Window and it is finally c_ulong. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment entirely, there's no value in it. The WindowID thing is clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
// XID is defined as 32-bit value in the X11 protocol so | ||
// there's no problem about higher bits truncation. | ||
// cf. https://www.x.org/docs/XProtocol/proto.pdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment also feels a bit strange. You can say WindowId is XID under the hood which doesn't exceed u32, so the conversion is lossless
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Because of X11/Wayland module separation
d5b0d66
to
c920d89
Compare
Thanks @kchibisov for reviewing my some nits. I think these are fixed now (checked all diffs in the "Files changed" tab), but EDITED: and sorry for late because of my private travelling... |
This PR can create windows with a user-specified parent window. It's intended to realize what discussed in issue #159 for X11.
This is a retry #2096. In that time I was not aware CI fails so passed long time, the master branch proceeds so much from that PR so I cannot follow changes.
TODO
CHANGELOG.md
if knowledge of this change could be valuable to users