| 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/frame/custom_frame_view_ash.h" | 9 #include "ash/frame/custom_frame_view_ash.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "ui/wm/core/coordinate_conversion.h" | 39 #include "ui/wm/core/coordinate_conversion.h" |
| 40 #include "ui/wm/core/shadow.h" | 40 #include "ui/wm/core/shadow.h" |
| 41 #include "ui/wm/core/shadow_controller.h" | 41 #include "ui/wm/core/shadow_controller.h" |
| 42 #include "ui/wm/core/shadow_types.h" | 42 #include "ui/wm/core/shadow_types.h" |
| 43 #include "ui/wm/core/window_animations.h" | 43 #include "ui/wm/core/window_animations.h" |
| 44 #include "ui/wm/core/window_util.h" | 44 #include "ui/wm/core/window_util.h" |
| 45 | 45 |
| 46 namespace exo { | 46 namespace exo { |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr) |
| 50 |
| 51 // Application Id set by the client. |
| 52 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kApplicationIdKey, nullptr); |
| 53 |
| 49 // This is a struct for accelerator keys used to close ShellSurfaces. | 54 // This is a struct for accelerator keys used to close ShellSurfaces. |
| 50 const struct Accelerator { | 55 const struct Accelerator { |
| 51 ui::KeyboardCode keycode; | 56 ui::KeyboardCode keycode; |
| 52 int modifiers; | 57 int modifiers; |
| 53 } kCloseWindowAccelerators[] = { | 58 } kCloseWindowAccelerators[] = { |
| 54 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, | 59 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, |
| 55 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, | 60 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, |
| 56 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; | 61 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; |
| 57 | 62 |
| 58 class CustomFrameView : public views::NonClientFrameView { | 63 class CustomFrameView : public views::NonClientFrameView { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 aura::Window* window = shell_surface_->widget_->GetNativeWindow(); | 269 aura::Window* window = shell_surface_->widget_->GetNativeWindow(); |
| 265 DCHECK_EQ(window->GetProperty(aura::client::kAnimationsDisabledKey), true); | 270 DCHECK_EQ(window->GetProperty(aura::client::kAnimationsDisabledKey), true); |
| 266 window->SetProperty(aura::client::kAnimationsDisabledKey, | 271 window->SetProperty(aura::client::kAnimationsDisabledKey, |
| 267 saved_animations_disabled_); | 272 saved_animations_disabled_); |
| 268 } | 273 } |
| 269 } | 274 } |
| 270 | 275 |
| 271 //////////////////////////////////////////////////////////////////////////////// | 276 //////////////////////////////////////////////////////////////////////////////// |
| 272 // ShellSurface, public: | 277 // ShellSurface, public: |
| 273 | 278 |
| 274 DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr) | |
| 275 | |
| 276 ShellSurface::ShellSurface(Surface* surface, | 279 ShellSurface::ShellSurface(Surface* surface, |
| 277 ShellSurface* parent, | 280 ShellSurface* parent, |
| 278 BoundsMode bounds_mode, | 281 BoundsMode bounds_mode, |
| 279 const gfx::Point& origin, | 282 const gfx::Point& origin, |
| 280 bool activatable, | 283 bool activatable, |
| 281 bool can_minimize, | 284 bool can_minimize, |
| 282 int container) | 285 int container) |
| 283 : widget_(nullptr), | 286 : widget_(nullptr), |
| 284 surface_(surface), | 287 surface_(surface), |
| 285 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), | 288 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 DCHECK_EQ(container_, ash::kShellWindowId_SystemModalContainer); | 510 DCHECK_EQ(container_, ash::kShellWindowId_SystemModalContainer); |
| 508 widget_->GetNativeWindow()->SetProperty( | 511 widget_->GetNativeWindow()->SetProperty( |
| 509 aura::client::kModalKey, | 512 aura::client::kModalKey, |
| 510 system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE); | 513 system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE); |
| 511 } | 514 } |
| 512 | 515 |
| 513 // static | 516 // static |
| 514 void ShellSurface::SetApplicationId(aura::Window* window, | 517 void ShellSurface::SetApplicationId(aura::Window* window, |
| 515 const std::string& id) { | 518 const std::string& id) { |
| 516 TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id", id); | 519 TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id", id); |
| 517 const ash::ShelfID shelf_id(id); | 520 window->SetProperty(kApplicationIdKey, new std::string(id)); |
| 518 window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize())); | |
| 519 } | 521 } |
| 520 | 522 |
| 521 // static | 523 // static |
| 522 const std::string ShellSurface::GetApplicationId(aura::Window* window) { | 524 const std::string* ShellSurface::GetApplicationId(aura::Window* window) { |
| 523 return ash::ShelfID::Deserialize(window->GetProperty(ash::kShelfIDKey)) | 525 return window->GetProperty(kApplicationIdKey); |
| 524 .app_id; | |
| 525 } | 526 } |
| 526 | 527 |
| 527 void ShellSurface::SetApplicationId(const std::string& application_id) { | 528 void ShellSurface::SetApplicationId(const std::string& application_id) { |
| 528 // Store the value in |application_id_| in case the window does not exist yet. | 529 // Store the value in |application_id_| in case the window does not exist yet. |
| 529 application_id_ = application_id; | 530 application_id_ = application_id; |
| 530 if (widget_ && widget_->GetNativeWindow()) | 531 if (widget_ && widget_->GetNativeWindow()) |
| 531 SetApplicationId(widget_->GetNativeWindow(), application_id); | 532 SetApplicationId(widget_->GetNativeWindow(), application_id); |
| 532 } | 533 } |
| 533 | 534 |
| 534 void ShellSurface::Move() { | 535 void ShellSurface::Move() { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 // static | 666 // static |
| 666 Surface* ShellSurface::GetMainSurface(const aura::Window* window) { | 667 Surface* ShellSurface::GetMainSurface(const aura::Window* window) { |
| 667 return window->GetProperty(kMainSurfaceKey); | 668 return window->GetProperty(kMainSurfaceKey); |
| 668 } | 669 } |
| 669 | 670 |
| 670 std::unique_ptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue() | 671 std::unique_ptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue() |
| 671 const { | 672 const { |
| 672 std::unique_ptr<base::trace_event::TracedValue> value( | 673 std::unique_ptr<base::trace_event::TracedValue> value( |
| 673 new base::trace_event::TracedValue()); | 674 new base::trace_event::TracedValue()); |
| 674 value->SetString("title", base::UTF16ToUTF8(title_)); | 675 value->SetString("title", base::UTF16ToUTF8(title_)); |
| 675 std::string application_id; | 676 if (GetWidget() && GetWidget()->GetNativeWindow()) { |
| 676 if (GetWidget() && GetWidget()->GetNativeWindow()) | 677 const std::string* application_id = |
| 677 application_id = GetApplicationId(GetWidget()->GetNativeWindow()); | 678 GetApplicationId(GetWidget()->GetNativeWindow()); |
| 678 value->SetString("application_id", application_id); | 679 |
| 680 if (application_id) |
| 681 value->SetString("application_id", *application_id); |
| 682 } |
| 679 return value; | 683 return value; |
| 680 } | 684 } |
| 681 | 685 |
| 682 //////////////////////////////////////////////////////////////////////////////// | 686 //////////////////////////////////////////////////////////////////////////////// |
| 683 // SurfaceDelegate overrides: | 687 // SurfaceDelegate overrides: |
| 684 | 688 |
| 685 void ShellSurface::OnSurfaceCommit() { | 689 void ShellSurface::OnSurfaceCommit() { |
| 686 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); | 690 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 687 surface_->CommitSurfaceHierarchy(); | 691 surface_->CommitSurfaceHierarchy(); |
| 688 | 692 |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 gfx::Point ShellSurface::GetMouseLocation() const { | 1670 gfx::Point ShellSurface::GetMouseLocation() const { |
| 1667 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); | 1671 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); |
| 1668 gfx::Point location = | 1672 gfx::Point location = |
| 1669 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); | 1673 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); |
| 1670 aura::Window::ConvertPointToTarget( | 1674 aura::Window::ConvertPointToTarget( |
| 1671 root_window, widget_->GetNativeWindow()->parent(), &location); | 1675 root_window, widget_->GetNativeWindow()->parent(), &location); |
| 1672 return location; | 1676 return location; |
| 1673 } | 1677 } |
| 1674 | 1678 |
| 1675 } // namespace exo | 1679 } // namespace exo |
| OLD | NEW |