f4146754600f53e4d0aeeda1e2378237352f87d2
[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   std::string GetTitle() const;
58
59   void SetAppId( const std::string appId );
60   std::string GetAppId() const;
61
62 private:
63
64   /**
65    * Construct a new ShellClient.
66    */
67   ShellClient();
68
69   /**
70    * A reference counted object may only be deleted by calling Unreference()
71    */
72   virtual ~ShellClient();
73
74   /**
75    * Second-phase constructor. Must be called immediately after creating a new ShellClient;
76    */
77   void Initialize( Pepper::Compositor compositor, struct wl_client* client, uint32_t version, uint32_t id );
78
79   static void SurfaceResourceDestroy( struct wl_resource* resource );
80   static void OnSurfaceDestroy( pepper_event_listener_t* listener, pepper_object_t* surface, uint32_t id, void* info, void* data );
81   static void OnSurfaceCommit( pepper_event_listener_t* listener, pepper_object_t* surface, uint32_t id, void* info, void* data );
82
83 private:
84
85   // Undefined
86   ShellClient( const ShellClient& );
87
88   // Undefined
89   ShellClient& operator=( const ShellClient& rhs );
90
91 private: // Data
92
93   Pepper::Compositor mCompositor;
94
95   wl_resource* mClient;
96   wl_resource* mSurfaceResource;
97
98   pepper_surface_t* mSurface;
99   pepper_view_t* mView;
100
101   pepper_event_listener_t* mSurfaceDestroyListener;
102   pepper_event_listener_t* mSurfaceCommitListener;
103
104   std::string mTitle;
105   std::string mAppId;
106
107   bool mSurfaceMapped;
108   bool mAckConfigure;
109
110   ConfigureCallback mConfigureCallback;
111   void* mConfigureCallbackData;
112   int mWidth;
113   int mHeight;
114 };
115
116 } // namespace Internal
117
118 // Helpers for public-api forwarding methods
119
120 inline Pepper::Internal::ShellClient& GetImplementation( Pepper::ShellClient& shellClient )
121 {
122   DALI_ASSERT_ALWAYS( shellClient && "ShellClient handle is empty" );
123
124   BaseObject& handle = shellClient.GetBaseObject();
125
126   return static_cast< Internal::ShellClient& >( handle );
127 }
128
129 inline const Pepper::Internal::ShellClient& GetImplementation( const Pepper::ShellClient& shellClient )
130 {
131   DALI_ASSERT_ALWAYS( shellClient && "ShellClient handle is empty" );
132
133   const BaseObject& handle = shellClient.GetBaseObject();
134
135   return static_cast< const Internal::ShellClient& >( handle );
136 }
137
138 } // namespace Pepper
139
140 } // namespace Dali
141
142 #endif // __DALI_PEPPER_INTERNAL_SHELL_CLIENT_H__