| OLD | NEW |
| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 InputMethod* NativeWidgetAura::CreateInputMethod() { | 341 InputMethod* NativeWidgetAura::CreateInputMethod() { |
| 342 aura::RootWindow* root_window = window_->GetRootWindow(); | 342 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 343 ui::InputMethod* host = | 343 ui::InputMethod* host = |
| 344 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 344 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
| 345 InputMethod* input_method = new InputMethodBridge(this, host); | 345 InputMethod* input_method = new InputMethodBridge(this, host); |
| 346 input_method->Init(GetWidget()); | 346 input_method->Init(GetWidget()); |
| 347 return input_method; | 347 return input_method; |
| 348 } | 348 } |
| 349 | 349 |
| 350 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 350 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| 351 gfx::Rect parent_bounds(window_->parent()->GetRootWindowBounds()); | 351 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); |
| 352 // When centering window, we take the intersection of the host and | 352 // When centering window, we take the intersection of the host and |
| 353 // the parent. We assume the root window represents the visible | 353 // the parent. We assume the root window represents the visible |
| 354 // rect of a single screen. | 354 // rect of a single screen. |
| 355 gfx::Rect work_area = | 355 gfx::Rect work_area = |
| 356 gfx::Screen::GetDisplayNearestWindow(window_).work_area(); | 356 gfx::Screen::GetDisplayNearestWindow(window_).work_area(); |
| 357 | 357 |
| 358 aura::client::ScreenPositionClient* screen_position_client = | 358 aura::client::ScreenPositionClient* screen_position_client = |
| 359 aura::client::GetScreenPositionClient(window_->GetRootWindow()); | 359 aura::client::GetScreenPositionClient(window_->GetRootWindow()); |
| 360 if (screen_position_client) { | 360 if (screen_position_client) { |
| 361 gfx::Point origin = work_area.origin(); | 361 gfx::Point origin = work_area.origin(); |
| 362 screen_position_client->ConvertPointFromScreen(window_->parent(), | 362 screen_position_client->ConvertPointFromScreen(window_->parent(), |
| 363 &origin); | 363 &origin); |
| 364 work_area.set_origin(origin); | 364 work_area.set_origin(origin); |
| 365 } | 365 } |
| 366 | 366 |
| 367 parent_bounds = parent_bounds.Intersect(work_area); | 367 parent_bounds = parent_bounds.Intersect(work_area); |
| 368 | 368 |
| 369 // If |window_|'s transient parent's bounds are big enough to fit it, then we | 369 // If |window_|'s transient parent's bounds are big enough to fit it, then we |
| 370 // center it with respect to the transient parent. | 370 // center it with respect to the transient parent. |
| 371 if (window_->transient_parent()) { | 371 if (window_->transient_parent()) { |
| 372 gfx::Rect transient_parent_rect = window_->transient_parent()-> | 372 gfx::Rect transient_parent_rect = window_->transient_parent()-> |
| 373 GetRootWindowBounds().Intersect(work_area); | 373 GetBoundsInRootWindow().Intersect(work_area); |
| 374 if (transient_parent_rect.height() >= size.height() && | 374 if (transient_parent_rect.height() >= size.height() && |
| 375 transient_parent_rect.width() >= size.width()) | 375 transient_parent_rect.width() >= size.width()) |
| 376 parent_bounds = transient_parent_rect; | 376 parent_bounds = transient_parent_rect; |
| 377 } | 377 } |
| 378 | 378 |
| 379 gfx::Rect window_bounds( | 379 gfx::Rect window_bounds( |
| 380 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, | 380 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, |
| 381 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, | 381 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, |
| 382 size.width(), | 382 size.width(), |
| 383 size.height()); | 383 size.height()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 void NativeWidgetAura::SetAccessibleState(ui::AccessibilityTypes::State state) { | 421 void NativeWidgetAura::SetAccessibleState(ui::AccessibilityTypes::State state) { |
| 422 // http://crbug.com/102570 | 422 // http://crbug.com/102570 |
| 423 // NOTIMPLEMENTED(); | 423 // NOTIMPLEMENTED(); |
| 424 } | 424 } |
| 425 | 425 |
| 426 void NativeWidgetAura::InitModalType(ui::ModalType modal_type) { | 426 void NativeWidgetAura::InitModalType(ui::ModalType modal_type) { |
| 427 if (modal_type != ui::MODAL_TYPE_NONE) | 427 if (modal_type != ui::MODAL_TYPE_NONE) |
| 428 window_->SetProperty(aura::client::kModalKey, modal_type); | 428 window_->SetProperty(aura::client::kModalKey, modal_type); |
| 429 } | 429 } |
| 430 | 430 |
| 431 gfx::Rect NativeWidgetAura::GetWindowScreenBounds() const { | 431 gfx::Rect NativeWidgetAura::GetWindowBoundsInScreen() const { |
| 432 return window_->GetScreenBounds(); | 432 return window_->GetBoundsInScreen(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 gfx::Rect NativeWidgetAura::GetClientAreaScreenBounds() const { | 435 gfx::Rect NativeWidgetAura::GetClientAreaBoundsInScreen() const { |
| 436 // View-to-screen coordinate system transformations depend on this returning | 436 // View-to-screen coordinate system transformations depend on this returning |
| 437 // the full window bounds, for example View::ConvertPointToScreen(). | 437 // the full window bounds, for example View::ConvertPointToScreen(). |
| 438 return window_->GetScreenBounds(); | 438 return window_->GetBoundsInScreen(); |
| 439 } | 439 } |
| 440 | 440 |
| 441 gfx::Rect NativeWidgetAura::GetRestoredBounds() const { | 441 gfx::Rect NativeWidgetAura::GetRestoredBounds() const { |
| 442 // Restored bounds should only be relevant if the window is minimized or | 442 // Restored bounds should only be relevant if the window is minimized or |
| 443 // maximized. However, in some places the code expectes GetRestoredBounds() | 443 // maximized. However, in some places the code expectes GetRestoredBounds() |
| 444 // to return the current window bounds if the window is not in either state. | 444 // to return the current window bounds if the window is not in either state. |
| 445 if (!IsMinimized() && !IsMaximized() && !IsFullscreen()) | 445 if (!IsMinimized() && !IsMaximized() && !IsFullscreen()) |
| 446 return window_->bounds(); | 446 return window_->bounds(); |
| 447 gfx::Rect* restore_bounds = | 447 gfx::Rect* restore_bounds = |
| 448 window_->GetProperty(aura::client::kRestoreBoundsKey); | 448 window_->GetProperty(aura::client::kRestoreBoundsKey); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 void NativeWidgetAura::ClearNativeFocus() { | 643 void NativeWidgetAura::ClearNativeFocus() { |
| 644 if (window_ && window_->GetFocusManager() && | 644 if (window_ && window_->GetFocusManager() && |
| 645 window_->Contains(window_->GetFocusManager()->GetFocusedWindow())) | 645 window_->Contains(window_->GetFocusManager()->GetFocusedWindow())) |
| 646 window_->GetFocusManager()->SetFocusedWindow(window_, NULL); | 646 window_->GetFocusManager()->SetFocusedWindow(window_, NULL); |
| 647 } | 647 } |
| 648 | 648 |
| 649 void NativeWidgetAura::FocusNativeView(gfx::NativeView native_view) { | 649 void NativeWidgetAura::FocusNativeView(gfx::NativeView native_view) { |
| 650 window_->GetFocusManager()->SetFocusedWindow(native_view, NULL); | 650 window_->GetFocusManager()->SetFocusedWindow(native_view, NULL); |
| 651 } | 651 } |
| 652 | 652 |
| 653 gfx::Rect NativeWidgetAura::GetWorkAreaScreenBounds() const { | 653 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { |
| 654 return gfx::Screen::GetDisplayNearestWindow(GetNativeView()).work_area(); | 654 return gfx::Screen::GetDisplayNearestWindow(GetNativeView()).work_area(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 void NativeWidgetAura::SetInactiveRenderingDisabled(bool value) { | 657 void NativeWidgetAura::SetInactiveRenderingDisabled(bool value) { |
| 658 if (!value) | 658 if (!value) |
| 659 active_window_observer_.reset(); | 659 active_window_observer_.reset(); |
| 660 else | 660 else |
| 661 active_window_observer_.reset(new ActiveWindowObserver(this)); | 661 active_window_observer_.reset(new ActiveWindowObserver(this)); |
| 662 } | 662 } |
| 663 | 663 |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 return aura::Env::GetInstance()->is_mouse_button_down(); | 1046 return aura::Env::GetInstance()->is_mouse_button_down(); |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 // static | 1049 // static |
| 1050 bool NativeWidgetPrivate::IsTouchDown() { | 1050 bool NativeWidgetPrivate::IsTouchDown() { |
| 1051 return aura::Env::GetInstance()->is_touch_down(); | 1051 return aura::Env::GetInstance()->is_touch_down(); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 } // namespace internal | 1054 } // namespace internal |
| 1055 } // namespace views | 1055 } // namespace views |
| OLD | NEW |