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

Side by Side Diff: ui/views/cocoa/bridged_native_widget.h

Issue 283053002: Add compositing, layers to app_list_demo Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto master -- probably slightly broken Created 6 years, 3 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 | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ 5 #ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_
6 #define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ 6 #define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #import "base/mac/scoped_nsobject.h" 10 #import "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "ui/compositor/layer_owner.h"
12 #import "ui/views/focus/focus_manager.h" 13 #import "ui/views/focus/focus_manager.h"
13 #include "ui/views/ime/input_method_delegate.h" 14 #include "ui/views/ime/input_method_delegate.h"
14 #include "ui/views/views_export.h" 15 #include "ui/views/views_export.h"
15 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
16 17
18 #import "content/browser/compositor/browser_compositor_view_mac.h"
19
17 @class BridgedContentView; 20 @class BridgedContentView;
18 @class ViewsNSWindowDelegate; 21 @class ViewsNSWindowDelegate;
19 22
20 namespace ui { 23 namespace ui {
21 class InputMethod; 24 class InputMethod;
22 } 25 }
23 26
24 namespace views { 27 namespace views {
25 28
26 class InputMethod; 29 class InputMethod;
27 class NativeWidgetMac; 30 class NativeWidgetMac;
28 class View; 31 class View;
29 32
30 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or 33 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or
31 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the 34 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the
32 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. 35 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window.
33 class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate, 36 class VIEWS_EXPORT BridgedNativeWidget
34 public FocusChangeListener { 37 : public ui::LayerDelegate,
38 public ui::LayerOwner,
39 public internal::InputMethodDelegate,
40 public FocusChangeListener,
41 public content::BrowserCompositorViewMacClient {
35 public: 42 public:
36 // Creates one side of the bridge. |parent| must not be NULL. 43 // Creates one side of the bridge. |parent| must not be NULL.
37 explicit BridgedNativeWidget(NativeWidgetMac* parent); 44 explicit BridgedNativeWidget(NativeWidgetMac* parent);
38 virtual ~BridgedNativeWidget(); 45 virtual ~BridgedNativeWidget();
39 46
40 // Initialize the bridge, "retains" ownership of |window|. 47 // Initialize the bridge, "retains" ownership of |window|.
41 void Init(base::scoped_nsobject<NSWindow> window, 48 void Init(base::scoped_nsobject<NSWindow> window,
42 const Widget::InitParams& params); 49 const Widget::InitParams& params);
43 50
44 // Sets or clears the focus manager to use for tracking focused views. 51 // Sets or clears the focus manager to use for tracking focused views.
45 // This does NOT take ownership of |focus_manager|. 52 // This does NOT take ownership of |focus_manager|.
46 void SetFocusManager(FocusManager* focus_manager); 53 void SetFocusManager(FocusManager* focus_manager);
47 54
55 // Changes the bounds of the window and the hosted layer if present.
56 void SetBounds(const gfx::Rect& new_bounds);
57
48 // Set or clears the views::View bridged by the content view. This does NOT 58 // Set or clears the views::View bridged by the content view. This does NOT
49 // take ownership of |view|. 59 // take ownership of |view|.
50 void SetRootView(views::View* view); 60 void SetRootView(views::View* view);
51 61
52 // Called internally by the NSWindowDelegate when the window is closing. 62 // Called internally by the NSWindowDelegate when the window is closing.
53 void OnWindowWillClose(); 63 void OnWindowWillClose();
54 64
55 // See widget.h for documentation. 65 // See widget.h for documentation.
56 InputMethod* CreateInputMethod(); 66 InputMethod* CreateInputMethod();
57 ui::InputMethod* GetHostInputMethod(); 67 ui::InputMethod* GetHostInputMethod();
58 68
69 ui::Layer* GetOrCreateLayer();
70
59 NativeWidgetMac* native_widget_mac() { return native_widget_mac_; } 71 NativeWidgetMac* native_widget_mac() { return native_widget_mac_; }
60 BridgedContentView* ns_view() { return bridged_view_; } 72 BridgedContentView* ns_view() { return bridged_view_; }
61 NSWindow* ns_window() { return window_; } 73 NSWindow* ns_window() { return window_; }
62 74
63 // Overridden from internal::InputMethodDelegate: 75 // Overridden from internal::InputMethodDelegate:
64 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; 76 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
65 77
78 // Overridden from content::BrowserCompositorViewMacClient:
79 virtual void BrowserCompositorViewFrameSwapped(
80 const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE;
81 virtual NSView* BrowserCompositorSuperview() OVERRIDE;
82 virtual ui::Layer* BrowserCompositorRootLayer() OVERRIDE;
83
66 private: 84 private:
67 // Closes all child windows. BridgedNativeWidget children will be destroyed. 85 // Closes all child windows. BridgedNativeWidget children will be destroyed.
68 void RemoveOrDestroyChildren(); 86 void RemoveOrDestroyChildren();
69 87
88 // Size the layer, taking into account display scale factor.
89 void SetLayerSize(const gfx::Size& size_in_dip);
90
91 void OnWindowBoundsChanged();
92
93 // Overridden from ui::LayerDelegate:
94 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
95 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
96 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE;
97
98 // Overridden from FocusChangeListener:
99 virtual void OnWillChangeFocus(View* focused_before,
100 View* focused_now) OVERRIDE;
101 virtual void OnDidChangeFocus(View* focused_before,
102 View* focused_now) OVERRIDE;
103
70 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this. 104 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this.
71 base::scoped_nsobject<NSWindow> window_; 105 base::scoped_nsobject<NSWindow> window_;
72 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_; 106 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_;
73 base::scoped_nsobject<BridgedContentView> bridged_view_; 107 base::scoped_nsobject<BridgedContentView> bridged_view_;
74 scoped_ptr<ui::InputMethod> input_method_; 108 scoped_ptr<ui::InputMethod> input_method_;
75 FocusManager* focus_manager_; // Weak. Owned by our Widget. 109 FocusManager* focus_manager_; // Weak. Owned by our Widget.
76 110
77 // Overridden from FocusChangeListener: 111 scoped_ptr<content::BrowserCompositorViewMac> compositor_view_;
78 virtual void OnWillChangeFocus(View* focused_before, 112 content::BrowserCompositorViewPlaceholderMac recycling_keepalive_;
79 View* focused_now) OVERRIDE;
80 virtual void OnDidChangeFocus(View* focused_before,
81 View* focused_now) OVERRIDE;
82 113
83 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); 114 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget);
84 }; 115 };
85 116
86 } // namespace views 117 } // namespace views
87 118
88 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ 119 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_
OLDNEW
« 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