Skip to content

Commit c3639e9

Browse files
committed
remove getXcbWindow and getXcbConnection
Signed-off-by: Michael Pollind <mpollind@gmail.com>
1 parent 454e7e4 commit c3639e9

File tree

6 files changed

+21
-27
lines changed

6 files changed

+21
-27
lines changed

include/nbl/ui/CWindowXCB.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,10 @@ class NBL_API2 CWindowXCB final : public IWindowXCB
2323
CWindowXCB(core::smart_refctd_ptr<CWindowManagerXCB>&& winManager, SCreationParams&& params);
2424
~CWindowXCB();
2525

26-
2726
const native_handle_t* getNativeHandle() const override {
2827
return &m_handle;
2928
}
3029

31-
// Display* getDisplay() const override { return m_dpy; }
32-
xcb_window_t getXcbWindow() const override { return m_handle.m_window; }
33-
xcb_connection_t* getXcbConnection() const override {
34-
return m_connection->getRawConnection();
35-
}
36-
3730
virtual IClipboardManager* getClipboardManager() override;
3831
virtual ICursorControl* getCursorControl() override;
3932
virtual IWindowManager* getManager() const override;

include/nbl/ui/IWindowXCB.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ class NBL_API2 IWindowXCB : public IWindow
2929

3030
virtual const native_handle_t* getNativeHandle() const = 0;
3131

32-
virtual xcb_window_t getXcbWindow() const = 0;
33-
virtual xcb_connection_t* getXcbConnection() const = 0;
34-
3532
virtual bool setWindowSize_impl(uint32_t width, uint32_t height) = 0;
3633
virtual bool setWindowPosition_impl(int32_t x, int32_t y) = 0;
3734
virtual bool setWindowRotation_impl(bool landscape) = 0;

src/nbl/ui/CClipboardManagerXCB.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,16 @@ namespace nbl::ui
3030

3131
void CClipboardManagerXCB::process(const IWindowXCB* window, xcb_generic_event_t* event) {
3232
const auto& xcb = m_connection->getXcbFunctionTable();
33-
33+
auto* windowHandle = window->getNativeHandle();
34+
assert(windowHandle && windowHandle->m_window != XCB_WINDOW_NONE && windowHandle->m_connection != nullptr);
3435
auto TARGETS = m_connection->resolveAtom(m_TARGETS);
3536

36-
const auto& native_handle = window->getNativeHandle();
37-
3837
switch(event->response_type & ~0x80) {
3938
// XCB_ATOM
4039
// Somone is requesting the clipboard data
4140
case XCB_SELECTION_REQUEST: {
4241
auto* sne = reinterpret_cast<xcb_selection_request_event_t*>(event);
43-
if(sne->requestor == window->getXcbWindow()) {
42+
if(sne->requestor == windowHandle->m_window) {
4443
if(sne->target == TARGETS) {
4544
std::vector<xcb_atom_t> targets;
4645
{
@@ -113,7 +112,7 @@ namespace nbl::ui
113112
// we've requested the clipboard data, and this is the reply
114113
case XCB_SELECTION_NOTIFY: {
115114
auto* sne = reinterpret_cast<xcb_selection_notify_event_t*>(event);
116-
if(sne->requestor == window->getXcbWindow()){
115+
if(sne->requestor == windowHandle->m_window){
117116
// xcb.pxcb_get_a
118117
xcb_atom_t fieldType = XCB_ATOM;
119118
if(sne->target != TARGETS) {

src/nbl/ui/CCursorControlXCB.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ namespace nbl::ui
2626
void CCursorControlXCB::setRelativePosition(IWindow* window, SRelativePosition position) {
2727
auto* windowXcb = static_cast<IWindowXCB*>(window);
2828
auto& xcb = m_connection->getXcbFunctionTable();
29-
auto xcbWindow = windowXcb->getXcbWindow();
30-
31-
xcb.pxcb_warp_pointer(m_connection->getRawConnection(), XCB_NONE, xcbWindow, 0, 0, 0, 0, position.x, position.y);
29+
auto* handle = windowXcb->getNativeHandle();
30+
assert(handle && handle->m_window != XCB_WINDOW_NONE);
31+
32+
xcb.pxcb_warp_pointer(m_connection->getRawConnection(), XCB_NONE, handle->m_window, 0, 0, 0, 0, position.x, position.y);
3233
xcb.pxcb_flush(m_connection->getRawConnection());
3334
}
3435

src/nbl/ui/CWindowXCB.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ void CWindowXCB::CDispatchThread::work(lock_t& lock){
3434
}
3535
auto& xcb = m_window.m_windowManager->getXcbFunctionTable();
3636
auto& connection = m_window.m_connection;
37+
auto& windowHandle = m_window.m_handle;
38+
3739

3840
auto MW_DELETE_WINDOW = connection->resolveAtom(m_window.m_WM_DELETE_WINDOW);
3941
auto NET_WM_PING = connection->resolveAtom(m_window.m_NET_WM_PING);
@@ -62,7 +64,7 @@ void CWindowXCB::CDispatchThread::work(lock_t& lock){
6264
}
6365
case XCB_DESTROY_WINDOW: {
6466
xcb_destroy_window_request_t* dwr = reinterpret_cast<xcb_destroy_window_request_t*>(event);
65-
if(dwr->window == m_window.m_handle.m_window) {
67+
if(dwr->window == windowHandle.m_window) {
6668
m_quit = true;
6769
eventCallback->onWindowClosed(&m_window);
6870
}
@@ -71,19 +73,19 @@ void CWindowXCB::CDispatchThread::work(lock_t& lock){
7173
case XCB_CLIENT_MESSAGE: {
7274
xcb_client_message_event_t* cme = reinterpret_cast<xcb_client_message_event_t*>(event);
7375
if(cme->data.data32[0] == MW_DELETE_WINDOW) {
74-
xcb.pxcb_unmap_window(m_window.getXcbConnection(), m_window.m_handle.m_window);
75-
xcb.pxcb_destroy_window(m_window.getXcbConnection(), m_window.m_handle.m_window);
76-
xcb.pxcb_flush(m_window.getXcbConnection());
77-
m_window.m_handle.m_window = 0;
76+
xcb.pxcb_unmap_window(windowHandle.m_connection, windowHandle.m_window);
77+
xcb.pxcb_destroy_window(windowHandle.m_connection, windowHandle.m_window);
78+
xcb.pxcb_flush(windowHandle.m_connection);
79+
windowHandle.m_window = 0;
7880
m_quit = true; // we need to quit the dispatch thread
7981
eventCallback->onWindowClosed(&m_window);
8082
} else if(cme->data.data32[0] == NET_WM_PING && cme->window != connection->primaryScreen()->root) {
8183
xcb_client_message_event_t ev = *cme;
8284
ev.response_type = XCB_CLIENT_MESSAGE;
8385
ev.window = m_window.m_handle.m_window;
8486
ev.type = NET_WM_PING;
85-
xcb.pxcb_send_event(m_window.getXcbConnection(), 0, m_window.m_handle.m_window, XCB_EVENT_MASK_NO_EVENT, reinterpret_cast<const char*>(&ev));
86-
xcb.pxcb_flush(m_window.getXcbConnection());
87+
xcb.pxcb_send_event(windowHandle.m_connection, 0, m_window.m_handle.m_window, XCB_EVENT_MASK_NO_EVENT, reinterpret_cast<const char*>(&ev));
88+
xcb.pxcb_flush(windowHandle.m_connection);
8789
}
8890
break;
8991
}

src/nbl/video/CSurfaceVulkan.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,13 @@ namespace nbl::video
151151
if(!api || !window)
152152
return nullptr;
153153

154+
auto* handle = window->getNativeHandle();
155+
assert(handle && handle->m_window != XCB_WINDOW_NONE && handle->m_connection != nullptr);
154156
VkXcbSurfaceCreateInfoKHR createInfo { VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR};
155157
createInfo.pNext = nullptr;
156158
createInfo.flags = 0;
157-
createInfo.connection = window->getXcbConnection();
158-
createInfo.window = window->getXcbWindow();
159+
createInfo.connection = handle->m_connection;
160+
createInfo.window = handle->m_window;
159161
VkSurfaceKHR vk_surface;
160162
if (vkCreateXcbSurfaceKHR(api->getInternalObject(), &createInfo, nullptr, &vk_surface) == VK_SUCCESS)
161163
{

0 commit comments

Comments
 (0)