Skip to content

Commit

Permalink
Change OSX 'activation policy' when running headless mode.
Browse files Browse the repository at this point in the history
...or also when outputting a file.

Fixes #10836.
  • Loading branch information
frewsxcv committed Apr 30, 2016
1 parent a7a8eba commit 71af66a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
10 changes: 5 additions & 5 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions ports/cef/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions ports/glutin/window.rs
Expand Up @@ -13,6 +13,8 @@ use euclid::size::TypedSize2D;
use euclid::{Size2D, Point2D};
use gleam::gl;
use glutin;
#[cfg(target_os = "macos")]
use glutin::os::macos::{ActivationPolicy, WindowBuilderExt};
use glutin::{Api, ElementState, Event, GlRequest, MouseButton, VirtualKeyCode, MouseScrollDelta};
use glutin::{TouchPhase};
use layers::geometry::DevicePixel;
Expand Down Expand Up @@ -65,6 +67,22 @@ const LINE_HEIGHT: f32 = 38.0;

const MULTISAMPLES: u16 = 16;

#[cfg(target_os = "macos")]
fn builder_with_platform_options(mut builder: glutin::WindowBuilder) -> glutin::WindowBuilder {
if opts::get().headless || opts::get().output_file.is_some() {
// Prevent the window from showing in Dock.app, stealing focus,
// or appearing at all when running in headless mode or generating an
// output file.
builder = builder.with_activation_policy(ActivationPolicy::Prohibited)
}
builder
}

#[cfg(not(target_os = "macos"))]
fn builder_with_platform_options(builder: glutin::WindowBuilder) -> glutin::WindowBuilder {
builder
}

/// The type of a window.
pub struct Window {
window: glutin::Window,
Expand Down Expand Up @@ -113,6 +131,8 @@ impl Window {
builder = builder.with_multisampling(MULTISAMPLES)
}

builder = builder_with_platform_options(builder);

let mut glutin_window = builder.build().unwrap();

unsafe { glutin_window.make_current().expect("Failed to make context current!") }
Expand Down
8 changes: 4 additions & 4 deletions ports/gonk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 71af66a

Please sign in to comment.