Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: components/exo/shell_surface.cc

Issue 2778733004: Add WindowPinType property on arua::Window (Closed)
Patch Set: Address review issues Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 476
476 if (!widget_) 477 if (!widget_)
477 CreateShellSurfaceWidget(ui::SHOW_STATE_FULLSCREEN); 478 CreateShellSurfaceWidget(ui::SHOW_STATE_FULLSCREEN);
478 479
479 // Note: This will ask client to configure its surface even if fullscreen 480 // Note: This will ask client to configure its surface even if fullscreen
480 // state doesn't change. 481 // state doesn't change.
481 ScopedConfigure scoped_configure(this, true); 482 ScopedConfigure scoped_configure(this, true);
482 widget_->SetFullscreen(fullscreen); 483 widget_->SetFullscreen(fullscreen);
483 } 484 }
484 485
485 void ShellSurface::SetPinned(bool pinned, bool trusted) { 486 void ShellSurface::SetPinned(ash::mojom::WindowPinType type) {
486 TRACE_EVENT2("exo", "ShellSurface::SetPinned", "pinned", pinned, "trusted", 487 TRACE_EVENT1("exo", "ShellSurface::SetPinned", "type",
487 trusted); 488 static_cast<int>(type));
488 489
489 if (!widget_) 490 if (!widget_)
490 CreateShellSurfaceWidget(ui::SHOW_STATE_NORMAL); 491 CreateShellSurfaceWidget(ui::SHOW_STATE_NORMAL);
491 492
492 // Note: This will ask client to configure its surface even if pinned 493 // Note: This will ask client to configure its surface even if pinned
493 // state doesn't change. 494 // state doesn't change.
494 ScopedConfigure scoped_configure(this, true); 495 ScopedConfigure scoped_configure(this, true);
495 if (pinned) { 496 widget_->GetNativeWindow()->SetProperty(ash::kWindowPinTypeKey, type);
496 ash::wm::PinWindow(widget_->GetNativeWindow(), 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 } 497 }
506 498
507 void ShellSurface::SetSystemUiVisibility(bool autohide) { 499 void ShellSurface::SetSystemUiVisibility(bool autohide) {
508 TRACE_EVENT1("exo", "ShellSurface::SetSystemUiVisibility", "autohide", 500 TRACE_EVENT1("exo", "ShellSurface::SetSystemUiVisibility", "autohide",
509 autohide); 501 autohide);
510 ash::wm::SetAutoHideShelf(widget_->GetNativeWindow(), autohide); 502 ash::wm::SetAutoHideShelf(widget_->GetNativeWindow(), autohide);
511 } 503 }
512 504
513 void ShellSurface::SetTitle(const base::string16& title) { 505 void ShellSurface::SetTitle(const base::string16& title) {
514 TRACE_EVENT1("exo", "ShellSurface::SetTitle", "title", 506 TRACE_EVENT1("exo", "ShellSurface::SetTitle", "title",
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 gfx::Point ShellSurface::GetMouseLocation() const { 1697 gfx::Point ShellSurface::GetMouseLocation() const {
1706 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); 1698 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow();
1707 gfx::Point location = 1699 gfx::Point location =
1708 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); 1700 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot();
1709 aura::Window::ConvertPointToTarget( 1701 aura::Window::ConvertPointToTarget(
1710 root_window, widget_->GetNativeWindow()->parent(), &location); 1702 root_window, widget_->GetNativeWindow()->parent(), &location);
1711 return location; 1703 return location;
1712 } 1704 }
1713 1705
1714 } // namespace exo 1706 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698