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/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_shell.h" |
| 14 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
| 15 #include "ash/public/cpp/shell_window_ids.h" | 15 #include "ash/public/cpp/shell_window_ids.h" |
| 16 #include "ash/public/cpp/window_properties.h" | |
| 16 #include "ash/wm/drag_window_resizer.h" | 17 #include "ash/wm/drag_window_resizer.h" |
| 17 #include "ash/wm/window_state_aura.h" | 18 #include "ash/wm/window_state_aura.h" |
| 18 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 19 #include "base/logging.h" | 20 #include "base/logging.h" |
| 20 #include "base/macros.h" | 21 #include "base/macros.h" |
| 21 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
| 24 #include "base/trace_event/trace_event_argument.h" | 25 #include "base/trace_event/trace_event_argument.h" |
| 25 #include "components/exo/surface.h" | 26 #include "components/exo/surface.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 42 #include "ui/wm/core/window_animations.h" | 43 #include "ui/wm/core/window_animations.h" |
| 43 #include "ui/wm/core/window_util.h" | 44 #include "ui/wm/core/window_util.h" |
| 44 | 45 |
| 45 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
| 46 #include "chromeos/audio/chromeos_sounds.h" | 47 #include "chromeos/audio/chromeos_sounds.h" |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 namespace exo { | 50 namespace exo { |
| 50 namespace { | 51 namespace { |
| 51 | 52 |
| 53 ash::mojom::WindowPinType GetPinType(bool pinned, bool trusted) { | |
|
reveman
2017/04/04 07:13:14
Please change ShellSurface::SetPinned to take an a
Peng
2017/04/04 15:08:14
Done.
| |
| 54 if (pinned) { | |
| 55 return trusted ? ash::mojom::WindowPinType::TRUSTED_PINNED | |
| 56 : ash::mojom::WindowPinType::PINNED; | |
| 57 } | |
| 58 return ash::mojom::WindowPinType::NONE; | |
| 59 } | |
| 60 | |
| 52 // This is a struct for accelerator keys used to close ShellSurfaces. | 61 // This is a struct for accelerator keys used to close ShellSurfaces. |
| 53 const struct Accelerator { | 62 const struct Accelerator { |
| 54 ui::KeyboardCode keycode; | 63 ui::KeyboardCode keycode; |
| 55 int modifiers; | 64 int modifiers; |
| 56 } kCloseWindowAccelerators[] = { | 65 } kCloseWindowAccelerators[] = { |
| 57 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, | 66 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, |
| 58 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, | 67 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, |
| 59 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; | 68 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; |
| 60 | 69 |
| 61 class CustomFrameView : public views::NonClientFrameView { | 70 class CustomFrameView : public views::NonClientFrameView { |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 void ShellSurface::SetPinned(bool pinned, bool trusted) { | 494 void ShellSurface::SetPinned(bool pinned, bool trusted) { |
| 486 TRACE_EVENT2("exo", "ShellSurface::SetPinned", "pinned", pinned, "trusted", | 495 TRACE_EVENT2("exo", "ShellSurface::SetPinned", "pinned", pinned, "trusted", |
| 487 trusted); | 496 trusted); |
| 488 | 497 |
| 489 if (!widget_) | 498 if (!widget_) |
| 490 CreateShellSurfaceWidget(ui::SHOW_STATE_NORMAL); | 499 CreateShellSurfaceWidget(ui::SHOW_STATE_NORMAL); |
| 491 | 500 |
| 492 // Note: This will ask client to configure its surface even if pinned | 501 // Note: This will ask client to configure its surface even if pinned |
| 493 // state doesn't change. | 502 // state doesn't change. |
| 494 ScopedConfigure scoped_configure(this, true); | 503 ScopedConfigure scoped_configure(this, true); |
| 495 if (pinned) { | 504 widget_->GetNativeWindow()->SetProperty(ash::kWindowPinTypeKey, |
| 496 ash::wm::PinWindow(widget_->GetNativeWindow(), trusted); | 505 GetPinType(pinned, trusted)); |
| 497 } else { | |
| 498 // At the moment, we cannot just unpin the window state, due to ash | |
| 499 // implementation. Instead, we call Restore() to unpin, if it is Pinned | |
| 500 // state. In this implementation, we may loose the previous state, | |
| 501 // if the previous state is fullscreen, etc. | |
| 502 if (ash::wm::GetWindowState(widget_->GetNativeWindow())->IsPinned()) | |
| 503 widget_->Restore(); | |
| 504 } | |
| 505 } | 506 } |
| 506 | 507 |
| 507 void ShellSurface::SetSystemUiVisibility(bool autohide) { | 508 void ShellSurface::SetSystemUiVisibility(bool autohide) { |
| 508 TRACE_EVENT1("exo", "ShellSurface::SetSystemUiVisibility", "autohide", | 509 TRACE_EVENT1("exo", "ShellSurface::SetSystemUiVisibility", "autohide", |
| 509 autohide); | 510 autohide); |
| 510 ash::wm::SetAutoHideShelf(widget_->GetNativeWindow(), autohide); | 511 ash::wm::SetAutoHideShelf(widget_->GetNativeWindow(), autohide); |
| 511 } | 512 } |
| 512 | 513 |
| 513 void ShellSurface::SetTitle(const base::string16& title) { | 514 void ShellSurface::SetTitle(const base::string16& title) { |
| 514 TRACE_EVENT1("exo", "ShellSurface::SetTitle", "title", | 515 TRACE_EVENT1("exo", "ShellSurface::SetTitle", "title", |
| (...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1705 gfx::Point ShellSurface::GetMouseLocation() const { | 1706 gfx::Point ShellSurface::GetMouseLocation() const { |
| 1706 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); | 1707 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); |
| 1707 gfx::Point location = | 1708 gfx::Point location = |
| 1708 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); | 1709 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); |
| 1709 aura::Window::ConvertPointToTarget( | 1710 aura::Window::ConvertPointToTarget( |
| 1710 root_window, widget_->GetNativeWindow()->parent(), &location); | 1711 root_window, widget_->GetNativeWindow()->parent(), &location); |
| 1711 return location; | 1712 return location; |
| 1712 } | 1713 } |
| 1713 | 1714 |
| 1714 } // namespace exo | 1715 } // namespace exo |
| OLD | NEW |