1 // Copyright 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef OZONE_WAYLAND_DISPATCHER_H_
6 #define OZONE_WAYLAND_DISPATCHER_H_
8 #include "base/threading/thread.h"
10 namespace ozonewayland {
12 class WaylandDispatcherDelegate;
13 class WindowChangeObserver;
15 // WaylandDispatcher class is used by OzoneDisplay for reading pending events
16 // coming from Wayland compositor and flush requests back. WaylandDispatcher is
17 // performed entirely in a separate IO thread and it can use polling as needed
18 // for the operations.
20 // WaylandDispatcher uses WaylandDispatcherDelegate to dispatch messages
23 class WaylandDispatcher : public base::Thread {
26 Flush = 0x01, // Handles Flush in worker thread.
27 Poll = 0x02 // To poll on a display fd. Task has no effect in case
28 // a valid display fd is not passed to WaylandDispatcher.
31 static WaylandDispatcher* GetInstance() { return instance_; }
32 void MotionNotify(float x, float y);
33 void ButtonNotify(unsigned handle, int state, int flags, float x, float y);
34 void AxisNotify(float x, float y, float xoffset, float yoffset);
35 void PointerEnter(unsigned handle, float x, float y);
36 void PointerLeave(unsigned handle, float x, float y);
37 void KeyNotify(unsigned type, unsigned code, unsigned modifiers);
38 void OutputSizeChanged(unsigned width, unsigned height);
40 // Posts task to worker thread.
41 void PostTask(Task type = Flush);
43 void SetWindowChangeObserver(WindowChangeObserver* observer);
44 void SetDelegate(WaylandDispatcherDelegate* delegate);
45 void SetActive(bool active);
48 explicit WaylandDispatcher(int fd = 0);
49 virtual ~WaylandDispatcher();
50 static void HandleFlush();
51 static void DisplayRun(WaylandDispatcher* data);
55 WaylandDispatcherDelegate* delegate_;
56 static WaylandDispatcher* instance_;
57 friend class OzoneDisplay;
58 DISALLOW_COPY_AND_ASSIGN(WaylandDispatcher);
61 } // namespace ozonewayland
63 #endif // OZONE_WAYLAND_DISPATCHER_H_