EGLWLInputEventExample: update for wayland version 1.0.0
authorNobuhiko Tanibata <ntanibata@jp.adit-jv.com>
Wed, 21 Nov 2012 14:11:45 +0000 (23:11 +0900)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Thu, 22 Nov 2012 10:03:26 +0000 (02:03 -0800)
Signed-off-by: Nobuhiko Tanibata <ntanibata@jp.adit-jv.com>
LayerManagerExamples/EGLWLInputEventExample/include/WLContext.h
LayerManagerExamples/EGLWLInputEventExample/src/WLContext.cpp
LayerManagerExamples/EGLWLInputEventExample/src/WLEyesRenderer.cpp
LayerManagerExamples/EGLWLInputEventExample/src/WaylandServerinfoProtocol.cpp

index 864959e..15f3a0e 100644 (file)
@@ -30,13 +30,13 @@ class WLContext
 // properties
 private:
     struct wl_display*    m_wlDisplay;
+    struct wl_registry*   m_wlRegistry;
     struct wl_compositor* m_wlCompositor;
     struct wl_seat*       m_wlSeat;
     struct wl_pointer*    m_wlPointer;
     struct wl_keyboard*   m_wlKeyboard;
     struct wl_touch*      m_wlTouch;
     struct serverinfo*    m_wlServerInfo;
-    uint32_t m_mask;
     uint32_t m_connectionId;
 
     struct wl_pointer_listener*  m_wlPointerListener;
@@ -54,6 +54,7 @@ public:
 
     struct wl_compositor* GetWLCompositor() const;
     struct wl_display* GetWLDisplay() const;
+    struct wl_registry* GetWLRegistry() const;
     struct wl_pointer* GetWLPointer() const;
     struct wl_keyboard* GetWLKeyboard() const;
     struct wl_touch* GetWLTouch() const;
@@ -72,11 +73,11 @@ public:
     void SetWLKeyboard(struct wl_keyboard* wlKeyboard);
     void SetWLTouch(struct wl_touch* wlTouch);
 
-    static void DisplayHandleGlobal(struct wl_display* display,
-                                    uint32_t id,
-                                    const char* interface,
-                                    uint32_t version,
-                                    void* data);
+    static void RegistryHandleGlobal(void* data,
+                                     struct wl_registry* registry,
+                                     uint32_t name,
+                                     const char* interface,
+                                     uint32_t version);
     static void ServerInfoListener(void* data,
                                    struct serverinfo* serverInfo,
                                    uint32_t clientHandle);
@@ -91,6 +92,7 @@ protected:
 
 inline struct wl_compositor* WLContext::GetWLCompositor() const { return m_wlCompositor; }
 inline struct wl_display* WLContext::GetWLDisplay() const { return m_wlDisplay; }
+inline struct wl_registry* WLContext::GetWLRegistry() const { return m_wlRegistry; }
 inline struct wl_pointer* WLContext::GetWLPointer() const { return m_wlPointer; }
 inline struct wl_keyboard* WLContext::GetWLKeyboard() const { return m_wlKeyboard; }
 inline struct wl_touch* WLContext::GetWLTouch() const { return m_wlTouch; }
@@ -103,7 +105,6 @@ inline struct wl_touch_listener* WLContext::GetWLTouchListener() const
     { return m_wlTouchListener; }
 inline uint32_t WLContext::GetConnectionId() const { return m_connectionId; }
 
-inline void WLContext::SetEventMask(uint32_t mask) { m_mask = mask; }
 inline void WLContext::SetWLCompositor(struct wl_compositor* wlCompositor)
     { m_wlCompositor = wlCompositor; }
 inline void WLContext::SetWLServerInfo(struct serverinfo* wlServerInfo)
index 874b0b9..1e017b4 100644 (file)
 
 //////////////////////////////////////////////////////////////////////////////
 
+static struct wl_registry_listener registryListener = {
+    WLContext::RegistryHandleGlobal,
+    NULL
+};
+
 static struct serverinfo_listener serverInfoListenerList = {
     WLContext::ServerInfoListener,
 };
@@ -40,12 +45,12 @@ static struct wl_seat_listener seatListener = {
 
 WLContext::WLContext()
 : m_wlDisplay(NULL)
+, m_wlRegistry(NULL)
 , m_wlCompositor(NULL)
 , m_wlSeat(NULL)
 , m_wlPointer(NULL)
 , m_wlTouch(NULL)
 , m_wlServerInfo(NULL)
-, m_mask(0)
 , m_connectionId(0)
 , m_wlPointerListener(NULL)
 , m_wlKeyboardListener(NULL)
@@ -61,13 +66,12 @@ WLContext::~WLContext()
 //////////////////////////////////////////////////////////////////////////////
 
 void
-WLContext::DisplayHandleGlobal(struct wl_display* display,
-                               uint32_t id,
-                               const char* interface,
-                               uint32_t version,
-                               void* data)
+WLContext::RegistryHandleGlobal(void* data,
+                                struct wl_registry* registry,
+                                uint32_t name,
+                                const char* interface,
+                                uint32_t version)
 {
-    WL_UNUSED(display);
     WL_UNUSED(version);
 
     WLContext* surface = static_cast<WLContext*>(data);
@@ -76,15 +80,16 @@ WLContext::DisplayHandleGlobal(struct wl_display* display,
     do {
         if (!strcmp(interface, "wl_compositor")){
             surface->SetWLCompositor(
-                (wl_compositor*)wl_display_bind(surface->GetWLDisplay(),
-                                                id,
-                                                &wl_compositor_interface));
+                (wl_compositor*)wl_registry_bind(registry,
+                                                name,
+                                                &wl_compositor_interface,
+                                                1));
             break;
         }
 
         if (!strcmp(interface, "serverinfo")){
-            struct serverinfo* wlServerInfo = (struct serverinfo*)wl_display_bind(
-                surface->GetWLDisplay(), id, &serverinfo_interface);
+            struct serverinfo* wlServerInfo = (struct serverinfo*)wl_registry_bind(
+                registry, name, &serverinfo_interface, 1);
             serverinfo_add_listener(wlServerInfo, &serverInfoListenerList, data);
             serverinfo_get_connection_id(wlServerInfo);
             surface->SetWLServerInfo(wlServerInfo);
@@ -92,24 +97,14 @@ WLContext::DisplayHandleGlobal(struct wl_display* display,
         }
 
         if (!strcmp(interface, "wl_seat")){
-            struct wl_seat* wlSeat = (wl_seat*)wl_display_bind(
-                surface->GetWLDisplay(), id, &wl_seat_interface);
+            struct wl_seat* wlSeat = (wl_seat*)wl_registry_bind(
+                registry, name, &wl_seat_interface, 1);
             wl_seat_add_listener(wlSeat, &seatListener, data);
             surface->SetWLSeat(wlSeat);
         }
     } while (0);
 }
 
-int
-WLContext::EventMaskUpdate(uint32_t mask, void* data)
-{
-    WLContext* surface = static_cast<WLContext*>(data);
-    assert(surface);
-
-    surface->SetEventMask(mask);
-    return 0;
-}
-
 void
 WLContext::ServerInfoListener(void* data,
                               struct serverinfo* serverInfo,
@@ -185,9 +180,9 @@ WLContext::InitWLContext(const struct wl_pointer_listener* wlPointerListener,
 
     m_wlDisplay = wl_display_connect(NULL);
 
-    wl_display_add_global_listener(m_wlDisplay, DisplayHandleGlobal, this);
-    wl_display_get_fd(m_wlDisplay, EventMaskUpdate, this);
-    wl_display_iterate(m_wlDisplay, WL_DISPLAY_READABLE);
+    m_wlRegistry = wl_display_get_registry(m_wlDisplay);
+    wl_registry_add_listener(m_wlRegistry, &registryListener, this);
+    wl_display_dispatch(m_wlDisplay);
     wl_display_roundtrip(m_wlDisplay);
 
     return true;
index 4ddbefc..d96d34f 100644 (file)
@@ -57,7 +57,7 @@ const struct wl_touch_listener TouchListener = {
 
 void WaitForEvent(struct wl_display* wlDisplay)
 {
-    wl_display_iterate(wlDisplay, WL_DISPLAY_READABLE);
+    wl_display_dispatch(wlDisplay);
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -502,6 +502,7 @@ DrawEyes(WLEGLSurface* surface, WLEyes* eyes)
 
     struct wl_callback* cb = wl_surface_frame(surface->GetWLSurface());
     wl_callback_add_listener(cb, &FrameListener, NULL);
+    wl_surface_commit(surface->GetWLSurface());
     wl_display_flush(surface->GetWLDisplay());
 
     return true;
index 8fa3cf5..e382793 100644 (file)
@@ -30,6 +30,7 @@
 #include <stdint.h>
 #include "wayland-util.h"
 
+#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
 
 static const struct wl_interface *types[] = {
        NULL,