pepper-dali update
[platform/core/uifw/pepper-dali.git] / pepper-dali / internal / shell-client-impl.h
1 #ifndef __DALI_PEPPER_INTERNAL_SHELL_CLIENT_H__
2 #define __DALI_PEPPER_INTERNAL_SHELL_CLIENT_H__
3
4 /*
5  * Copyright (c) 2016 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 // INTERNAL INCLUDES
22 #include <pepper-dali/internal/shell-client.h>
23
24 // EXTERNAL INCLUDES
25 #include <dali/public-api/common/intrusive-ptr.h>
26 #include <dali/public-api/object/base-object.h>
27 #include <wayland-server.h>
28 #include <pepper.h>
29
30 namespace Dali
31 {
32
33 namespace Pepper
34 {
35
36 namespace Internal
37 {
38
39 class ShellClient;
40 typedef IntrusivePtr<ShellClient> ShellClientPtr;
41
42 class ShellClient : public BaseObject
43 {
44 public:
45
46   typedef void (*ConfigureCallback)( void* data, int width, int height );
47
48   static ShellClientPtr New( Pepper::Compositor compositor, struct wl_client* client, uint32_t version, uint32_t id );
49
50   void Configure( int width, int height, ConfigureCallback callback, void* data );
51   void AckConfigure();
52
53   pepper_view_t* GetView();
54   void GetSurface( wl_client* client, unsigned int id, wl_resource* surfaceResource );
55
56   void SetTitle( const std::string& title );
57   const std::string& GetTitle() const;
58
59   void SetAppId( const std::string& appId );
60   const std::string& GetAppId() const;
61
62   void MapSurface();
63   void UnmapSurface();
64
65 private:
66
67   /**
68    * Construct a new ShellClient.
69    */
70   ShellClient();
71
72   /**
73    * A reference counted object may only be deleted by calling Unreference()
74    */
75   virtual ~ShellClient();
76
77   /**
78    * Second-phase constructor. Must be called immediately after creating a new ShellClient;
79    */
80   void Initialize( Pepper::Compositor compositor, struct wl_client* client, uint32_t version, uint32_t id );
81
82   static void SurfaceResourceDestroy( struct wl_resource* resource );
83   static void OnSurfaceDestroy( pepper_event_listener_t* listener, pepper_object_t* surface, uint32_t id, void* info, void* data );
84   static void OnSurfaceCommit( pepper_event_listener_t* listener, pepper_object_t* surface, uint32_t id, void* info, void* data );
85
86 private:
87
88   // Undefined
89   ShellClient( const ShellClient& );
90
91   // Undefined
92   ShellClient& operator=( const ShellClient& rhs );
93
94 private: // Data
95
96   Pepper::Compositor mCompositor;
97
98   wl_resource* mClient;
99   wl_resource* mSurfaceResource;
100
101   pepper_surface_t* mSurface;
102   pepper_view_t* mView;
103
104   pepper_event_listener_t* mSurfaceDestroyListener;
105   pepper_event_listener_t* mSurfaceCommitListener;
106
107   std::string mTitle;
108   std::string mAppId;
109
110   bool mNeedSurfaceMap;
111   bool mAckConfigure;
112
113   ConfigureCallback mConfigureCallback;
114   void* mConfigureCallbackData;
115   int mWidth;
116   int mHeight;
117 };
118
119 } // namespace Internal
120
121 // Helpers for public-api forwarding methods
122
123 inline Pepper::Internal::ShellClient& GetImplementation( Pepper::ShellClient& shellClient )
124 {
125   DALI_ASSERT_ALWAYS( shellClient && "ShellClient handle is empty" );
126
127   BaseObject& handle = shellClient.GetBaseObject();
128
129   return static_cast< Internal::ShellClient& >( handle );
130 }
131
132 inline const Pepper::Internal::ShellClient& GetImplementation( const Pepper::ShellClient& shellClient )
133 {
134   DALI_ASSERT_ALWAYS( shellClient && "ShellClient handle is empty" );
135
136   const BaseObject& handle = shellClient.GetBaseObject();
137
138   return static_cast< const Internal::ShellClient& >( handle );
139 }
140
141 } // namespace Pepper
142
143 } // namespace Dali
144
145 #endif // __DALI_PEPPER_INTERNAL_SHELL_CLIENT_H__