diff options
author | ynovikov@chromium.org <ynovikov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 01:17:43 +0000 |
---|---|---|
committer | ynovikov@chromium.org <ynovikov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 01:17:43 +0000 |
commit | 0f14c9b247e66074f243780536c8e40dfc69e775 (patch) | |
tree | 6eb36b1e406b4c58e64d15c05c7b226a66fe7d92 /ui | |
parent | b19b26685ea97d2339c0442c1ecae82d4139083c (diff) | |
download | chromium_src-0f14c9b247e66074f243780536c8e40dfc69e775.zip chromium_src-0f14c9b247e66074f243780536c8e40dfc69e775.tar.gz chromium_src-0f14c9b247e66074f243780536c8e40dfc69e775.tar.bz2 |
Add is_internal_display_ property to aura::RootWindowHostLinux.
Make RootWindowHostLinux aware whether it resides on internal display.
Required for ChromeOS multi monitor support.
BUG=171310
TEST=Compiles. Manually verified with printouts that is_internal_display_
has correct value when: booting,
switching single / extended desktop / mirror modes and
switching primary display.
Review URL: https://chromiumcodereview.appspot.com/12321086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/env.cc | 6 | ||||
-rw-r--r-- | ui/aura/env.h | 4 | ||||
-rw-r--r-- | ui/aura/env_observer.h | 3 | ||||
-rw-r--r-- | ui/aura/root_window.cc | 1 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.cc | 27 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.h | 13 |
6 files changed, 53 insertions, 1 deletions
diff --git a/ui/aura/env.cc b/ui/aura/env.cc index ecccaf1..2a03b2a 100644 --- a/ui/aura/env.cc +++ b/ui/aura/env.cc @@ -98,6 +98,12 @@ void Env::NotifyWindowInitialized(Window* window) { FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); } +void Env::NotifyRootWindowInitialized(RootWindow* root_window) { + FOR_EACH_OBSERVER(EnvObserver, + observers_, + OnRootWindowInitialized(root_window)); +} + //////////////////////////////////////////////////////////////////////////////// // Env, ui::EventTarget implementation: diff --git a/ui/aura/env.h b/ui/aura/env.h index ae4f1a6..6a0a83e 100644 --- a/ui/aura/env.h +++ b/ui/aura/env.h @@ -75,12 +75,16 @@ class AURA_EXPORT Env : public ui::EventTarget { private: friend class Window; + friend class RootWindow; void Init(); // Called by the Window when it is initialized. Notifies observers. void NotifyWindowInitialized(Window* window); + // Called by the RootWindow when it is initialized. Notifies observers. + void NotifyRootWindowInitialized(RootWindow* root_window); + // Overridden from ui::EventTarget: virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE; virtual ui::EventTarget* GetParentTarget() OVERRIDE; diff --git a/ui/aura/env_observer.h b/ui/aura/env_observer.h index 3e0f76e..b624f91 100644 --- a/ui/aura/env_observer.h +++ b/ui/aura/env_observer.h @@ -17,6 +17,9 @@ class AURA_EXPORT EnvObserver { // Called when |window| has been initialized. virtual void OnWindowInitialized(Window* window) = 0; + // Called when |root_window| has been initialized. + virtual void OnRootWindowInitialized(RootWindow* root_window) {}; + // Called when a RootWindow's host is activated. virtual void OnRootWindowActivated(RootWindow* root_window) {} diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 7ff474f..649bc9a 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -156,6 +156,7 @@ void RootWindow::Init() { compositor()->SetRootLayer(layer()); SetBounds( ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); + Env::GetInstance()->NotifyRootWindowInitialized(this); Show(); } diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc index 873ddd4..c3c6f0d 100644 --- a/ui/aura/root_window_host_linux.cc +++ b/ui/aura/root_window_host_linux.cc @@ -263,6 +263,7 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) current_cursor_(ui::kCursorNull), window_mapped_(false), bounds_(bounds), + is_internal_display_(false), focus_when_shown_(false), touch_calibrate_(new internal::TouchEventCalibrate), mouse_move_filter_(new MouseMoveFilter), @@ -332,9 +333,11 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) XStoreName(xdisplay_, xwindow_, name.c_str()); XRRSelectInput(xdisplay_, x_root_window_, RRScreenChangeNotifyMask | RROutputChangeNotifyMask); + Env::GetInstance()->AddObserver(this); } RootWindowHostLinux::~RootWindowHostLinux() { + Env::GetInstance()->RemoveObserver(this); base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(this); base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(xwindow_); @@ -402,6 +405,7 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { bool size_changed = bounds_.size() != bounds.size(); bool origin_changed = bounds_.origin() != bounds.origin(); bounds_ = bounds; + UpdateIsInternalDisplay(); // Always update barrier and mouse location because |bounds_| might // have already been updated in |SetBounds|. if (pointer_barriers_.get()) { @@ -564,6 +568,7 @@ void RootWindowHostLinux::SetBounds(const gfx::Rect& bounds) { // (possibly synthetic) ConfigureNotify about the actual size and correct // |bounds_| later. bounds_ = bounds; + UpdateIsInternalDisplay(); if (origin_changed) delegate_->OnHostMoved(bounds.origin()); if (size_changed || current_scale != new_scale) { @@ -833,6 +838,21 @@ void RootWindowHostLinux::PrepareForShutdown() { base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(xwindow_); } +void RootWindowHostLinux::OnWindowInitialized(Window* window) { +} + +void RootWindowHostLinux::OnRootWindowInitialized(RootWindow* root_window) { + // UpdateIsInternalDisplay relies on: + // 1. delegate_ pointing to RootWindow - available after SetDelegate. + // 2. RootWindow's kDisplayIdKey property set - available by the time + // RootWindow::Init is called. + // (set in DisplayManager::CreateRootWindowForDisplay) + // Ready when NotifyRootWindowInitialized is called from RootWindow::Init. + if (!delegate_ || root_window != GetRootWindow()) + return; + UpdateIsInternalDisplay(); +} + bool RootWindowHostLinux::DispatchEventForRootWindow( const base::NativeEvent& event) { switch (event->type) { @@ -1001,6 +1021,13 @@ scoped_ptr<ui::XScopedImage> RootWindowHostLinux::GetXImage( return image.Pass(); } +void RootWindowHostLinux::UpdateIsInternalDisplay() { + RootWindow* root_window = GetRootWindow(); + gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); + gfx::Display display = screen->GetDisplayNearestWindow(root_window); + is_internal_display_ = display.IsInternal(); +} + // static RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { return new RootWindowHostLinux(bounds); diff --git a/ui/aura/root_window_host_linux.h b/ui/aura/root_window_host_linux.h index 85fcd3b..0be11db 100644 --- a/ui/aura/root_window_host_linux.h +++ b/ui/aura/root_window_host_linux.h @@ -14,6 +14,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" +#include "ui/aura/env_observer.h" #include "ui/aura/root_window_host.h" #include "ui/base/x/x11_atom_cache.h" #include "ui/base/x/x11_util.h" @@ -30,7 +31,8 @@ class TouchEventCalibrate; } class RootWindowHostLinux : public RootWindowHost, - public MessageLoop::Dispatcher { + public MessageLoop::Dispatcher, + public EnvObserver { public: explicit RootWindowHostLinux(const gfx::Rect& bounds); virtual ~RootWindowHostLinux(); @@ -67,6 +69,9 @@ class RootWindowHostLinux : public RootWindowHost, virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void PrepareForShutdown() OVERRIDE; + // EnvObserver overrides. + virtual void OnWindowInitialized(Window* window) OVERRIDE; + virtual void OnRootWindowInitialized(RootWindow* root_window) OVERRIDE; private: class MouseMoveFilter; @@ -94,6 +99,9 @@ class RootWindowHostLinux : public RootWindowHost, // CopyAreaToSkCanvas() and GrabSnapshot(). scoped_ptr<ui::XScopedImage> GetXImage(const gfx::Rect& snapshot_bounds); + // Update is_internal_display_ based on delegate_ state + void UpdateIsInternalDisplay(); + RootWindowHostDelegate* delegate_; // The display and the native X window hosting the root window. @@ -115,6 +123,9 @@ class RootWindowHostLinux : public RootWindowHost, // The bounds of |x_root_window_|. gfx::Rect x_root_bounds_; + // True if the root host resides on the internal display + bool is_internal_display_; + // True if the window should be focused when the window is shown. bool focus_when_shown_; |