diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 14:11:09 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 14:11:09 +0000 |
commit | 4def0e69084b16e3920ed095a4fcb197565a6d1f (patch) | |
tree | c1f933916c0a63a22228f24bdb818d5901faea4b | |
parent | be9324e03918d6c0591c844cd1a7a4d7b8f45452 (diff) | |
download | chromium_src-4def0e69084b16e3920ed095a4fcb197565a6d1f.zip chromium_src-4def0e69084b16e3920ed095a4fcb197565a6d1f.tar.gz chromium_src-4def0e69084b16e3920ed095a4fcb197565a6d1f.tar.bz2 |
Gets ScreenAura to correctly calculate work area, and hooks
WindowSizer up to it. Also removes window_sizer_win when building aura
as we shouldn't be using it with aura. Lastly I had to add AURA_EXPORT
to the FocusManager as visual studio doesn't like it when you try to
export a class that inherits from a non-exported class.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: http://codereview.chromium.org/8346026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106279 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/window_sizer.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer_aura.cc | 41 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer_gtk.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer_mac.mm | 10 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer_unittest.cc | 20 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer_win.cc | 11 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 7 | ||||
-rw-r--r-- | ui/aura/desktop.cc | 5 | ||||
-rw-r--r-- | ui/aura/desktop.h | 6 | ||||
-rw-r--r-- | ui/aura/focus_manager.h | 3 | ||||
-rw-r--r-- | ui/aura/screen_aura.cc | 34 | ||||
-rw-r--r-- | ui/aura/screen_aura.h | 20 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 7 | ||||
-rw-r--r-- | ui/aura_shell/shell.cc | 4 |
14 files changed, 78 insertions, 103 deletions
diff --git a/chrome/browser/ui/window_sizer.h b/chrome/browser/ui/window_sizer.h index 7b21cdc..cf57e37 100644 --- a/chrome/browser/ui/window_sizer.h +++ b/chrome/browser/ui/window_sizer.h @@ -56,11 +56,6 @@ class WindowSizer { virtual gfx::Rect GetMonitorWorkAreaMatching( const gfx::Rect& match_rect) const = 0; - // Returns the delta between the work area and the monitor bounds for the - // monitor that most closely intersects the provided bounds. - virtual gfx::Point GetBoundsOffsetMatching( - const gfx::Rect& match_rect) const = 0; - // Ensures number and coordinates of work areas are up-to-date. You must // call this before calling either of the below functions, as work areas can // change while the program is running. diff --git a/chrome/browser/ui/window_sizer_aura.cc b/chrome/browser/ui/window_sizer_aura.cc index e4e8d53..c8d313b 100644 --- a/chrome/browser/ui/window_sizer_aura.cc +++ b/chrome/browser/ui/window_sizer_aura.cc @@ -4,47 +4,38 @@ #include "chrome/browser/ui/window_sizer.h" -#include "ui/aura/desktop.h" -#include "ui/aura/window.h" +#include "base/compiler_specific.h" #include "ui/gfx/screen.h" -// TODO(oshima): Get This from WindowManager +// This doesn't matter for aura, which has different tiling. +// static const int WindowSizer::kWindowTilePixels = 10; -// An implementation of WindowSizer::MonitorInfoProvider that gets the actual -// monitor information from X via GDK. +// An implementation of WindowSizer::MonitorInfoProvider. This assumes a single +// monitor, which is currently the case. class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { public: - DefaultMonitorInfoProvider() { } + DefaultMonitorInfoProvider() {} - virtual gfx::Rect GetPrimaryMonitorWorkArea() const { - return gfx::Screen::GetMonitorWorkAreaNearestPoint( - gfx::Point(0, 0)); + virtual gfx::Rect GetPrimaryMonitorWorkArea() const OVERRIDE { + return gfx::Screen::GetMonitorWorkAreaNearestPoint(gfx::Point()); } - virtual gfx::Rect GetPrimaryMonitorBounds() const { - aura::Desktop* desktop = aura::Desktop::GetInstance(); - return gfx::Rect(desktop->GetHostSize()); + virtual gfx::Rect GetPrimaryMonitorBounds() const OVERRIDE { + return gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point()); } virtual gfx::Rect GetMonitorWorkAreaMatching( - const gfx::Rect& match_rect) const { - return gfx::Screen::GetMonitorWorkAreaNearestPoint( - match_rect.origin()); - } - - virtual gfx::Point GetBoundsOffsetMatching( - const gfx::Rect& match_rect) const { - return GetMonitorWorkAreaMatching(match_rect).origin(); + const gfx::Rect& match_rect) const OVERRIDE { + return gfx::Screen::GetMonitorWorkAreaNearestPoint(gfx::Point()); } - void UpdateWorkAreas() { + virtual void UpdateWorkAreas() OVERRIDE { work_areas_.clear(); work_areas_.push_back(GetPrimaryMonitorBounds()); } private: - DISALLOW_COPY_AND_ASSIGN(DefaultMonitorInfoProvider); }; @@ -56,9 +47,7 @@ WindowSizer::CreateDefaultMonitorInfoProvider() { // static gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) { - // TODO(oshima):This is used to control panel/popups, and this may - // not be needed on aura environment as they must be controlled by - // WM. - NOTIMPLEMENTED(); + // TODO(oshima):This is used to control panel/popups, and this may not be + // needed on aura environment as they must be controlled by WM. return gfx::Point(); } diff --git a/chrome/browser/ui/window_sizer_gtk.cc b/chrome/browser/ui/window_sizer_gtk.cc index 2d2dff6..6746eea 100644 --- a/chrome/browser/ui/window_sizer_gtk.cc +++ b/chrome/browser/ui/window_sizer_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -45,12 +45,6 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { return GetPrimaryMonitorWorkArea(); } - virtual gfx::Point GetBoundsOffsetMatching( - const gfx::Rect& match_rect) const { - // TODO(thestig) Implement multi-monitor support. - return GetPrimaryMonitorWorkArea().origin(); - } - void UpdateWorkAreas() { // TODO(thestig) Implement multi-monitor support. work_areas_.clear(); diff --git a/chrome/browser/ui/window_sizer_mac.mm b/chrome/browser/ui/window_sizer_mac.mm index 5d1bb66..56cf887 100644 --- a/chrome/browser/ui/window_sizer_mac.mm +++ b/chrome/browser/ui/window_sizer_mac.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -47,14 +47,6 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { return ConvertCoordinateSystem([match_screen visibleFrame]); } - virtual gfx::Point GetBoundsOffsetMatching( - const gfx::Rect& match_rect) const { - NSScreen* match_screen = GetMatchingScreen(match_rect); - gfx::Rect bounds = ConvertCoordinateSystem([match_screen frame]); - gfx::Rect work_area = ConvertCoordinateSystem([match_screen visibleFrame]); - return gfx::Point(work_area.x() - bounds.x(), work_area.y() - bounds.y()); - } - virtual void UpdateWorkAreas(); private: diff --git a/chrome/browser/ui/window_sizer_unittest.cc b/chrome/browser/ui/window_sizer_unittest.cc index 22410f0..8532e74 100644 --- a/chrome/browser/ui/window_sizer_unittest.cc +++ b/chrome/browser/ui/window_sizer_unittest.cc @@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/ui/window_sizer.h" + #include <vector> -#include "chrome/browser/ui/window_sizer.h" +#include "base/compiler_specific.h" #include "base/logging.h" #include "testing/gtest/include/gtest/gtest.h" @@ -53,28 +55,20 @@ class TestMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { } // Overridden from WindowSizer::MonitorInfoProvider: - virtual gfx::Rect GetPrimaryMonitorWorkArea() const { + virtual gfx::Rect GetPrimaryMonitorWorkArea() const OVERRIDE { return work_areas_[0]; } - virtual gfx::Rect GetPrimaryMonitorBounds() const { + virtual gfx::Rect GetPrimaryMonitorBounds() const OVERRIDE { return monitor_bounds_[0]; } virtual gfx::Rect GetMonitorWorkAreaMatching( - const gfx::Rect& match_rect) const { + const gfx::Rect& match_rect) const OVERRIDE { return work_areas_[GetMonitorIndexMatchingBounds(match_rect)]; } - virtual gfx::Point GetBoundsOffsetMatching( - const gfx::Rect& match_rect) const { - int monitor_index = GetMonitorIndexMatchingBounds(match_rect); - gfx::Rect bounds = monitor_bounds_[monitor_index]; - const gfx::Rect& work_area = work_areas_[monitor_index]; - return gfx::Point(work_area.x() - bounds.x(), work_area.y() - bounds.y()); - } - - virtual void UpdateWorkAreas() { } + virtual void UpdateWorkAreas() OVERRIDE {} private: size_t GetMonitorIndexMatchingBounds(const gfx::Rect& match_rect) const { diff --git a/chrome/browser/ui/window_sizer_win.cc b/chrome/browser/ui/window_sizer_win.cc index a2952a40..9a4fa37 100644 --- a/chrome/browser/ui/window_sizer_win.cc +++ b/chrome/browser/ui/window_sizer_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -37,15 +37,6 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { return gfx::Rect(monitor_info.rcWork); } - virtual gfx::Point GetBoundsOffsetMatching( - const gfx::Rect& match_rect) const { - RECT other_bounds_rect = match_rect.ToRECT(); - MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( - &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); - return gfx::Point(monitor_info.rcWork.left - monitor_info.rcMonitor.left, - monitor_info.rcWork.top - monitor_info.rcMonitor.top); - } - void UpdateWorkAreas() { work_areas_.clear(); EnumDisplayMonitors(NULL, NULL, diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 17a9b93..48b69ae 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -4156,6 +4156,8 @@ ['exclude', '^browser/ui/views/omnibox/omnibox_view_win.cc'], ['exclude', '^browser/ui/views/omnibox/omnibox_view_win.h'], ['exclude', '^browser/ui/views/shell_dialogs_win.cc'], + ['include', '^browser/ui/views/simple_message_box_views.cc'], + ['include', '^browser/ui/views/simple_message_box_views.h'], ['exclude', '^browser/ui/views/simple_message_box_win.cc'], ['exclude', '^browser/ui/views/ssl_client_certificate_selector.cc'], ['exclude', '^browser/ui/views/tab_contents/native_tab_contents_container_win.cc'], @@ -4170,13 +4172,12 @@ ['exclude', '^browser/ui/views/task_manager_view.cc'], ['exclude', '^browser/ui/views/task_manager_view.h'], ['exclude', '^browser/ui/views/user_data_dir_dialog.cc'], - ['exclude', '^browser/ui/window_snapshot/window_snapshot_win.cc'], - ['include', '^browser/ui/views/simple_message_box_views.cc'], - ['include', '^browser/ui/views/simple_message_box_views.h'], ['include', '^browser/ui/webui/collected_cookies_ui_delegate.cc'], ['include', '^browser/ui/webui/collected_cookies_ui_delegate.h'], ['include', '^browser/ui/webui/cookies_tree_model_adapter.cc'], ['include', '^browser/ui/webui/cookies_tree_model_adapter.h'], + ['exclude', '^browser/ui/window_sizer_win.cc'], + ['exclude', '^browser/ui/window_snapshot/window_snapshot_win.cc'], ], 'dependencies': [ '../ui/aura_shell/aura_shell.gyp:aura_shell', diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc index 35409a9..92ec22d 100644 --- a/ui/aura/desktop.cc +++ b/ui/aura/desktop.cc @@ -33,12 +33,12 @@ Desktop::Desktop() ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), active_window_(NULL), in_destructor_(false), + screen_(NULL), capture_window_(NULL), mouse_pressed_handler_(NULL), mouse_moved_handler_(NULL), focused_window_(NULL), touch_event_handler_(NULL) { - set_name("RootWindow"); if (compositor_factory_) { compositor_ = (*Desktop::compositor_factory())(); @@ -46,7 +46,8 @@ Desktop::Desktop() compositor_ = ui::Compositor::Create(this, host_->GetAcceleratedWidget(), host_->GetSize()); } - gfx::Screen::SetInstance(new internal::ScreenAura); + screen_ = new ScreenAura; + gfx::Screen::SetInstance(screen_); host_->SetDesktop(this); DCHECK(compositor_.get()); last_mouse_location_ = host_->QueryMouseLocation(); diff --git a/ui/aura/desktop.h b/ui/aura/desktop.h index 94356b8..16a0244 100644 --- a/ui/aura/desktop.h +++ b/ui/aura/desktop.h @@ -31,6 +31,7 @@ class DesktopHost; class DesktopObserver; class KeyEvent; class MouseEvent; +class ScreenAura; class TouchEvent; // Desktop is responsible for hosting a set of windows. @@ -57,6 +58,7 @@ class AURA_EXPORT Desktop : public ui::CompositorDelegate, Window* active_window() { return active_window_; } Window* mouse_pressed_handler() { return mouse_pressed_handler_; } Window* capture_window() { return capture_window_; } + ScreenAura* screen() { return screen_; } void SetDelegate(DesktopDelegate* delegate); @@ -114,6 +116,8 @@ class AURA_EXPORT Desktop : public ui::CompositorDelegate, void AddObserver(DesktopObserver* observer); void RemoveObserver(DesktopObserver* observer); + // Capture ------------------------------------------------------------------- + // Sets capture to the specified window. void SetCapture(Window* window); @@ -166,6 +170,8 @@ class AURA_EXPORT Desktop : public ui::CompositorDelegate, ObserverList<DesktopObserver> observers_; + ScreenAura* screen_; + // The capture window. When not-null, this window receives all the mouse and // touch events. Window* capture_window_; diff --git a/ui/aura/focus_manager.h b/ui/aura/focus_manager.h index 43243c6..02edbaf 100644 --- a/ui/aura/focus_manager.h +++ b/ui/aura/focus_manager.h @@ -7,6 +7,7 @@ #pragma once #include "base/basictypes.h" +#include "ui/aura/aura_export.h" namespace aura { class Window; @@ -15,7 +16,7 @@ namespace internal { // An interface implemented by the RootWindow to expose the focused window and // allow for it to be changed. -class FocusManager { +class AURA_EXPORT FocusManager { public: // Sets the currently focused window. Before the currently focused window is // changed, the previous focused window's delegate is sent a blur diff --git a/ui/aura/screen_aura.cc b/ui/aura/screen_aura.cc index 58d1c5a..16d1367 100644 --- a/ui/aura/screen_aura.cc +++ b/ui/aura/screen_aura.cc @@ -9,18 +9,7 @@ #include "ui/aura/window.h" #include "ui/gfx/native_widget_types.h" -namespace { - -gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point, - bool work_area) { - // TODO(oshima): Take point/work_area into account. Support multiple monitors. - return gfx::Rect(aura::Desktop::GetInstance()->GetHostSize()); -} - -} // namespace - namespace aura { -namespace internal { ScreenAura::ScreenAura() { } @@ -34,25 +23,21 @@ gfx::Point ScreenAura::GetCursorScreenPointImpl() { gfx::Rect ScreenAura::GetMonitorWorkAreaNearestWindowImpl( gfx::NativeWindow window) { - gfx::Rect bounds = GetMonitorAreaNearestWindow(window); - // Emulate that a work area can be smaller than its monitor. - bounds.Inset(10, 10, 10, 10); - return bounds; + return GetWorkAreaBounds(); } gfx::Rect ScreenAura::GetMonitorAreaNearestWindowImpl( gfx::NativeWindow window) { - // TODO(oshima): Take point/work_area into account. Support multiple monitors. - return gfx::Rect(aura::Desktop::GetInstance()->GetHostSize()); + return GetBounds(); } gfx::Rect ScreenAura::GetMonitorWorkAreaNearestPointImpl( const gfx::Point& point) { - return GetMonitorAreaOrWorkAreaNearestPoint(point, true); + return GetWorkAreaBounds(); } gfx::Rect ScreenAura::GetMonitorAreaNearestPointImpl(const gfx::Point& point) { - return GetMonitorAreaOrWorkAreaNearestPoint(point, false); + return GetBounds(); } gfx::NativeWindow ScreenAura::GetWindowAtCursorScreenPointImpl() { @@ -60,5 +45,14 @@ gfx::NativeWindow ScreenAura::GetWindowAtCursorScreenPointImpl() { return Desktop::GetInstance()->GetTopWindowContainingPoint(point); } -} // namespace internal +gfx::Rect ScreenAura::GetBounds() { + return gfx::Rect(aura::Desktop::GetInstance()->GetHostSize()); +} + +gfx::Rect ScreenAura::GetWorkAreaBounds() { + gfx::Rect bounds(GetBounds()); + bounds.Inset(work_area_insets_); + return bounds; +} + } // namespace aura diff --git a/ui/aura/screen_aura.h b/ui/aura/screen_aura.h index 3479b42..5ebacf8 100644 --- a/ui/aura/screen_aura.h +++ b/ui/aura/screen_aura.h @@ -7,18 +7,23 @@ #pragma once #include "base/compiler_specific.h" +#include "ui/aura/aura_export.h" +#include "ui/gfx/insets.h" #include "ui/gfx/screen.h" namespace aura { -namespace internal { // Aura implementation of gfx::Screen. Implemented here to avoid circular // dependencies. -class ScreenAura : public gfx::Screen { +class AURA_EXPORT ScreenAura : public gfx::Screen { public: ScreenAura(); virtual ~ScreenAura(); + void set_work_area_insets(const gfx::Insets& insets) { + work_area_insets_ = insets; + } + protected: virtual gfx::Point GetCursorScreenPointImpl() OVERRIDE; virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl( @@ -31,11 +36,18 @@ class ScreenAura : public gfx::Screen { const gfx::Point& point) OVERRIDE; virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() OVERRIDE; -private: + private: + // We currently support only one monitor. These two methods return the bounds + // and work area. + gfx::Rect GetBounds(); + gfx::Rect GetWorkAreaBounds(); + + // Insets for the work area. + gfx::Insets work_area_insets_; + DISALLOW_COPY_AND_ASSIGN(ScreenAura); }; -} // namespace internal } // namespace aura #endif // UI_AURA_SCREEN_AURA_H_ diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index b89ca9b..79504d8 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -19,9 +19,10 @@ #include "ui/aura/test/test_window_delegate.h" #include "ui/aura/window_delegate.h" #include "ui/aura/window_observer.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/compositor/layer.h" -#include "ui/base/keycodes/keyboard_codes.h" +#include "ui/gfx/screen.h" namespace aura { namespace test { @@ -842,7 +843,8 @@ TEST_F(WindowTest, Fullscreen) { TEST_F(WindowTest, Maximized) { gfx::Rect original_bounds = gfx::Rect(100, 100, 100, 100); - gfx::Rect desktop_bounds(Desktop::GetInstance()->GetHostSize()); + gfx::Rect desktop_bounds( + gfx::Screen::GetMonitorWorkAreaNearestPoint(gfx::Point())); scoped_ptr<Window> w(CreateTestWindowWithDelegate( NULL, 1, original_bounds, NULL)); EXPECT_EQ(original_bounds, w->bounds()); @@ -851,7 +853,6 @@ TEST_F(WindowTest, Maximized) { w->Maximize(); EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, w->show_state()); gfx::Rect max_bounds(desktop_bounds); - max_bounds.Inset(10, 10, 10, 10); EXPECT_EQ(max_bounds, w->bounds()); w->Restore(); EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc index 72e2e5e..a44d5eb 100644 --- a/ui/aura_shell/shell.cc +++ b/ui/aura_shell/shell.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "ui/aura/desktop.h" +#include "ui/aura/screen_aura.h" #include "ui/aura/toplevel_window_container.h" #include "ui/aura/window.h" #include "ui/aura/window_types.h" @@ -158,6 +159,9 @@ void Shell::Init() { launcher_.reset(new Launcher(toplevel_container)); desktop_layout->set_launcher_widget(launcher_->widget()); desktop_layout->set_status_area_widget(internal::CreateStatusArea()); + aura::Desktop::GetInstance()->screen()->set_work_area_insets( + gfx::Insets(0, 0, launcher_->widget()->GetWindowScreenBounds().height(), + 0)); } void Shell::SetDelegate(ShellDelegate* delegate) { |