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

Side by Side Diff: ash/wm/drag_window_resizer.cc

Issue 2660873002: Move two utility functions from ash/screen_util.h to ui/wm/core/coordinate_conversion.h (Closed)
Patch Set: rebase Created 3 years, 10 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
« no previous file with comments | « ash/wm/drag_window_controller.cc ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/wm/drag_window_resizer.h" 5 #include "ash/wm/drag_window_resizer.h"
6 6
7 #include "ash/common/wm/window_positioning_utils.h" 7 #include "ash/common/wm/window_positioning_utils.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
10 #include "ash/display/mouse_cursor_event_filter.h" 10 #include "ash/display/mouse_cursor_event_filter.h"
11 #include "ash/screen_util.h"
12 #include "ash/shell.h" 11 #include "ash/shell.h"
13 #include "ash/wm/drag_window_controller.h" 12 #include "ash/wm/drag_window_controller.h"
14 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
15 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
16 #include "ui/aura/client/aura_constants.h" 15 #include "ui/aura/client/aura_constants.h"
17 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
18 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
19 #include "ui/aura/window_delegate.h" 18 #include "ui/aura/window_delegate.h"
20 #include "ui/aura/window_event_dispatcher.h" 19 #include "ui/aura/window_event_dispatcher.h"
21 #include "ui/base/hit_test.h" 20 #include "ui/base/hit_test.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const gfx::Size& size = dst_display.work_area().size(); 83 const gfx::Size& size = dst_display.work_area().size();
85 gfx::Rect bounds = GetAuraTarget()->bounds(); 84 gfx::Rect bounds = GetAuraTarget()->bounds();
86 if (bounds.width() > size.width()) { 85 if (bounds.width() > size.width()) {
87 int diff = bounds.width() - size.width(); 86 int diff = bounds.width() - size.width();
88 bounds.set_x(bounds.x() + diff / 2); 87 bounds.set_x(bounds.x() + diff / 2);
89 bounds.set_width(size.width()); 88 bounds.set_width(size.width());
90 } 89 }
91 if (bounds.height() > size.height()) 90 if (bounds.height() > size.height())
92 bounds.set_height(size.height()); 91 bounds.set_height(size.height());
93 92
94 gfx::Rect dst_bounds = 93 gfx::Rect dst_bounds = bounds;
95 ScreenUtil::ConvertRectToScreen(GetAuraTarget()->parent(), bounds); 94 ::wm::ConvertRectToScreen(GetAuraTarget()->parent(), &dst_bounds);
96 95
97 // Adjust the position so that the cursor is on the window. 96 // Adjust the position so that the cursor is on the window.
98 if (!dst_bounds.Contains(last_mouse_location_in_screen)) { 97 if (!dst_bounds.Contains(last_mouse_location_in_screen)) {
99 if (last_mouse_location_in_screen.x() < dst_bounds.x()) 98 if (last_mouse_location_in_screen.x() < dst_bounds.x())
100 dst_bounds.set_x(last_mouse_location_in_screen.x()); 99 dst_bounds.set_x(last_mouse_location_in_screen.x());
101 else if (last_mouse_location_in_screen.x() > dst_bounds.right()) 100 else if (last_mouse_location_in_screen.x() > dst_bounds.right())
102 dst_bounds.set_x(last_mouse_location_in_screen.x() - 101 dst_bounds.set_x(last_mouse_location_in_screen.x() -
103 dst_bounds.width()); 102 dst_bounds.width());
104 } 103 }
105 ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(dst_display.bounds(), 104 ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(dst_display.bounds(),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 136
138 void DragWindowResizer::UpdateDragWindow( 137 void DragWindowResizer::UpdateDragWindow(
139 const gfx::Rect& bounds_in_parent, 138 const gfx::Rect& bounds_in_parent,
140 const gfx::Point& drag_location_in_screen) { 139 const gfx::Point& drag_location_in_screen) {
141 if (details().window_component != HTCAPTION || !ShouldAllowMouseWarp()) 140 if (details().window_component != HTCAPTION || !ShouldAllowMouseWarp())
142 return; 141 return;
143 142
144 if (!drag_window_controller_) 143 if (!drag_window_controller_)
145 drag_window_controller_.reset(new DragWindowController(GetAuraTarget())); 144 drag_window_controller_.reset(new DragWindowController(GetAuraTarget()));
146 145
147 const gfx::Rect bounds_in_screen = ScreenUtil::ConvertRectToScreen( 146 gfx::Rect bounds_in_screen = bounds_in_parent;
148 GetAuraTarget()->parent(), bounds_in_parent); 147 ::wm::ConvertRectToScreen(GetAuraTarget()->parent(), &bounds_in_screen);
149 148
150 gfx::Rect root_bounds_in_screen = 149 gfx::Rect root_bounds_in_screen =
151 GetAuraTarget()->GetRootWindow()->GetBoundsInScreen(); 150 GetAuraTarget()->GetRootWindow()->GetBoundsInScreen();
152 float opacity = 1.0f; 151 float opacity = 1.0f;
153 if (!root_bounds_in_screen.Contains(drag_location_in_screen)) { 152 if (!root_bounds_in_screen.Contains(drag_location_in_screen)) {
154 gfx::Rect visible_bounds = root_bounds_in_screen; 153 gfx::Rect visible_bounds = root_bounds_in_screen;
155 visible_bounds.Intersect(bounds_in_screen); 154 visible_bounds.Intersect(bounds_in_screen);
156 opacity = DragWindowController::GetDragWindowOpacity(bounds_in_screen, 155 opacity = DragWindowController::GetDragWindowOpacity(bounds_in_screen,
157 visible_bounds); 156 visible_bounds);
158 } 157 }
159 GetAuraTarget()->layer()->SetOpacity(opacity); 158 GetAuraTarget()->layer()->SetOpacity(opacity);
160 drag_window_controller_->Update(bounds_in_screen, drag_location_in_screen); 159 drag_window_controller_->Update(bounds_in_screen, drag_location_in_screen);
161 } 160 }
162 161
163 bool DragWindowResizer::ShouldAllowMouseWarp() { 162 bool DragWindowResizer::ShouldAllowMouseWarp() {
164 return details().window_component == HTCAPTION && 163 return details().window_component == HTCAPTION &&
165 !::wm::GetTransientParent(GetAuraTarget()) && 164 !::wm::GetTransientParent(GetAuraTarget()) &&
166 wm::IsWindowUserPositionable(GetAuraTarget()); 165 wm::IsWindowUserPositionable(GetAuraTarget());
167 } 166 }
168 167
169 aura::Window* DragWindowResizer::GetAuraTarget() { 168 aura::Window* DragWindowResizer::GetAuraTarget() {
170 return WmWindow::GetAuraWindow(GetTarget()); 169 return WmWindow::GetAuraWindow(GetTarget());
171 } 170 }
172 171
173 } // namespace ash 172 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/drag_window_controller.cc ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698