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

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

Issue 2480713003: Window prerequisites for ShelfWindowWatcher panel support. (Closed)
Patch Set: Support and test pre-widget exo ShellSurface::SetApplicationId. Created 4 years, 1 month 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
« no previous file with comments | « components/exo/shell_surface.h ('k') | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 25 matching lines...) Expand all
36 #include "ui/wm/core/coordinate_conversion.h" 36 #include "ui/wm/core/coordinate_conversion.h"
37 #include "ui/wm/core/shadow.h" 37 #include "ui/wm/core/shadow.h"
38 #include "ui/wm/core/shadow_controller.h" 38 #include "ui/wm/core/shadow_controller.h"
39 #include "ui/wm/core/shadow_types.h" 39 #include "ui/wm/core/shadow_types.h"
40 #include "ui/wm/core/window_util.h" 40 #include "ui/wm/core/window_util.h"
41 41
42 #if defined(OS_CHROMEOS) 42 #if defined(OS_CHROMEOS)
43 #include "chromeos/audio/chromeos_sounds.h" 43 #include "chromeos/audio/chromeos_sounds.h"
44 #endif 44 #endif
45 45
46 DECLARE_WINDOW_PROPERTY_TYPE(std::string*)
47
48 namespace exo { 46 namespace exo {
49 namespace { 47 namespace {
50 48
51 // This is a struct for accelerator keys used to close ShellSurfaces. 49 // This is a struct for accelerator keys used to close ShellSurfaces.
52 const struct Accelerator { 50 const struct Accelerator {
53 ui::KeyboardCode keycode; 51 ui::KeyboardCode keycode;
54 int modifiers; 52 int modifiers;
55 } kCloseWindowAccelerators[] = { 53 } kCloseWindowAccelerators[] = {
56 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, 54 {ui::VKEY_W, ui::EF_CONTROL_DOWN},
57 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, 55 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN},
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 aura::Window* window = shell_surface_->widget_->GetNativeWindow(); 320 aura::Window* window = shell_surface_->widget_->GetNativeWindow();
323 DCHECK_EQ(window->GetProperty(aura::client::kAnimationsDisabledKey), true); 321 DCHECK_EQ(window->GetProperty(aura::client::kAnimationsDisabledKey), true);
324 window->SetProperty(aura::client::kAnimationsDisabledKey, 322 window->SetProperty(aura::client::kAnimationsDisabledKey,
325 saved_animations_disabled_); 323 saved_animations_disabled_);
326 } 324 }
327 } 325 }
328 326
329 //////////////////////////////////////////////////////////////////////////////// 327 ////////////////////////////////////////////////////////////////////////////////
330 // ShellSurface, public: 328 // ShellSurface, public:
331 329
332 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(std::string*, kApplicationIdKey, nullptr)
333 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr) 330 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr)
334 331
335 ShellSurface::ShellSurface(Surface* surface, 332 ShellSurface::ShellSurface(Surface* surface,
336 ShellSurface* parent, 333 ShellSurface* parent,
337 const gfx::Rect& initial_bounds, 334 const gfx::Rect& initial_bounds,
338 bool activatable, 335 bool activatable,
339 int container) 336 int container)
340 : widget_(nullptr), 337 : widget_(nullptr),
341 surface_(surface), 338 surface_(surface),
342 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), 339 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr),
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 << "Only a window in SystemModalContainer can change the modality"; 522 << "Only a window in SystemModalContainer can change the modality";
526 return; 523 return;
527 } 524 }
528 widget_->GetNativeWindow()->SetProperty( 525 widget_->GetNativeWindow()->SetProperty(
529 aura::client::kModalKey, 526 aura::client::kModalKey,
530 system_modal ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE); 527 system_modal ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE);
531 } 528 }
532 529
533 // static 530 // static
534 void ShellSurface::SetApplicationId(aura::Window* window, 531 void ShellSurface::SetApplicationId(aura::Window* window,
535 std::string* application_id) { 532 const std::string& id) {
536 window->SetProperty(kApplicationIdKey, application_id); 533 TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id", id);
534 window->SetProperty(aura::client::kAppIdKey, new std::string(id));
537 } 535 }
538 536
539 // static 537 // static
540 const std::string ShellSurface::GetApplicationId(aura::Window* window) { 538 const std::string ShellSurface::GetApplicationId(aura::Window* window) {
541 std::string* string_ptr = window->GetProperty(kApplicationIdKey); 539 std::string* string_ptr = window->GetProperty(aura::client::kAppIdKey);
542 return string_ptr ? *string_ptr : std::string(); 540 return string_ptr ? *string_ptr : std::string();
543 } 541 }
544 542
545 void ShellSurface::SetApplicationId(const std::string& application_id) { 543 void ShellSurface::SetApplicationId(const std::string& application_id) {
546 TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id", 544 // Store the value in |application_id_| in case the window does not exist yet.
547 application_id);
548
549 application_id_ = application_id; 545 application_id_ = application_id;
546 if (widget_ && widget_->GetNativeWindow())
547 SetApplicationId(widget_->GetNativeWindow(), application_id);
550 } 548 }
551 549
552 void ShellSurface::Move() { 550 void ShellSurface::Move() {
553 TRACE_EVENT0("exo", "ShellSurface::Move"); 551 TRACE_EVENT0("exo", "ShellSurface::Move");
554 552
555 if (widget_ && !widget_->movement_disabled()) 553 if (widget_ && !widget_->movement_disabled())
556 AttemptToStartDrag(HTCAPTION); 554 AttemptToStartDrag(HTCAPTION);
557 } 555 }
558 556
559 void ShellSurface::Resize(int component) { 557 void ShellSurface::Resize(int component) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 // static 617 // static
620 Surface* ShellSurface::GetMainSurface(const aura::Window* window) { 618 Surface* ShellSurface::GetMainSurface(const aura::Window* window) {
621 return window->GetProperty(kMainSurfaceKey); 619 return window->GetProperty(kMainSurfaceKey);
622 } 620 }
623 621
624 std::unique_ptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue() 622 std::unique_ptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue()
625 const { 623 const {
626 std::unique_ptr<base::trace_event::TracedValue> value( 624 std::unique_ptr<base::trace_event::TracedValue> value(
627 new base::trace_event::TracedValue()); 625 new base::trace_event::TracedValue());
628 value->SetString("title", base::UTF16ToUTF8(title_)); 626 value->SetString("title", base::UTF16ToUTF8(title_));
629 value->SetString("application_id", application_id_); 627 std::string application_id;
628 if (GetWidget() && GetWidget()->GetNativeWindow())
629 application_id = GetApplicationId(GetWidget()->GetNativeWindow());
630 value->SetString("application_id", application_id);
630 return value; 631 return value;
631 } 632 }
632 633
633 //////////////////////////////////////////////////////////////////////////////// 634 ////////////////////////////////////////////////////////////////////////////////
634 // SurfaceDelegate overrides: 635 // SurfaceDelegate overrides:
635 636
636 void ShellSurface::OnSurfaceCommit() { 637 void ShellSurface::OnSurfaceCommit() {
637 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); 638 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
638 surface_->CommitSurfaceHierarchy(); 639 surface_->CommitSurfaceHierarchy();
639 640
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 : views::Widget::InitParams::ACTIVATABLE_NO; 1017 : views::Widget::InitParams::ACTIVATABLE_NO;
1017 1018
1018 // Note: NativeWidget owns this widget. 1019 // Note: NativeWidget owns this widget.
1019 widget_ = new ShellSurfaceWidget(this); 1020 widget_ = new ShellSurfaceWidget(this);
1020 widget_->Init(params); 1021 widget_->Init(params);
1021 1022
1022 aura::Window* window = widget_->GetNativeWindow(); 1023 aura::Window* window = widget_->GetNativeWindow();
1023 window->SetName("ExoShellSurface"); 1024 window->SetName("ExoShellSurface");
1024 window->AddChild(surface_->window()); 1025 window->AddChild(surface_->window());
1025 window->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter(widget_))); 1026 window->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter(widget_)));
1026 SetApplicationId(window, &application_id_); 1027 SetApplicationId(window, application_id_);
1027 SetMainSurface(window, surface_); 1028 SetMainSurface(window, surface_);
1028 1029
1029 // Start tracking changes to window bounds and window state. 1030 // Start tracking changes to window bounds and window state.
1030 window->AddObserver(this); 1031 window->AddObserver(this);
1031 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); 1032 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window);
1032 window_state->AddObserver(this); 1033 window_state->AddObserver(this);
1033 1034
1034 // Absolete positioned shell surfaces may request the bounds that does not 1035 // Absolete positioned shell surfaces may request the bounds that does not
1035 // fill the entire work area / display in maximized / fullscreen state. 1036 // fill the entire work area / display in maximized / fullscreen state.
1036 // Allow such clients to update the bounds in these states. 1037 // Allow such clients to update the bounds in these states.
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 shadow_overlay_->layer()->Add(shadow->layer()); 1399 shadow_overlay_->layer()->Add(shadow->layer());
1399 window->AddChild(shadow_overlay_); 1400 window->AddChild(shadow_overlay_);
1400 shadow_overlay_->Show(); 1401 shadow_overlay_->Show();
1401 } 1402 }
1402 shadow_overlay_->SetBounds(shadow_bounds); 1403 shadow_overlay_->SetBounds(shadow_bounds);
1403 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); 1404 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size()));
1404 } 1405 }
1405 } 1406 }
1406 1407
1407 } // namespace exo 1408 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/shell_surface.h ('k') | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698