| // 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/display/mojo/display.mojom"; |
| import "ui/events/mojo/event.mojom"; |
| import "ui/gfx/geometry/mojo/geometry.mojom"; |
| import "ui/gfx/mojo/ca_layer_params.mojom"; |
| |
| struct ValidateUserInterfaceItemResult { |
| // Whether or not the specified sender should be enabled. |
| bool enable; |
| |
| // If true, then the item should be disabled if there exists no key equivalent |
| // for the item. |
| bool disable_if_has_no_key_equivalent; |
| |
| // The new title to set for the item (unset if the title is not to be |
| // changed). |
| mojo_base.mojom.String16? new_title; |
| |
| // Whether or not to change the hidden state for the item, and the new hidden |
| // state to set. |
| bool set_hidden_state; |
| bool new_hidden_state; |
| |
| // Whether or not to change the toggled state for the item, and the new toggle |
| // state to set. |
| bool set_toggle_state; |
| bool new_toggle_state; |
| }; |
| |
| // The interface through which a NativeWidgetMac may interact with an NSWindow |
| // in another process. |
| interface BridgedNativeWidgetHost { |
| // Update the views::Widget, ui::Compositor and ui::Layer's visibility. |
| OnVisibilityChanged(bool visible); |
| |
| // Called when the window's native theme changes. |
| OnWindowNativeThemeChanged(); |
| |
| // Resize the underlying views::View to |new_size| in response to the NSView's |
| // frame changing size. Note that this will not necessarily match the content |
| // bounds from OnWindowGeometryChanged. |
| OnViewSizeChanged(gfx.mojom.Size new_size); |
| |
| // Indicate if full keyboard accessibility is needed and update focus if |
| // needed. |
| SetKeyboardAccessible(bool enabled); |
| |
| // Indicate if the NSView for this widget is the first responder for the |
| // NSWindow for this widget. |
| OnIsFirstResponderChanged(bool is_first_responder); |
| |
| // Indicate if mouse capture is active. |
| OnMouseCaptureActiveChanged(bool capture_is_active); |
| |
| // Handle events. Note that whether or not the event is actually handled is |
| // not returned. |
| OnScrollEvent(ui.mojom.Event event); |
| OnMouseEvent(ui.mojom.Event event); |
| OnGestureEvent(ui.mojom.Event event); |
| |
| // Synchronously dispatch a key event and return in |event_handled| whether |
| // or not the event was handled. This method is to be used only via the |
| // BridgedNativeWidgetHostHelper interface. |
| [Sync] |
| DispatchKeyEventRemote(ui.mojom.Event event) => (bool event_handled); |
| |
| // Synchronously dispatch a key event to the current menu controller (if one |
| // exists and is owned by the widget for this). Return in |event_swallowed| |
| // whether or not the event was swallowed (that is, if the menu's dispatch |
| // returned POST_DISPATCH_NONE). Return in |event_handled| whether or not the |
| // event was handled (that is, if the event in the caller's scope should be |
| // marked as handled). This method is to be used only via the |
| // BridgedNativeWidgetHostHelper interface. |
| [Sync] |
| DispatchKeyEventToMenuControllerRemote(ui.mojom.Event event) => |
| (bool event_swallowed, bool event_handled); |
| |
| // Synchronously return in |has_menu_controller| whether or not a menu |
| // controller exists for this widget. |
| [Sync] |
| GetHasMenuController() => (bool has_menu_controller); |
| |
| // Synchronously query if |location_in_content| is a draggable background. |
| [Sync] |
| GetIsDraggableBackgroundAt(gfx.mojom.Point location_in_content) => |
| (bool is_draggable_background); |
| |
| // Synchronously query the tooltip text for |location_in_content|. |
| [Sync] |
| GetTooltipTextAt(gfx.mojom.Point location_in_content) => |
| (mojo_base.mojom.String16 new_tooltip_text); |
| |
| // Synchronously query the value of IsModal for this widget and store it in |
| // |widget_is_modal|. |
| [Sync] |
| GetWidgetIsModal() => (bool widget_is_modal); |
| |
| // Synchronously return in |is_textual| whether or not the focused view |
| // contains text that can be selected and copied. |
| [Sync] |
| GetIsFocusedViewTextual() => (bool is_textual); |
| |
| // Called whenever the NSWindow's size or position changes. |
| OnWindowGeometryChanged( |
| gfx.mojom.Rect window_bounds_in_screen_dips, |
| gfx.mojom.Rect content_bounds_in_screen_dips); |
| |
| // Called when the window begins transitioning to or from being fullscreen. |
| OnWindowFullscreenTransitionStart( |
| bool target_fullscreen_state); |
| |
| // Called when the window has completed its transition to or from being |
| // fullscreen. Note that if there are multiple consecutive transitions |
| // (because a new transition was initiated before the previous one completed) |
| // then this will only be called when all transitions have competed. |
| OnWindowFullscreenTransitionComplete(bool is_fullscreen); |
| |
| // Called when the window is miniaturized or deminiaturized. |
| OnWindowMiniaturizedChanged(bool miniaturized); |
| |
| // Called when the current display or the properties of the current display |
| // change. |
| OnWindowDisplayChanged(display.mojom.Display display); |
| |
| // Called before the NSWindow is closed and destroyed. |
| OnWindowWillClose(); |
| |
| // Called after the NSWindow has been closed and destroyed. |
| OnWindowHasClosed(); |
| |
| // Called when the NSWindow becomes key or resigns from being key. Additional |
| // state required for the transition include whether or not the content NSView |
| // is the first responder for the NSWindow in |is_content_first_responder| and |
| // whether or not the NSApp's full keyboard access is enabled in |
| // |full_keyboard_access_enabled|. |
| OnWindowKeyStatusChanged(bool is_key, |
| bool is_content_first_responder, |
| bool full_keyboard_access_enabled); |
| |
| // Accept or cancel the current dialog window (depending on the value of |
| // |button|), if a current dialog exists. |
| DoDialogButtonAction(ui.mojom.DialogButton button); |
| |
| // Synchronously determine if the specified button exists in the current |
| // dialog (if any), along with its label, whether or not it is enabled, and |
| // whether or not it is the default button.. |
| [Sync] |
| GetDialogButtonInfo(ui.mojom.DialogButton button) => (bool button_exists, |
| mojo_base.mojom.String16 title, |
| bool is_button_enabled, |
| bool is_button_default); |
| |
| // Synchronously return in |buttons_exist| whether or not any buttons exist |
| // for the current dialog. |
| [Sync] |
| GetDoDialogButtonsExist() => (bool buttons_exist); |
| |
| // Synchronously query if the NSWindow should display its title. |
| [Sync] |
| GetShouldShowWindowTitle() => (bool should_show_window_title); |
| |
| // Synchronously query if the NSWindow can become key (activate, in views |
| // terminology). |
| [Sync] |
| GetCanWindowBecomeKey() => (bool can_window_become_key); |
| |
| // Synchronously query if the NSWindow should always render as if it is |
| // the key window (is active, in views terminology). |
| [Sync] |
| GetAlwaysRenderWindowAsKey() => (bool always_render_as_key); |
| |
| // Synchronously query if the NSWindow should always render as if it is |
| // the key window (is active, in views terminology). |
| [Sync] |
| GetCanWindowClose() => (bool can_window_close); |
| |
| // Synchronously query if the NSWindow's theme frame overrides the titlebar |
| // height, and, if so, what the overridden height is. |
| [Sync] |
| GetWindowFrameTitlebarHeight() => (bool override_titlebar_height, |
| float titlebar_height); |
| |
| // Handle "Move focus to the window toolbar" shortcut. |
| OnFocusWindowToolbar(); |
| |
| // Return in |element_token| the token for the AX node for this view. Return |
| // the pid of the browser process to be registered as a remote UI process. Set |
| // the AX node for this view to have the element indicated by |window_token| |
| // as its window and the element indicated by |view_token| as its parent. |
| [Sync] |
| GetAccessibilityTokens(array<uint8> window_token, |
| array<uint8> view_token) => |
| (int64 host_pid, array<uint8> element_token); |
| |
| // Return the result for -[NSUserInterfaceValidations |
| // validateUserInterfaceItem] for a given command, along with any state for |
| // that item that should be updated. |
| [Sync] |
| ValidateUserInterfaceItem(int32 command) => |
| (ValidateUserInterfaceItemResult result); |
| }; |