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

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

Issue 1915363002: Rename gfx::Display/Screen to display::Display/Screen in views/wm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanups Created 4 years, 7 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
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/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "third_party/skia/include/core/SkRegion.h" 11 #include "third_party/skia/include/core/SkRegion.h"
12 #include "ui/aura/client/aura_constants.h" 12 #include "ui/aura/client/aura_constants.h"
13 #include "ui/aura/client/cursor_client.h" 13 #include "ui/aura/client/cursor_client.h"
14 #include "ui/aura/client/focus_client.h" 14 #include "ui/aura/client/focus_client.h"
15 #include "ui/aura/client/screen_position_client.h" 15 #include "ui/aura/client/screen_position_client.h"
16 #include "ui/aura/client/window_tree_client.h" 16 #include "ui/aura/client/window_tree_client.h"
17 #include "ui/aura/env.h" 17 #include "ui/aura/env.h"
18 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
19 #include "ui/aura/window_event_dispatcher.h" 19 #include "ui/aura/window_event_dispatcher.h"
20 #include "ui/aura/window_observer.h" 20 #include "ui/aura/window_observer.h"
21 #include "ui/aura/window_tree_host.h" 21 #include "ui/aura/window_tree_host.h"
22 #include "ui/base/dragdrop/os_exchange_data.h" 22 #include "ui/base/dragdrop/os_exchange_data.h"
23 #include "ui/base/ui_base_types.h" 23 #include "ui/base/ui_base_types.h"
24 #include "ui/compositor/layer.h" 24 #include "ui/compositor/layer.h"
25 #include "ui/display/screen.h"
25 #include "ui/events/event.h" 26 #include "ui/events/event.h"
26 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
27 #include "ui/gfx/font_list.h" 28 #include "ui/gfx/font_list.h"
28 #include "ui/gfx/screen.h"
29 #include "ui/native_theme/native_theme_aura.h" 29 #include "ui/native_theme/native_theme_aura.h"
30 #include "ui/views/drag_utils.h" 30 #include "ui/views/drag_utils.h"
31 #include "ui/views/views_delegate.h" 31 #include "ui/views/views_delegate.h"
32 #include "ui/views/widget/drop_helper.h" 32 #include "ui/views/widget/drop_helper.h"
33 #include "ui/views/widget/native_widget_delegate.h" 33 #include "ui/views/widget/native_widget_delegate.h"
34 #include "ui/views/widget/root_view.h" 34 #include "ui/views/widget/root_view.h"
35 #include "ui/views/widget/tooltip_manager_aura.h" 35 #include "ui/views/widget/tooltip_manager_aura.h"
36 #include "ui/views/widget/widget_aura_utils.h" 36 #include "ui/views/widget/widget_aura_utils.h"
37 #include "ui/views/widget/widget_delegate.h" 37 #include "ui/views/widget/widget_delegate.h"
38 #include "ui/views/widget/window_reorderer.h" 38 #include "ui/views/widget/window_reorderer.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 context = parent; 132 context = parent;
133 parent = NULL; 133 parent = NULL;
134 } 134 }
135 // SetAlwaysOnTop before SetParent so that always-on-top container is used. 135 // SetAlwaysOnTop before SetParent so that always-on-top container is used.
136 SetAlwaysOnTop(params.keep_on_top); 136 SetAlwaysOnTop(params.keep_on_top);
137 // Make sure we have a real |window_bounds|. 137 // Make sure we have a real |window_bounds|.
138 if (parent && window_bounds == gfx::Rect()) { 138 if (parent && window_bounds == gfx::Rect()) {
139 // If a parent is specified but no bounds are given, 139 // If a parent is specified but no bounds are given,
140 // use the origin of the parent's display so that the widget 140 // use the origin of the parent's display so that the widget
141 // will be added to the same display as the parent. 141 // will be added to the same display as the parent.
142 gfx::Rect bounds = 142 gfx::Rect bounds = display::Screen::GetScreen()
143 gfx::Screen::GetScreen()->GetDisplayNearestWindow(parent).bounds(); 143 ->GetDisplayNearestWindow(parent)
144 .bounds();
144 window_bounds.set_origin(bounds.origin()); 145 window_bounds.set_origin(bounds.origin());
145 } 146 }
146 } 147 }
147 148
148 // Set properties before adding to the parent so that its layout manager sees 149 // Set properties before adding to the parent so that its layout manager sees
149 // the correct values. 150 // the correct values.
150 OnSizeConstraintsChanged(); 151 OnSizeConstraintsChanged();
151 152
152 if (parent) { 153 if (parent) {
153 parent->AddChild(window_); 154 parent->AddChild(window_);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 279 }
279 280
280 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { 281 void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
281 if (!window_) 282 if (!window_)
282 return; 283 return;
283 284
284 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); 285 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow());
285 // When centering window, we take the intersection of the host and 286 // When centering window, we take the intersection of the host and
286 // the parent. We assume the root window represents the visible 287 // the parent. We assume the root window represents the visible
287 // rect of a single screen. 288 // rect of a single screen.
288 gfx::Rect work_area = 289 gfx::Rect work_area = display::Screen::GetScreen()
289 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_).work_area(); 290 ->GetDisplayNearestWindow(window_)
291 .work_area();
290 292
291 aura::client::ScreenPositionClient* screen_position_client = 293 aura::client::ScreenPositionClient* screen_position_client =
292 aura::client::GetScreenPositionClient(window_->GetRootWindow()); 294 aura::client::GetScreenPositionClient(window_->GetRootWindow());
293 if (screen_position_client) { 295 if (screen_position_client) {
294 gfx::Point origin = work_area.origin(); 296 gfx::Point origin = work_area.origin();
295 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(), 297 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(),
296 &origin); 298 &origin);
297 work_area.set_origin(origin); 299 work_area.set_origin(origin);
298 } 300 }
299 301
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 400
399 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { 401 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) {
400 if (!window_) 402 if (!window_)
401 return; 403 return;
402 404
403 aura::Window* root = window_->GetRootWindow(); 405 aura::Window* root = window_->GetRootWindow();
404 if (root) { 406 if (root) {
405 aura::client::ScreenPositionClient* screen_position_client = 407 aura::client::ScreenPositionClient* screen_position_client =
406 aura::client::GetScreenPositionClient(root); 408 aura::client::GetScreenPositionClient(root);
407 if (screen_position_client) { 409 if (screen_position_client) {
408 gfx::Display dst_display = 410 display::Display dst_display =
409 gfx::Screen::GetScreen()->GetDisplayMatching(bounds); 411 display::Screen::GetScreen()->GetDisplayMatching(bounds);
410 screen_position_client->SetBounds(window_, bounds, dst_display); 412 screen_position_client->SetBounds(window_, bounds, dst_display);
411 return; 413 return;
412 } 414 }
413 } 415 }
414 window_->SetBounds(bounds); 416 window_->SetBounds(bounds);
415 } 417 }
416 418
417 void NativeWidgetAura::SetSize(const gfx::Size& size) { 419 void NativeWidgetAura::SetSize(const gfx::Size& size) {
418 if (window_) 420 if (window_)
419 window_->SetBounds(gfx::Rect(window_->bounds().origin(), size)); 421 window_->SetBounds(gfx::Rect(window_->bounds().origin(), size));
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 639
638 void NativeWidgetAura::ClearNativeFocus() { 640 void NativeWidgetAura::ClearNativeFocus() {
639 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); 641 aura::client::FocusClient* client = aura::client::GetFocusClient(window_);
640 if (window_ && client && window_->Contains(client->GetFocusedWindow())) 642 if (window_ && client && window_->Contains(client->GetFocusedWindow()))
641 client->ResetFocusWithinActiveWindow(window_); 643 client->ResetFocusWithinActiveWindow(window_);
642 } 644 }
643 645
644 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { 646 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const {
645 if (!window_) 647 if (!window_)
646 return gfx::Rect(); 648 return gfx::Rect();
647 return gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_).work_area(); 649 return display::Screen::GetScreen()
650 ->GetDisplayNearestWindow(window_)
651 .work_area();
648 } 652 }
649 653
650 Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop( 654 Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop(
651 const gfx::Vector2d& drag_offset, 655 const gfx::Vector2d& drag_offset,
652 Widget::MoveLoopSource source, 656 Widget::MoveLoopSource source,
653 Widget::MoveLoopEscapeBehavior escape_behavior) { 657 Widget::MoveLoopEscapeBehavior escape_behavior) {
654 // |escape_behavior| is only needed on windows when running the native message 658 // |escape_behavior| is only needed on windows when running the native message
655 // loop. 659 // loop.
656 if (!window_ || !window_->GetRootWindow()) 660 if (!window_ || !window_->GetRootWindow())
657 return Widget::MOVE_LOOP_CANCELED; 661 return Widget::MOVE_LOOP_CANCELED;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); 1175 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont));
1172 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); 1176 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
1173 return gfx::FontList(gfx::Font(caption_font.get())); 1177 return gfx::FontList(gfx::Font(caption_font.get()));
1174 #else 1178 #else
1175 return gfx::FontList(); 1179 return gfx::FontList();
1176 #endif 1180 #endif
1177 } 1181 }
1178 1182
1179 } // namespace internal 1183 } // namespace internal
1180 } // namespace views 1184 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/x11_window_event_filter.cc ('k') | ui/views/widget/native_widget_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698