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 | 8 |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/accessibility_delegate.h" | |
| 11 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 13 #include "ash/common/system/tray/system_tray_notifier.h" | |
| 14 #include "ash/common/wm/window_resizer.h" | 12 #include "ash/common/wm/window_resizer.h" |
| 15 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 16 #include "ash/common/wm/window_state_delegate.h" | 14 #include "ash/common/wm/window_state_delegate.h" |
| 17 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
| 18 #include "ash/wm/window_state_aura.h" | 16 #include "ash/wm/window_state_aura.h" |
| 19 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 20 #include "base/logging.h" | 18 #include "base/logging.h" |
| 21 #include "base/macros.h" | 19 #include "base/macros.h" |
| 22 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 ui::ET_TOUCH_PRESSED, | 226 ui::ET_TOUCH_PRESSED, |
| 229 ui::ET_POINTER_DOWN, | 227 ui::ET_POINTER_DOWN, |
| 230 ui::ET_POINTER_WHEEL_CHANGED, | 228 ui::ET_POINTER_WHEEL_CHANGED, |
| 231 ui::ET_GESTURE_BEGIN, | 229 ui::ET_GESTURE_BEGIN, |
| 232 ui::ET_SCROLL, | 230 ui::ET_SCROLL, |
| 233 ui::ET_SCROLL_FLING_START}; | 231 ui::ET_SCROLL_FLING_START}; |
| 234 bool is_earcon_event_type = | 232 bool is_earcon_event_type = |
| 235 std::find(std::begin(kEarconEventTypes), std::end(kEarconEventTypes), | 233 std::find(std::begin(kEarconEventTypes), std::end(kEarconEventTypes), |
| 236 event->type()) != std::end(kEarconEventTypes); | 234 event->type()) != std::end(kEarconEventTypes); |
| 237 if (is_earcon_event_type) | 235 if (is_earcon_event_type) |
| 238 ash::WmShell::Get()->accessibility_delegate()->PlayEarcon( | 236 WMHelper::GetInstance()->PlayEarcon(chromeos::SOUND_VOLUME_ADJUST); |
| 239 chromeos::SOUND_VOLUME_ADJUST); | |
| 240 #endif | 237 #endif |
| 241 event->SetHandled(); | 238 event->SetHandled(); |
| 242 } | 239 } |
| 243 } | 240 } |
| 244 | 241 |
| 245 private: | 242 private: |
| 246 DISALLOW_COPY_AND_ASSIGN(ShadowUnderlayEventHandler); | 243 DISALLOW_COPY_AND_ASSIGN(ShadowUnderlayEventHandler); |
| 247 }; | 244 }; |
| 248 | 245 |
| 249 } // namespace | 246 } // namespace |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 } | 372 } |
| 376 WMHelper::GetInstance()->RemoveActivationObserver(this); | 373 WMHelper::GetInstance()->RemoveActivationObserver(this); |
| 377 if (parent_) | 374 if (parent_) |
| 378 parent_->RemoveObserver(this); | 375 parent_->RemoveObserver(this); |
| 379 if (surface_) { | 376 if (surface_) { |
| 380 if (scale_ != 1.0) | 377 if (scale_ != 1.0) |
| 381 surface_->window()->SetTransform(gfx::Transform()); | 378 surface_->window()->SetTransform(gfx::Transform()); |
| 382 surface_->SetSurfaceDelegate(nullptr); | 379 surface_->SetSurfaceDelegate(nullptr); |
| 383 surface_->RemoveSurfaceObserver(this); | 380 surface_->RemoveSurfaceObserver(this); |
| 384 } | 381 } |
| 385 ash::WmShell::Get()->system_tray_notifier()->RemoveAccessibilityObserver( | 382 WMHelper::GetInstance()->RemoveAccessibilityObserver(this); |
| 386 this); | |
| 387 } | 383 } |
| 388 | 384 |
| 389 void ShellSurface::AcknowledgeConfigure(uint32_t serial) { | 385 void ShellSurface::AcknowledgeConfigure(uint32_t serial) { |
| 390 TRACE_EVENT1("exo", "ShellSurface::AcknowledgeConfigure", "serial", serial); | 386 TRACE_EVENT1("exo", "ShellSurface::AcknowledgeConfigure", "serial", serial); |
| 391 | 387 |
| 392 // Apply all configs that are older or equal to |serial|. The result is that | 388 // Apply all configs that are older or equal to |serial|. The result is that |
| 393 // the origin of the main surface will move and the resize direction will | 389 // the origin of the main surface will move and the resize direction will |
| 394 // change to reflect the acknowledgement of configure request with |serial| | 390 // change to reflect the acknowledgement of configure request with |serial| |
| 395 // at the next call to Commit(). | 391 // at the next call to Commit(). |
| 396 while (!pending_configs_.empty()) { | 392 while (!pending_configs_.empty()) { |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 801 // views::Views overrides: | 797 // views::Views overrides: |
| 802 | 798 |
| 803 gfx::Size ShellSurface::GetPreferredSize() const { | 799 gfx::Size ShellSurface::GetPreferredSize() const { |
| 804 if (!geometry_.IsEmpty()) | 800 if (!geometry_.IsEmpty()) |
| 805 return geometry_.size(); | 801 return geometry_.size(); |
| 806 | 802 |
| 807 return surface_ ? surface_->window()->layer()->size() : gfx::Size(); | 803 return surface_ ? surface_->window()->layer()->size() : gfx::Size(); |
| 808 } | 804 } |
| 809 | 805 |
| 810 //////////////////////////////////////////////////////////////////////////////// | 806 //////////////////////////////////////////////////////////////////////////////// |
| 811 // ash::AccessibilityObserver overrides: | |
| 812 | |
| 813 void ShellSurface::OnAccessibilityModeChanged( | |
| 814 ash::AccessibilityNotificationVisibility) { | |
| 815 UpdateShadow(); | |
| 816 } | |
| 817 | |
| 818 //////////////////////////////////////////////////////////////////////////////// | |
| 819 // ash::wm::WindowStateObserver overrides: | 807 // ash::wm::WindowStateObserver overrides: |
| 820 | 808 |
| 821 void ShellSurface::OnPreWindowStateTypeChange( | 809 void ShellSurface::OnPreWindowStateTypeChange( |
| 822 ash::wm::WindowState* window_state, | 810 ash::wm::WindowState* window_state, |
| 823 ash::wm::WindowStateType old_type) { | 811 ash::wm::WindowStateType old_type) { |
| 824 ash::wm::WindowStateType new_type = window_state->GetStateType(); | 812 ash::wm::WindowStateType new_type = window_state->GetStateType(); |
| 825 if (ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(old_type) || | 813 if (ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(old_type) || |
| 826 ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(new_type)) { | 814 ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(new_type)) { |
| 827 // When transitioning in/out of maximized or fullscreen mode we need to | 815 // When transitioning in/out of maximized or fullscreen mode we need to |
| 828 // make sure we have a configure callback before we allow the default | 816 // make sure we have a configure callback before we allow the default |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 909 | 897 |
| 910 if (gained_active == widget_->GetNativeWindow() || | 898 if (gained_active == widget_->GetNativeWindow() || |
| 911 lost_active == widget_->GetNativeWindow()) { | 899 lost_active == widget_->GetNativeWindow()) { |
| 912 DCHECK(activatable_); | 900 DCHECK(activatable_); |
| 913 Configure(); | 901 Configure(); |
| 914 UpdateShadow(); | 902 UpdateShadow(); |
| 915 } | 903 } |
| 916 } | 904 } |
| 917 | 905 |
| 918 //////////////////////////////////////////////////////////////////////////////// | 906 //////////////////////////////////////////////////////////////////////////////// |
| 907 // WMHelper::AccessibilityObserver overrides: | |
| 908 | |
| 909 void ShellSurface::OnAccessibilityModeChanged() { | |
| 910 UpdateShadow(); | |
| 911 } | |
| 912 | |
| 913 //////////////////////////////////////////////////////////////////////////////// | |
| 919 // ui::EventHandler overrides: | 914 // ui::EventHandler overrides: |
| 920 | 915 |
| 921 void ShellSurface::OnKeyEvent(ui::KeyEvent* event) { | 916 void ShellSurface::OnKeyEvent(ui::KeyEvent* event) { |
| 922 if (!resizer_) { | 917 if (!resizer_) { |
| 923 views::View::OnKeyEvent(event); | 918 views::View::OnKeyEvent(event); |
| 924 return; | 919 return; |
| 925 } | 920 } |
| 926 | 921 |
| 927 if (event->type() == ui::ET_KEY_PRESSED && | 922 if (event->type() == ui::ET_KEY_PRESSED && |
| 928 event->key_code() == ui::VKEY_ESCAPE) { | 923 event->key_code() == ui::VKEY_ESCAPE) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 focus_manager->RegisterAccelerator( | 1062 focus_manager->RegisterAccelerator( |
| 1068 ui::Accelerator(entry.keycode, entry.modifiers), | 1063 ui::Accelerator(entry.keycode, entry.modifiers), |
| 1069 ui::AcceleratorManager::kNormalPriority, this); | 1064 ui::AcceleratorManager::kNormalPriority, this); |
| 1070 } | 1065 } |
| 1071 | 1066 |
| 1072 // Set delegate for handling of fullscreening. | 1067 // Set delegate for handling of fullscreening. |
| 1073 window_state->SetDelegate(std::unique_ptr<ash::wm::WindowStateDelegate>( | 1068 window_state->SetDelegate(std::unique_ptr<ash::wm::WindowStateDelegate>( |
| 1074 new CustomWindowStateDelegate(widget_))); | 1069 new CustomWindowStateDelegate(widget_))); |
| 1075 | 1070 |
| 1076 // Receive accessibility changes to update shadow underlay. | 1071 // Receive accessibility changes to update shadow underlay. |
| 1077 ash::WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 1072 WMHelper::GetInstance()->AddAccessibilityObserver(this); |
|
David Tseng
2017/01/17 22:43:41
I don't understand how your cl replaces this obser
| |
| 1078 | 1073 |
| 1079 // Show widget next time Commit() is called. | 1074 // Show widget next time Commit() is called. |
| 1080 pending_show_widget_ = true; | 1075 pending_show_widget_ = true; |
| 1081 } | 1076 } |
| 1082 | 1077 |
| 1083 void ShellSurface::Configure() { | 1078 void ShellSurface::Configure() { |
| 1084 DCHECK(widget_); | 1079 DCHECK(widget_); |
| 1085 | 1080 |
| 1086 // Delay configure callback if |scoped_configure_| is set. | 1081 // Delay configure callback if |scoped_configure_| is set. |
| 1087 if (scoped_configure_) { | 1082 if (scoped_configure_) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1343 // Clients that provide translucent contents should not be using | 1338 // Clients that provide translucent contents should not be using |
| 1344 // rectangular shadows as this method requires opaque contents to | 1339 // rectangular shadows as this method requires opaque contents to |
| 1345 // cast a shadow that represent it correctly. | 1340 // cast a shadow that represent it correctly. |
| 1346 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); | 1341 shadow_underlay_->Init(ui::LAYER_SOLID_COLOR); |
| 1347 shadow_underlay_->layer()->SetColor(SK_ColorBLACK); | 1342 shadow_underlay_->layer()->SetColor(SK_ColorBLACK); |
| 1348 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); | 1343 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); |
| 1349 window->AddChild(shadow_underlay_); | 1344 window->AddChild(shadow_underlay_); |
| 1350 window->StackChildAtBottom(shadow_underlay_); | 1345 window->StackChildAtBottom(shadow_underlay_); |
| 1351 } | 1346 } |
| 1352 | 1347 |
| 1353 bool underlay_capture_events = ash::WmShell::Get() | 1348 bool underlay_capture_events = |
| 1354 ->accessibility_delegate() | 1349 WMHelper::GetInstance()->IsSpokenFeedbackEnabled() && |
| 1355 ->IsSpokenFeedbackEnabled() && | 1350 widget_->IsActive(); |
| 1356 widget_->IsActive(); | |
| 1357 | 1351 |
| 1358 float shadow_underlay_opacity = rectangular_shadow_background_opacity_; | 1352 float shadow_underlay_opacity = rectangular_shadow_background_opacity_; |
| 1359 // Put the black background layer behind the window if | 1353 // Put the black background layer behind the window if |
| 1360 // 1) the window is in immersive fullscreen or is active with | 1354 // 1) the window is in immersive fullscreen or is active with |
| 1361 // spoken feedback enabled. | 1355 // spoken feedback enabled. |
| 1362 // 2) the window can control the bounds of the window in fullscreen ( | 1356 // 2) the window can control the bounds of the window in fullscreen ( |
| 1363 // thus the background can be visible). | 1357 // thus the background can be visible). |
| 1364 // 3) the window has no transform (the transformed background may | 1358 // 3) the window has no transform (the transformed background may |
| 1365 // not cover the entire background, e.g. overview mode). | 1359 // not cover the entire background, e.g. overview mode). |
| 1366 if ((widget_->IsFullscreen() || underlay_capture_events) && | 1360 if ((widget_->IsFullscreen() || underlay_capture_events) && |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1397 shadow_overlay_->layer()->Add(shadow->layer()); | 1391 shadow_overlay_->layer()->Add(shadow->layer()); |
| 1398 window->AddChild(shadow_overlay_); | 1392 window->AddChild(shadow_overlay_); |
| 1399 shadow_overlay_->Show(); | 1393 shadow_overlay_->Show(); |
| 1400 } | 1394 } |
| 1401 shadow_overlay_->SetBounds(shadow_bounds); | 1395 shadow_overlay_->SetBounds(shadow_bounds); |
| 1402 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); | 1396 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); |
| 1403 } | 1397 } |
| 1404 } | 1398 } |
| 1405 | 1399 |
| 1406 } // namespace exo | 1400 } // namespace exo |
| OLD | NEW |