Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/frame/custom_frame_view_ash.h" | 10 #include "ash/common/frame/custom_frame_view_ash.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 : widget_(nullptr), | 366 : widget_(nullptr), |
| 367 surface_(surface), | 367 surface_(surface), |
| 368 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), | 368 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), |
| 369 initial_bounds_(initial_bounds), | 369 initial_bounds_(initial_bounds), |
| 370 transform_to_screen_(std::move(transform_to_screen)), | 370 transform_to_screen_(std::move(transform_to_screen)), |
| 371 transform_from_screen_(std::move(transform_from_screen)), | 371 transform_from_screen_(std::move(transform_from_screen)), |
| 372 activatable_(activatable), | 372 activatable_(activatable), |
| 373 can_minimize_(can_minimize), | 373 can_minimize_(can_minimize), |
| 374 container_(container) { | 374 container_(container) { |
| 375 WMHelper::GetInstance()->AddActivationObserver(this); | 375 WMHelper::GetInstance()->AddActivationObserver(this); |
| 376 WMHelper::GetInstance()->AddShellObserver(this); | |
| 376 surface_->SetSurfaceDelegate(this); | 377 surface_->SetSurfaceDelegate(this); |
| 377 surface_->AddSurfaceObserver(this); | 378 surface_->AddSurfaceObserver(this); |
| 378 surface_->window()->Show(); | 379 surface_->window()->Show(); |
| 379 set_owned_by_client(); | 380 set_owned_by_client(); |
| 380 if (parent_) | 381 if (parent_) |
| 381 parent_->AddObserver(this); | 382 parent_->AddObserver(this); |
| 382 } | 383 } |
| 383 | 384 |
| 384 ShellSurface::ShellSurface(Surface* surface) | 385 ShellSurface::ShellSurface(Surface* surface) |
| 385 : ShellSurface(surface, | 386 : ShellSurface(surface, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 398 ash::wm::GetWindowState(widget_->GetNativeWindow())->RemoveObserver(this); | 399 ash::wm::GetWindowState(widget_->GetNativeWindow())->RemoveObserver(this); |
| 399 widget_->GetNativeWindow()->RemoveObserver(this); | 400 widget_->GetNativeWindow()->RemoveObserver(this); |
| 400 // Remove transient children so they are not automatically destroyed. | 401 // Remove transient children so they are not automatically destroyed. |
| 401 for (auto child : wm::GetTransientChildren(widget_->GetNativeWindow())) | 402 for (auto child : wm::GetTransientChildren(widget_->GetNativeWindow())) |
| 402 wm::RemoveTransientChild(widget_->GetNativeWindow(), child); | 403 wm::RemoveTransientChild(widget_->GetNativeWindow(), child); |
| 403 if (widget_->IsVisible()) | 404 if (widget_->IsVisible()) |
| 404 widget_->Hide(); | 405 widget_->Hide(); |
| 405 widget_->CloseNow(); | 406 widget_->CloseNow(); |
| 406 } | 407 } |
| 407 WMHelper::GetInstance()->RemoveActivationObserver(this); | 408 WMHelper::GetInstance()->RemoveActivationObserver(this); |
| 409 WMHelper::GetInstance()->RemoveShellObserver(this); | |
| 408 if (parent_) | 410 if (parent_) |
| 409 parent_->RemoveObserver(this); | 411 parent_->RemoveObserver(this); |
| 410 if (surface_) { | 412 if (surface_) { |
| 411 if (scale_ != 1.0) | 413 if (scale_ != 1.0) |
| 412 surface_->window()->SetTransform(gfx::Transform()); | 414 surface_->window()->SetTransform(gfx::Transform()); |
| 413 surface_->SetSurfaceDelegate(nullptr); | 415 surface_->SetSurfaceDelegate(nullptr); |
| 414 surface_->RemoveSurfaceObserver(this); | 416 surface_->RemoveSurfaceObserver(this); |
| 415 } | 417 } |
| 416 WMHelper::GetInstance()->RemoveAccessibilityObserver(this); | 418 WMHelper::GetInstance()->RemoveAccessibilityObserver(this); |
| 417 } | 419 } |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 927 | 929 |
| 928 //////////////////////////////////////////////////////////////////////////////// | 930 //////////////////////////////////////////////////////////////////////////////// |
| 929 // ash::wm::WindowStateObserver overrides: | 931 // ash::wm::WindowStateObserver overrides: |
| 930 | 932 |
| 931 void ShellSurface::OnPreWindowStateTypeChange( | 933 void ShellSurface::OnPreWindowStateTypeChange( |
| 932 ash::wm::WindowState* window_state, | 934 ash::wm::WindowState* window_state, |
| 933 ash::wm::WindowStateType old_type) { | 935 ash::wm::WindowStateType old_type) { |
| 934 ash::wm::WindowStateType new_type = window_state->GetStateType(); | 936 ash::wm::WindowStateType new_type = window_state->GetStateType(); |
| 935 if (ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(old_type) || | 937 if (ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(old_type) || |
| 936 ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(new_type)) { | 938 ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(new_type)) { |
| 939 EndDragOrMove(false /* revert */); | |
|
reveman
2017/01/23 20:23:48
how is other chrome windows handling this?
Dominik Laskowski
2017/01/23 23:01:36
It's not handled. If you enter full screen after d
reveman
2017/01/26 06:50:21
That sounds like a bug. Is there a more general wa
| |
| 940 | |
| 937 // When transitioning in/out of maximized or fullscreen mode we need to | 941 // When transitioning in/out of maximized or fullscreen mode we need to |
| 938 // make sure we have a configure callback before we allow the default | 942 // make sure we have a configure callback before we allow the default |
| 939 // cross-fade animations. The configure callback provides a mechanism for | 943 // cross-fade animations. The configure callback provides a mechanism for |
| 940 // the client to inform us that a frame has taken the state change into | 944 // the client to inform us that a frame has taken the state change into |
| 941 // account and without this cross-fade animations are unreliable. | 945 // account and without this cross-fade animations are unreliable. |
| 942 if (configure_callback_.is_null()) | 946 if (configure_callback_.is_null()) |
| 943 scoped_animations_disabled_.reset(new ScopedAnimationsDisabled(this)); | 947 scoped_animations_disabled_.reset(new ScopedAnimationsDisabled(this)); |
| 944 } | 948 } |
| 945 } | 949 } |
| 946 | 950 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1021 | 1025 |
| 1022 if (gained_active == widget_->GetNativeWindow() || | 1026 if (gained_active == widget_->GetNativeWindow() || |
| 1023 lost_active == widget_->GetNativeWindow()) { | 1027 lost_active == widget_->GetNativeWindow()) { |
| 1024 DCHECK(activatable_); | 1028 DCHECK(activatable_); |
| 1025 Configure(); | 1029 Configure(); |
| 1026 UpdateShadow(); | 1030 UpdateShadow(); |
| 1027 } | 1031 } |
| 1028 } | 1032 } |
| 1029 | 1033 |
| 1030 //////////////////////////////////////////////////////////////////////////////// | 1034 //////////////////////////////////////////////////////////////////////////////// |
| 1035 // WMHelper::ShellObserver overrides: | |
| 1036 | |
| 1037 void ShellSurface::OnOverviewModeStarted() { | |
| 1038 EndDragOrMove(false /* revert */); | |
|
reveman
2017/01/23 20:23:48
is this also a problem for non-exo window dragging
Dominik Laskowski
2017/01/23 23:01:36
Yes, entering/exiting overview mode while dragging
reveman
2017/01/26 06:50:21
Ok, let's do Ash first and once that lands we'll m
| |
| 1039 ignore_widget_bounds_changes_ = true; | |
|
reveman
2017/01/23 20:23:48
why is this needed? seems fragile to rely on us de
Dominik Laskowski
2017/01/23 23:01:36
When entering overview mode, a lost focus event ca
reveman
2017/01/26 06:50:21
Why do they need to be discarded? Doesn't this lea
| |
| 1040 } | |
| 1041 | |
| 1042 void ShellSurface::OnOverviewModeEnded() { | |
| 1043 ignore_widget_bounds_changes_ = false; | |
| 1044 } | |
| 1045 | |
| 1046 //////////////////////////////////////////////////////////////////////////////// | |
| 1031 // WMHelper::AccessibilityObserver overrides: | 1047 // WMHelper::AccessibilityObserver overrides: |
| 1032 | 1048 |
| 1033 void ShellSurface::OnAccessibilityModeChanged() { | 1049 void ShellSurface::OnAccessibilityModeChanged() { |
| 1034 UpdateShadow(); | 1050 UpdateShadow(); |
| 1035 } | 1051 } |
| 1036 | 1052 |
| 1037 //////////////////////////////////////////////////////////////////////////////// | 1053 //////////////////////////////////////////////////////////////////////////////// |
| 1038 // ui::EventHandler overrides: | 1054 // ui::EventHandler overrides: |
| 1039 | 1055 |
| 1040 void ShellSurface::OnKeyEvent(ui::KeyEvent* event) { | 1056 void ShellSurface::OnKeyEvent(ui::KeyEvent* event) { |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1403 // Return early if the shell is currently managing the bounds of the widget. | 1419 // Return early if the shell is currently managing the bounds of the widget. |
| 1404 // 1) When a window is either maximized/fullscreen/pinned, and the bounds | 1420 // 1) When a window is either maximized/fullscreen/pinned, and the bounds |
| 1405 // isn't controlled by a client. | 1421 // isn't controlled by a client. |
| 1406 ash::wm::WindowState* window_state = | 1422 ash::wm::WindowState* window_state = |
| 1407 ash::wm::GetWindowState(widget_->GetNativeWindow()); | 1423 ash::wm::GetWindowState(widget_->GetNativeWindow()); |
| 1408 if (window_state->IsMaximizedOrFullscreenOrPinned() && | 1424 if (window_state->IsMaximizedOrFullscreenOrPinned() && |
| 1409 !window_state->allow_set_bounds_in_maximized()) { | 1425 !window_state->allow_set_bounds_in_maximized()) { |
| 1410 return; | 1426 return; |
| 1411 } | 1427 } |
| 1412 | 1428 |
| 1413 // 2) When a window is being dragged. | 1429 // 2) When a window is being dragged, or is being moved by the shell. |
| 1414 if (IsResizing()) | 1430 if (IsResizing() || ignore_widget_bounds_changes_) |
| 1415 return; | 1431 return; |
| 1416 | 1432 |
| 1417 // Return early if there is pending configure requests. | 1433 // Return early if there is pending configure requests. |
| 1418 if (!pending_configs_.empty() || scoped_configure_) | 1434 if (!pending_configs_.empty() || scoped_configure_) |
| 1419 return; | 1435 return; |
| 1420 | 1436 |
| 1421 gfx::Rect visible_bounds = GetVisibleBounds(); | 1437 gfx::Rect visible_bounds = GetVisibleBounds(); |
| 1422 gfx::Rect new_widget_bounds = | 1438 gfx::Rect new_widget_bounds = |
| 1423 widget_->non_client_view()->GetWindowBoundsForClientBounds( | 1439 widget_->non_client_view()->GetWindowBoundsForClientBounds( |
| 1424 visible_bounds); | 1440 visible_bounds); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1586 gfx::Point ShellSurface::GetMouseLocation() const { | 1602 gfx::Point ShellSurface::GetMouseLocation() const { |
| 1587 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); | 1603 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); |
| 1588 gfx::Point location = | 1604 gfx::Point location = |
| 1589 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); | 1605 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); |
| 1590 aura::Window::ConvertPointToTarget( | 1606 aura::Window::ConvertPointToTarget( |
| 1591 root_window, widget_->GetNativeWindow()->parent(), &location); | 1607 root_window, widget_->GetNativeWindow()->parent(), &location); |
| 1592 return location; | 1608 return location; |
| 1593 } | 1609 } |
| 1594 | 1610 |
| 1595 } // namespace exo | 1611 } // namespace exo |
| OLD | NEW |