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

feat(linux): Add necessary features for creating GL windows #495

Merged
merged 7 commits into from
Jul 25, 2022
Merged

Conversation

wusyong
Copy link
Member

@wusyong wusyong commented Jul 24, 2022

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

Here are some features added for incoming GL window feature:

  • On Linux, add EventLoopWindowTargetExtUnix for methods to determine if the backend is x11 or wayland.
  • On Linux, add x11 module for glutin internal use. This is basically just x11-dl, but winit secretly exports it.
  • On Linux, add auto_transparent attribute so users can draw the window manually.

There might be more but these are the minimum requirements for egui + glutin/glow.

@wusyong wusyong requested a review from a team as a code owner July 24, 2022 18:20
Comment on lines +143 to +156
// Set GDK Visual
if let Some(screen) = window.screen() {
if let Some(visual) = screen.rgba_visual() {
window.set_visual(Some(&visual));
}
}

window.connect_draw(|_, cr| {
cr.set_source_rgba(0., 0., 0., 0.);
cr.set_operator(cairo::Operator::Source);
let _ = cr.paint();
cr.set_operator(cairo::Operator::Over);
Inhibit(false)
});
window.set_app_paintable(true);
// Set a few attributes to make the window can be painted.
// See Gtk drawing model for more info:
// https://docs.gtk.org/gtk3/drawing-model.html
window.set_app_paintable(true);
let widget = window.upcast_ref::<gtk::Widget>();
unsafe {
gtk::ffi::gtk_widget_set_double_buffered(widget.to_glib_none().0, 0);
Copy link
Member Author

Choose a reason for hiding this comment

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

Many are optional but I make these become default to all windows.
Tested with wry and it looks fine.
This should also reduce some overhead when dealing with draw signal overall.

Copy link
Member

Choose a reason for hiding this comment

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

sounds fine, we can revert back if any issues are reported.

@wusyong wusyong changed the title Gl feat(linux): Add necessary features for creating GL windows Jul 24, 2022
src/platform/unix.rs Show resolved Hide resolved
src/platform_impl/linux/window.rs Outdated Show resolved Hide resolved
src/platform/unix.rs Outdated Show resolved Hide resolved
src/platform/unix.rs Outdated Show resolved Hide resolved
src/platform/unix.rs Outdated Show resolved Hide resolved
- Rename trait method name to `with_transparent_draw`.
- Use enum struct variant on WireUpEvents.
- Hide doc on x11 module.
.changes/gl.md Outdated Show resolved Hide resolved
@wusyong wusyong merged commit db7e5cb into dev Jul 25, 2022
@wusyong wusyong deleted the gl branch July 25, 2022 12:55
@github-actions github-actions bot mentioned this pull request Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants