diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-05 21:47:33 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-05 21:47:33 +0000 |
commit | 8f05ceaab534c9e0fd354e34b61e70ac48888e2c (patch) | |
tree | d8430a5bf076b96b6bc087a3d7f457bdef251a76 /ui | |
parent | db84517c5e965d72adb9ce8edaf89a229f3f59fa (diff) | |
download | chromium_src-8f05ceaab534c9e0fd354e34b61e70ac48888e2c.zip chromium_src-8f05ceaab534c9e0fd354e34b61e70ac48888e2c.tar.gz chromium_src-8f05ceaab534c9e0fd354e34b61e70ac48888e2c.tar.bz2 |
In-chorme viewer for metro (part 2)
- Wires metro mouse move, mouse click to aura viewer
- Introduces a new RootWindowHost, one that is remote
BUG=151718
TEST=see bug
Review URL: https://codereview.chromium.org/11047012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/aura.gyp | 2 | ||||
-rw-r--r-- | ui/aura/remote_root_window_host_win.cc | 159 | ||||
-rw-r--r-- | ui/aura/remote_root_window_host_win.h | 67 | ||||
-rw-r--r-- | ui/aura/root_window.cc | 6 | ||||
-rw-r--r-- | ui/aura/root_window_host.h | 6 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.cc | 14 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.h | 4 | ||||
-rw-r--r-- | ui/aura/root_window_host_win.cc | 14 | ||||
-rw-r--r-- | ui/aura/root_window_host_win.h | 5 | ||||
-rw-r--r-- | ui/metro_viewer/metro_viewer_messages.h | 15 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_linux.cc | 6 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_linux.h | 1 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_win.cc | 7 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_win.h | 1 |
14 files changed, 280 insertions, 27 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index 07daf50..76b7fe8 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -88,6 +88,8 @@ 'display_change_observer_x11.h', 'display_manager.cc', 'display_manager.h', + 'remote_root_window_host_win.cc', + 'remote_root_window_host_win.h', 'root_window_host.h', 'root_window_host_delegate.h', 'root_window_host_linux.cc', diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc new file mode 100644 index 0000000..de3ccd8 --- /dev/null +++ b/ui/aura/remote_root_window_host_win.cc @@ -0,0 +1,159 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/aura/remote_root_window_host_win.h" + +#include <windows.h> + +#include <algorithm> + +#include "base/message_loop.h" +#include "ui/aura/client/capture_client.h" +#include "ui/aura/env.h" +#include "ui/aura/root_window.h" +#include "ui/base/cursor/cursor_loader_win.h" +#include "ui/base/events/event.h" +#include "ui/base/view_prop.h" + +using std::max; +using std::min; + +namespace aura { + +namespace { + +const char* kRootWindowHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__"; + +} // namespace + +RemoteRootWindowHostWin* g_instance = NULL; + +RemoteRootWindowHostWin* RemoteRootWindowHostWin::Instance() { + return g_instance; +} + +RemoteRootWindowHostWin* RemoteRootWindowHostWin::Create( + const gfx::Rect& bounds) { + g_instance = new RemoteRootWindowHostWin(bounds); + return g_instance; +} + +RemoteRootWindowHostWin::RemoteRootWindowHostWin(const gfx::Rect& bounds) + : delegate_(NULL) { + prop_.reset(new ui::ViewProp(NULL, kRootWindowHostWinKey, this)); +} + +RemoteRootWindowHostWin::~RemoteRootWindowHostWin() { +} + +void RemoteRootWindowHostWin::SetDelegate(RootWindowHostDelegate* delegate) { + delegate_ = delegate; +} + +RootWindow* RemoteRootWindowHostWin::GetRootWindow() { + return delegate_->AsRootWindow(); +} + +gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() { + // TODO(cpu): This is bad. Chrome's compositor needs a valid window + // initially and then later on we swap it. Since the compositor never + // uses this initial window we tell ourselves this hack is ok to get + // thing off the ground. + return ::GetDesktopWindow(); +} + +void RemoteRootWindowHostWin::Show() { +} + +void RemoteRootWindowHostWin::Hide() { + NOTIMPLEMENTED(); +} + +void RemoteRootWindowHostWin::ToggleFullScreen() { +} + +gfx::Rect RemoteRootWindowHostWin::GetBounds() const { + gfx::Rect r(gfx::Point(0, 0), aura::RootWindowHost::GetNativeScreenSize()); + return r; +} + +void RemoteRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { +} + +gfx::Point RemoteRootWindowHostWin::GetLocationOnNativeScreen() const { + return gfx::Point(0, 0); +} + +void RemoteRootWindowHostWin::SetCursor(gfx::NativeCursor native_cursor) { +} + +void RemoteRootWindowHostWin::SetCapture() { +} + +void RemoteRootWindowHostWin::ReleaseCapture() { +} + +void RemoteRootWindowHostWin::ShowCursor(bool show) { +} + +bool RemoteRootWindowHostWin::QueryMouseLocation(gfx::Point* location_return) { + POINT pt; + GetCursorPos(&pt); + *location_return = + gfx::Point(static_cast<int>(pt.x), static_cast<int>(pt.y)); + return true; +} + +bool RemoteRootWindowHostWin::ConfineCursorToRootWindow() { + return true; +} + +bool RemoteRootWindowHostWin::GrabSnapshot( + const gfx::Rect& snapshot_bounds, + std::vector<unsigned char>* png_representation) { + NOTIMPLEMENTED(); + return false; +} + +void RemoteRootWindowHostWin::UnConfineCursor() { +} + +void RemoteRootWindowHostWin::MoveCursorTo(const gfx::Point& location) { +} + +void RemoteRootWindowHostWin::SetFocusWhenShown(bool focus_when_shown) { + NOTIMPLEMENTED(); +} + +void RemoteRootWindowHostWin::PostNativeEvent( + const base::NativeEvent& native_event) { +} + +void RemoteRootWindowHostWin::OnDeviceScaleFactorChanged( + float device_scale_factor) { + NOTIMPLEMENTED(); +} + +void RemoteRootWindowHostWin::PrepareForShutdown() { + NOTIMPLEMENTED(); +} + +void RemoteRootWindowHostWin::OnMouseMoved(int x, int y, int extra) { + gfx::Point location(x, y); + ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, 0); + delegate_->OnHostMouseEvent(&event); +} + +void RemoteRootWindowHostWin::OnMouseClick(int x, int y, int extra) { + gfx::Point location(x, y); + ui::EventType type = (extra == 1) ? + ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED; + ui::MouseEvent event(type, location, location, 0); + event.SetClickCount(1); + event.set_flags(ui::EF_LEFT_MOUSE_BUTTON); + delegate_->OnHostMouseEvent(&event); +} + +} // namespace aura + diff --git a/ui/aura/remote_root_window_host_win.h b/ui/aura/remote_root_window_host_win.h new file mode 100644 index 0000000..52990c9 --- /dev/null +++ b/ui/aura/remote_root_window_host_win.h @@ -0,0 +1,67 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_AURA_REMOTE_ROOT_WINDOW_HOST_WIN_H_ +#define UI_AURA_REMOTE_ROOT_WINDOW_HOST_WIN_H_ + +#include <vector> + +#include "base/compiler_specific.h" +#include "ui/aura/root_window_host.h" +#include "ui/base/win/window_impl.h" + +namespace ui { +class ViewProp; +} + +namespace aura { +// RootWindowHost implementaton that receives events from a different process. +class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost { + public: + static RemoteRootWindowHostWin* Instance(); + static RemoteRootWindowHostWin* Create(const gfx::Rect& bounds); + + void OnMouseMoved(int x, int y, int extra); + void OnMouseClick(int x, int y, int extra); + + private: + RemoteRootWindowHostWin(const gfx::Rect& bounds); + virtual ~RemoteRootWindowHostWin(); + + // RootWindowHost overrides: + virtual void SetDelegate(RootWindowHostDelegate* delegate) OVERRIDE; + virtual RootWindow* GetRootWindow() OVERRIDE; + virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; + virtual void Show() OVERRIDE; + virtual void Hide() OVERRIDE; + virtual void ToggleFullScreen() OVERRIDE; + virtual gfx::Rect GetBounds() const OVERRIDE; + virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; + virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; + virtual void SetCapture() OVERRIDE; + virtual void ReleaseCapture() OVERRIDE; + virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; + virtual void ShowCursor(bool show) OVERRIDE; + virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; + virtual bool ConfineCursorToRootWindow() OVERRIDE; + virtual void UnConfineCursor() OVERRIDE; + virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; + virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; + virtual bool GrabSnapshot( + const gfx::Rect& snapshot_bounds, + std::vector<unsigned char>* png_representation) OVERRIDE; + virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; + virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; + virtual void PrepareForShutdown() OVERRIDE; + + RootWindowHostDelegate* delegate_; + scoped_ptr<ui::ViewProp> prop_; + + DISALLOW_COPY_AND_ASSIGN(RemoteRootWindowHostWin); +}; + +} // namespace aura + +#endif // UI_AURA_REMOTE_ROOT_WINDOW_HOST_WIN_H_ + diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 4af5464..10d2297 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -83,8 +83,10 @@ void SetLastMouseLocation(const Window* root_window, RootWindowHost* CreateHost(RootWindow* root_window, const RootWindow::CreateParams& params) { - return params.host ? params.host : - RootWindowHost::Create(root_window, params.initial_bounds); + RootWindowHost* host = params.host ? + params.host : RootWindowHost::Create(params.initial_bounds); + host->SetDelegate(root_window); + return host; } } // namespace diff --git a/ui/aura/root_window_host.h b/ui/aura/root_window_host.h index 5105fa9..fdd2e3c 100644 --- a/ui/aura/root_window_host.h +++ b/ui/aura/root_window_host.h @@ -31,13 +31,15 @@ class AURA_EXPORT RootWindowHost { virtual ~RootWindowHost() {} // Creates a new RootWindowHost. The caller owns the returned value. - static RootWindowHost* Create(RootWindowHostDelegate* delegate, - const gfx::Rect& bounds); + static RootWindowHost* Create(const gfx::Rect& bounds); // Returns the actual size of the screen. // (gfx::Screen only reports on the virtual desktop exposed by Aura.) static gfx::Size GetNativeScreenSize(); + // Sets the delegate, which is normally done by the root window. + virtual void SetDelegate(RootWindowHostDelegate* delegate) = 0; + virtual RootWindow* GetRootWindow() = 0; // Returns the RootWindowHost for the specified accelerated widget, or NULL if diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc index 3ce1cde..d068d8b 100644 --- a/ui/aura/root_window_host_linux.cc +++ b/ui/aura/root_window_host_linux.cc @@ -331,9 +331,8 @@ class TouchEventCalibrate : public base::MessagePumpObserver { } // namespace internal -RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, - const gfx::Rect& bounds) - : delegate_(delegate), +RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) + : delegate_(NULL), xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), xwindow_(0), x_root_window_(DefaultRootWindow(xdisplay_)), @@ -698,6 +697,10 @@ void RootWindowHostLinux::DispatchXI2Event(const base::NativeEvent& event) { XFreeEventData(xev->xgeneric.display, &last_event.xcookie); } +void RootWindowHostLinux::SetDelegate(RootWindowHostDelegate* delegate) { + delegate_ = delegate; +} + RootWindow* RootWindowHostLinux::GetRootWindow() { return delegate_->AsRootWindow(); } @@ -1011,9 +1014,8 @@ void RootWindowHostLinux::TranslateAndDispatchMouseEvent( } // static -RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, - const gfx::Rect& bounds) { - return new RootWindowHostLinux(delegate, bounds); +RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { + return new RootWindowHostLinux(bounds); } // static diff --git a/ui/aura/root_window_host_linux.h b/ui/aura/root_window_host_linux.h index 21e95ce..c244039 100644 --- a/ui/aura/root_window_host_linux.h +++ b/ui/aura/root_window_host_linux.h @@ -30,8 +30,7 @@ class TouchEventCalibrate; class RootWindowHostLinux : public RootWindowHost, public MessageLoop::Dispatcher { public: - RootWindowHostLinux(RootWindowHostDelegate* delegate, - const gfx::Rect& bounds); + RootWindowHostLinux(const gfx::Rect& bounds); virtual ~RootWindowHostLinux(); // Overridden from Dispatcher overrides: @@ -46,6 +45,7 @@ class RootWindowHostLinux : public RootWindowHost, void DispatchXI2Event(const base::NativeEvent& event); // RootWindowHost Overrides. + virtual void SetDelegate(RootWindowHostDelegate* delegate) OVERRIDE; virtual RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; diff --git a/ui/aura/root_window_host_win.cc b/ui/aura/root_window_host_win.cc index fef153d..9f3b6a7 100644 --- a/ui/aura/root_window_host_win.cc +++ b/ui/aura/root_window_host_win.cc @@ -28,9 +28,8 @@ const char* kRootWindowHostWinKey = "__AURA_ROOT_WINDOW_HOST_WIN__"; } // namespace // static -RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, - const gfx::Rect& bounds) { - return new RootWindowHostWin(delegate, bounds); +RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { + return new RootWindowHostWin(bounds); } // static @@ -46,9 +45,8 @@ gfx::Size RootWindowHost::GetNativeScreenSize() { GetSystemMetrics(SM_CYSCREEN)); } -RootWindowHostWin::RootWindowHostWin(RootWindowHostDelegate* delegate, - const gfx::Rect& bounds) - : delegate_(delegate), +RootWindowHostWin::RootWindowHostWin(const gfx::Rect& bounds) + : delegate_(NULL), fullscreen_(false), has_capture_(false), saved_window_style_(0), @@ -62,6 +60,10 @@ RootWindowHostWin::~RootWindowHostWin() { DestroyWindow(hwnd()); } +void RootWindowHostWin::SetDelegate(RootWindowHostDelegate* delegate) { + delegate_ = delegate; +} + RootWindow* RootWindowHostWin::GetRootWindow() { return delegate_->AsRootWindow(); } diff --git a/ui/aura/root_window_host_win.h b/ui/aura/root_window_host_win.h index 8c8810c..f7d6dda 100644 --- a/ui/aura/root_window_host_win.h +++ b/ui/aura/root_window_host_win.h @@ -17,11 +17,10 @@ namespace aura { class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl { public: - RootWindowHostWin(RootWindowHostDelegate* delegate, - const gfx::Rect& bounds); + RootWindowHostWin(const gfx::Rect& bounds); virtual ~RootWindowHostWin(); - // RootWindowHost: + virtual void SetDelegate(RootWindowHostDelegate* delegate) OVERRIDE; virtual RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; diff --git a/ui/metro_viewer/metro_viewer_messages.h b/ui/metro_viewer/metro_viewer_messages.h index 776e06b..66d482c 100644 --- a/ui/metro_viewer/metro_viewer_messages.h +++ b/ui/metro_viewer/metro_viewer_messages.h @@ -15,8 +15,15 @@ // Inform the browser of the surface to target for compositing. IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_SetTargetSurface, gfx::NativeViewId /* target hwnd */) +// Informs the browser that the mouse moved. +IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_MouseMoved, + int, /* x-coordinate */ + int, /* y-coordinate */ + int /* modifiers */) +// Inforoms the brower that a mouse button was pressed. +IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_MouseButton, + int, /* x-coordinate */ + int, /* y-coordinate */ + int /* modifiers */) + -IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_MouseEvent, - int, /* msg */ - uintptr_t, /* message's wParam */ - intptr_t /* message's lParam */) diff --git a/ui/views/widget/desktop_root_window_host_linux.cc b/ui/views/widget/desktop_root_window_host_linux.cc index b0b1dbc..c32e87a 100644 --- a/ui/views/widget/desktop_root_window_host_linux.cc +++ b/ui/views/widget/desktop_root_window_host_linux.cc @@ -157,7 +157,6 @@ aura::RootWindow* DesktopRootWindowHostLinux::InitRootWindow( root_window_->Init(); root_window_->AddChild(content_window_); root_window_->SetLayoutManager(new DesktopLayoutManager(root_window_)); - root_window_host_delegate_ = root_window_; // If we're given a parent, we need to mark ourselves as transient to another // window. Otherwise activation gets screwy. @@ -559,6 +558,11 @@ void DesktopRootWindowHostLinux::FlashFrame(bool flash_frame) { //////////////////////////////////////////////////////////////////////////////// // DesktopRootWindowHostLinux, aura::RootWindowHost implementation: +void DesktopRootWindowHostLinux::SetDelegate( + aura::RootWindowHostDelegate* delegate) { + root_window_host_delegate_ = delegate; +} + aura::RootWindow* DesktopRootWindowHostLinux::GetRootWindow() { return root_window_; } diff --git a/ui/views/widget/desktop_root_window_host_linux.h b/ui/views/widget/desktop_root_window_host_linux.h index 8180b9b..8de4f76 100644 --- a/ui/views/widget/desktop_root_window_host_linux.h +++ b/ui/views/widget/desktop_root_window_host_linux.h @@ -129,6 +129,7 @@ class VIEWS_EXPORT DesktopRootWindowHostLinux virtual void FlashFrame(bool flash_frame) OVERRIDE; // Overridden from aura::RootWindowHost: + virtual void SetDelegate(aura::RootWindowHostDelegate* delegate) OVERRIDE; virtual aura::RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; diff --git a/ui/views/widget/desktop_root_window_host_win.cc b/ui/views/widget/desktop_root_window_host_win.cc index efae689..ecdf1d9 100644 --- a/ui/views/widget/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_root_window_host_win.cc @@ -77,7 +77,6 @@ aura::RootWindow* DesktopRootWindowHostWin::Init( root_window_->Init(); root_window_->AddChild(content_window_); - root_window_host_delegate_ = root_window_; native_widget_delegate_->OnNativeWidgetCreated(); @@ -313,6 +312,12 @@ void DesktopRootWindowHostWin::FlashFrame(bool flash_frame) { //////////////////////////////////////////////////////////////////////////////// // DesktopRootWindowHostWin, RootWindowHost implementation: + +void DesktopRootWindowHostWin::SetDelegate( + aura::RootWindowHostDelegate* delegate) { + root_window_host_delegate_ = delegate; +} + aura::RootWindow* DesktopRootWindowHostWin::GetRootWindow() { return root_window_; } diff --git a/ui/views/widget/desktop_root_window_host_win.h b/ui/views/widget/desktop_root_window_host_win.h index 8580057..f8d9299 100644 --- a/ui/views/widget/desktop_root_window_host_win.h +++ b/ui/views/widget/desktop_root_window_host_win.h @@ -92,6 +92,7 @@ class VIEWS_EXPORT DesktopRootWindowHostWin virtual void FlashFrame(bool flash_frame) OVERRIDE; // Overridden from aura::RootWindowHost: + virtual void SetDelegate(aura::RootWindowHostDelegate* delegate) OVERRIDE; virtual aura::RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; |