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/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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 window->SetProperty(aura::client::kAnimationsDisabledKey, | 306 window->SetProperty(aura::client::kAnimationsDisabledKey, |
| 307 saved_animations_disabled_); | 307 saved_animations_disabled_); |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 //////////////////////////////////////////////////////////////////////////////// | 311 //////////////////////////////////////////////////////////////////////////////// |
| 312 // ShellSurface, public: | 312 // ShellSurface, public: |
| 313 | 313 |
| 314 DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr) | 314 DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr) |
| 315 | 315 |
| 316 namespace { | |
|
reveman
2017/05/17 15:31:06
nit: for consistency, please remove this namespace
yawano
2017/05/18 02:06:28
Done. Moved it to the anonymous namespace at the t
| |
| 317 | |
| 318 // An application Id which is set by a wayland server. This property is not | |
|
reveman
2017/05/17 15:31:06
This code should not be referring to wayland. How
yawano
2017/05/18 02:06:28
Done.
| |
| 319 // exported. | |
| 320 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kExoAppIdKey, nullptr); | |
| 321 | |
| 322 } // namespace | |
| 323 | |
| 316 ShellSurface::ShellSurface(Surface* surface, | 324 ShellSurface::ShellSurface(Surface* surface, |
| 317 ShellSurface* parent, | 325 ShellSurface* parent, |
| 318 BoundsMode bounds_mode, | 326 BoundsMode bounds_mode, |
| 319 const gfx::Point& origin, | 327 const gfx::Point& origin, |
| 320 bool activatable, | 328 bool activatable, |
| 321 bool can_minimize, | 329 bool can_minimize, |
| 322 int container) | 330 int container) |
| 323 : widget_(nullptr), | 331 : widget_(nullptr), |
| 324 surface_(surface), | 332 surface_(surface), |
| 325 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), | 333 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 DCHECK_EQ(container_, ash::kShellWindowId_SystemModalContainer); | 556 DCHECK_EQ(container_, ash::kShellWindowId_SystemModalContainer); |
| 549 widget_->GetNativeWindow()->SetProperty( | 557 widget_->GetNativeWindow()->SetProperty( |
| 550 aura::client::kModalKey, | 558 aura::client::kModalKey, |
| 551 system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE); | 559 system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE); |
| 552 } | 560 } |
| 553 | 561 |
| 554 // static | 562 // static |
| 555 void ShellSurface::SetApplicationId(aura::Window* window, | 563 void ShellSurface::SetApplicationId(aura::Window* window, |
| 556 const std::string& id) { | 564 const std::string& id) { |
| 557 TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id", id); | 565 TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id", id); |
| 558 const ash::ShelfID shelf_id(id); | 566 window->SetProperty(kExoAppIdKey, new std::string(id)); |
| 559 window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize())); | |
| 560 } | 567 } |
| 561 | 568 |
| 562 // static | 569 // static |
| 563 const std::string ShellSurface::GetApplicationId(aura::Window* window) { | 570 const std::string ShellSurface::GetApplicationId(aura::Window* window) { |
|
reveman
2017/05/17 15:31:06
can this return a pointer instead so we don't have
yawano
2017/05/18 02:06:28
Done.
| |
| 564 return ash::ShelfID::Deserialize(window->GetProperty(ash::kShelfIDKey)) | 571 std::string* string_ptr = window->GetProperty(kExoAppIdKey); |
| 565 .app_id; | 572 return string_ptr ? *string_ptr : std::string(); |
| 566 } | 573 } |
| 567 | 574 |
| 568 void ShellSurface::SetApplicationId(const std::string& application_id) { | 575 void ShellSurface::SetApplicationId(const std::string& application_id) { |
| 569 // Store the value in |application_id_| in case the window does not exist yet. | 576 // Store the value in |application_id_| in case the window does not exist yet. |
| 570 application_id_ = application_id; | 577 application_id_ = application_id; |
| 571 if (widget_ && widget_->GetNativeWindow()) | 578 if (widget_ && widget_->GetNativeWindow()) |
| 572 SetApplicationId(widget_->GetNativeWindow(), application_id); | 579 SetApplicationId(widget_->GetNativeWindow(), application_id); |
| 573 } | 580 } |
| 574 | 581 |
| 575 void ShellSurface::Move() { | 582 void ShellSurface::Move() { |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1737 gfx::Point ShellSurface::GetMouseLocation() const { | 1744 gfx::Point ShellSurface::GetMouseLocation() const { |
| 1738 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); | 1745 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); |
| 1739 gfx::Point location = | 1746 gfx::Point location = |
| 1740 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); | 1747 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); |
| 1741 aura::Window::ConvertPointToTarget( | 1748 aura::Window::ConvertPointToTarget( |
| 1742 root_window, widget_->GetNativeWindow()->parent(), &location); | 1749 root_window, widget_->GetNativeWindow()->parent(), &location); |
| 1743 return location; | 1750 return location; |
| 1744 } | 1751 } |
| 1745 | 1752 |
| 1746 } // namespace exo | 1753 } // namespace exo |
| OLD | NEW |