// Copyright 2015 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 mus.mojom;

import "components/mus/public/interfaces/input_event_constants.mojom";
import "components/mus/public/interfaces/input_event_matcher.mojom";
import "components/mus/public/interfaces/input_events.mojom";
import "components/mus/public/interfaces/input_key_codes.mojom";
import "components/mus/public/interfaces/window_manager.mojom";
import "components/mus/public/interfaces/window_tree.mojom";
import "ui/mojo/geometry/geometry.mojom";

// WindowTreeHost encapsulates a unique underlying platform window, with a tree
// of windows.
interface WindowTreeHost {
  // Sets the size of the platform window.
  SetSize(mojo.Size size);

  // Sets a title string to be displayed on the platform window.
  SetTitle(string title);

  // Add and remove accelerators. When accelerators are registered the
  // WindowTreeHostClient receives the event via OnAccelerator() rather than the
  // target window. The id is defined by the client and can be used to more
  // easily identify the accelerator's action. If an accelerator with the same
  // id or the same matcher already exists, then the accelerator is not added,
  // and returns false.
  AddAccelerator(uint32 id, EventMatcher matcher) => (bool success);
  RemoveAccelerator(uint32 id);

  // Enables (or disables) child windows of |window_id| to be activated.
  AddActivationParent(uint32 window_id);
  RemoveActivationParent(uint32 window_id);

  ActivateNextWindow();

  // Sets the underlay surface offset for the specified window and additional
  // hit area. The underlay surface is drawn at the bounds of the window minus
  // the offset. The hit area is extended from the bounds of the window by
  // |hit_area|.
  // TODO(sky): pull this into the WindowTree API exposed for the
  // windowmanager.
  SetUnderlaySurfaceOffsetAndExtendedHitArea(uint32 window_id,
                                             int32 x_offset,
                                             int32 y_offset,
                                             mojo.Insets hit_area);
};

interface WindowTreeHostClient {
  // An accelerator registered via AddAccelerator() has been triggered.
  OnAccelerator(uint32 id, Event event);
};

interface WindowTreeHostFactory {
  CreateWindowTreeHost(WindowTreeHost& window_tree_host,
                       WindowTreeHostClient? host_client,
                       WindowTreeClient tree_client,
                       WindowManager? window_manager);
};