Merge "Set proper locale to harfbuzz" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / wayland-manager.h
1 #ifndef __DALI_WAYLAND_MANAGER_H__
2 #define __DALI_WAYLAND_MANAGER_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <wayland-extension/xdg-shell-client-protocol.h>   // from wayland
23
24 // INTERNAL INCLUDES
25 #include <wl-types.h>
26 #include <file-descriptor-monitor.h>
27 #include "input-manager.h"
28 #include "wayland-window.h"
29 #include "compositor-output-region/compositor-output.h"
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40
41
42 class WindowEventInterface;
43 class PerformanceInterface;
44
45 /**
46  * Client used to talk to Wayland server over a UNIX domain stream socket.
47  *
48  * Brief overview of Wayland:
49  *
50  * Transport mechanism = Socket
51  * Display = handles all the data sent from and to the compositor
52  * Display has a file descriptor that can be monitored for read / write events
53  *
54  * wl client function calls will place messages in a queue
55  * Calling wl_display_flush() will flush the messages to  the server
56  *
57  * Incoming data is handled in two steps: queueing and dispatching.
58  * In the queue step, the data coming from the display fd is interpreted and
59  * added to a queue. On the dispatch step, the handler for the incoming event is called.
60  *
61  * This class uses the Wayland thread safe API's because the TPL (Tizen Platform Layer) will
62  * be communicating with the Wayland compositor at the same time in the DALi render thread.
63  *
64  *
65  */
66 class WaylandManager
67 {
68
69 public:
70
71   /**
72    * @brief Constructor
73    */
74   WaylandManager();
75
76   /**
77    * @brief Destructor
78    */
79   ~WaylandManager();
80
81   /**
82    * @brief Connect to Wayland server and setup internal data structures
83    */
84   void Initialise();
85
86   /**
87    * @brief Assign window event interface.
88    * @param[in] eventInterface window event interface
89    */
90   void AssignWindowEventInterface( WindowEventInterface* eventInterface);
91
92   /**
93    * @brief create a surface for a window
94    * @param[in] window window object
95    */
96   void CreateSurface( Dali::Wayland::Window& window );
97
98   /**
99    * @brief get the wayland surface
100    * @return surface
101    */
102   WlSurface* GetSurface();
103
104 private: // change to private
105
106   /**
107    * @brief Install file descriptor monitor
108    */
109   void InstallFileDescriptorMonitor();
110
111   /**
112    * @brief File descriptor callback function, triggered when wayland compositor
113    * sends an event to the client (us)
114    * @param[in] eventTypeMask
115    */
116   void FileDescriptorCallback( FileDescriptorMonitor::EventType eventTypeMask );
117
118   /**
119    * @brief Reads and dispatches any events from the Wayland compositor
120    * We have a file descriptor monitor active to decide when to call this function
121    */
122   void ReadAndDispatchEvents();
123
124   /**
125    * @brief helper to get wayland interfaces
126    */
127   void GetWaylandInterfaces();
128
129 public:
130
131
132   InputManager  mInputManager;
133   CompositorOutput mCompositorOutput;     ///< handles monitor information and DPI
134   WlDisplay* mDisplay;        ///< Wayland display, handles all the data sent from and to the compositor
135   WlShell* mShell;            ///< shell
136   WlCompositor* mCompositor;  ///< compositor
137   int mDisplayFileDescriptor; ///< File descriptor used by wayland client socket
138   FileDescriptorMonitor* mFileDescriptorMonitor;  ///< File descriptor monitor
139   WlXdgShell* mXdgShell;                ///< XDG Shell
140   WlSurface* mSurface;                  ///< Wayland surface
141   WlShellSurface* mShellSurface;        ///< Shell surface
142   WlXdgShellSurface*  mXdgSurface;      ///< XDG Shell surface
143
144
145 };
146 } // Internal
147 } // Adaptor
148 } // Dali
149
150 #endif