Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: ui/views/widget/native_widget_aura.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: new android code Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "third_party/skia/include/core/SkRegion.h" 9 #include "third_party/skia/include/core/SkRegion.h"
10 #include "ui/aura/client/activation_change_observer.h" 10 #include "ui/aura/client/activation_change_observer.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { 54 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) {
55 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); 55 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds));
56 } 56 }
57 57
58 } // namespace 58 } // namespace
59 59
60 //////////////////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////////////////
61 // NativeWidgetAura, public: 61 // NativeWidgetAura, public:
62 62
63 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) 63 NativeWidgetAura::NativeWidgetAura(
64 internal::NativeWidgetDelegate* delegate, gfx::NativeView parent)
64 : delegate_(delegate), 65 : delegate_(delegate),
65 ALLOW_THIS_IN_INITIALIZER_LIST(desktop_helper_( 66 ALLOW_THIS_IN_INITIALIZER_LIST(desktop_helper_(
66 ViewsDelegate::views_delegate ? 67 ViewsDelegate::views_delegate ?
67 ViewsDelegate::views_delegate->CreateNativeWidgetHelper(this) : 68 ViewsDelegate::views_delegate->CreateNativeWidgetHelper(this, parent):
68 NULL)), 69 NULL)),
69 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 70 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
70 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 71 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
71 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), 72 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
72 can_activate_(true), 73 can_activate_(true),
73 destroying_(false), 74 destroying_(false),
74 cursor_(gfx::kNullCursor), 75 cursor_(gfx::kNullCursor),
75 saved_window_state_(ui::SHOW_STATE_DEFAULT) { 76 saved_window_state_(ui::SHOW_STATE_DEFAULT) {
76 } 77 }
77 78
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 SetAlwaysOnTop(params.keep_on_top); 130 SetAlwaysOnTop(params.keep_on_top);
130 // If the parent is not specified, find the default parent for 131 // If the parent is not specified, find the default parent for
131 // the |window_| using the desired |window_bounds|. 132 // the |window_| using the desired |window_bounds|.
132 if (!parent) { 133 if (!parent) {
133 parent = aura::client::GetStackingClient(params.GetParent())-> 134 parent = aura::client::GetStackingClient(params.GetParent())->
134 GetDefaultParent(window_, window_bounds); 135 GetDefaultParent(window_, window_bounds);
135 } else if (window_bounds == gfx::Rect()) { 136 } else if (window_bounds == gfx::Rect()) {
136 // If a parent is specified but no bounds are given, 137 // If a parent is specified but no bounds are given,
137 // use the origin of the parent's display so that the widget 138 // use the origin of the parent's display so that the widget
138 // will be added to the same display as the parent. 139 // will be added to the same display as the parent.
139 gfx::Rect bounds = gfx::Screen::GetDisplayNearestWindow(parent).bounds(); 140 gfx::Rect bounds = gfx::Screen::GetScreenFor(parent)->
141 GetDisplayNearestWindow(parent).bounds();
140 window_bounds.set_origin(bounds.origin()); 142 window_bounds.set_origin(bounds.origin());
141 } 143 }
142 window_->SetParent(parent); 144 window_->SetParent(parent);
143 } 145 }
144 146
145 // Wait to set the bounds until we have a parent. That way we can know our 147 // Wait to set the bounds until we have a parent. That way we can know our
146 // true state/bounds (the LayoutManager may enforce a particular 148 // true state/bounds (the LayoutManager may enforce a particular
147 // state/bounds). 149 // state/bounds).
148 if (IsMaximized()) 150 if (IsMaximized())
149 SetRestoreBounds(window_, window_bounds); 151 SetRestoreBounds(window_, window_bounds);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 279
278 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() { 280 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() {
279 return this; 281 return this;
280 } 282 }
281 283
282 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { 284 void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
283 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); 285 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow());
284 // When centering window, we take the intersection of the host and 286 // When centering window, we take the intersection of the host and
285 // the parent. We assume the root window represents the visible 287 // the parent. We assume the root window represents the visible
286 // rect of a single screen. 288 // rect of a single screen.
287 gfx::Rect work_area = 289 gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)->
288 gfx::Screen::GetDisplayNearestWindow(window_).work_area(); 290 GetDisplayNearestWindow(window_).work_area();
289 291
290 aura::client::ScreenPositionClient* screen_position_client = 292 aura::client::ScreenPositionClient* screen_position_client =
291 aura::client::GetScreenPositionClient(window_->GetRootWindow()); 293 aura::client::GetScreenPositionClient(window_->GetRootWindow());
292 if (screen_position_client) { 294 if (screen_position_client) {
293 gfx::Point origin = work_area.origin(); 295 gfx::Point origin = work_area.origin();
294 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(), 296 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(),
295 &origin); 297 &origin);
296 work_area.set_origin(origin); 298 work_area.set_origin(origin);
297 } 299 }
298 300
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 387 }
386 return window_->GetBoundsInScreen(); 388 return window_->GetBoundsInScreen();
387 } 389 }
388 390
389 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { 391 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) {
390 aura::RootWindow* root = window_->GetRootWindow(); 392 aura::RootWindow* root = window_->GetRootWindow();
391 if (root) { 393 if (root) {
392 aura::client::ScreenPositionClient* screen_position_client = 394 aura::client::ScreenPositionClient* screen_position_client =
393 aura::client::GetScreenPositionClient(root); 395 aura::client::GetScreenPositionClient(root);
394 if (screen_position_client) { 396 if (screen_position_client) {
395 gfx::Display dst_display = gfx::Screen::GetDisplayMatching(bounds); 397 gfx::Display dst_display =
398 gfx::Screen::GetScreenFor(window_)->GetDisplayMatching(bounds);
396 screen_position_client->SetBounds(window_, bounds, dst_display); 399 screen_position_client->SetBounds(window_, bounds, dst_display);
397 return; 400 return;
398 } 401 }
399 } 402 }
400 window_->SetBounds(bounds); 403 window_->SetBounds(bounds);
401 } 404 }
402 405
403 void NativeWidgetAura::SetSize(const gfx::Size& size) { 406 void NativeWidgetAura::SetSize(const gfx::Size& size) {
404 window_->SetBounds(gfx::Rect(window_->bounds().origin(), size)); 407 window_->SetBounds(gfx::Rect(window_->bounds().origin(), size));
405 } 408 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 cursor_client->SetCursor(cursor); 587 cursor_client->SetCursor(cursor);
585 } 588 }
586 589
587 void NativeWidgetAura::ClearNativeFocus() { 590 void NativeWidgetAura::ClearNativeFocus() {
588 if (window_ && window_->GetFocusManager() && 591 if (window_ && window_->GetFocusManager() &&
589 window_->Contains(window_->GetFocusManager()->GetFocusedWindow())) 592 window_->Contains(window_->GetFocusManager()->GetFocusedWindow()))
590 window_->GetFocusManager()->SetFocusedWindow(window_, NULL); 593 window_->GetFocusManager()->SetFocusedWindow(window_, NULL);
591 } 594 }
592 595
593 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { 596 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const {
594 return gfx::Screen::GetDisplayNearestWindow(GetNativeView()).work_area(); 597 return gfx::Screen::GetScreenFor(GetNativeView())->
598 GetDisplayNearestWindow(GetNativeView()).work_area();
595 } 599 }
596 600
597 void NativeWidgetAura::SetInactiveRenderingDisabled(bool value) { 601 void NativeWidgetAura::SetInactiveRenderingDisabled(bool value) {
598 if (!value) { 602 if (!value) {
599 active_window_observer_.reset(); 603 active_window_observer_.reset();
600 } else { 604 } else {
601 active_window_observer_.reset( 605 active_window_observer_.reset(
602 new NativeWidgetAuraWindowObserver(window_, delegate_)); 606 new NativeWidgetAuraWindowObserver(window_, delegate_));
603 } 607 }
604 } 608 }
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 return false; 912 return false;
909 } 913 }
910 914
911 namespace internal { 915 namespace internal {
912 916
913 //////////////////////////////////////////////////////////////////////////////// 917 ////////////////////////////////////////////////////////////////////////////////
914 // internal::NativeWidgetPrivate, public: 918 // internal::NativeWidgetPrivate, public:
915 919
916 // static 920 // static
917 NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( 921 NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
918 internal::NativeWidgetDelegate* delegate) { 922 internal::NativeWidgetDelegate* delegate,
919 return new NativeWidgetAura(delegate); 923 gfx::NativeView parent) {
924 return new NativeWidgetAura(delegate, parent);
920 } 925 }
921 926
922 // static 927 // static
923 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( 928 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView(
924 gfx::NativeView native_view) { 929 gfx::NativeView native_view) {
925 return reinterpret_cast<NativeWidgetPrivate*>(native_view->user_data()); 930 return reinterpret_cast<NativeWidgetPrivate*>(native_view->user_data());
926 } 931 }
927 932
928 // static 933 // static
929 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow( 934 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 return aura::Env::GetInstance()->is_mouse_button_down(); 1009 return aura::Env::GetInstance()->is_mouse_button_down();
1005 } 1010 }
1006 1011
1007 // static 1012 // static
1008 bool NativeWidgetPrivate::IsTouchDown() { 1013 bool NativeWidgetPrivate::IsTouchDown() {
1009 return aura::Env::GetInstance()->is_touch_down(); 1014 return aura::Env::GetInstance()->is_touch_down();
1010 } 1015 }
1011 1016
1012 } // namespace internal 1017 } // namespace internal
1013 } // namespace views 1018 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698