// 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;
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;
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);
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; }
{ 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)
//////////////////////////////////////////////////////////////////////////////
+static struct wl_registry_listener registryListener = {
+ WLContext::RegistryHandleGlobal,
+ NULL
+};
+
static struct serverinfo_listener serverInfoListenerList = {
WLContext::ServerInfoListener,
};
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)
//////////////////////////////////////////////////////////////////////////////
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);
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);
}
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,
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, ®istryListener, this);
+ wl_display_dispatch(m_wlDisplay);
wl_display_roundtrip(m_wlDisplay);
return true;