mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
@ -11,11 +11,11 @@ use surface_map::SurfaceMap;
|
|||
use windowing;
|
||||
use windowing::{MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
|
||||
|
||||
use euclid::Matrix4;
|
||||
use euclid::point::{Point2D, TypedPoint2D};
|
||||
use euclid::rect::{Rect, TypedRect};
|
||||
use euclid::point::TypedPoint2D;
|
||||
use euclid::rect::TypedRect;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use euclid::size::TypedSize2D;
|
||||
use euclid::{Size2D, Point2D, Rect, Matrix4};
|
||||
use gfx::paint_task::{ChromeToPaintMsg, PaintRequest};
|
||||
use gfx_traits::color;
|
||||
use gleam::gl;
|
||||
|
@ -390,7 +390,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
self.send_buffer_requests_for_all_layers();
|
||||
}
|
||||
|
||||
(Msg::GetNativeDisplay(chan), ShutdownState::NotShuttingDown) => {
|
||||
(Msg::GetNativeDisplay(chan),
|
||||
ShutdownState::NotShuttingDown) => {
|
||||
chan.send(Some(self.native_display.clone())).unwrap();
|
||||
}
|
||||
|
||||
|
@ -415,11 +416,27 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
self.surface_map.insert_surfaces(&self.native_display, native_surfaces);
|
||||
}
|
||||
|
||||
(Msg::ScrollFragmentPoint(pipeline_id, layer_id, point),
|
||||
(Msg::ScrollFragmentPoint(pipeline_id, layer_id, point, _),
|
||||
ShutdownState::NotShuttingDown) => {
|
||||
self.scroll_fragment_to_point(pipeline_id, layer_id, point);
|
||||
}
|
||||
|
||||
(Msg::MoveTo(point),
|
||||
ShutdownState::NotShuttingDown) => {
|
||||
self.window.set_position(point);
|
||||
}
|
||||
|
||||
(Msg::ResizeTo(size),
|
||||
ShutdownState::NotShuttingDown) => {
|
||||
self.window.set_inner_size(size);
|
||||
}
|
||||
|
||||
(Msg::GetClientWindow(send),
|
||||
ShutdownState::NotShuttingDown) => {
|
||||
let rect = self.window.client_window();
|
||||
send.send(rect).unwrap();
|
||||
}
|
||||
|
||||
(Msg::Status(message), ShutdownState::NotShuttingDown) => {
|
||||
self.window.status(message);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ use compositor;
|
|||
use headless;
|
||||
use windowing::{WindowEvent, WindowMethods};
|
||||
|
||||
use euclid::point::Point2D;
|
||||
use euclid::rect::Rect;
|
||||
use euclid::{Size2D, Point2D, Rect};
|
||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use layers::layers::{BufferRequest, LayerBufferSet};
|
||||
use layers::platform::surface::{NativeDisplay, NativeSurface};
|
||||
|
@ -66,8 +65,20 @@ pub fn run_script_listener_thread(compositor_proxy: Box<CompositorProxy + 'stati
|
|||
receiver: IpcReceiver<ScriptToCompositorMsg>) {
|
||||
while let Ok(msg) = receiver.recv() {
|
||||
match msg {
|
||||
ScriptToCompositorMsg::ScrollFragmentPoint(pipeline_id, layer_id, point) => {
|
||||
compositor_proxy.send(Msg::ScrollFragmentPoint(pipeline_id, layer_id, point));
|
||||
ScriptToCompositorMsg::ScrollFragmentPoint(pipeline_id, layer_id, point, _smooth) => {
|
||||
compositor_proxy.send(Msg::ScrollFragmentPoint(pipeline_id, layer_id, point, _smooth));
|
||||
}
|
||||
|
||||
ScriptToCompositorMsg::GetClientWindow(send) => {
|
||||
compositor_proxy.send(Msg::GetClientWindow(send));
|
||||
}
|
||||
|
||||
ScriptToCompositorMsg::MoveTo(point) => {
|
||||
compositor_proxy.send(Msg::MoveTo(point));
|
||||
}
|
||||
|
||||
ScriptToCompositorMsg::ResizeTo(size) => {
|
||||
compositor_proxy.send(Msg::ResizeTo(size));
|
||||
}
|
||||
|
||||
ScriptToCompositorMsg::Exit => {
|
||||
|
@ -159,7 +170,7 @@ pub enum Msg {
|
|||
/// Alerts the compositor that the specified layer's rect has changed.
|
||||
SetLayerRect(PipelineId, LayerId, Rect<f32>),
|
||||
/// Scroll a page in a window
|
||||
ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>),
|
||||
ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>, bool),
|
||||
/// Requests that the compositor assign the painted buffers to the given layers.
|
||||
AssignPaintedBuffers(PipelineId, Epoch, Vec<(LayerId, Box<LayerBufferSet>)>, FrameTreeId),
|
||||
/// Alerts the compositor that the current page has changed its title.
|
||||
|
@ -201,6 +212,12 @@ pub enum Msg {
|
|||
CollectMemoryReports(mem::ReportsChan),
|
||||
/// A status message to be displayed by the browser chrome.
|
||||
Status(Option<String>),
|
||||
/// Get Window Informations size and position
|
||||
GetClientWindow(IpcSender<(Size2D<u32>, Point2D<i32>)>),
|
||||
/// Move the window to a point
|
||||
MoveTo(Point2D<i32>),
|
||||
/// Resize the window to size
|
||||
ResizeTo(Size2D<u32>),
|
||||
}
|
||||
|
||||
impl Debug for Msg {
|
||||
|
@ -232,6 +249,9 @@ impl Debug for Msg {
|
|||
Msg::ReturnUnusedNativeSurfaces(..) => write!(f, "ReturnUnusedNativeSurfaces"),
|
||||
Msg::CollectMemoryReports(..) => write!(f, "CollectMemoryReports"),
|
||||
Msg::Status(..) => write!(f, "Status"),
|
||||
Msg::GetClientWindow(..) => write!(f, "GetClientWindow"),
|
||||
Msg::MoveTo(..) => write!(f, "MoveTo"),
|
||||
Msg::ResizeTo(..) => write!(f, "ResizeTo"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use compositor_task::{CompositorEventListener, CompositorReceiver, Msg};
|
|||
use windowing::WindowEvent;
|
||||
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::Size2D;
|
||||
use euclid::{Size2D, Point2D};
|
||||
use msg::constellation_msg::AnimationState;
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use msg::constellation_msg::{ConstellationChan, WindowSizeData};
|
||||
|
@ -89,6 +89,11 @@ impl CompositorEventListener for NullCompositor {
|
|||
response_chan.send(()).unwrap();
|
||||
}
|
||||
|
||||
Msg::GetClientWindow(send) => {
|
||||
let rect = (Size2D::zero(), Point2D::zero());
|
||||
send.send(rect).unwrap();
|
||||
}
|
||||
|
||||
Msg::ChangeRunningAnimationsState(pipeline_id, animation_state) => {
|
||||
match animation_state {
|
||||
AnimationState::AnimationsPresent |
|
||||
|
@ -121,6 +126,8 @@ impl CompositorEventListener for NullCompositor {
|
|||
Msg::ViewportConstrained(..) => {}
|
||||
Msg::CreatePng(..) |
|
||||
Msg::PaintTaskExited(..) |
|
||||
Msg::MoveTo(..) |
|
||||
Msg::ResizeTo(..) |
|
||||
Msg::IsReadyToSaveImageReply(..) => {}
|
||||
Msg::NewFavicon(..) => {}
|
||||
Msg::HeadParsed => {}
|
||||
|
|
|
@ -9,6 +9,7 @@ use compositor_task::{CompositorProxy, CompositorReceiver};
|
|||
use euclid::point::TypedPoint2D;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::TypedSize2D;
|
||||
use euclid::{Size2D, Point2D};
|
||||
use layers::geometry::DevicePixel;
|
||||
use layers::platform::surface::NativeDisplay;
|
||||
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||
|
@ -103,6 +104,13 @@ pub trait WindowMethods {
|
|||
/// Presents the window to the screen (perhaps by page flipping).
|
||||
fn present(&self);
|
||||
|
||||
/// Return the size of the window with head and borders and position of the window values
|
||||
fn client_window(&self) -> (Size2D<u32>, Point2D<i32>);
|
||||
/// Set the size inside of borders and head
|
||||
fn set_inner_size(&self, size: Size2D<u32>);
|
||||
/// Set the window position
|
||||
fn set_position(&self, point: Point2D<i32>);
|
||||
|
||||
/// Sets the page title for the current page.
|
||||
fn set_page_title(&self, title: Option<String>);
|
||||
/// Sets the load data for the current page.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue