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

Unified Diff: ui/views/cocoa/bridged_native_widget.h

Issue 659233002: STASH: Epic Experimental patch for toolkit-views App List on Mac Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Fix a few things. Works@master Created 6 years, 2 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 | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/cocoa/bridged_native_widget.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_native_widget.h
diff --git a/ui/views/cocoa/bridged_native_widget.h b/ui/views/cocoa/bridged_native_widget.h
index 05eeabf92a4f2f6bbec9d4d6d62023d7847b1c7f..679c4968ecdf5385e28592abfc52421d7a3cd8e3 100644
--- a/ui/views/cocoa/bridged_native_widget.h
+++ b/ui/views/cocoa/bridged_native_widget.h
@@ -9,11 +9,14 @@
#import "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/compositor/layer_owner.h"
#import "ui/views/focus/focus_manager.h"
#include "ui/views/ime/input_method_delegate.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/widget.h"
+#import "content/browser/compositor/browser_compositor_view_mac.h"
+
@class BridgedContentView;
@class ViewsNSWindowDelegate;
@@ -30,8 +33,12 @@ class View;
// A bridge to an NSWindow managed by an instance of NativeWidgetMac or
// DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the
// NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window.
-class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate,
- public FocusChangeListener {
+class VIEWS_EXPORT BridgedNativeWidget
+ : public ui::LayerDelegate,
+ public ui::LayerOwner,
+ public internal::InputMethodDelegate,
+ public FocusChangeListener,
+ public content::BrowserCompositorViewMacClient {
public:
// Creates one side of the bridge. |parent| must not be NULL.
explicit BridgedNativeWidget(NativeWidgetMac* parent);
@@ -45,6 +52,9 @@ class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate,
// This does NOT take ownership of |focus_manager|.
void SetFocusManager(FocusManager* focus_manager);
+ // Changes the bounds of the window and the hosted layer if present.
+ void SetBounds(const gfx::Rect& new_bounds);
+
// Set or clears the views::View bridged by the content view. This does NOT
// take ownership of |view|.
void SetRootView(views::View* view);
@@ -65,6 +75,19 @@ class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate,
// invert the value of target_fullscreen_state().
void ToggleDesiredFullscreenState();
+ // Called by the NSWindowDelegate when the size of the window changes.
+ void OnSizeChanged();
+
+ // Called by the NSWindowDelegate when the visibility of the window may have
+ // changed. For example, due to a (de)miniaturize operation, or the window
+ // being reordered in (or out of) the screen list.
+ void OnVisibilityChanged();
+
+ // Called by the NSWindowDelegate when the window moves to a new display or
+ // when the display properties (backing store scale factor or colorspace
+ // changes.
+ void OnDisplayChanged();
+
// See widget.h for documentation.
InputMethod* CreateInputMethod();
ui::InputMethod* GetHostInputMethod();
@@ -73,6 +96,8 @@ class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate,
// fullscreen or transitioning between fullscreen states.
gfx::Rect GetRestoredBounds() const;
+ ui::Layer* GetOrCreateLayer();
+
NativeWidgetMac* native_widget_mac() { return native_widget_mac_; }
BridgedContentView* ns_view() { return bridged_view_; }
NSWindow* ns_window() { return window_; }
@@ -82,10 +107,29 @@ class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate,
// Overridden from internal::InputMethodDelegate:
virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) override;
+ // Overridden from content::BrowserCompositorViewMacClient:
+ virtual bool BrowserCompositorViewShouldAckImmediately() const OVERRIDE;
+ virtual void BrowserCompositorViewFrameSwapped(
+ const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE;
+ virtual NSView* BrowserCompositorSuperview() OVERRIDE;
+ virtual ui::Layer* BrowserCompositorRootLayer() OVERRIDE;
+
private:
// Closes all child windows. BridgedNativeWidget children will be destroyed.
void RemoveOrDestroyChildren();
+ // Size the layer, taking into account display scale factor.
+ void SetLayerSize(const gfx::Size& size_in_dip);
+
+ void OnWindowBoundsChanged();
+
+ // Overridden from ui::LayerDelegate:
+ virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
+ virtual void OnDelegatedFrameDamage(
+ const gfx::Rect& damage_rect_in_dip) OVERRIDE;
+ virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
+ virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE;
+
views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this.
base::scoped_nsobject<NSWindow> window_;
base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_;
@@ -93,6 +137,10 @@ class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate,
scoped_ptr<ui::InputMethod> input_method_;
FocusManager* focus_manager_; // Weak. Owned by our Widget.
+ base::scoped_nsobject<NSView> compositor_superview_;
+ scoped_ptr<content::BrowserCompositorViewMac> compositor_view_;
+ content::BrowserCompositorViewPlaceholderMac recycling_keepalive_;
+
// Tracks the bounds when the window last started entering fullscreen. Used to
// provide an answer for GetRestoredBounds(), but not ever sent to Cocoa (it
// has its own copy, but doesn't provide access to it).
@@ -106,6 +154,10 @@ class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate,
// can not currently be changed.
bool in_fullscreen_transition_;
+ // Stores the value last read from -[NSWindow isVisible], to detect visibility
+ // changes.
+ bool window_visible_;
+
// Overridden from FocusChangeListener:
virtual void OnWillChangeFocus(View* focused_before,
View* focused_now) override;
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/cocoa/bridged_native_widget.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698