Revert "[3.0] NativeImageSource with tbm_surface for tizen 3.0 wayland"
[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
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 namespace Adaptor
37 {
38
39
40
41 class WindowEventInterface;
42 class PerformanceInterface;
43
44 /**
45  * Client used to talk to Wayland server over a UNIX domain stream socket.
46  *
47  * Brief overview of Wayland:
48  *
49  * Transport mechanism = Socket
50  * Display = handles all the data sent from and to the compositor
51  * Display has a file descriptor that can be monitored for read / write events
52  *
53  * wl client function calls will place messages in a queue
54  * Calling wl_display_flush() will flush the messages to  the server
55  *
56  * Incoming data is handled in two steps: queueing and dispatching.
57  * In the queue step, the data coming from the display fd is interpreted and
58  * added to a queue. On the dispatch step, the handler for the incoming event is called.
59  *
60  * default queue is dispatched by calling wl_display_dispatch().
61  *
62  * The compositor sends out the frame event every time it draws a frame.
63  * wl_display_frame_callback() to schedule a callback per frame.
64  *
65  *
66  * wl_display_dispatch(). This will dispatch any events queued on the default queue and
67  * attempt to read from the display fd if it's empty.
68  * Events read are then queued on the appropriate queues according to the proxy assignment.
69  *
70  *
71  */
72 class WaylandManager
73 {
74
75 public:
76
77   /**
78    * @brief Constructor
79    */
80   WaylandManager();
81
82   /**
83    * @brief Destructor
84    */
85   ~WaylandManager();
86
87   /**
88    * @brief Connect to Wayland server and setup internal data structures
89    */
90   void Initialise();
91
92   /**
93    * @brief Assign window event interface.
94    * @param[in] eventInterface window event interface
95    */
96   void AssignWindowEventInterface( WindowEventInterface* eventInterface);
97
98   /**
99    * @brief create a surface for a window
100    * @param[in] window window object
101    */
102   void CreateSurface( Dali::Wayland::Window& window );
103
104   /**
105    * @brief get the wayland surface
106    * @return surface
107    */
108   WlSurface* GetSurface();
109
110 private: // change to private
111
112   /**
113    * @brief Install file descriptor monitor
114    */
115   void InstallFileDescriptorMonitor();
116
117   /**
118    * @brief File descriptor callback function, triggered when wayland compositor
119    * sends an event to the client (us)
120    * @param[in] eventTypeMask
121    */
122   void FileDescriptorCallback( FileDescriptorMonitor::EventType eventTypeMask );
123
124   /**
125    * @brief helper to get wayland interfaces
126    */
127   void GetWaylandInterfaces();
128
129 public:
130
131
132   InputManager  mInputManager;
133   WlDisplay* mDisplay;        ///< Wayland display, handles all the data sent from and to the compositor
134   WlShell* mShell;            ///< shell
135   WlCompositor* mCompositor;  ///< compositor
136   int mDisplayFileDescriptor; ///< File descriptor used by wayland client socket
137   FileDescriptorMonitor* mFileDescriptorMonitor;  ///< File descriptor monitor
138   WlXdgShell* mXdgShell;                ///< XDG Shell
139   WlSurface* mSurface;                  ///< Wayland surface
140   WlShellSurface* mShellSurface;        ///< Shell surface
141   WlXdgShellSurface*  mXdgSurface;      ///< XDG Shell surface
142
143
144 };
145 } // Internal
146 } // Adaptor
147 } // Dali
148
149 #endif