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

Headless sharing and X11 screen id on 0.29.1 #1

Open
wants to merge 2 commits into
base: 0.29.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion glutin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ wayland-csd-adwaita-notitle = ["winit/wayland-csd-adwaita-notitle"]

[dependencies]
once_cell = "1.13"
winit = { version = "0.27.1", default-features = false }
# Patch needed to make WindowBuilder platform-specific info public for X11 screen
# https://github.com/tonarino/winit/pull/2
winit = { version = "0.27.5", git = "https://github.com/tonarino/winit", branch = "fix-and-publish-x11-screen-id", default-features = false }

[target.'cfg(target_os = "android")'.dependencies]
glutin_egl_sys = { version = "0.1.6", path = "../glutin_egl_sys" }
Expand Down
6 changes: 5 additions & 1 deletion glutin/src/platform_impl/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,19 @@ impl Context {
) -> Result<Self, CreationError> {
let gl_profile = helpers::get_gl_profile(gl_attr, pf_reqs)?;
let attributes = helpers::build_nsattributes(pf_reqs, gl_profile)?;
let share_ctx = gl_attr.sharing.map_or(nil, |c| *c.get_id());

let context = unsafe {
let pixelformat = NSOpenGLPixelFormat::alloc(nil).initWithAttributes_(&attributes);
if pixelformat == nil {
return Err(CreationError::OsError(
"Could not create the pixel format".to_string(),
));
}

let context =
NSOpenGLContext::alloc(nil).initWithFormat_shareContext_(pixelformat, nil);
NSOpenGLContext::alloc(nil).initWithFormat_shareContext_(pixelformat, share_ctx);

if context == nil {
return Err(CreationError::OsError(
"Could not create the rendering context".to_string(),
Expand Down
4 changes: 3 additions & 1 deletion glutin/src/platform_impl/unix/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ impl Context {
};

// Get the screen_id for the window being built.
let screen_id = unsafe { (xconn.xlib.XDefaultScreen)(xconn.display) };
let screen_id = wb.platform_specific.screen_id.unwrap_or_else(|| {
unsafe { (xconn.xlib.XDefaultScreen)(xconn.display) }
});

let mut builder_glx_u = None;
let mut builder_egl_u = None;
Expand Down