| // Copyright 2018 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. |
| |
| module views_bridge_mac.mojom; |
| |
| import "mojo/public/mojom/base/string16.mojom"; |
| import "ui/base/mojo/ui_base_types.mojom"; |
| import "ui/gfx/geometry/mojo/geometry.mojom"; |
| import "ui/gfx/mojo/ca_layer_params.mojom"; |
| |
| // The window class (subclass of kNativeWidgetMacNSWindow) to use for a given |
| // window. |
| enum WindowClass { |
| // NativeWidgetMacNSWindow |
| kDefault, |
| // BrowserNativeWidgetWindow |
| kBrowser, |
| // NativeWidgetMacFramelessNSWindow |
| kFrameless, |
| }; |
| |
| // Parameters used to described creation of an NSWindow. |
| struct CreateWindowParams { |
| // The subclass of NativeWidgetMacNSWindow to use for this window. |
| WindowClass window_class; |
| |
| // The NSWindowStyleMask for the window. |
| uint64 style_mask; |
| |
| // Whether or not the titlebar should be forced to be transparent. If so, then |
| // the window is responsible for drawing its own titlebar. Note that the |
| // traffic lights will be drawn independent of this setting. |
| bool titlebar_appears_transparent; |
| |
| // Whether or not to hide the default title drawn by the window. If so, then |
| // the window is responsible for drawing its own title. |
| bool window_title_hidden; |
| |
| // Whether or not window animations should be initially enabled. |
| bool animation_enabled; |
| }; |
| |
| // Ways of changing the visibility of the bridged NSWindow. |
| enum WindowVisibilityState { |
| // Hides with -[NSWindow orderOut:]. |
| kHideWindow, |
| // Shows with -[NSWindow makeKeyAndOrderFront:]. |
| kShowAndActivateWindow, |
| // Shows with -[NSWindow orderWindow:..]. Orders the window above its parent |
| // if it has one. |
| kShowInactive |
| }; |
| |
| // Window transitions to animate, mirrors views::Widget::VisibilityTransition. |
| enum VisibilityTransition { |
| kShow = 1, |
| kHide = 2, |
| kBoth = 3, |
| kNone = 4, |
| }; |
| |
| struct BridgedNativeWidgetInitParams { |
| ui.mojom.ModalType modal_type; |
| // If true, the underlying window potentially be seen through. |
| bool is_translucent; |
| // True if the widget is considered top level widget. |
| bool widget_is_top_level; |
| // True if the bounds specified to SetBounds should be treated as though they |
| // are in screen coordinates. |
| bool position_window_in_screen_coords; |
| // If true, then the NSWindow is set to have a shadow using |
| // -[NSWindow setHasShadow:YES]. |
| bool has_window_server_shadow; |
| // If true, the NSWindow's collection behavior is set to include |
| // NSWindowCollectionBehaviorParticipatesInCycle (this is not the |
| // default for NSWindows with NSBorderlessWindowMask). |
| bool force_into_collection_cycle; |
| }; |
| |
| // The interface through which a NativeWidgetMac may interact with an NSWindow |
| // in another process. |
| interface BridgedNativeWidget { |
| // Create and set the NSWindow for the bridge. |
| CreateWindow(CreateWindowParams params); |
| |
| // Set the BridgedNativeWidget indicated by |parent_id| to be the parent of |
| // this BridgedNativeWidget. |
| SetParent(uint64 parent_id); |
| |
| // Initialize the window's style. |
| InitWindow(BridgedNativeWidgetInitParams params); |
| |
| // Initialize the view to display compositor output. This will send the |
| // current visibility and dimensions (and any future updates) to the |
| // BridgedNativeWidgetHost. |
| InitCompositorView(); |
| |
| // Create the NSView to be the content view for the window. Use |ns_view_id| |
| // to look up this NSView in other functions (e.g, to specify a parent view). |
| CreateContentView(uint64 ns_view_id, gfx.mojom.Rect bounds); |
| |
| // Destroy the content NSView for this window. Note that the window will |
| // become blank once this has been called. |
| DestroyContentView(); |
| |
| // Initiate the closing of the window (the closing may be animated or posted |
| // to be run later). |
| CloseWindow(); |
| |
| // Immediately close the window (which will have the consequence of deleting |
| // |this| and its host). |
| CloseWindowNow(); |
| |
| // Specify initial bounds for the window via |new_bounds| in screen |
| // coordinates. It is invalid for |new_bounds| to have an empty size and |
| // non-zero position. The size of the window will be expanded so that the |
| // content size will be at least |minimum_content_size|. |
| SetInitialBounds(gfx.mojom.Rect new_bounds, |
| gfx.mojom.Size minimum_content_size); |
| |
| // Specify new bounds for the window via |new_bounds| in screen coordinates. |
| // The size of the window will be expanded so that the content size will be |
| // at least |minimum_content_size|. |
| SetBounds(gfx.mojom.Rect new_bounds, |
| gfx.mojom.Size minimum_content_size); |
| |
| // Centers the window and sets its content size to |content_size|. The size of |
| // the window will be expanded so that the content size will be at least |
| // |minimum_content_size|. |
| SetSizeAndCenter(gfx.mojom.Size content_size, |
| gfx.mojom.Size minimum_content_size); |
| |
| // Sets the desired visibility of the window and updates the visibility of |
| // descendant windows where necessary. |
| SetVisibilityState(WindowVisibilityState new_state); |
| |
| // Enables or disables all window animations. |
| SetAnimationEnabled(bool animation_enabled); |
| |
| // Sets which transitions will animate. Currently this only affects non-native |
| // animations. |
| SetTransitionsToAnimate(VisibilityTransition transitions); |
| |
| // Sets the collection behavior so that the window will or will not be visible |
| // on all spaces. |
| SetVisibleOnAllSpaces(bool always_visible); |
| |
| // Called by NativeWidgetMac to initiate a transition to the specified target |
| // fullscreen state. |
| SetFullscreen(bool fullscreen); |
| |
| // Miniaturize or deminiaturize the window. |
| SetMiniaturized(bool miniaturized); |
| |
| // Called by NativeWidgetMac when the window size constraints change. |
| SetSizeConstraints(gfx.mojom.Size min_size, |
| gfx.mojom.Size max_size, |
| bool is_resizable, |
| bool is_maximizable); |
| |
| // Set the opacity of the NSWindow. |
| SetOpacity(float opacity); |
| |
| // Set the content aspect ratio of the NSWindow. |
| SetContentAspectRatio(gfx.mojom.SizeF aspect_ratio); |
| |
| // Specify the content to draw in the NSView. |
| SetCALayerParams(gfx.mojom.CALayerParams ca_layer_params); |
| |
| // Set the NSWindow's title text. |
| SetWindowTitle(mojo_base.mojom.String16 title); |
| |
| // Make the content view be the first responder for the NSWindow. |
| MakeFirstResponder(); |
| |
| // Clear the touchbar. |
| ClearTouchBar(); |
| |
| // Update the tooltip text at the current mouse location. |
| UpdateTooltip(); |
| |
| // Acquiring mouse capture first steals capture from any existing |
| // CocoaMouseCaptureDelegate, then captures all mouse events until released. |
| AcquireCapture(); |
| ReleaseCapture(); |
| |
| // Redispatch a keyboard event using the widget's window's CommandDispatcher. |
| // Note that the callers of this method use content::NativeWebKeyboardEvent, |
| // which would introduce a layering violation here. Specify explicitly as |
| // arguments only what is used in constructing the |os_event| member of |
| // content::NativeWebKeyboardEvent, to avoid this layering violation. |
| RedispatchKeyEvent( |
| uint64 type, |
| uint64 modifier_flags, |
| double timestamp, |
| mojo_base.mojom.String16 characters, |
| mojo_base.mojom.String16 characters_ignoring_modifiers, |
| uint32 key_code); |
| }; |