| Index: services/ui/ws/cursor_state.h
|
| diff --git a/services/ui/ws/cursor_state.h b/services/ui/ws/cursor_state.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b6af262b57eb644341c40243fc2f0ce02eab0358
|
| --- /dev/null
|
| +++ b/services/ui/ws/cursor_state.h
|
| @@ -0,0 +1,65 @@
|
| +// Copyright 2017 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.
|
| +
|
| +#ifndef SERVICES_UI_WS_CURSOR_STATE_H_
|
| +#define SERVICES_UI_WS_CURSOR_STATE_H_
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/optional.h"
|
| +#include "ui/base/cursor/cursor_data.h"
|
| +
|
| +namespace ui {
|
| +namespace ws {
|
| +
|
| +class DisplayManager;
|
| +
|
| +// Owns all the state about if and how the cursor is displayed in mus.
|
| +class CursorState {
|
| + public:
|
| + explicit CursorState(DisplayManager* display_manager);
|
| + ~CursorState();
|
| +
|
| + // Sets the normal cursor which would be used if the window manager hasn't
|
| + // set an override cursor.
|
| + void SetCurrentWindowCursor(const ui::CursorData& cursor);
|
| +
|
| + // When the cursor is locked, changes to the cursor are queued up. Queued
|
| + // changes are performed atomically when the cursor is unlocked.
|
| + void LockCursor();
|
| + void UnlockCursor();
|
| +
|
| + // Whether the cursor is visible on the display.
|
| + void SetCursorVisible(bool visible);
|
| +
|
| + // Sets a cursor globally, which overrides the per-window cursors.
|
| + void SetGlobalOverrideCursor(const base::Optional<ui::CursorData>& cursor);
|
| +
|
| + private:
|
| + // A snapshot of the cursor state at a specific time.
|
| + class StateSnapshot;
|
| +
|
| + // Synchronizes |current_state_| with all the platform displays.
|
| + void SetPlatformCursor();
|
| +
|
| + // Contains are the displays we notify on cursor changes.
|
| + DisplayManager* display_manager_;
|
| +
|
| + // Number of times LockCursor() has been invoked without a corresponding
|
| + // UnlockCursor().
|
| + int cursor_lock_count_ = 0;
|
| +
|
| + // The current state of the cursor.
|
| + std::unique_ptr<StateSnapshot> current_state_;
|
| +
|
| + // The cursor state to restore when the cursor is unlocked.
|
| + std::unique_ptr<StateSnapshot> state_on_unlock_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CursorState);
|
| +};
|
| +
|
| +} // namespace ws
|
| +} // namespace ui
|
| +
|
| +#endif // SERVICES_UI_WS_CURSOR_STATE_H_
|
|
|