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

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

Issue 93873013: Make sure the dragged window is smaller than work area in the target display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 const gfx::Rect dst_bounds = 128 // Adjust the size and position so that it doesn't exceed the size of
129 ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), 129 // work area.
130 GetTarget()->bounds()); 130 const gfx::Size& size = dst_display.work_area().size();
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());
varkha 2013/12/12 16:20:46 Is this enough for a vertical arrangement where th
oshima 2013/12/12 19:07:14 I don't think the screen layout does matter. I had
varkha 2013/12/12 22:10:47 I understand - we are probably never shrinking the
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());
varkha 2013/12/12 16:20:46 Same here - does it consider vertical screen arran
varkha 2013/12/12 22:10:47 sg. Thanks for the explanation.
150 }
131 GetTarget()->SetBoundsInScreen(dst_bounds, dst_display); 151 GetTarget()->SetBoundsInScreen(dst_bounds, dst_display);
132 } 152 }
133 } 153 }
134 154
135 void DragWindowResizer::RevertDrag() { 155 void DragWindowResizer::RevertDrag() {
136 next_window_resizer_->RevertDrag(); 156 next_window_resizer_->RevertDrag();
137 157
138 drag_window_controller_.reset(); 158 drag_window_controller_.reset();
139 GetTarget()->layer()->SetOpacity(details_.initial_opacity); 159 GetTarget()->layer()->SetOpacity(details_.initial_opacity);
140 } 160 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 if (!tray_user->TransferWindowToUser(details_.window)) { 288 if (!tray_user->TransferWindowToUser(details_.window)) {
269 GetTarget()->layer()->SetOpacity(old_opacity); 289 GetTarget()->layer()->SetOpacity(old_opacity);
270 return false; 290 return false;
271 } 291 }
272 RevertDrag(); 292 RevertDrag();
273 return true; 293 return true;
274 } 294 }
275 295
276 } // namespace internal 296 } // namespace internal
277 } // namespace ash 297 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698