| Index: components/mus/ws/window_manager_state.h
|
| diff --git a/components/mus/ws/window_manager_state.h b/components/mus/ws/window_manager_state.h
|
| index c0fe99aaf8b8fa996083457c42a680728f0194d7..af6f3899817b62427d9a4cddebf8c31c7b4c463e 100644
|
| --- a/components/mus/ws/window_manager_state.h
|
| +++ b/components/mus/ws/window_manager_state.h
|
| @@ -8,27 +8,47 @@
|
| #include <stdint.h>
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/timer/timer.h"
|
| #include "components/mus/public/interfaces/display.mojom.h"
|
| +#include "components/mus/ws/connection_manager.h"
|
| +#include "components/mus/ws/event_dispatcher.h"
|
| +#include "components/mus/ws/event_dispatcher_delegate.h"
|
| #include "components/mus/ws/user_id.h"
|
|
|
| +namespace cc {
|
| +struct SurfaceId;
|
| +}
|
| +
|
| namespace mus {
|
| namespace ws {
|
|
|
| class Display;
|
| +class PlatformDisplay;
|
| class ServerWindow;
|
| class WindowTree;
|
|
|
| +namespace test {
|
| +class WindowManagerStateTestApi;
|
| +}
|
| +
|
| // Manages the state associated with a connection to a WindowManager for
|
| // a specific user.
|
| -class WindowManagerState {
|
| +class WindowManagerState : public EventDispatcherDelegate {
|
| public:
|
| // Creates a WindowManagerState that can host content from any user.
|
| - explicit WindowManagerState(Display* display);
|
| - WindowManagerState(Display* display, const UserId& user_id);
|
| - ~WindowManagerState();
|
| + WindowManagerState(Display* display,
|
| + PlatformDisplay* platform_display,
|
| + cc::SurfaceId surface_id);
|
| + WindowManagerState(Display* display,
|
| + PlatformDisplay* platform_display,
|
| + cc::SurfaceId surface_id,
|
| + const UserId& user_id);
|
| + ~WindowManagerState() override;
|
|
|
| bool is_user_id_valid() const { return is_user_id_valid_; }
|
|
|
| + const UserId& user_id() const { return user_id_; }
|
| +
|
| ServerWindow* root() { return root_.get(); }
|
| const ServerWindow* root() const { return root_.get(); }
|
|
|
| @@ -46,22 +66,97 @@ class WindowManagerState {
|
| return got_frame_decoration_values_;
|
| }
|
|
|
| + void SetCapture(ServerWindow* window, bool in_nonclient_area);
|
| + ServerWindow* capture_window() { return event_dispatcher_.capture_window(); }
|
| + const ServerWindow* capture_window() const {
|
| + return event_dispatcher_.capture_window();
|
| + }
|
| +
|
| + // Returns true if this is the WindowManager of the active user.
|
| + bool IsActive() const;
|
| +
|
| + // TODO(sky): EventDispatcher is really an implementation detail and should
|
| + // not be exposed.
|
| + EventDispatcher* event_dispatcher() { return &event_dispatcher_; }
|
| +
|
| + // Processes an event from PlatformDisplay.
|
| + void ProcessEvent(const ui::Event& event);
|
| +
|
| + // Called when the ack from an event dispatched to a WindowTree is received.
|
| + // TODO(sky): make this private and use a callback.
|
| + void OnEventAck(mojom::WindowTree* tree);
|
| +
|
| // Returns a mojom::Display for the specified display. WindowManager specific
|
| // values are not set.
|
| mojom::DisplayPtr ToMojomDisplay() const;
|
|
|
| + void OnWillDestroyTree(WindowTree* tree);
|
| +
|
| private:
|
| + class ProcessedEventTarget;
|
| friend class Display;
|
| -
|
| - WindowManagerState(Display* display, bool is_user_id_valid,
|
| + friend class test::WindowManagerStateTestApi;
|
| +
|
| + // There are two types of events that may be queued, both occur only when
|
| + // waiting for an ack from a client.
|
| + // . We get an event from the PlatformDisplay. This results in |event| being
|
| + // set, but |processed_target| is null.
|
| + // . We get an event from the EventDispatcher. In this case both |event| and
|
| + // |processed_target| are valid.
|
| + // The second case happens if EventDispatcher generates more than one event
|
| + // at a time.
|
| + struct QueuedEvent {
|
| + QueuedEvent();
|
| + ~QueuedEvent();
|
| +
|
| + scoped_ptr<ui::Event> event;
|
| + scoped_ptr<ProcessedEventTarget> processed_target;
|
| + };
|
| +
|
| + WindowManagerState(Display* display,
|
| + PlatformDisplay* platform_display,
|
| + cc::SurfaceId surface_id,
|
| + bool is_user_id_valid,
|
| const UserId& user_id);
|
|
|
| + ConnectionManager* connection_manager();
|
| +
|
| + void OnEventAckTimeout();
|
| +
|
| + // Schedules an event to be processed later.
|
| + void QueueEvent(const ui::Event& event,
|
| + scoped_ptr<ProcessedEventTarget> processed_event_target);
|
| +
|
| + // Processes the next valid event in |event_queue_|. If the event has already
|
| + // been processed it is dispatched, otherwise the event is passed to the
|
| + // EventDispatcher for processing.
|
| + void ProcessNextEventFromQueue();
|
| +
|
| + // Dispatches the event to the appropriate client and starts the ack timer.
|
| + void DispatchInputEventToWindowImpl(ServerWindow* target,
|
| + bool in_nonclient_area,
|
| + const ui::Event& event);
|
| +
|
| + // EventDispatcherDelegate:
|
| + void OnAccelerator(uint32_t accelerator_id, const ui::Event& event) override;
|
| + void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override;
|
| + ServerWindow* GetFocusedWindowForEventDispatcher() override;
|
| + void SetNativeCapture() override;
|
| + void ReleaseNativeCapture() override;
|
| + void OnServerWindowCaptureLost(ServerWindow* window) override;
|
| + void DispatchInputEventToWindow(ServerWindow* target,
|
| + bool in_nonclient_area,
|
| + const ui::Event& event) override;
|
| +
|
| Display* display_;
|
| + PlatformDisplay* platform_display_;
|
| // If this was created implicitly by a call
|
| // WindowTreeHostFactory::CreateWindowTreeHost(), then |is_user_id_valid_|
|
| // is false.
|
| const bool is_user_id_valid_;
|
| const UserId user_id_;
|
| + // Root ServerWindow of this WindowManagerState. |root_| has a parent, the
|
| + // root ServerWindow of the Display.
|
| scoped_ptr<ServerWindow> root_;
|
| WindowTree* tree_ = nullptr;
|
|
|
| @@ -69,6 +164,12 @@ class WindowManagerState {
|
| bool got_frame_decoration_values_ = false;
|
| mojom::FrameDecorationValuesPtr frame_decoration_values_;
|
|
|
| + mojom::WindowTree* tree_awaiting_input_ack_ = nullptr;
|
| + std::queue<scoped_ptr<QueuedEvent>> event_queue_;
|
| + base::OneShotTimer event_ack_timer_;
|
| +
|
| + EventDispatcher event_dispatcher_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(WindowManagerState);
|
| };
|
|
|
|
|