• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2010, 2011 BMW Car IT GmbH
4  * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
5  *
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 #ifndef _WLCONTEXT_H_
21 #define _WLCONTEXT_H_
22 
23 #include <wayland-client.h>
24 #include <wayland-client-protocol.h>
25 #include <ivi-application-client-protocol.h>
26 #include <wayland-cursor.h>
27 
28 
29 struct seat_data {
30     struct wl_seat *wlSeat;
31     struct wl_keyboard *wlKeyboard;
32     struct wl_pointer *wlPointer;
33     struct wl_touch *wlTouch;
34     class WLContext *ctx;
35 };
36 
37 class WLContext
38 {
39 // properties
40 private:
41     struct wl_display*    m_wlDisplay;
42     struct wl_registry*   m_wlRegistry;
43     struct wl_compositor* m_wlCompositor;
44     struct ivi_application*    m_iviApp;
45 
46     struct wl_pointer_listener*  m_wlPointerListener;
47     struct wl_keyboard_listener* m_wlKeyboardListener;
48     struct wl_touch_listener*    m_wlTouchListener;
49 
50     struct wl_cursor_theme* m_wlCursorTheme;
51     struct wl_cursor* m_wlCursor;
52     struct wl_shm* m_wlShm;
53     struct wl_surface *m_pointerSurface;
54 
55 // methods
56 public:
57     WLContext();
58     virtual ~WLContext();
59 
60     bool InitWLContext(const struct wl_pointer_listener* wlPointerListener = NULL,
61                        const struct wl_keyboard_listener* wlKeyboardListener = NULL,
62                        const struct wl_touch_listener* wlTouchListener = NULL);
63 
64     struct wl_compositor* GetWLCompositor() const;
65     struct wl_display* GetWLDisplay() const;
66     struct wl_registry* GetWLRegistry() const;
67     struct wl_pointer_listener* GetWLPointerListener() const;
68     struct wl_keyboard_listener* GetWLKeyboardListener() const;
69     struct wl_touch_listener* GetWLTouchListener() const;
70     struct ivi_application* GetIviApp() const;
71     struct wl_cursor_theme* GetWLCursorTheme() const;
72     struct wl_cursor* GetWLCursor() const;
73     struct wl_shm* GetWLShm() const;
74     struct wl_surface* GetPointerSurface() const;
75 
76     void SetEventMask(uint32_t mask);
77     void SetWLCompositor(struct wl_compositor* wlCompositor);
78     void SetIviApp(struct ivi_application* iviApp);
79     void SetWLSeat(struct wl_seat* wlSeat);
80     void SetWLPointer(struct wl_pointer* wlPointer);
81     void SetWLKeyboard(struct wl_keyboard* wlKeyboard);
82     void SetWLTouch(struct wl_touch* wlTouch);
83     void SetWLCursorTheme(struct wl_cursor_theme* wlCursorTheme);
84     void SetWLCursor(struct wl_cursor* wlCursor);
85     void SetWLShm(struct wl_shm* wlShm);
86     void SetPointerSurface(struct wl_surface* pointerSurface);
87 
88     static void RegistryHandleGlobal(void* data,
89                                      struct wl_registry* registry,
90                                      uint32_t name,
91                                      const char* interface,
92                                      uint32_t version);
93     static void SeatHandleCapabilities(void* data,
94                                        struct wl_seat* seat,
95                                        uint32_t caps);
96     static int EventMaskUpdate(uint32_t mask, void* data);
97 
98 protected:
99     void DestroyWLContext();
100 };
101 
GetWLCompositor()102 inline struct wl_compositor* WLContext::GetWLCompositor() const { return m_wlCompositor; }
GetWLDisplay()103 inline struct wl_display* WLContext::GetWLDisplay() const { return m_wlDisplay; }
GetWLRegistry()104 inline struct wl_registry* WLContext::GetWLRegistry() const { return m_wlRegistry; }
GetWLPointerListener()105 inline struct wl_pointer_listener* WLContext::GetWLPointerListener() const
106     { return m_wlPointerListener; }
GetWLKeyboardListener()107 inline struct wl_keyboard_listener* WLContext::GetWLKeyboardListener() const
108     { return m_wlKeyboardListener; }
GetWLTouchListener()109 inline struct wl_touch_listener* WLContext::GetWLTouchListener() const
110     { return m_wlTouchListener; }
GetIviApp()111 inline struct ivi_application* WLContext::GetIviApp() const { return m_iviApp; }
GetWLCursorTheme()112 inline struct wl_cursor_theme* WLContext::GetWLCursorTheme() const { return m_wlCursorTheme; }
GetWLCursor()113 inline struct wl_cursor* WLContext::GetWLCursor() const { return m_wlCursor; }
GetWLShm()114 inline struct wl_shm* WLContext::GetWLShm() const { return m_wlShm; }
GetPointerSurface()115 inline struct wl_surface* WLContext::GetPointerSurface() const
116     { return m_pointerSurface; }
SetWLCompositor(struct wl_compositor * wlCompositor)117 inline void WLContext::SetWLCompositor(struct wl_compositor* wlCompositor)
118     { m_wlCompositor = wlCompositor; }
SetIviApp(struct ivi_application * iviApp)119 inline void WLContext::SetIviApp(struct ivi_application* iviApp)
120     { m_iviApp = iviApp; }
SetWLCursorTheme(struct wl_cursor_theme * wlCursorTheme)121 inline void WLContext::SetWLCursorTheme(struct wl_cursor_theme* wlCursorTheme)
122     { m_wlCursorTheme = wlCursorTheme; }
SetWLCursor(struct wl_cursor * wlCursor)123 inline void WLContext::SetWLCursor(struct wl_cursor* wlCursor)
124     { m_wlCursor = wlCursor; }
SetWLShm(struct wl_shm * wlShm)125 inline void WLContext::SetWLShm(struct wl_shm* wlShm) { m_wlShm = wlShm; }
SetPointerSurface(struct wl_surface * pointerSurface)126 inline void WLContext::SetPointerSurface(struct wl_surface* pointerSurface)
127     { m_pointerSurface = pointerSurface; }
128 
129 #endif /* _WLCONTEXT_H_ */
130