Switch X11 and wayland to the new design

This commit is contained in:
Pierre Krieger 2015-09-21 11:52:21 +02:00
parent b5d0a3eb67
commit 5182023fd6
3 changed files with 55 additions and 26 deletions

View file

@ -13,14 +13,16 @@ use api::dlopen;
use api::egl;
use api::egl::Context as EglContext;
use BuilderAttribs;
use ContextError;
use CreationError;
use Event;
use PixelFormat;
use CursorState;
use MouseCursor;
use GlAttributes;
use GlContext;
use PixelFormatRequirements;
use WindowAttributes;
use std::collections::VecDeque;
use std::ops::{Deref, DerefMut};
@ -241,7 +243,9 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
}
impl Window {
pub fn new(builder: BuilderAttribs) -> Result<Window, CreationError> {
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
opengl: &GlAttributes<&Window>) -> Result<Window, CreationError>
{
use self::wayland::internals::FFI;
let wayland_context = match *WAYLAND_CONTEXT {
@ -251,7 +255,7 @@ impl Window {
if !is_egl_available() { return Err(CreationError::NotSupported) }
let (w, h) = builder.window.dimensions.unwrap_or((800, 600));
let (w, h) = window.dimensions.unwrap_or((800, 600));
let surface = EGLSurface::new(
wayland_context.compositor.create_surface(),
@ -259,12 +263,12 @@ impl Window {
h as i32
);
let mut shell_window = if let Some(PlatformMonitorID::Wayland(ref monitor)) = builder.window.monitor {
let mut shell_window = if let Some(PlatformMonitorID::Wayland(ref monitor)) = window.monitor {
let shell_surface = wayland_context.shell.get_shell_surface(surface);
shell_surface.set_fullscreen(ShellFullscreenMethod::Default, Some(&monitor.output));
ShellWindow::Plain(shell_surface)
} else {
if builder.window.decorations {
if window.decorations {
ShellWindow::Decorated(match DecoratedSurface::new(
surface,
w as i32,
@ -291,7 +295,7 @@ impl Window {
});
try!(EglContext::new(
egl,
&builder.pf_reqs, &builder.opengl.clone().map_sharing(|_| unimplemented!()), // TODO:
pf_reqs, &opengl.clone().map_sharing(|_| unimplemented!()), // TODO:
egl::NativeDisplay::Wayland(Some(wayland_context.display.ptr() as *const _)))
.and_then(|p| p.finish((**shell_window.get_shell()).ptr() as *const _))
)