From a67ba4ba55a9609d055aa1b4786cb7413be0e98b Mon Sep 17 00:00:00 2001 From: Lars Bergstrom Date: Fri, 22 May 2015 21:02:26 -0500 Subject: [PATCH 1/4] Add X11 features required for linking against ffi functions --- Cargo.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index a952eea5d9..032f4adacd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -108,3 +108,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"] From 24badd4a8e93ccc59ae6a6450a87b34f1d4f1412 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Tue, 16 Jun 2015 19:22:04 -0600 Subject: [PATCH 2/4] Send travis notifications to Homu --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index d9ff49620a..91a8bb2f0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 From 0ac6b52a0dadbe6a29e9875bec7781efd4293952 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 26 Jun 2015 20:26:16 -0400 Subject: [PATCH 3/4] add back headless feature --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 032f4adacd..a64b4901cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ build = "build.rs" [features] default = ["window"] window = [] +headless = [] [dependencies] gl_common = "0.0.4" From f3769309ea44a0240e0964b07b056ca54e77bcf3 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 8 May 2015 21:12:01 -0400 Subject: [PATCH 4/4] add ability to set parent window when creating windows --- src/api/x11/window.rs | 13 +++++++++---- src/lib.rs | 11 +++++++---- src/window.rs | 10 ++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs index 36b60e42b2..aa20808640 100644 --- a/src/api/x11/window.rs +++ b/src/api/x11/window.rs @@ -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? @@ -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; @@ -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); diff --git a/src/lib.rs b/src/lib.rs index 49b8d9ab82..be6e25027d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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")] @@ -381,7 +381,8 @@ pub struct BuilderAttribs<'a> { srgb: Option, transparent: bool, decorations: bool, - multitouch: bool + multitouch: bool, + parent: *mut libc::c_void, } impl BuilderAttribs<'static> { @@ -408,7 +409,8 @@ impl BuilderAttribs<'static> { srgb: None, transparent: false, decorations: true, - multitouch: false + multitouch: false, + parent: std::ptr::null_mut(), } } } @@ -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) diff --git a/src/window.rs b/src/window.rs index 00174d3d36..9982e2daaf 100644 --- a/src/window.rs +++ b/src/window.rs @@ -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, @@ -609,3 +615,7 @@ impl MonitorID { id.get_dimensions() } } + + +/// Identifier for a display system window. +pub type WindowID = *mut libc::c_void;