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

Side by Side Diff: components/exo/shell_surface.cc

Issue 2645663004: exo: Initial support for multiple displays in ARC (Closed)
Patch Set: Refactor Created 3 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/exo/shell_surface.h" 5 #include "components/exo/shell_surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/frame/custom_frame_view_ash.h" 9 #include "ash/common/frame/custom_frame_view_ash.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/wm/window_resizer.h" 11 #include "ash/common/wm/window_resizer.h"
12 #include "ash/common/wm/window_state.h" 12 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm_shell.h"
13 #include "ash/common/wm_window.h" 14 #include "ash/common/wm_window.h"
14 #include "ash/public/cpp/shell_window_ids.h" 15 #include "ash/public/cpp/shell_window_ids.h"
16 #include "ash/wm/drag_window_resizer.h"
15 #include "ash/wm/window_state_aura.h" 17 #include "ash/wm/window_state_aura.h"
16 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
17 #include "base/logging.h" 19 #include "base/logging.h"
18 #include "base/macros.h" 20 #include "base/macros.h"
19 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
20 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
21 #include "base/trace_event/trace_event.h" 23 #include "base/trace_event/trace_event.h"
22 #include "base/trace_event/trace_event_argument.h" 24 #include "base/trace_event/trace_event_argument.h"
23 #include "components/exo/surface.h" 25 #include "components/exo/surface.h"
24 #include "ui/aura/client/aura_constants.h" 26 #include "ui/aura/client/aura_constants.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 138 }
137 return aura::WindowTargeter::FindTargetForEvent(root, event); 139 return aura::WindowTargeter::FindTargetForEvent(root, event);
138 } 140 }
139 141
140 private: 142 private:
141 views::Widget* const widget_; 143 views::Widget* const widget_;
142 144
143 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); 145 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter);
144 }; 146 };
145 147
148 class CustomWindowResizer : public ash::WindowResizer {
reveman 2017/03/06 19:02:13 Please add a class description that explains how t
Dominik Laskowski 2017/03/08 23:13:22 Done.
149 public:
150 explicit CustomWindowResizer(ash::wm::WindowState* window_state)
151 : WindowResizer(window_state), shell_(GetTarget()->GetShell()) {
152 shell_->LockCursor();
153 }
154 ~CustomWindowResizer() override { shell_->UnlockCursor(); }
155
156 // Overridden from ash::WindowResizer:
157 void Drag(const gfx::Point& location, int event_flags) override {}
158 void CompleteDrag() override {}
159 void RevertDrag() override {}
160
161 private:
162 ash::WmShell* const shell_;
163
164 DISALLOW_COPY_AND_ASSIGN(CustomWindowResizer);
165 };
166
146 class ShellSurfaceWidget : public views::Widget { 167 class ShellSurfaceWidget : public views::Widget {
147 public: 168 public:
148 explicit ShellSurfaceWidget(ShellSurface* shell_surface) 169 explicit ShellSurfaceWidget(ShellSurface* shell_surface)
149 : shell_surface_(shell_surface) {} 170 : shell_surface_(shell_surface) {}
150 171
151 // Overridden from views::Widget 172 // Overridden from views::Widget
152 void Close() override { shell_surface_->Close(); } 173 void Close() override { shell_surface_->Close(); }
153 void OnKeyEvent(ui::KeyEvent* event) override { 174 void OnKeyEvent(ui::KeyEvent* event) override {
154 // TODO(hidehiko): Handle ESC + SHIFT + COMMAND accelerator key 175 // TODO(hidehiko): Handle ESC + SHIFT + COMMAND accelerator key
155 // to escape pinned mode. 176 // to escape pinned mode.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 int container) 318 int container)
298 : widget_(nullptr), 319 : widget_(nullptr),
299 surface_(surface), 320 surface_(surface),
300 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), 321 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr),
301 bounds_mode_(bounds_mode), 322 bounds_mode_(bounds_mode),
302 origin_(origin), 323 origin_(origin),
303 activatable_(activatable), 324 activatable_(activatable),
304 can_minimize_(can_minimize), 325 can_minimize_(can_minimize),
305 container_(container) { 326 container_(container) {
306 WMHelper::GetInstance()->AddActivationObserver(this); 327 WMHelper::GetInstance()->AddActivationObserver(this);
328 WMHelper::GetInstance()->AddDisplayConfigurationObserver(this);
307 surface_->SetSurfaceDelegate(this); 329 surface_->SetSurfaceDelegate(this);
308 surface_->AddSurfaceObserver(this); 330 surface_->AddSurfaceObserver(this);
309 surface_->window()->Show(); 331 surface_->window()->Show();
310 set_owned_by_client(); 332 set_owned_by_client();
311 if (parent_) 333 if (parent_)
312 parent_->AddObserver(this); 334 parent_->AddObserver(this);
313 } 335 }
314 336
315 ShellSurface::ShellSurface(Surface* surface) 337 ShellSurface::ShellSurface(Surface* surface)
316 : ShellSurface(surface, 338 : ShellSurface(surface,
(...skipping 12 matching lines...) Expand all
329 ash::wm::GetWindowState(widget_->GetNativeWindow())->RemoveObserver(this); 351 ash::wm::GetWindowState(widget_->GetNativeWindow())->RemoveObserver(this);
330 widget_->GetNativeWindow()->RemoveObserver(this); 352 widget_->GetNativeWindow()->RemoveObserver(this);
331 // Remove transient children so they are not automatically destroyed. 353 // Remove transient children so they are not automatically destroyed.
332 for (auto child : wm::GetTransientChildren(widget_->GetNativeWindow())) 354 for (auto child : wm::GetTransientChildren(widget_->GetNativeWindow()))
333 wm::RemoveTransientChild(widget_->GetNativeWindow(), child); 355 wm::RemoveTransientChild(widget_->GetNativeWindow(), child);
334 if (widget_->IsVisible()) 356 if (widget_->IsVisible())
335 widget_->Hide(); 357 widget_->Hide();
336 widget_->CloseNow(); 358 widget_->CloseNow();
337 } 359 }
338 WMHelper::GetInstance()->RemoveActivationObserver(this); 360 WMHelper::GetInstance()->RemoveActivationObserver(this);
361 WMHelper::GetInstance()->RemoveDisplayConfigurationObserver(this);
339 if (parent_) 362 if (parent_)
340 parent_->RemoveObserver(this); 363 parent_->RemoveObserver(this);
341 if (surface_) { 364 if (surface_) {
342 if (scale_ != 1.0) 365 if (scale_ != 1.0)
343 surface_->window()->SetTransform(gfx::Transform()); 366 surface_->window()->SetTransform(gfx::Transform());
344 surface_->SetSurfaceDelegate(nullptr); 367 surface_->SetSurfaceDelegate(nullptr);
345 surface_->RemoveSurfaceObserver(this); 368 surface_->RemoveSurfaceObserver(this);
346 } 369 }
347 WMHelper::GetInstance()->RemoveAccessibilityObserver(this); 370 WMHelper::GetInstance()->RemoveAccessibilityObserver(this);
348 } 371 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 545 }
523 546
524 void ShellSurface::Move() { 547 void ShellSurface::Move() {
525 TRACE_EVENT0("exo", "ShellSurface::Move"); 548 TRACE_EVENT0("exo", "ShellSurface::Move");
526 549
527 if (!widget_) 550 if (!widget_)
528 return; 551 return;
529 552
530 switch (bounds_mode_) { 553 switch (bounds_mode_) {
531 case BoundsMode::SHELL: 554 case BoundsMode::SHELL:
555 case BoundsMode::CLIENT:
532 AttemptToStartDrag(HTCAPTION); 556 AttemptToStartDrag(HTCAPTION);
533 return; 557 return;
534 case BoundsMode::CLIENT:
535 case BoundsMode::FIXED: 558 case BoundsMode::FIXED:
536 return; 559 return;
537 } 560 }
538 561
539 NOTREACHED(); 562 NOTREACHED();
540 } 563 }
541 564
542 void ShellSurface::Resize(int component) { 565 void ShellSurface::Resize(int component) {
543 TRACE_EVENT1("exo", "ShellSurface::Resize", "component", component); 566 TRACE_EVENT1("exo", "ShellSurface::Resize", "component", component);
544 567
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 } 1014 }
992 1015
993 //////////////////////////////////////////////////////////////////////////////// 1016 ////////////////////////////////////////////////////////////////////////////////
994 // WMHelper::AccessibilityObserver overrides: 1017 // WMHelper::AccessibilityObserver overrides:
995 1018
996 void ShellSurface::OnAccessibilityModeChanged() { 1019 void ShellSurface::OnAccessibilityModeChanged() {
997 UpdateShadow(); 1020 UpdateShadow();
998 } 1021 }
999 1022
1000 //////////////////////////////////////////////////////////////////////////////// 1023 ////////////////////////////////////////////////////////////////////////////////
1024 // WMHelper::DisplayConfigurationObserver overrides:
1025
1026 void ShellSurface::OnDisplayConfigurationChanged() {
1027 if (!display_config_changed_callback_.is_null())
1028 display_config_changed_callback_.Run();
1029 }
1030
1031 ////////////////////////////////////////////////////////////////////////////////
1001 // ui::EventHandler overrides: 1032 // ui::EventHandler overrides:
1002 1033
1003 void ShellSurface::OnKeyEvent(ui::KeyEvent* event) { 1034 void ShellSurface::OnKeyEvent(ui::KeyEvent* event) {
1004 if (!resizer_) { 1035 if (!resizer_) {
1005 views::View::OnKeyEvent(event); 1036 views::View::OnKeyEvent(event);
1006 return; 1037 return;
1007 } 1038 }
1008 1039
1009 if (event->type() == ui::ET_KEY_PRESSED && 1040 if (bounds_mode_ == BoundsMode::SHELL &&
1041 event->type() == ui::ET_KEY_PRESSED &&
1010 event->key_code() == ui::VKEY_ESCAPE) { 1042 event->key_code() == ui::VKEY_ESCAPE) {
1011 EndDrag(true /* revert */); 1043 EndDrag(true /* revert */);
1012 } 1044 }
1013 } 1045 }
1014 1046
1015 void ShellSurface::OnMouseEvent(ui::MouseEvent* event) { 1047 void ShellSurface::OnMouseEvent(ui::MouseEvent* event) {
1016 if (!resizer_) { 1048 if (!resizer_) {
1017 views::View::OnMouseEvent(event); 1049 views::View::OnMouseEvent(event);
1018 return; 1050 return;
1019 } 1051 }
1020 1052
1021 if (event->handled()) 1053 if (event->handled())
1022 return; 1054 return;
1023 1055
1024 if ((event->flags() & 1056 if ((event->flags() &
1025 (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0) 1057 (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0)
1026 return; 1058 return;
1027 1059
1028 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) { 1060 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) {
1029 // We complete the drag instead of reverting it, as reverting it will 1061 // We complete the drag instead of reverting it, as reverting it will
1030 // result in a weird behavior when a client produces a modal dialog 1062 // result in a weird behavior when a client produces a modal dialog
1031 // while the drag is in progress. 1063 // while the drag is in progress.
1032 EndDrag(false /* revert */); 1064 EndDrag(false /* revert */);
1033 return; 1065 return;
1034 } 1066 }
1035 1067
1036 switch (event->type()) { 1068 switch (event->type()) {
1037 case ui::ET_MOUSE_DRAGGED: { 1069 case ui::ET_MOUSE_DRAGGED: {
1070 if (bounds_mode_ == BoundsMode::CLIENT)
1071 break;
1072
1038 gfx::Point location(event->location()); 1073 gfx::Point location(event->location());
1039 aura::Window::ConvertPointToTarget(widget_->GetNativeWindow(), 1074 aura::Window::ConvertPointToTarget(widget_->GetNativeWindow(),
1040 widget_->GetNativeWindow()->parent(), 1075 widget_->GetNativeWindow()->parent(),
1041 &location); 1076 &location);
1042 ScopedConfigure scoped_configure(this, false); 1077 ScopedConfigure scoped_configure(this, false);
1043 resizer_->Drag(location, event->flags()); 1078 resizer_->Drag(location, event->flags());
1044 event->StopPropagation(); 1079 event->StopPropagation();
1045 break; 1080 break;
1046 } 1081 }
1047 case ui::ET_MOUSE_RELEASED: { 1082 case ui::ET_MOUSE_RELEASED: {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 } 1238 }
1204 1239
1205 // Apply origin offset and resize component at the first Commit() after this 1240 // Apply origin offset and resize component at the first Commit() after this
1206 // configure request has been acknowledged. 1241 // configure request has been acknowledged.
1207 pending_configs_.push_back({serial, origin_offset, resize_component}); 1242 pending_configs_.push_back({serial, origin_offset, resize_component});
1208 LOG_IF(WARNING, pending_configs_.size() > 100) 1243 LOG_IF(WARNING, pending_configs_.size() > 100)
1209 << "Number of pending configure acks for shell surface has reached: " 1244 << "Number of pending configure acks for shell surface has reached: "
1210 << pending_configs_.size(); 1245 << pending_configs_.size();
1211 } 1246 }
1212 1247
1248 aura::Window* ShellSurface::GetDragWindow() const {
1249 if (bounds_mode_ == BoundsMode::SHELL)
1250 return widget_->GetNativeWindow();
1251
1252 if (bounds_mode_ == BoundsMode::CLIENT && surface_)
1253 return surface_->window();
1254
1255 return nullptr;
1256 }
1257
1213 void ShellSurface::AttemptToStartDrag(int component) { 1258 void ShellSurface::AttemptToStartDrag(int component) {
1214 DCHECK(widget_); 1259 DCHECK(widget_);
1215 1260
1216 // Cannot start another drag if one is already taking place. 1261 // Cannot start another drag if one is already taking place.
1217 if (resizer_) 1262 if (resizer_)
1218 return; 1263 return;
1219 1264
1220 if (widget_->GetNativeWindow()->HasCapture()) 1265 aura::Window* window = GetDragWindow();
1266 if (!window || window->HasCapture())
1221 return; 1267 return;
1222 1268
1223 aura::Window* root_window = widget_->GetNativeWindow()->GetRootWindow(); 1269 if (bounds_mode_ == BoundsMode::SHELL) {
1224 gfx::Point drag_location = 1270 // Set the cursor before calling CreateWindowResizer(), as that will
1225 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); 1271 // eventually call LockCursor() and prevent the cursor from changing.
1226 aura::Window::ConvertPointToTarget( 1272 aura::client::CursorClient* cursor_client =
1227 root_window, widget_->GetNativeWindow()->parent(), &drag_location); 1273 aura::client::GetCursorClient(window->GetRootWindow());
1274 DCHECK(cursor_client);
1228 1275
1229 // Set the cursor before calling CreateWindowResizer(), as that will 1276 switch (component) {
1230 // eventually call LockCursor() and prevent the cursor from changing. 1277 case HTCAPTION:
1231 aura::client::CursorClient* cursor_client = 1278 cursor_client->SetCursor(ui::kCursorPointer);
1232 aura::client::GetCursorClient(root_window); 1279 break;
1233 DCHECK(cursor_client); 1280 case HTTOP:
1281 cursor_client->SetCursor(ui::kCursorNorthResize);
1282 break;
1283 case HTTOPRIGHT:
1284 cursor_client->SetCursor(ui::kCursorNorthEastResize);
1285 break;
1286 case HTRIGHT:
1287 cursor_client->SetCursor(ui::kCursorEastResize);
1288 break;
1289 case HTBOTTOMRIGHT:
1290 cursor_client->SetCursor(ui::kCursorSouthEastResize);
1291 break;
1292 case HTBOTTOM:
1293 cursor_client->SetCursor(ui::kCursorSouthResize);
1294 break;
1295 case HTBOTTOMLEFT:
1296 cursor_client->SetCursor(ui::kCursorSouthWestResize);
1297 break;
1298 case HTLEFT:
1299 cursor_client->SetCursor(ui::kCursorWestResize);
1300 break;
1301 case HTTOPLEFT:
1302 cursor_client->SetCursor(ui::kCursorNorthWestResize);
1303 break;
1304 default:
1305 NOTREACHED();
1306 break;
1307 }
1234 1308
1235 switch (component) { 1309 resizer_ = ash::CreateWindowResizer(
1236 case HTCAPTION: 1310 ash::WmWindow::Get(window), GetMouseLocation(), component,
1237 cursor_client->SetCursor(ui::kCursorPointer); 1311 aura::client::WINDOW_MOVE_SOURCE_MOUSE);
1238 break; 1312 if (!resizer_)
1239 case HTTOP: 1313 return;
1240 cursor_client->SetCursor(ui::kCursorNorthResize); 1314
1241 break; 1315 // Apply pending origin offsets and resize direction before starting a
1242 case HTTOPRIGHT: 1316 // new resize operation. These can still be pending if the client has
1243 cursor_client->SetCursor(ui::kCursorNorthEastResize); 1317 // acknowledged the configure request but not yet called Commit().
1244 break; 1318 origin_offset_ += pending_origin_offset_;
1245 case HTRIGHT: 1319 pending_origin_offset_ = gfx::Vector2d();
1246 cursor_client->SetCursor(ui::kCursorEastResize); 1320 resize_component_ = pending_resize_component_;
1247 break; 1321 } else {
1248 case HTBOTTOMRIGHT: 1322 DCHECK(bounds_mode_ == BoundsMode::CLIENT);
1249 cursor_client->SetCursor(ui::kCursorSouthEastResize); 1323
1250 break; 1324 ash::wm::WindowState* window_state =
1251 case HTBOTTOM: 1325 ash::wm::GetWindowState(widget_->GetNativeWindow());
1252 cursor_client->SetCursor(ui::kCursorSouthResize); 1326 DCHECK(!window_state->drag_details());
1253 break; 1327 DCHECK(component == HTCAPTION);
1254 case HTBOTTOMLEFT: 1328 window_state->CreateDragDetails(GetMouseLocation(), component,
1255 cursor_client->SetCursor(ui::kCursorSouthWestResize); 1329 aura::client::WINDOW_MOVE_SOURCE_MOUSE);
1256 break; 1330
1257 case HTLEFT: 1331 // The resizer renders phantom windows, but does not move the window.
reveman 2017/03/06 19:02:13 Is it not also used for moving windows between dis
Dominik Laskowski 2017/03/08 23:13:22 True, amended.
1258 cursor_client->SetCursor(ui::kCursorWestResize); 1332 resizer_.reset(ash::DragWindowResizer::Create(
1259 break; 1333 new CustomWindowResizer(window_state), window_state));
1260 case HTTOPLEFT:
1261 cursor_client->SetCursor(ui::kCursorNorthWestResize);
1262 break;
1263 default:
1264 NOTREACHED();
1265 break;
1266 } 1334 }
1267 1335
1268 resizer_ = ash::CreateWindowResizer(
1269 ash::WmWindow::Get(widget_->GetNativeWindow()), drag_location, component,
1270 aura::client::WINDOW_MOVE_SOURCE_MOUSE);
1271 if (!resizer_)
1272 return;
1273
1274 // Apply pending origin offsets and resize direction before starting a new
1275 // resize operation. These can still be pending if the client has acknowledged
1276 // the configure request but not yet called Commit().
1277 origin_offset_ += pending_origin_offset_;
1278 pending_origin_offset_ = gfx::Vector2d();
1279 resize_component_ = pending_resize_component_;
1280
1281 WMHelper::GetInstance()->AddPreTargetHandler(this); 1336 WMHelper::GetInstance()->AddPreTargetHandler(this);
1282 widget_->GetNativeWindow()->SetCapture(); 1337 window->SetCapture();
1283 1338
1284 // Notify client that resizing state has changed. 1339 // Notify client that resizing state has changed.
1285 if (IsResizing()) 1340 if (IsResizing())
1286 Configure(); 1341 Configure();
1287 } 1342 }
1288 1343
1289 void ShellSurface::EndDrag(bool revert) { 1344 void ShellSurface::EndDrag(bool revert) {
1290 DCHECK(widget_); 1345 DCHECK(widget_);
1291 DCHECK(resizer_); 1346 DCHECK(resizer_);
1292 1347
1348 aura::Window* window = GetDragWindow();
1349 DCHECK(window);
1350 DCHECK(window->HasCapture());
1351
1293 bool was_resizing = IsResizing(); 1352 bool was_resizing = IsResizing();
1294 1353
1295 if (revert) 1354 if (revert)
1296 resizer_->RevertDrag(); 1355 resizer_->RevertDrag();
1297 else 1356 else
1298 resizer_->CompleteDrag(); 1357 resizer_->CompleteDrag();
1299 1358
1300 WMHelper::GetInstance()->RemovePreTargetHandler(this); 1359 WMHelper::GetInstance()->RemovePreTargetHandler(this);
1301 widget_->GetNativeWindow()->ReleaseCapture(); 1360 window->ReleaseCapture();
1302 resizer_.reset(); 1361 resizer_.reset();
1303 1362
1304 // Notify client that resizing state has changed. 1363 // Notify client that resizing state has changed.
1305 if (was_resizing) 1364 if (was_resizing)
1306 Configure(); 1365 Configure();
1307 1366
1308 UpdateWidgetBounds(); 1367 UpdateWidgetBounds();
1309 } 1368 }
1310 1369
1311 bool ShellSurface::IsResizing() const { 1370 bool ShellSurface::IsResizing() const {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 new_widget_bounds.set_origin( 1463 new_widget_bounds.set_origin(
1405 widget_->GetWindowBoundsInScreen().origin()); 1464 widget_->GetWindowBoundsInScreen().origin());
1406 } 1465 }
1407 break; 1466 break;
1408 } 1467 }
1409 1468
1410 // Set |ignore_window_bounds_changes_| as this change to window bounds 1469 // Set |ignore_window_bounds_changes_| as this change to window bounds
1411 // should not result in a configure request. 1470 // should not result in a configure request.
1412 DCHECK(!ignore_window_bounds_changes_); 1471 DCHECK(!ignore_window_bounds_changes_);
1413 ignore_window_bounds_changes_ = true; 1472 ignore_window_bounds_changes_ = true;
1414 if (widget_->GetWindowBoundsInScreen() != new_widget_bounds) 1473 const gfx::Rect widget_bounds = widget_->GetWindowBoundsInScreen();
1415 widget_->SetBounds(new_widget_bounds); 1474 if (widget_bounds != new_widget_bounds) {
1475 if (bounds_mode_ != BoundsMode::CLIENT || !resizer_) {
1476 widget_->SetBounds(new_widget_bounds);
1477 UpdateSurfaceBounds();
1478 } else {
1479 // TODO(domlaskowski): Synchronize window state transitions with the
1480 // client, and abort client-side dragging on transition to fullscreen.
1481 LOG_IF(ERROR, widget_bounds.size() != new_widget_bounds.size())
reveman 2017/03/06 19:02:13 nit: DLOG_IF if this is something a malicious clie
Dominik Laskowski 2017/03/08 23:13:22 Done.
1482 << "Window size changed during client-driven drag";
1483
1484 // Convert from screen to display coordinates.
1485 gfx::Point origin = new_widget_bounds.origin();
1486 wm::ConvertPointFromScreen(widget_->GetNativeWindow()->parent(), &origin);
1487 new_widget_bounds.set_origin(origin);
1488
1489 // Move the window relative to the current display.
1490 widget_->GetNativeWindow()->SetBounds(new_widget_bounds);
1491 UpdateSurfaceBounds();
1492
1493 // Render phantom windows when beyond the current display.
1494 resizer_->Drag(GetMouseLocation(), 0);
1495 }
1496 }
1497
1416 ignore_window_bounds_changes_ = false; 1498 ignore_window_bounds_changes_ = false;
1417 } 1499 }
1418 1500
1419 void ShellSurface::UpdateSurfaceBounds() { 1501 void ShellSurface::UpdateSurfaceBounds() {
1420 gfx::Rect client_view_bounds = 1502 gfx::Rect client_view_bounds =
1421 widget_->non_client_view()->frame_view()->GetBoundsForClientView(); 1503 widget_->non_client_view()->frame_view()->GetBoundsForClientView();
1422 1504
1423 surface_->window()->SetBounds( 1505 surface_->window()->SetBounds(
1424 gfx::Rect(GetSurfaceOrigin() + client_view_bounds.OffsetFromOrigin(), 1506 gfx::Rect(GetSurfaceOrigin() + client_view_bounds.OffsetFromOrigin(),
1425 surface_->window()->layer()->size())); 1507 surface_->window()->layer()->size()));
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 // Surfaces that can't be activated are usually menus and tooltips. Use a 1651 // Surfaces that can't be activated are usually menus and tooltips. Use a
1570 // small style shadow for them. 1652 // small style shadow for them.
1571 if (!activatable_) 1653 if (!activatable_)
1572 shadow->SetElevation(wm::ShadowElevation::SMALL); 1654 shadow->SetElevation(wm::ShadowElevation::SMALL);
1573 // We don't have rounded corners unless frame is enabled. 1655 // We don't have rounded corners unless frame is enabled.
1574 if (!frame_enabled_) 1656 if (!frame_enabled_)
1575 shadow->SetRoundedCornerRadius(0); 1657 shadow->SetRoundedCornerRadius(0);
1576 } 1658 }
1577 } 1659 }
1578 1660
1661 gfx::Point ShellSurface::GetMouseLocation() const {
1662 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow();
1663 gfx::Point location =
1664 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot();
1665 aura::Window::ConvertPointToTarget(
1666 root_window, widget_->GetNativeWindow()->parent(), &location);
1667 return location;
1668 }
1669
1579 } // namespace exo 1670 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698