blob: e1f4519daca33e8a291c77b4c8fc9f6a0b7fde71 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.ui.scenic;
using fuchsia.images;
using fuchsia.mem;
using fuchsia.ui.gfx;
using fuchsia.ui.pointer;
using fuchsia.ui.views;
using zx;
/// Scenic.TakeScreenshot() returns a raw BGRA formatted image in
/// sRGB color space and with a non-linear transfer function in this
/// struct.
resource struct ScreenshotData {
fuchsia.images.ImageInfo info;
fuchsia.mem.Buffer data;
};
/// The protocol endpoints used in creating a Scenic Session.
resource table SessionEndpoints {
/// Enqueue commands and present content.
/// Required.
1: request<Session> session;
/// Receive session-related events.
/// Optional.
2: SessionListener session_listener;
/// Change view focus, within the session view's subtree.
/// Optional.
3: request<fuchsia.ui.views.Focuser> view_focuser;
/// Learn when this session view receives or loses view focus.
/// Optional.
4: request<fuchsia.ui.views.ViewRefFocused> view_ref_focused;
/// Ask for touch events and negotiate for gesture ownership.
/// Optional.
5: request<fuchsia.ui.pointer.TouchSource> touch_source;
/// Ask for mouse events.
/// Optional.
6: request<fuchsia.ui.pointer.MouseSource> mouse_source;
};
[Discoverable]
protocol Scenic {
/// Create a new Session, which is the primary way to interact with Scenic.
CreateSession(request<Session> session, SessionListener? listener);
/// Create a new Session, which is the primary way to interact with Scenic.
///
/// In this variant, the caller may register a request for focus management.
/// The `view_focuser`'s client is coupled to the requested `session`, and
/// this coupling acts as a security boundary: the ViewRef used as the basis
/// for authority by `view_focuser` must come from `session`.
[Transitional]
CreateSession2(request<Session> session, SessionListener? listener,
request<fuchsia.ui.views.Focuser>? view_focuser);
/// Create a new Session, which is the primary way to interact with Scenic.
///
/// In this variant, the caller may submit a combination of protocols
/// that make sense for it. The Session protocol is the only required
/// protocol. The SessionEndpoints table may be extended with more protocol
/// fields, but these extensions should retain ABI and API compatibility
/// with existing (pre-compiled) clients.
///
/// The response acknowledges the request to create a Session, but actual
/// creation may happen later.
[Transitional]
CreateSessionT(SessionEndpoints endpoints) -> ();
/// Get information about the Scenic's primary display.
// TODO(fxbug.dev/23687): in the future there will probably be a DisplayManager, and
// info about which displays to use will be provided to the Scenic.
GetDisplayInfo() -> (fuchsia.ui.gfx.DisplayInfo info);
/// Gets an event signaled with displayOwnedSignal or displayNotOwnedSignal
/// when display ownership changes.
GetDisplayOwnershipEvent() -> (zx.handle:EVENT ownership_event);
/// Take a screenshot and return the data in `img_data`. `img_data` will
/// not contain BGRA data if `success` is false.
// TODO(fxbug.dev/23901): The permissions here are too wide (anyone can take a
// screenshot), we should narrow them.
TakeScreenshot() -> (ScreenshotData img_data, bool success);
};
const uint32 displayOwnedSignal = 0x02000000;
const uint32 displayNotOwnedSignal = 0x01000000;