88#include " nbl/ui/IWindowXCB.h"
99#include " nbl/ui/CWindowXCB.h"
1010#include " nbl/ui/CCursorControlXCB.h"
11- // #include "nbl/ui/CClipboardManagerXCB.h"
1211#include " nbl/ui/CWindowManagerXCB.h"
1312
1413#include < cstdint>
@@ -96,59 +95,11 @@ CWindowXCB::CWindowXCB(native_handle_t&& handle, core::smart_refctd_ptr<CWindowM
9695 IWindowXCB (std::move(params)),
9796 m_handle (std::move(handle)),
9897 m_windowManager (std::move(winManager)),
99- // m_connection(core::make_smart_refctd_ptr<XCBConnection>(core::smart_refctd_ptr<CWindowManagerXCB>(m_windowManager))),
100- // m_cursorControl(core::make_smart_refctd_ptr<CCursorControlXCB>(core::smart_refctd_ptr<XCBConnection>(m_connection))),
10198 m_dispatcher (*this ) {
10299
103100 auto & xcb = m_handle.m_connection ->getXcbFunctionTable ();
104101 auto & xcbIccm = m_handle.m_connection ->getXcbIcccmFunctionTable ();
105102
106- // // m_handle.m_connection = m_connection->getRawConnection();
107- // // m_handle.m_window = xcb.pxcb_generate_id(m_connection->getNativeHandle());
108- // // m_handle.m_connection = m_connection->getNativeHandle();
109-
110- // const auto* primaryScreen = xcb::primaryScreen(m_handle.m_connection);
111-
112- // uint32_t eventMask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
113- // uint32_t valueList[] = {
114- // primaryScreen->black_pixel,
115- // XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
116- // XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE
117- // };
118-
119- // xcb_void_cookie_t xcbCheckResult = xcb.pxcb_create_window(
120- // m_handle.m_connection, XCB_COPY_FROM_PARENT, m_handle.m_window, primaryScreen->root,
121- // static_cast<int16_t>(m_x),
122- // static_cast<int16_t>(m_y),
123- // static_cast<int16_t>(m_width),
124- // static_cast<int16_t>(m_height), 4,
125- // XCB_WINDOW_CLASS_INPUT_OUTPUT, primaryScreen->root_visual, eventMask,
126- // valueList);
127-
128- // setWindowSize(m_width, m_height);
129-
130- // auto WM_DELETE_WINDOW = xcb::resolveAtom(m_handle.m_connection, m_WM_DELETE_WINDOW);
131- // auto NET_WM_PING = xcb::resolveAtom(m_handle.m_connection, m_NET_WM_PING);
132- // auto WM_PROTOCOLS = xcb::resolveAtom(m_handle.m_connection, m_WM_PROTOCOLS);
133-
134- // const std::array atoms {WM_DELETE_WINDOW, NET_WM_PING};
135- // xcb.pxcb_change_property(
136- // m_handle.m_connection,
137- // XCB_PROP_MODE_REPLACE,
138- // m_handle.m_window,
139- // WM_PROTOCOLS, XCB_ATOM_ATOM, 32, atoms.size(), atoms.data());
140-
141-
142- // auto motifHints = XCBConnection::createFlagsToMotifWmHints(getFlags().value);
143- // xcb::setMotifWmHints(m_handle.m_window, motifHints);
144-
145- // if(isAlwaysOnTop()) {
146- // XCBConnection::AtomToken<core::StringLiteral("NET_WM_STATE_ABOVE")> NET_WM_STATE_ABOVE;
147- // m_connection->setNetMWState(
148- // primaryScreen->root,
149- // m_handle.m_window, false, m_connection->resolveAtom(NET_WM_STATE_ABOVE));
150- // }
151-
152103 xcb.pxcb_map_window (*m_handle.m_connection , m_handle.m_window );
153104 xcb.pxcb_flush (*m_handle.m_connection );
154105
@@ -170,71 +121,11 @@ IWindowManager* CWindowXCB::getManager() {
170121 return m_windowManager.get ();
171122}
172123
173- bool CWindowXCB::setWindowSize (uint32_t width, uint32_t height) {
174- auto & xcb = m_windowManager->getXcbFunctionTable ();
175- auto & xcbIccm = m_windowManager->getXcbIcccmFunctionTable ();
176-
177- // xcb_size_hints_t hints = {0};
178-
179- // xcbIccm.pxcb_icccm_size_hints_set_size(&hints, true, width, height);
180- // xcbIccm.pxcb_icccm_size_hints_set_min_size(&hints, width, height);
181- // xcbIccm.pxcb_icccm_size_hints_set_max_size(&hints, width, height);
182- // xcbIccm.pxcb_icccm_set_wm_normal_hints(m_connection->getNativeHandle(), m_handle.m_window, &hints);
183- return true ;
184- }
185-
186- bool CWindowXCB::setWindowPosition (int32_t x, int32_t y) {
187- auto & xcb = m_windowManager->getXcbFunctionTable ();
188-
189- // const int32_t values[] = { x, y };
190- // auto cookie = xcb.pxcb_configure_window_checked(m_connection->getNativeHandle(), m_handle.m_window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
191- // bool check = checkXcbCookie(xcb, m_connection->getNativeHandle(), cookie);
192- // xcb.pxcb_flush(m_connection->getNativeHandle());
193- return true ;
194- }
195-
196124void CWindowXCB::setCaption (const std::string_view& caption) {
197- auto & xcb = m_windowManager->getXcbFunctionTable ();
198-
199- // xcb.pxcb_change_property(m_connection->getNativeHandle(), XCB_PROP_MODE_REPLACE, m_handle.m_window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, static_cast<uint32_t>(caption.size()), reinterpret_cast<const void* const>(caption.data()));
200- // xcb.pxcb_flush(m_connection->getNativeHandle());
201- }
202-
203- bool CWindowXCB::setWindowRotation (bool landscape) {
204- return true ;
205- }
206-
207- bool CWindowXCB::setWindowVisible ( bool visible) {
208- auto & xcb = m_windowManager->getXcbFunctionTable ();
209-
210- // if(visible) {
211- // xcb.pxcb_map_window(m_connection->getNativeHandle(), m_handle.m_window);
212- // xcb.pxcb_flush(m_connection->getNativeHandle());
213- // } else {
214- // xcb.pxcb_unmap_window(m_connection->getNativeHandle(), m_handle.m_window);
215- // xcb.pxcb_flush(m_connection->getNativeHandle());
216- // }
217- return true ;
218- }
219-
220- bool CWindowXCB::setWindowMaximized (bool maximized) {
221- auto & xcb = m_windowManager->getXcbFunctionTable ();
222- // const auto* primaryScreen = m_connection->primaryScreen();
223-
224- // m_connection->setNetMWState(
225- // primaryScreen->root,
226- // m_handle.m_window, maximized && !isBorderless(), m_connection->resolveAtom(m_NET_WM_STATE_FULLSCREEN));
227-
228- // m_connection->setNetMWState(
229- // primaryScreen->root,
230- // m_handle.m_window, maximized && isBorderless(),
231- // m_connection->resolveAtom(m_NET_WM_STATE_MAXIMIZED_VERT),
232- // m_connection->resolveAtom(m_NET_WM_STATE_MAXIMIZED_HORZ));
233-
234- // xcb.pxcb_flush(m_connection->getNativeHandle());
235- return true ;
125+ auto & xcb = m_handle.m_connection ->getXcbFunctionTable ();
126+ xcb.pxcb_change_property (*m_handle.m_connection , XCB_PROP_MODE_REPLACE, m_handle.m_window , XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8 , static_cast <uint32_t >(caption.size ()), reinterpret_cast <const void * const >(caption.data ()));
127+ xcb.pxcb_flush (*m_handle.m_connection );
236128}
237-
238129}
239130
240131#endif
0 commit comments