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_client.h" | 10 #include "ui/aura/client/activation_client.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 InputMethod* NativeWidgetAura::CreateInputMethod() { | 342 InputMethod* NativeWidgetAura::CreateInputMethod() { |
343 aura::RootWindow* root_window = window_->GetRootWindow(); | 343 aura::RootWindow* root_window = window_->GetRootWindow(); |
344 ui::InputMethod* host = | 344 ui::InputMethod* host = |
345 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 345 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
346 InputMethod* input_method = new InputMethodBridge(this, host); | 346 InputMethod* input_method = new InputMethodBridge(this, host); |
347 input_method->Init(GetWidget()); | 347 input_method->Init(GetWidget()); |
348 return input_method; | 348 return input_method; |
349 } | 349 } |
350 | 350 |
351 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 351 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
352 gfx::Rect parent_bounds(window_->parent()->GetScreenBounds()); | 352 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); |
353 // When centering window, we take the intersection of the host and | 353 // When centering window, we take the intersection of the host and |
354 // the parent. We assume the root window represents the visible | 354 // the parent. We assume the root window represents the visible |
355 // rect of a single screen. | 355 // rect of a single screen. |
356 gfx::Rect work_area = gfx::Screen::GetMonitorWorkAreaNearestWindow(window_); | 356 gfx::Rect work_area = gfx::Screen::GetMonitorWorkAreaNearestWindow(window_); |
357 parent_bounds = parent_bounds.Intersect(work_area); | 357 parent_bounds = parent_bounds.Intersect(work_area); |
358 | 358 |
359 // If |window_|'s transient parent's bounds are big enough to fit it, then we | 359 // If |window_|'s transient parent's bounds are big enough to fit it, then we |
360 // center it with respect to the transient parent. | 360 // center it with respect to the transient parent. |
361 if (window_->transient_parent()) { | 361 if (window_->transient_parent()) { |
362 gfx::Rect transient_parent_rect = window_->transient_parent()-> | 362 gfx::Rect transient_parent_rect = window_->transient_parent()-> |
363 GetScreenBounds().Intersect(work_area); | 363 GetBoundsInRootWindow().Intersect(work_area); |
364 if (transient_parent_rect.height() >= size.height() && | 364 if (transient_parent_rect.height() >= size.height() && |
365 transient_parent_rect.width() >= size.width()) | 365 transient_parent_rect.width() >= size.width()) |
366 parent_bounds = transient_parent_rect; | 366 parent_bounds = transient_parent_rect; |
367 } | 367 } |
368 | 368 |
369 gfx::Rect window_bounds( | 369 gfx::Rect window_bounds( |
370 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, | 370 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, |
371 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, | 371 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, |
372 size.width(), | 372 size.width(), |
373 size.height()); | 373 size.height()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 //NOTIMPLEMENTED(); | 413 //NOTIMPLEMENTED(); |
414 } | 414 } |
415 | 415 |
416 void NativeWidgetAura::InitModalType(ui::ModalType modal_type) { | 416 void NativeWidgetAura::InitModalType(ui::ModalType modal_type) { |
417 if (modal_type != ui::MODAL_TYPE_NONE) | 417 if (modal_type != ui::MODAL_TYPE_NONE) |
418 window_->SetProperty(aura::client::kModalKey, modal_type); | 418 window_->SetProperty(aura::client::kModalKey, modal_type); |
419 } | 419 } |
420 | 420 |
421 gfx::Rect NativeWidgetAura::GetWindowScreenBounds() const { | 421 gfx::Rect NativeWidgetAura::GetWindowScreenBounds() const { |
422 #if defined(ENABLE_DIP) | 422 #if defined(ENABLE_DIP) |
423 return ConvertRectFromMonitor(window_->GetScreenBounds()); | 423 return ConvertRectFromMonitor(window_->GetBoundsInRootWindow()); |
424 #else | 424 #else |
425 return window_->GetScreenBounds(); | 425 gfx::Rect bounds = window_->GetBoundsInRootWindow(); |
| 426 if (desktop_helper_.get()) |
| 427 bounds = desktop_helper_->ChangeRootWindowBoundsToScreenBounds(bounds); |
| 428 return bounds; |
426 #endif | 429 #endif |
427 } | 430 } |
428 | 431 |
429 gfx::Rect NativeWidgetAura::GetClientAreaScreenBounds() const { | 432 gfx::Rect NativeWidgetAura::GetClientAreaScreenBounds() const { |
430 // View-to-screen coordinate system transformations depend on this returning | 433 // View-to-screen coordinate system transformations depend on this returning |
431 // the full window bounds, for example View::ConvertPointToScreen(). | 434 // the full window bounds, for example View::ConvertPointToScreen(). |
432 #if defined(ENABLE_DIP) | 435 #if defined(ENABLE_DIP) |
433 return ConvertRectFromMonitor(window_->GetScreenBounds()); | 436 return ConvertRectFromMonitor(window_->GetBoundsInRootWindow()); |
434 #else | 437 #else |
435 return window_->GetScreenBounds(); | 438 gfx::Rect bounds = window_->GetBoundsInRootWindow(); |
| 439 if (desktop_helper_.get()) |
| 440 bounds = desktop_helper_->ChangeRootWindowBoundsToScreenBounds(bounds); |
| 441 return bounds; |
436 #endif | 442 #endif |
437 } | 443 } |
438 | 444 |
439 gfx::Rect NativeWidgetAura::GetRestoredBounds() const { | 445 gfx::Rect NativeWidgetAura::GetRestoredBounds() const { |
440 // Restored bounds should only be relevant if the window is minimized or | 446 // Restored bounds should only be relevant if the window is minimized or |
441 // maximized. However, in some places the code expectes GetRestoredBounds() | 447 // maximized. However, in some places the code expectes GetRestoredBounds() |
442 // to return the current window bounds if the window is not in either state. | 448 // to return the current window bounds if the window is not in either state. |
443 if (!IsMinimized() && !IsMaximized() && !IsFullscreen()) | 449 if (!IsMinimized() && !IsMaximized() && !IsFullscreen()) |
444 return window_->bounds(); | 450 return window_->bounds(); |
445 gfx::Rect* restore_bounds = | 451 gfx::Rect* restore_bounds = |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 } | 1055 } |
1050 } | 1056 } |
1051 | 1057 |
1052 // static | 1058 // static |
1053 bool NativeWidgetPrivate::IsMouseButtonDown() { | 1059 bool NativeWidgetPrivate::IsMouseButtonDown() { |
1054 return aura::Env::GetInstance()->is_mouse_button_down(); | 1060 return aura::Env::GetInstance()->is_mouse_button_down(); |
1055 } | 1061 } |
1056 | 1062 |
1057 } // namespace internal | 1063 } // namespace internal |
1058 } // namespace views | 1064 } // namespace views |
OLD | NEW |