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

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

Issue 108343005: Revert 240542 "Make sure the dragged window is smaller than work..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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 "ash/wm/drag_window_resizer.h" 5 #include "ash/wm/drag_window_resizer.h"
6 6
7 #include "ash/display/mouse_cursor_event_filter.h" 7 #include "ash/display/mouse_cursor_event_filter.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Check if the destination is another display. 118 // Check if the destination is another display.
119 gfx::Point last_mouse_location_in_screen = last_mouse_location_; 119 gfx::Point last_mouse_location_in_screen = last_mouse_location_;
120 wm::ConvertPointToScreen(GetTarget()->parent(), 120 wm::ConvertPointToScreen(GetTarget()->parent(),
121 &last_mouse_location_in_screen); 121 &last_mouse_location_in_screen);
122 gfx::Screen* screen = Shell::GetScreen(); 122 gfx::Screen* screen = Shell::GetScreen();
123 const gfx::Display dst_display = 123 const gfx::Display dst_display =
124 screen->GetDisplayNearestPoint(last_mouse_location_in_screen); 124 screen->GetDisplayNearestPoint(last_mouse_location_in_screen);
125 125
126 if (dst_display.id() != 126 if (dst_display.id() !=
127 screen->GetDisplayNearestWindow(GetTarget()->GetRootWindow()).id()) { 127 screen->GetDisplayNearestWindow(GetTarget()->GetRootWindow()).id()) {
128 // Adjust the size and position so that it doesn't exceed the size of 128 const gfx::Rect dst_bounds =
129 // work area. 129 ScreenAsh::ConvertRectToScreen(GetTarget()->parent(),
130 const gfx::Size& size = dst_display.work_area().size(); 130 GetTarget()->bounds());
131 gfx::Rect bounds = GetTarget()->bounds();
132 if (bounds.width() > size.width()) {
133 int diff = bounds.width() - size.width();
134 bounds.set_x(bounds.x() + diff / 2);
135 bounds.set_width(size.width());
136 }
137 if (bounds.height() > size.height())
138 bounds.set_height(size.height());
139
140 gfx::Rect dst_bounds =
141 ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds);
142
143 // Adjust the position so that the cursor is on the window.
144 if (!dst_bounds.Contains(last_mouse_location_in_screen)) {
145 if (last_mouse_location_in_screen.x() < dst_bounds.x())
146 dst_bounds.set_x(last_mouse_location_in_screen.x());
147 else if (last_mouse_location_in_screen.x() > dst_bounds.right())
148 dst_bounds.set_x(
149 last_mouse_location_in_screen.x() - dst_bounds.width());
150 }
151 GetTarget()->SetBoundsInScreen(dst_bounds, dst_display); 131 GetTarget()->SetBoundsInScreen(dst_bounds, dst_display);
152 } 132 }
153 } 133 }
154 134
155 void DragWindowResizer::RevertDrag() { 135 void DragWindowResizer::RevertDrag() {
156 next_window_resizer_->RevertDrag(); 136 next_window_resizer_->RevertDrag();
157 137
158 drag_window_controller_.reset(); 138 drag_window_controller_.reset();
159 GetTarget()->layer()->SetOpacity(details_.initial_opacity); 139 GetTarget()->layer()->SetOpacity(details_.initial_opacity);
160 } 140 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 if (!tray_user->TransferWindowToUser(details_.window)) { 268 if (!tray_user->TransferWindowToUser(details_.window)) {
289 GetTarget()->layer()->SetOpacity(old_opacity); 269 GetTarget()->layer()->SetOpacity(old_opacity);
290 return false; 270 return false;
291 } 271 }
292 RevertDrag(); 272 RevertDrag();
293 return true; 273 return true;
294 } 274 }
295 275
296 } // namespace internal 276 } // namespace internal
297 } // namespace ash 277 } // namespace ash
OLDNEW
« no previous file with comments | « trunk/src/ash/root_window_controller_unittest.cc ('k') | trunk/src/ash/wm/drag_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698