native_widget_mac_ns_window_host.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_VIEWS_COCOA_NATIVE_WIDGET_MAC_NS_WINDOW_HOST_H_
  5. #define UI_VIEWS_COCOA_NATIVE_WIDGET_MAC_NS_WINDOW_HOST_H_
  6. #include <list>
  7. #include <map>
  8. #include <memory>
  9. #include <string>
  10. #include <vector>
  11. #include "base/mac/scoped_nsobject.h"
  12. #include "base/memory/raw_ptr.h"
  13. #include "components/remote_cocoa/app_shim/native_widget_ns_window_host_helper.h"
  14. #include "components/remote_cocoa/app_shim/ns_view_ids.h"
  15. #include "components/remote_cocoa/browser/application_host.h"
  16. #include "components/remote_cocoa/browser/scoped_cg_window_id.h"
  17. #include "components/remote_cocoa/common/native_widget_ns_window.mojom.h"
  18. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  19. #include "mojo/public/cpp/bindings/associated_receiver.h"
  20. #include "mojo/public/cpp/bindings/associated_remote.h"
  21. #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
  22. #include "ui/base/cocoa/accessibility_focus_overrider.h"
  23. #include "ui/compositor/layer_owner.h"
  24. #include "ui/display/mac/display_link_mac.h"
  25. #include "ui/views/cocoa/drag_drop_client_mac.h"
  26. #include "ui/views/cocoa/native_widget_mac_event_monitor.h"
  27. #include "ui/views/views_export.h"
  28. #include "ui/views/widget/widget.h"
  29. #include "ui/views/window/dialog_observer.h"
  30. @class NativeWidgetMacNSWindow;
  31. @class NSAccessibilityRemoteUIElement;
  32. @class NSView;
  33. namespace remote_cocoa {
  34. class NativeWidgetNSWindowBridge;
  35. class ScopedNativeWindowMapping;
  36. } // namespace remote_cocoa
  37. namespace ui {
  38. class RecyclableCompositorMac;
  39. } // namespace ui
  40. namespace views {
  41. class NativeWidgetMac;
  42. class NativeWidgetMacEventMonitor;
  43. class TextInputHost;
  44. // The portion of NativeWidgetMac that lives in the browser process. This
  45. // communicates to the NativeWidgetNSWindowBridge, which interacts with the
  46. // Cocoa APIs, and which may live in an app shim process.
  47. class VIEWS_EXPORT NativeWidgetMacNSWindowHost
  48. : public remote_cocoa::NativeWidgetNSWindowHostHelper,
  49. public remote_cocoa::ApplicationHost::Observer,
  50. public remote_cocoa::mojom::NativeWidgetNSWindowHost,
  51. public DialogObserver,
  52. public ui::AccessibilityFocusOverrider::Client,
  53. public ui::LayerDelegate,
  54. public ui::LayerOwner,
  55. public ui::AcceleratedWidgetMacNSView {
  56. public:
  57. // Retrieves the bridge host associated with the given NativeWindow. Returns
  58. // null if the supplied handle has no associated Widget.
  59. static NativeWidgetMacNSWindowHost* GetFromNativeWindow(
  60. gfx::NativeWindow window);
  61. static NativeWidgetMacNSWindowHost* GetFromNativeView(gfx::NativeView view);
  62. // Key used to bind the content NSView to the overlay widget in immersive
  63. // mode.
  64. static const char kImmersiveContentNSView[];
  65. // Unique integer id handles are used to bridge between the
  66. // NativeWidgetMacNSWindowHost in one process and the NativeWidgetNSWindowHost
  67. // potentially in another.
  68. static NativeWidgetMacNSWindowHost* GetFromId(
  69. uint64_t bridged_native_widget_id);
  70. uint64_t bridged_native_widget_id() const { return widget_id_; }
  71. // Creates one side of the bridge. |owner| must not be NULL.
  72. explicit NativeWidgetMacNSWindowHost(NativeWidgetMac* owner);
  73. NativeWidgetMacNSWindowHost(const NativeWidgetMacNSWindowHost&) = delete;
  74. NativeWidgetMacNSWindowHost& operator=(const NativeWidgetMacNSWindowHost&) =
  75. delete;
  76. ~NativeWidgetMacNSWindowHost() override;
  77. // The NativeWidgetMac that owns |this|.
  78. views::NativeWidgetMac* native_widget_mac() const {
  79. return native_widget_mac_;
  80. }
  81. NativeWidgetMacNSWindowHost* parent() const { return parent_; }
  82. std::vector<NativeWidgetMacNSWindowHost*> children() const {
  83. return children_;
  84. }
  85. // The bridge factory that was used to create the true NSWindow for this
  86. // widget. This is nullptr for in-process windows.
  87. remote_cocoa::ApplicationHost* application_host() const {
  88. return application_host_;
  89. }
  90. TextInputHost* text_input_host() const { return text_input_host_.get(); }
  91. // A NSWindow that is guaranteed to exist in this process. If the bridge
  92. // object for this host is in this process, then this points to the bridge's
  93. // NSWindow. Otherwise, it mirrors the id and bounds of the child window.
  94. NativeWidgetMacNSWindow* GetInProcessNSWindow() const;
  95. // Return the accessibility object for the content NSView.
  96. gfx::NativeViewAccessible GetNativeViewAccessibleForNSView() const;
  97. // Return the accessibility object for the NSWindow.
  98. gfx::NativeViewAccessible GetNativeViewAccessibleForNSWindow() const;
  99. // The mojo interface through which to communicate with the underlying
  100. // NSWindow and NSView. This points to either |remote_ns_window_remote_| or
  101. // |in_process_ns_window_bridge_|.
  102. remote_cocoa::mojom::NativeWidgetNSWindow* GetNSWindowMojo() const;
  103. // Direct access to the NativeWidgetNSWindowBridge that this is hosting.
  104. // TODO(ccameron): Remove all accesses to this member, and replace them
  105. // with methods that may be sent across processes.
  106. remote_cocoa::NativeWidgetNSWindowBridge* GetInProcessNSWindowBridge() const {
  107. return in_process_ns_window_bridge_.get();
  108. }
  109. TooltipManager* tooltip_manager() { return tooltip_manager_.get(); }
  110. DragDropClientMac* drag_drop_client() const {
  111. return drag_drop_client_.get();
  112. }
  113. // Create and set the bridge object to be in this process.
  114. void CreateInProcessNSWindowBridge(
  115. base::scoped_nsobject<NativeWidgetMacNSWindow> window);
  116. // Create and set the bridge object to be potentially in another process.
  117. void CreateRemoteNSWindow(
  118. remote_cocoa::ApplicationHost* application_host,
  119. remote_cocoa::mojom::CreateWindowParamsPtr window_create_params);
  120. void InitWindow(const Widget::InitParams& params,
  121. const gfx::Rect& initial_bounds_in_screen);
  122. // Close the window immediately. This function may result in |this| being
  123. // deleted.
  124. void CloseWindowNow();
  125. // Changes the bounds of the window and the hosted layer if present. The
  126. // argument is always a location in screen coordinates (in contrast to the
  127. // views::Widget::SetBounds method, when the argument is only sometimes in
  128. // screen coordinates).
  129. void SetBoundsInScreen(const gfx::Rect& bounds);
  130. // Tell the window to transition to being fullscreen or not-fullscreen.
  131. // If `fullscreen` is true, then `target_display_id` specifies the display to
  132. // which window should move (or an invalid display, to use the default).
  133. void SetFullscreen(bool fullscreen,
  134. int64_t target_display_id = display::kInvalidDisplayId);
  135. // The ultimate fullscreen state that is being targeted (irrespective of any
  136. // active transitions).
  137. bool target_fullscreen_state() const { return target_fullscreen_state_; }
  138. // Set the root view (set during initialization and un-set during teardown).
  139. void SetRootView(views::View* root_view);
  140. // Return the id through which the NSView for |root_view_| may be looked up.
  141. uint64_t GetRootViewNSViewId() const { return root_view_id_; }
  142. // Initialize the ui::Compositor and ui::Layer.
  143. void CreateCompositor(const Widget::InitParams& params);
  144. // Set the window's title, returning true if the title has changed.
  145. bool SetWindowTitle(const std::u16string& title);
  146. // Called when the owning Widget's Init method has completed.
  147. void OnWidgetInitDone();
  148. // Redispatch a keyboard event using the widget's window's CommandDispatcher.
  149. // Return true if the event is handled.
  150. bool RedispatchKeyEvent(NSEvent* event);
  151. // Geometry of the window, in DIPs.
  152. const gfx::Rect& GetWindowBoundsInScreen() const {
  153. return window_bounds_in_screen_;
  154. }
  155. // Geometry of the content area of the window, in DIPs. Note that this is not
  156. // necessarily the same as the views::View's size.
  157. gfx::Rect GetContentBoundsInScreen() const;
  158. // The display that the window is currently on (or best guess thereof).
  159. const display::Display& GetCurrentDisplay() const { return display_; }
  160. // The restored bounds will be derived from the current NSWindow frame unless
  161. // fullscreen or transitioning between fullscreen states.
  162. gfx::Rect GetRestoredBounds() const;
  163. // An opaque blob of AppKit data which includes, among other things, a
  164. // window's workspace and fullscreen state, and can be retrieved from or
  165. // applied to a window.
  166. const std::vector<uint8_t>& GetWindowStateRestorationData() const;
  167. // Set |parent_| and update the old and new parents' |children_|. It is valid
  168. // to set |new_parent| to nullptr. Propagate this to the BridgedNativeWidget.
  169. void SetParent(NativeWidgetMacNSWindowHost* new_parent);
  170. // Properties set and queried by views. Not actually native.
  171. void SetNativeWindowProperty(const char* name, void* value);
  172. void* GetNativeWindowProperty(const char* name) const;
  173. // Updates |attached_native_view_host_views_| on
  174. // NativeViewHost::Attach()/Detach().
  175. void OnNativeViewHostAttach(const views::View* view, NSView* native_view);
  176. void OnNativeViewHostDetach(const views::View* view);
  177. // Sorts child NSViews according to NativeViewHosts order in views hierarchy.
  178. void ReorderChildViews();
  179. bool IsVisible() const { return is_visible_; }
  180. bool IsMiniaturized() const { return is_miniaturized_; }
  181. bool IsWindowKey() const { return is_window_key_; }
  182. bool IsMouseCaptureActive() const { return is_mouse_capture_active_; }
  183. // Add a NSEvent local event monitor, which will send events to `client`
  184. // before they are dispatched to their ordinary target. Clients may specify
  185. // that they have handled an event, which will prevent further dispatch. All
  186. // clients will receive all events, in the order that the clients were added,
  187. // regardless of whether or not a previous client handled the event.
  188. std::unique_ptr<NativeWidgetMacEventMonitor> AddEventMonitor(
  189. NativeWidgetMacEventMonitor::Client* client);
  190. void RemoveEventMonitor(NativeWidgetMacEventMonitor*);
  191. // Used by NativeWidgetPrivate::GetGlobalCapture.
  192. static NSView* GetGlobalCaptureView();
  193. // Add, update and remove the remote window controls overlay view for a PWA.
  194. void AddRemoteWindowControlsOverlayView(
  195. remote_cocoa::mojom::WindowControlsOverlayNSViewType overlay_type);
  196. void UpdateRemoteWindowControlsOverlayView(
  197. const gfx::Rect& bounds,
  198. remote_cocoa::mojom::WindowControlsOverlayNSViewType overlay_type);
  199. void RemoveRemoteWindowControlsOverlayView(
  200. remote_cocoa::mojom::WindowControlsOverlayNSViewType overlay_type);
  201. private:
  202. friend class TextInputHost;
  203. void UpdateCompositorProperties();
  204. void DestroyCompositor();
  205. // Sort |attached_native_view_host_views_| by the order in which their
  206. // NSViews should appear as subviews. This does a recursive pre-order
  207. // traversal of the views::View tree starting at |view|.
  208. void GetAttachedNativeViewHostViewsRecursive(
  209. View* view,
  210. std::vector<NSView*>* attached_native_view_host_views_ordered) const;
  211. // If we are accessing the BridgedNativeWidget through mojo, then
  212. // |in_process_ns_window_| is not the true window that is resized. This
  213. // function updates the frame of |in_process_ns_window_| to keep it in sync
  214. // for any native calls that may use it (e.g, for context menu positioning).
  215. void UpdateLocalWindowFrame(const gfx::Rect& frame);
  216. // NativeWidgetNSWindowHostHelper:
  217. id GetNativeViewAccessible() override;
  218. void DispatchKeyEvent(ui::KeyEvent* event) override;
  219. bool DispatchKeyEventToMenuController(ui::KeyEvent* event) override;
  220. void GetWordAt(const gfx::Point& location_in_content,
  221. bool* found_word,
  222. gfx::DecoratedText* decorated_word,
  223. gfx::Point* baseline_point) override;
  224. remote_cocoa::DragDropClient* GetDragDropClient() override;
  225. ui::TextInputClient* GetTextInputClient() override;
  226. bool MustPostTaskToRunModalSheetAnimation() const override;
  227. // remote_cocoa::ApplicationHost::Observer:
  228. void OnApplicationHostDestroying(
  229. remote_cocoa::ApplicationHost* host) override;
  230. // remote_cocoa::mojom::NativeWidgetNSWindowHost:
  231. void OnVisibilityChanged(bool visible) override;
  232. void OnWindowNativeThemeChanged() override;
  233. void OnViewSizeChanged(const gfx::Size& new_size) override;
  234. bool GetSheetOffsetY(int32_t* offset_y) override;
  235. void SetKeyboardAccessible(bool enabled) override;
  236. void OnIsFirstResponderChanged(bool is_first_responder) override;
  237. void OnMouseCaptureActiveChanged(bool capture_is_active) override;
  238. void OnScrollEvent(std::unique_ptr<ui::Event> event) override;
  239. void OnMouseEvent(std::unique_ptr<ui::Event> event) override;
  240. void OnGestureEvent(std::unique_ptr<ui::Event> event) override;
  241. bool DispatchKeyEventRemote(std::unique_ptr<ui::Event> event,
  242. bool* event_handled) override;
  243. bool DispatchKeyEventToMenuControllerRemote(std::unique_ptr<ui::Event> event,
  244. bool* event_swallowed,
  245. bool* event_handled) override;
  246. bool DispatchMonitorEvent(std::unique_ptr<ui::Event> event,
  247. bool* event_handled) override;
  248. bool GetHasMenuController(bool* has_menu_controller) override;
  249. bool GetIsDraggableBackgroundAt(const gfx::Point& location_in_content,
  250. bool* is_draggable_background) override;
  251. bool GetTooltipTextAt(const gfx::Point& location_in_content,
  252. std::u16string* new_tooltip_text) override;
  253. bool GetWidgetIsModal(bool* widget_is_modal) override;
  254. bool GetIsFocusedViewTextual(bool* is_textual) override;
  255. void OnWindowGeometryChanged(
  256. const gfx::Rect& window_bounds_in_screen_dips,
  257. const gfx::Rect& content_bounds_in_screen_dips) override;
  258. void OnWindowFullscreenTransitionStart(bool target_fullscreen_state) override;
  259. void OnWindowFullscreenTransitionComplete(
  260. bool target_fullscreen_state) override;
  261. void OnWindowMiniaturizedChanged(bool miniaturized) override;
  262. void OnWindowDisplayChanged(const display::Display& display) override;
  263. void OnWindowWillClose() override;
  264. void OnWindowHasClosed() override;
  265. void OnWindowKeyStatusChanged(bool is_key,
  266. bool is_content_first_responder,
  267. bool full_keyboard_access_enabled) override;
  268. void OnWindowStateRestorationDataChanged(
  269. const std::vector<uint8_t>& data) override;
  270. void DoDialogButtonAction(ui::DialogButton button) override;
  271. bool GetDialogButtonInfo(ui::DialogButton type,
  272. bool* button_exists,
  273. std::u16string* button_label,
  274. bool* is_button_enabled,
  275. bool* is_button_default) override;
  276. bool GetDoDialogButtonsExist(bool* buttons_exist) override;
  277. bool GetShouldShowWindowTitle(bool* should_show_window_title) override;
  278. bool GetCanWindowBecomeKey(bool* can_window_become_key) override;
  279. bool GetAlwaysRenderWindowAsKey(bool* always_render_as_key) override;
  280. bool OnWindowCloseRequested(bool* can_window_close) override;
  281. bool GetWindowFrameTitlebarHeight(bool* override_titlebar_height,
  282. float* titlebar_height) override;
  283. void OnFocusWindowToolbar() override;
  284. void SetRemoteAccessibilityTokens(
  285. const std::vector<uint8_t>& window_token,
  286. const std::vector<uint8_t>& view_token) override;
  287. bool GetRootViewAccessibilityToken(int64_t* pid,
  288. std::vector<uint8_t>* token) override;
  289. bool ValidateUserInterfaceItem(
  290. int32_t command,
  291. remote_cocoa::mojom::ValidateUserInterfaceItemResultPtr* out_result)
  292. override;
  293. bool ExecuteCommand(int32_t command,
  294. WindowOpenDisposition window_open_disposition,
  295. bool is_before_first_responder,
  296. bool* was_executed) override;
  297. bool HandleAccelerator(const ui::Accelerator& accelerator,
  298. bool require_priority_handler,
  299. bool* was_handled) override;
  300. // remote_cocoa::mojom::NativeWidgetNSWindowHost, synchronous callbacks:
  301. void GetSheetOffsetY(GetSheetOffsetYCallback callback) override;
  302. void DispatchKeyEventRemote(std::unique_ptr<ui::Event> event,
  303. DispatchKeyEventRemoteCallback callback) override;
  304. void DispatchKeyEventToMenuControllerRemote(
  305. std::unique_ptr<ui::Event> event,
  306. DispatchKeyEventToMenuControllerRemoteCallback callback) override;
  307. void DispatchMonitorEvent(std::unique_ptr<ui::Event> event,
  308. DispatchMonitorEventCallback callback) override;
  309. void GetHasMenuController(GetHasMenuControllerCallback callback) override;
  310. void GetIsDraggableBackgroundAt(
  311. const gfx::Point& location_in_content,
  312. GetIsDraggableBackgroundAtCallback callback) override;
  313. void GetTooltipTextAt(const gfx::Point& location_in_content,
  314. GetTooltipTextAtCallback callback) override;
  315. void GetWidgetIsModal(GetWidgetIsModalCallback callback) override;
  316. void GetIsFocusedViewTextual(
  317. GetIsFocusedViewTextualCallback callback) override;
  318. void GetDialogButtonInfo(ui::DialogButton button,
  319. GetDialogButtonInfoCallback callback) override;
  320. void GetDoDialogButtonsExist(
  321. GetDoDialogButtonsExistCallback callback) override;
  322. void GetShouldShowWindowTitle(
  323. GetShouldShowWindowTitleCallback callback) override;
  324. void GetCanWindowBecomeKey(GetCanWindowBecomeKeyCallback callback) override;
  325. void GetAlwaysRenderWindowAsKey(
  326. GetAlwaysRenderWindowAsKeyCallback callback) override;
  327. void OnWindowCloseRequested(OnWindowCloseRequestedCallback callback) override;
  328. void GetWindowFrameTitlebarHeight(
  329. GetWindowFrameTitlebarHeightCallback callback) override;
  330. void GetRootViewAccessibilityToken(
  331. GetRootViewAccessibilityTokenCallback callback) override;
  332. void ValidateUserInterfaceItem(
  333. int32_t command,
  334. ValidateUserInterfaceItemCallback callback) override;
  335. void ExecuteCommand(int32_t command,
  336. WindowOpenDisposition window_open_disposition,
  337. bool is_before_first_responder,
  338. ExecuteCommandCallback callback) override;
  339. void HandleAccelerator(const ui::Accelerator& accelerator,
  340. bool require_priority_handler,
  341. HandleAcceleratorCallback callback) override;
  342. // DialogObserver:
  343. void OnDialogChanged() override;
  344. // ui::AccessibilityFocusOverrider::Client:
  345. id GetAccessibilityFocusedUIElement() override;
  346. // ui::LayerDelegate:
  347. void OnPaintLayer(const ui::PaintContext& context) override;
  348. void OnDeviceScaleFactorChanged(float old_device_scale_factor,
  349. float new_device_scale_factor) override;
  350. void UpdateVisualState() override;
  351. // ui::AcceleratedWidgetMacNSView:
  352. void AcceleratedWidgetCALayerParamsUpdated() override;
  353. void OnVSyncParametersUpdated(base::TimeTicks timebase,
  354. base::TimeDelta interval);
  355. // The id that this bridge may be looked up from.
  356. const uint64_t widget_id_;
  357. const raw_ptr<views::NativeWidgetMac>
  358. native_widget_mac_; // Weak. Owns |this_|.
  359. // Structure used to look up this structure's interfaces from its
  360. // gfx::NativeWindow.
  361. std::unique_ptr<remote_cocoa::ScopedNativeWindowMapping>
  362. native_window_mapping_;
  363. // Parent and child widgets.
  364. raw_ptr<NativeWidgetMacNSWindowHost> parent_ = nullptr;
  365. std::vector<NativeWidgetMacNSWindowHost*> children_;
  366. // The factory that was used to create |remote_ns_window_remote_|. This must
  367. // be the same as |parent_->application_host_|.
  368. raw_ptr<remote_cocoa::ApplicationHost> application_host_ = nullptr;
  369. Widget::InitParams::Type widget_type_ = Widget::InitParams::TYPE_WINDOW;
  370. // The id that may be used to look up the NSView for |root_view_|.
  371. const uint64_t root_view_id_;
  372. // Weak. Owned by |native_widget_mac_|.
  373. raw_ptr<views::View> root_view_ = nullptr;
  374. std::unique_ptr<DragDropClientMac> drag_drop_client_;
  375. // The mojo remote for a BridgedNativeWidget, which may exist in another
  376. // process.
  377. mojo::AssociatedRemote<remote_cocoa::mojom::NativeWidgetNSWindow>
  378. remote_ns_window_remote_;
  379. // Remote accessibility objects corresponding to the NSWindow and its root
  380. // NSView.
  381. base::scoped_nsobject<NSAccessibilityRemoteUIElement>
  382. remote_window_accessible_;
  383. base::scoped_nsobject<NSAccessibilityRemoteUIElement> remote_view_accessible_;
  384. // Used to force the NSApplication's focused accessibility element to be the
  385. // views::Views accessibility tree when the NSView for this is focused.
  386. ui::AccessibilityFocusOverrider accessibility_focus_overrider_;
  387. // TODO(ccameron): Rather than instantiate a NativeWidgetNSWindowBridge here,
  388. // we will instantiate a mojo NativeWidgetNSWindowBridge interface to a Cocoa
  389. // instance that may be in another process.
  390. std::unique_ptr<remote_cocoa::NativeWidgetNSWindowBridge>
  391. in_process_ns_window_bridge_;
  392. // Window that is guaranteed to exist in this process (see
  393. // GetInProcessNSWindow).
  394. base::scoped_nsobject<NativeWidgetMacNSWindow> in_process_ns_window_;
  395. // Id mapping for |in_process_ns_window_|'s content NSView.
  396. std::unique_ptr<remote_cocoa::ScopedNSViewIdMapping>
  397. in_process_view_id_mapping_;
  398. std::unique_ptr<TooltipManager> tooltip_manager_;
  399. std::unique_ptr<TextInputHost> text_input_host_;
  400. std::u16string window_title_;
  401. // The display that the window is currently on.
  402. display::Display display_;
  403. // Display link for getting vsync info for |display_|.
  404. scoped_refptr<ui::DisplayLinkMac> display_link_;
  405. // The geometry of the window and its contents view, in screen coordinates.
  406. gfx::Rect window_bounds_in_screen_;
  407. gfx::Rect content_bounds_in_screen_;
  408. std::vector<uint8_t> state_restoration_data_;
  409. bool is_visible_ = false;
  410. bool target_fullscreen_state_ = false;
  411. bool in_fullscreen_transition_ = false;
  412. bool is_miniaturized_ = false;
  413. bool is_window_key_ = false;
  414. bool is_mouse_capture_active_ = false;
  415. bool is_headless_mode_window_ = false;
  416. gfx::Rect window_bounds_before_fullscreen_;
  417. // Weak pointers to event monitors for this widget. The event monitors
  418. // themselves will remove themselves from this list.
  419. std::list<NativeWidgetMacEventMonitor*> event_monitors_;
  420. std::unique_ptr<ui::RecyclableCompositorMac> compositor_;
  421. std::unique_ptr<remote_cocoa::ScopedCGWindowID> scoped_cg_window_id_;
  422. // Properties used by Set/GetNativeWindowProperty.
  423. std::map<std::string, void*> native_window_properties_;
  424. // Contains NativeViewHost->gfx::NativeView associations for NativeViewHosts
  425. // attached to |this|.
  426. std::map<const views::View*, NSView*> attached_native_view_host_views_;
  427. mojo::AssociatedReceiver<remote_cocoa::mojom::NativeWidgetNSWindowHost>
  428. remote_ns_window_host_receiver_{this};
  429. base::WeakPtrFactory<NativeWidgetMacNSWindowHost>
  430. weak_factory_for_vsync_update_{this};
  431. base::WeakPtrFactory<NativeWidgetMacNSWindowHost> weak_factory_{this};
  432. };
  433. } // namespace views
  434. #endif // UI_VIEWS_COCOA_NATIVE_WIDGET_MAC_NS_WINDOW_HOST_H_