Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Glutin update #44

Merged
merged 4 commits into from
Aug 22, 2015
Merged
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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ after_success:
[ $TRAVIS_BRANCH = master ] &&
[ $TRAVIS_PULL_REQUEST = false ] &&
cargo publish --token ${CRATESIO_TOKEN}

notifications:
webhooks: http://build.servo.org:54856/travis
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build = "build.rs"
[features]
default = ["window"]
window = []
headless = []

[dependencies]
gl_common = "0.0.4"
Expand Down Expand Up @@ -108,3 +109,11 @@ wayland-client = { version = "0.2.1", features = ["egl", "dlopen"] }
wayland-kbd = "0.2.0"
wayland-window = "0.1.0"
x11-dl = "~2.0"

[target.i686-unknown-linux-gnu.dependencies.x11]
version = "*"
features = ["xlib", "xf86vmode", "xcursor"]

[target.x86_64-unknown-linux-gnu.dependencies.x11]
version = "*"
features = ["xlib", "xf86vmode", "xcursor"]
13 changes: 9 additions & 4 deletions src/api/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,17 @@ impl Window {
},
};

// getting the parent window
let parent = if builder.parent.is_null() {
unsafe { (display.xlib.XDefaultRootWindow)(display.display) }
} else {
builder.parent as ffi::Window
};
// getting the root window
let root = unsafe { (display.xlib.XDefaultRootWindow)(display.display) };

// creating the color map
let cmap = unsafe {
let cmap = (display.xlib.XCreateColormap)(display.display, root,
let cmap = (display.xlib.XCreateColormap)(display.display, parent,
visual_infos.visual as *mut _,
ffi::AllocNone);
// TODO: error checking?
Expand All @@ -422,7 +427,7 @@ impl Window {
swa
};

let mut window_attributes = ffi::CWBorderPixel | ffi::CWColormap | ffi::CWEventMask;
let mut window_attributes = ffi::CWBorderPixel | ffi::CWEventMask | ffi::CWColormap;

if builder.transparent {
window_attributes |= ffi::CWBackPixel;
Expand All @@ -440,7 +445,7 @@ impl Window {

// finally creating the window
let window = unsafe {
let win = (display.xlib.XCreateWindow)(display.display, root, 0, 0, dimensions.0 as libc::c_uint,
let win = (display.xlib.XCreateWindow)(display.display, parent, 0, 0, dimensions.0 as libc::c_uint,
dimensions.1 as libc::c_uint, 0, visual_infos.depth, ffi::InputOutput as libc::c_uint,
visual_infos.visual as *mut _, window_attributes,
&mut set_win_attr);
Expand Down
11 changes: 7 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extern crate x11_dl;
pub use events::*;
pub use headless::{HeadlessRendererBuilder, HeadlessContext};
#[cfg(feature = "window")]
pub use window::{WindowBuilder, Window, WindowProxy, PollEventsIterator, WaitEventsIterator};
pub use window::{WindowBuilder, Window, WindowID, WindowProxy, PollEventsIterator, WaitEventsIterator};
#[cfg(feature = "window")]
pub use window::{AvailableMonitorsIter, MonitorID, get_available_monitors, get_primary_monitor};
#[cfg(feature = "window")]
Expand Down Expand Up @@ -381,7 +381,8 @@ pub struct BuilderAttribs<'a> {
srgb: Option<bool>,
transparent: bool,
decorations: bool,
multitouch: bool
multitouch: bool,
parent: *mut libc::c_void,
}

impl BuilderAttribs<'static> {
Expand All @@ -408,7 +409,8 @@ impl BuilderAttribs<'static> {
srgb: None,
transparent: false,
decorations: true,
multitouch: false
multitouch: false,
parent: std::ptr::null_mut(),
}
}
}
Expand Down Expand Up @@ -440,7 +442,8 @@ impl<'a> BuilderAttribs<'a> {
srgb: self.srgb,
transparent: self.transparent,
decorations: self.decorations,
multitouch: self.multitouch
multitouch: self.multitouch,
parent: self.parent,
};

(new_attribs, sharing)
Expand Down
10 changes: 10 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ impl<'a> WindowBuilder<'a> {
self
}

/// Sets the parent window
pub fn with_parent(mut self, parent: WindowID) -> WindowBuilder<'a> {
self.attribs.parent = parent;
self
}

/// Builds the window.
///
/// Error should be very rare and only occur in case of permission denied, incompatible system,
Expand Down Expand Up @@ -609,3 +615,7 @@ impl MonitorID {
id.get_dimensions()
}
}


/// Identifier for a display system window.
pub type WindowID = *mut libc::c_void;