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

Unified Diff: ash/common/wm/forwarding_layer_delegate.cc

Issue 2129773002: [CrOS] Initial rough cut of alt-tab window cycling UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: function rename Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/wm/forwarding_layer_delegate.h ('k') | ash/wm/drag_window_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/wm/forwarding_layer_delegate.cc
diff --git a/ash/common/wm/forwarding_layer_delegate.cc b/ash/common/wm/forwarding_layer_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..822fd675a1a16d9d2e836c752b509cd039d8dbf6
--- /dev/null
+++ b/ash/common/wm/forwarding_layer_delegate.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/common/wm/forwarding_layer_delegate.h"
+
+#include "ash/common/wm_window.h"
+#include "base/callback.h"
+#include "ui/compositor/layer.h"
+
+namespace ash {
+namespace wm {
+
+ForwardingLayerDelegate::ForwardingLayerDelegate(WmWindow* original_window,
+ ui::LayerDelegate* delegate)
+ : original_window_(original_window), original_delegate_(delegate) {}
+
+ForwardingLayerDelegate::~ForwardingLayerDelegate() {}
+
+void ForwardingLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
+ if (!original_delegate_)
+ return;
+ // |original_delegate_| may have already been deleted or
+ // disconnected by this time. Check if |original_delegate_| is still
+ // used by the original_window tree, or skip otherwise.
+ if (IsDelegateValid(original_window_->GetLayer()))
+ original_delegate_->OnPaintLayer(context);
+ else
+ original_delegate_ = nullptr;
+}
+
+void ForwardingLayerDelegate::OnDelegatedFrameDamage(
+ const gfx::Rect& damage_rect_in_dip) {}
+
+void ForwardingLayerDelegate::OnDeviceScaleFactorChanged(
+ float device_scale_factor) {
+ // Don't tell the original delegate about device scale factor change
+ // on cloned layer because the original layer is still on the same display.
+}
+
+base::Closure ForwardingLayerDelegate::PrepareForLayerBoundsChange() {
+ return base::Closure();
+}
+
+bool ForwardingLayerDelegate::IsDelegateValid(ui::Layer* layer) const {
+ if (layer->delegate() == original_delegate_)
+ return true;
+ for (auto* child : layer->children()) {
+ if (IsDelegateValid(child))
+ return true;
+ }
+ return false;
+}
+
+} // namespace wm
+} // namespace ash
« no previous file with comments | « ash/common/wm/forwarding_layer_delegate.h ('k') | ash/wm/drag_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698