mirror of
https://github.com/servo/servo.git
synced 2025-10-01 00:59:15 +01:00
Implement viewport functions for window #1718
This commit is contained in:
parent
9f85370885
commit
f0987380dd
14 changed files with 466 additions and 63 deletions
|
@ -20,6 +20,8 @@ use wrappers::CefWrap;
|
|||
|
||||
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use euclid::point::Point2D;
|
||||
use euclid::rect::Rect;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use gleam::gl;
|
||||
|
@ -147,16 +149,16 @@ impl Window {
|
|||
Cursor::TextCursor => msg_send![class("NSCursor"), IBeamCursor],
|
||||
Cursor::GrabCursor | Cursor::AllScrollCursor =>
|
||||
msg_send![class("NSCursor"), openHandCursor],
|
||||
Cursor::NoDropCursor | Cursor::NotAllowedCursor =>
|
||||
Cursor::NoDropCursor | Cursor::NotAllowedCursor =>
|
||||
msg_send![class("NSCursor"), operationNotAllowedCursor],
|
||||
Cursor::PointerCursor => msg_send![class("NSCursor"), pointingHandCursor],
|
||||
Cursor::SResizeCursor => msg_send![class("NSCursor"), resizeDownCursor],
|
||||
Cursor::WResizeCursor => msg_send![class("NSCursor"), resizeLeftCursor],
|
||||
Cursor::EwResizeCursor | Cursor::ColResizeCursor =>
|
||||
Cursor::EwResizeCursor | Cursor::ColResizeCursor =>
|
||||
msg_send![class("NSCursor"), resizeLeftRightCursor],
|
||||
Cursor::EResizeCursor => msg_send![class("NSCursor"), resizeRightCursor],
|
||||
Cursor::NResizeCursor => msg_send![class("NSCursor"), resizeUpCursor],
|
||||
Cursor::NsResizeCursor | Cursor::RowResizeCursor =>
|
||||
Cursor::NsResizeCursor | Cursor::RowResizeCursor =>
|
||||
msg_send![class("NSCursor"), resizeUpDownCursor],
|
||||
Cursor::VerticalTextCursor => msg_send![class("NSCursor"), IBeamCursorForVerticalLayout],
|
||||
_ => msg_send![class("NSCursor"), arrowCursor],
|
||||
|
@ -223,6 +225,22 @@ impl WindowMethods for Window {
|
|||
}
|
||||
}
|
||||
|
||||
fn client_window(&self) -> (Size2D<u32>, Point2D<i32>) {
|
||||
let size = self.size().to_untyped();
|
||||
let width = size.width as u32;
|
||||
let height = size.height as u32;
|
||||
//TODO get real window position
|
||||
(Size2D::new(width, height), Point2D::zero())
|
||||
}
|
||||
|
||||
fn set_inner_size(&self, size: Size2D<u32>) {
|
||||
|
||||
}
|
||||
|
||||
fn set_position(&self, point: Point2D<i32>) {
|
||||
|
||||
}
|
||||
|
||||
fn present(&self) {
|
||||
let browser = self.cef_browser.borrow();
|
||||
match *browser {
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use euclid::size::TypedSize2D;
|
||||
use euclid::{Size2D, Point2D};
|
||||
use gleam::gl;
|
||||
use glutin;
|
||||
use layers::geometry::DevicePixel;
|
||||
|
@ -25,8 +26,6 @@ use NestedEventLoopListener;
|
|||
#[cfg(feature = "window")]
|
||||
use compositing::windowing::{MouseWindowEvent, WindowNavigateMsg};
|
||||
#[cfg(feature = "window")]
|
||||
use euclid::point::Point2D;
|
||||
#[cfg(feature = "window")]
|
||||
use glutin::{Api, ElementState, Event, GlRequest, MouseButton, VirtualKeyCode, MouseScrollDelta};
|
||||
#[cfg(feature = "window")]
|
||||
use msg::constellation_msg::{KeyState, NONE, CONTROL, SHIFT, ALT, SUPER};
|
||||
|
@ -521,6 +520,22 @@ impl WindowMethods for Window {
|
|||
Size2D::typed(width as f32, height as f32)
|
||||
}
|
||||
|
||||
fn client_window(&self) -> (Size2D<u32>, Point2D<i32>) {
|
||||
let (width, height) = self.window.get_outer_size().unwrap();
|
||||
let size = Size2D::new(width, height);
|
||||
let (x, y) = self.window.get_position().unwrap();
|
||||
let origin = Point2D::new(x as i32, y as i32);
|
||||
(size, origin)
|
||||
}
|
||||
|
||||
fn set_inner_size(&self, size: Size2D<u32>) {
|
||||
self.window.set_inner_size(size.width as u32, size.height as u32)
|
||||
}
|
||||
|
||||
fn set_position(&self, point: Point2D<i32>) {
|
||||
self.window.set_position(point.x, point.y)
|
||||
}
|
||||
|
||||
fn present(&self) {
|
||||
self.window.swap_buffers().unwrap();
|
||||
}
|
||||
|
@ -748,6 +763,20 @@ impl WindowMethods for Window {
|
|||
fn present(&self) {
|
||||
}
|
||||
|
||||
fn set_inner_size(&self, _: Size2D<u32>) {
|
||||
|
||||
}
|
||||
|
||||
fn set_position(&self, _: Point2D<i32>) {
|
||||
|
||||
}
|
||||
|
||||
fn client_window(&self) -> (Size2D<u32>, Point2D<i32>) {
|
||||
let width = self.width;
|
||||
let height = self.height;
|
||||
(Size2D::new(width, height), Point2D::zero())
|
||||
}
|
||||
|
||||
fn create_compositor_channel(_: &Option<Rc<Window>>)
|
||||
-> (Box<CompositorProxy + Send>, Box<CompositorReceiver>) {
|
||||
let (sender, receiver) = channel();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use euclid::point::Point2D;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use gleam::gl;
|
||||
|
@ -790,6 +791,20 @@ impl WindowMethods for Window {
|
|||
Size2D::typed(self.width as f32, self.height as f32)
|
||||
}
|
||||
|
||||
fn client_window(&self) -> (Size2D<u32>, Point2D<i32>) {
|
||||
let width = self.width as u32;
|
||||
let height = self.height as u32;
|
||||
(Size2D::new(width, height), Point2D::zero())
|
||||
}
|
||||
|
||||
fn set_inner_size(&self, _: Size2D<u32>) {
|
||||
|
||||
}
|
||||
|
||||
fn set_position(&self, _: Point2D<i32>) {
|
||||
|
||||
}
|
||||
|
||||
/// Presents the window to the screen (perhaps by page flipping).
|
||||
fn present(&self) {
|
||||
let _ = egl::SwapBuffers(self.dpy, self.surf);
|
||||
|
@ -870,4 +885,3 @@ impl CompositorProxy for GonkCompositorProxy {
|
|||
} as Box<CompositorProxy + Send>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue