diff options
Diffstat (limited to 'src/xwayland/XWM.cpp')
| -rw-r--r-- | src/xwayland/XWM.cpp | 603 |
1 files changed, 303 insertions, 300 deletions
diff --git a/src/xwayland/XWM.cpp b/src/xwayland/XWM.cpp index c62758c5..8e4f9a87 100644 --- a/src/xwayland/XWM.cpp +++ b/src/xwayland/XWM.cpp @@ -24,12 +24,12 @@ using namespace Hyprutils::OS; #define INCR_CHUNK_SIZE (64 * 1024) static int onX11Event(int fd, uint32_t mask, void* data) { - return g_pXWayland->pWM->onEvent(fd, mask); + return g_pXWayland->m_wm->onEvent(fd, mask); } SP<CXWaylandSurface> CXWM::windowForXID(xcb_window_t wid) { - for (auto const& s : surfaces) { - if (s->xID == wid) + for (auto const& s : m_surfaces) { + if (s->m_xID == wid) return s; } @@ -40,8 +40,8 @@ void CXWM::handleCreate(xcb_create_notify_event_t* e) { if (isWMWindow(e->window)) return; - const auto XSURF = surfaces.emplace_back(SP<CXWaylandSurface>(new CXWaylandSurface(e->window, CBox{e->x, e->y, e->width, e->height}, e->override_redirect))); - XSURF->self = XSURF; + const auto XSURF = m_surfaces.emplace_back(SP<CXWaylandSurface>(new CXWaylandSurface(e->window, CBox{e->x, e->y, e->width, e->height}, e->override_redirect))); + XSURF->m_self = XSURF; Debug::log(LOG, "[xwm] New XSurface at {:x} with xid of {}", (uintptr_t)XSURF.get(), e->window); const auto WINDOW = CWindow::create(XSURF); @@ -56,8 +56,8 @@ void CXWM::handleDestroy(xcb_destroy_notify_event_t* e) { if (!XSURF) return; - XSURF->events.destroy.emit(); - std::erase_if(surfaces, [XSURF](const auto& other) { return XSURF == other; }); + XSURF->m_events.destroy.emit(); + std::erase_if(m_surfaces, [XSURF](const auto& other) { return XSURF == other; }); } void CXWM::handleConfigureRequest(xcb_configure_request_event_t* e) { @@ -71,9 +71,9 @@ void CXWM::handleConfigureRequest(xcb_configure_request_event_t* e) { if (!(MASK & GEOMETRY)) return; - XSURF->events.configureRequest.emit(CBox{MASK & XCB_CONFIG_WINDOW_X ? e->x : XSURF->geometry.x, MASK & XCB_CONFIG_WINDOW_Y ? e->y : XSURF->geometry.y, - MASK & XCB_CONFIG_WINDOW_WIDTH ? e->width : XSURF->geometry.width, - MASK & XCB_CONFIG_WINDOW_HEIGHT ? e->height : XSURF->geometry.height}); + XSURF->m_events.configureRequest.emit(CBox{MASK & XCB_CONFIG_WINDOW_X ? e->x : XSURF->m_geometry.x, MASK & XCB_CONFIG_WINDOW_Y ? e->y : XSURF->m_geometry.y, + MASK & XCB_CONFIG_WINDOW_WIDTH ? e->width : XSURF->m_geometry.width, + MASK & XCB_CONFIG_WINDOW_HEIGHT ? e->height : XSURF->m_geometry.height}); } void CXWM::handleConfigureNotify(xcb_configure_notify_event_t* e) { @@ -82,12 +82,12 @@ void CXWM::handleConfigureNotify(xcb_configure_notify_event_t* e) { if (!XSURF) return; - if (XSURF->geometry == CBox{e->x, e->y, e->width, e->height}) + if (XSURF->m_geometry == CBox{e->x, e->y, e->width, e->height}) return; - XSURF->geometry = {e->x, e->y, e->width, e->height}; + XSURF->m_geometry = {e->x, e->y, e->width, e->height}; updateOverrideRedirect(XSURF, e->override_redirect); - XSURF->events.setGeometry.emit(); + XSURF->m_events.setGeometry.emit(); } void CXWM::handleMapRequest(xcb_map_request_event_t* e) { @@ -96,20 +96,21 @@ void CXWM::handleMapRequest(xcb_map_request_event_t* e) { if (!XSURF) return; - xcb_map_window(connection, e->window); + xcb_map_window(m_connection, e->window); XSURF->restackToTop(); const bool SMALL = - XSURF->geometry.size() < Vector2D{2, 2} || (XSURF->sizeHints && XSURF->geometry.size() < Vector2D{XSURF->sizeHints->min_width, XSURF->sizeHints->min_height}); - const bool HAS_HINTS = XSURF->sizeHints && Vector2D{XSURF->sizeHints->base_width, XSURF->sizeHints->base_height} > Vector2D{5, 5}; - const auto DESIREDSIZE = HAS_HINTS ? Vector2D{XSURF->sizeHints->base_width, XSURF->sizeHints->base_height} : Vector2D{800, 800}; + XSURF->m_geometry.size() < Vector2D{2, 2} || (XSURF->m_sizeHints && XSURF->m_geometry.size() < Vector2D{XSURF->m_sizeHints->min_width, XSURF->m_sizeHints->min_height}); + const bool HAS_HINTS = XSURF->m_sizeHints && Vector2D{XSURF->m_sizeHints->base_width, XSURF->m_sizeHints->base_height} > Vector2D{5, 5}; + const auto DESIREDSIZE = HAS_HINTS ? Vector2D{XSURF->m_sizeHints->base_width, XSURF->m_sizeHints->base_height} : Vector2D{800, 800}; // if it's too small, configure it. - if (SMALL && !XSURF->overrideRedirect) // default to 800 x 800 - XSURF->configure({XSURF->geometry.pos(), DESIREDSIZE}); + if (SMALL && !XSURF->m_overrideRedirect) // default to 800 x 800 + XSURF->configure({XSURF->m_geometry.pos(), DESIREDSIZE}); - Debug::log(LOG, "[xwm] Mapping window {} in X (geometry {}x{} at {}x{}))", e->window, XSURF->geometry.width, XSURF->geometry.height, XSURF->geometry.x, XSURF->geometry.y); + Debug::log(LOG, "[xwm] Mapping window {} in X (geometry {}x{} at {}x{}))", e->window, XSURF->m_geometry.width, XSURF->m_geometry.height, XSURF->m_geometry.x, + XSURF->m_geometry.y); // read data again. Some apps for some reason fail to send WINDOW_TYPE // this shouldn't happen but does, I prolly fucked up somewhere, this is a band-aid @@ -126,12 +127,12 @@ void CXWM::handleMapNotify(xcb_map_notify_event_t* e) { updateOverrideRedirect(XSURF, e->override_redirect); - if (XSURF->overrideRedirect) + if (XSURF->m_overrideRedirect) return; XSURF->setWithdrawn(false); sendState(XSURF); - xcb_flush(connection); + xcb_flush(m_connection); XSURF->considerMap(); } @@ -145,23 +146,23 @@ void CXWM::handleUnmapNotify(xcb_unmap_notify_event_t* e) { XSURF->unmap(); dissociate(XSURF); - if (XSURF->overrideRedirect) + if (XSURF->m_overrideRedirect) return; XSURF->setWithdrawn(true); sendState(XSURF); - xcb_flush(connection); + xcb_flush(m_connection); } static bool lookupParentExists(SP<CXWaylandSurface> XSURF, SP<CXWaylandSurface> prospectiveChild) { std::vector<SP<CXWaylandSurface>> visited; - while (XSURF->parent) { - if (XSURF->parent == prospectiveChild) + while (XSURF->m_parent) { + if (XSURF->m_parent == prospectiveChild) return true; visited.emplace_back(XSURF); - XSURF = XSURF->parent.lock(); + XSURF = XSURF->m_parent.lock(); if (std::find(visited.begin(), visited.end(), XSURF) != visited.end()) return false; @@ -179,8 +180,8 @@ std::string CXWM::getAtomName(uint32_t atom) { } // Get the name of the atom - auto const atom_name_cookie = xcb_get_atom_name(connection, atom); - auto* atom_name_reply = xcb_get_atom_name_reply(connection, atom_name_cookie, nullptr); + auto const atom_name_cookie = xcb_get_atom_name(m_connection, atom); + auto* atom_name_reply = xcb_get_atom_name_reply(m_connection, atom_name_cookie, nullptr); if (!atom_name_reply) return "Unknown"; @@ -198,90 +199,90 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_ propName = getAtomName(atom); if (atom == XCB_ATOM_WM_CLASS) { - size_t len = xcb_get_property_value_length(reply); - char* string = (char*)xcb_get_property_value(reply); - XSURF->state.appid = std::string{string, len}; - if (std::count(XSURF->state.appid.begin(), XSURF->state.appid.end(), '\000') == 2) - XSURF->state.appid = XSURF->state.appid.substr(XSURF->state.appid.find_first_of('\000') + 1); // fuck you X - if (!XSURF->state.appid.empty()) - XSURF->state.appid.pop_back(); - XSURF->events.metadataChanged.emit(); + size_t len = xcb_get_property_value_length(reply); + char* string = (char*)xcb_get_property_value(reply); + XSURF->m_state.appid = std::string{string, len}; + if (std::count(XSURF->m_state.appid.begin(), XSURF->m_state.appid.end(), '\000') == 2) + XSURF->m_state.appid = XSURF->m_state.appid.substr(XSURF->m_state.appid.find_first_of('\000') + 1); // fuck you X + if (!XSURF->m_state.appid.empty()) + XSURF->m_state.appid.pop_back(); + XSURF->m_events.metadataChanged.emit(); } else if (atom == XCB_ATOM_WM_NAME || atom == HYPRATOMS["_NET_WM_NAME"]) { size_t len = xcb_get_property_value_length(reply); char* string = (char*)xcb_get_property_value(reply); if (reply->type != HYPRATOMS["UTF8_STRING"] && reply->type != HYPRATOMS["TEXT"] && reply->type != XCB_ATOM_STRING) return; - XSURF->state.title = std::string{string, len}; - XSURF->events.metadataChanged.emit(); + XSURF->m_state.title = std::string{string, len}; + XSURF->m_events.metadataChanged.emit(); } else if (atom == HYPRATOMS["_NET_WM_WINDOW_TYPE"]) { xcb_atom_t* atomsArr = (xcb_atom_t*)xcb_get_property_value(reply); size_t atomsNo = reply->value_len; - XSURF->atoms.clear(); + XSURF->m_atoms.clear(); for (size_t i = 0; i < atomsNo; ++i) { - XSURF->atoms.push_back(atomsArr[i]); + XSURF->m_atoms.push_back(atomsArr[i]); } } else if (atom == HYPRATOMS["_NET_WM_STATE"]) { xcb_atom_t* atoms = (xcb_atom_t*)xcb_get_property_value(reply); for (uint32_t i = 0; i < reply->value_len; i++) { if (atoms[i] == HYPRATOMS["_NET_WM_STATE_MODAL"]) - XSURF->modal = true; + XSURF->m_modal = true; } } else if (atom == HYPRATOMS["WM_HINTS"]) { if (reply->value_len != 0) { - XSURF->hints = makeUnique<xcb_icccm_wm_hints_t>(); - xcb_icccm_get_wm_hints_from_reply(XSURF->hints.get(), reply); + XSURF->m_hints = makeUnique<xcb_icccm_wm_hints_t>(); + xcb_icccm_get_wm_hints_from_reply(XSURF->m_hints.get(), reply); - if (!(XSURF->hints->flags & XCB_ICCCM_WM_HINT_INPUT)) - XSURF->hints->input = true; + if (!(XSURF->m_hints->flags & XCB_ICCCM_WM_HINT_INPUT)) + XSURF->m_hints->input = true; } } else if (atom == HYPRATOMS["WM_WINDOW_ROLE"]) { size_t len = xcb_get_property_value_length(reply); if (len <= 0) - XSURF->role = ""; + XSURF->m_role = ""; else { - XSURF->role = std::string{(char*)xcb_get_property_value(reply), len}; - XSURF->role = XSURF->role.substr(0, XSURF->role.find_first_of('\000')); + XSURF->m_role = std::string{(char*)xcb_get_property_value(reply), len}; + XSURF->m_role = XSURF->m_role.substr(0, XSURF->m_role.find_first_of('\000')); } } else if (atom == XCB_ATOM_WM_TRANSIENT_FOR) { if (reply->type == XCB_ATOM_WINDOW) { - const auto XID = (xcb_window_t*)xcb_get_property_value(reply); - XSURF->transient = XID; + const auto XID = (xcb_window_t*)xcb_get_property_value(reply); + XSURF->m_transient = XID; if (XID) { if (const auto NEWXSURF = windowForXID(*XID); NEWXSURF && !lookupParentExists(XSURF, NEWXSURF)) { - XSURF->parent = NEWXSURF; - NEWXSURF->children.emplace_back(XSURF); + XSURF->m_parent = NEWXSURF; + NEWXSURF->m_children.emplace_back(XSURF); } else Debug::log(LOG, "[xwm] Denying transient because it would create a loop"); } } } else if (atom == HYPRATOMS["WM_NORMAL_HINTS"]) { if (reply->type == HYPRATOMS["WM_SIZE_HINTS"] && reply->value_len > 0) { - XSURF->sizeHints = makeUnique<xcb_size_hints_t>(); - std::memset(XSURF->sizeHints.get(), 0, sizeof(xcb_size_hints_t)); + XSURF->m_sizeHints = makeUnique<xcb_size_hints_t>(); + std::memset(XSURF->m_sizeHints.get(), 0, sizeof(xcb_size_hints_t)); - xcb_icccm_get_wm_size_hints_from_reply(XSURF->sizeHints.get(), reply); + xcb_icccm_get_wm_size_hints_from_reply(XSURF->m_sizeHints.get(), reply); - const int32_t FLAGS = XSURF->sizeHints->flags; + const int32_t FLAGS = XSURF->m_sizeHints->flags; const bool HASMIN = (FLAGS & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE); const bool HASBASE = (FLAGS & XCB_ICCCM_SIZE_HINT_BASE_SIZE); if (!HASMIN && !HASBASE) { - XSURF->sizeHints->min_width = -1; - XSURF->sizeHints->min_height = -1; - XSURF->sizeHints->base_width = -1; - XSURF->sizeHints->base_height = -1; + XSURF->m_sizeHints->min_width = -1; + XSURF->m_sizeHints->min_height = -1; + XSURF->m_sizeHints->base_width = -1; + XSURF->m_sizeHints->base_height = -1; } else if (!HASBASE) { - XSURF->sizeHints->base_width = XSURF->sizeHints->min_width; - XSURF->sizeHints->base_height = XSURF->sizeHints->min_height; + XSURF->m_sizeHints->base_width = XSURF->m_sizeHints->min_width; + XSURF->m_sizeHints->base_height = XSURF->m_sizeHints->min_height; } else if (!HASMIN) { - XSURF->sizeHints->min_width = XSURF->sizeHints->base_width; - XSURF->sizeHints->min_height = XSURF->sizeHints->base_height; + XSURF->m_sizeHints->min_width = XSURF->m_sizeHints->base_width; + XSURF->m_sizeHints->min_height = XSURF->m_sizeHints->base_height; } if (!(FLAGS & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)) { - XSURF->sizeHints->max_width = -1; - XSURF->sizeHints->max_height = -1; + XSURF->m_sizeHints->max_width = -1; + XSURF->m_sizeHints->max_height = -1; } } } else if (atom == HYPRATOMS["WM_PROTOCOLS"]) { @@ -292,7 +293,7 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_ for (size_t i = 0; i < reply->value_len; ++i) { vec.emplace_back(atoms[i]); } - XSURF->protocols = vec; + XSURF->m_protocols = vec; } } else { Debug::log(TRACE, "[xwm] Unhandled prop {} -> {}", atom, propName); @@ -308,8 +309,8 @@ void CXWM::handlePropertyNotify(xcb_property_notify_event_t* e) { if (!XSURF) return; - xcb_get_property_cookie_t cookie = xcb_get_property(connection, 0, XSURF->xID, e->atom, XCB_ATOM_ANY, 0, 2048); - xcb_get_property_reply_t* reply = xcb_get_property_reply(connection, cookie, nullptr); + xcb_get_property_cookie_t cookie = xcb_get_property(m_connection, 0, XSURF->m_xID, e->atom, XCB_ATOM_ANY, 0, 2048); + xcb_get_property_reply_t* reply = xcb_get_property_reply(m_connection, cookie, nullptr); if (!reply) { Debug::log(ERR, "[xwm] Failed to read property notify cookie"); return; @@ -329,39 +330,39 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) { std::string propName = getAtomName(e->type); if (e->type == HYPRATOMS["WM_PROTOCOLS"]) { - if (e->data.data32[1] == XSURF->lastPingSeq && e->data.data32[0] == HYPRATOMS["_NET_WM_PING"]) { + if (e->data.data32[1] == XSURF->m_lastPingSeq && e->data.data32[0] == HYPRATOMS["_NET_WM_PING"]) { g_pANRManager->onResponse(XSURF); return; } } else if (e->type == HYPRATOMS["WL_SURFACE_ID"]) { - if (XSURF->surface) { + if (XSURF->m_surface) { Debug::log(WARN, "[xwm] Re-assignment of WL_SURFACE_ID"); dissociate(XSURF); } auto id = e->data.data32[0]; - auto resource = wl_client_get_object(g_pXWayland->pServer->xwaylandClient, id); + auto resource = wl_client_get_object(g_pXWayland->m_server->m_xwaylandClient, id); if (resource) { auto surf = CWLSurfaceResource::fromResource(resource); associate(XSURF, surf); } } else if (e->type == HYPRATOMS["WL_SURFACE_SERIAL"]) { - if (XSURF->wlSerial) { + if (XSURF->m_wlSerial) { Debug::log(WARN, "[xwm] Re-assignment of WL_SURFACE_SERIAL"); dissociate(XSURF); } uint32_t serialLow = e->data.data32[0]; uint32_t serialHigh = e->data.data32[1]; - XSURF->wlSerial = ((uint64_t)serialHigh << 32) | serialLow; + XSURF->m_wlSerial = ((uint64_t)serialHigh << 32) | serialLow; - Debug::log(LOG, "[xwm] surface {:x} requests serial {:x}", (uintptr_t)XSURF.get(), XSURF->wlSerial); + Debug::log(LOG, "[xwm] surface {:x} requests serial {:x}", (uintptr_t)XSURF.get(), XSURF->m_wlSerial); - for (auto const& res : shellResources) { + for (auto const& res : m_shellResources) { if (!res) continue; - if (res->m_serial != XSURF->wlSerial || !XSURF->wlSerial) + if (res->m_serial != XSURF->m_wlSerial || !XSURF->m_wlSerial) continue; associate(XSURF, res->m_surface.lock()); @@ -391,15 +392,15 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) { }; if (prop == HYPRATOMS["_NET_WM_STATE_FULLSCREEN"]) - XSURF->state.requestsFullscreen = updateState(action, XSURF->fullscreen); + XSURF->m_state.requestsFullscreen = updateState(action, XSURF->m_fullscreen); } - XSURF->events.stateChanged.emit(); + XSURF->m_events.stateChanged.emit(); } } else if (e->type == HYPRATOMS["_NET_ACTIVE_WINDOW"]) { - XSURF->events.activate.emit(); + XSURF->m_events.activate.emit(); } else if (e->type == HYPRATOMS["XdndStatus"]) { - if (dndDataOffers.empty() || !dndDataOffers.at(0)->getSource()) { + if (m_dndDataOffers.empty() || !m_dndDataOffers.at(0)->getSource()) { Debug::log(TRACE, "[xwm] Rejecting XdndStatus message: nothing to get"); return; } @@ -408,16 +409,16 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) { const bool ACCEPTED = data->data32[1] & 1; if (ACCEPTED) - dndDataOffers.at(0)->getSource()->accepted(""); + m_dndDataOffers.at(0)->getSource()->accepted(""); Debug::log(LOG, "[xwm] XdndStatus: accepted: {}"); } else if (e->type == HYPRATOMS["XdndFinished"]) { - if (dndDataOffers.empty() || !dndDataOffers.at(0)->getSource()) { + if (m_dndDataOffers.empty() || !m_dndDataOffers.at(0)->getSource()) { Debug::log(TRACE, "[xwm] Rejecting XdndFinished message: nothing to get"); return; } - dndDataOffers.at(0)->getSource()->sendDndFinished(); + m_dndDataOffers.at(0)->getSource()->sendDndFinished(); Debug::log(LOG, "[xwm] XdndFinished"); } else { @@ -437,10 +438,10 @@ void CXWM::handleFocusIn(xcb_focus_in_event_t* e) { if (!XSURF) return; - if (focusedSurface && focusedSurface->pid == XSURF->pid && e->sequence - lastFocusSeq <= 255) + if (m_focusedSurface && m_focusedSurface->m_pid == XSURF->m_pid && e->sequence - m_lastFocusSeq <= 255) focusWindow(XSURF); else - focusWindow(focusedSurface.lock()); + focusWindow(m_focusedSurface.lock()); } void CXWM::handleFocusOut(xcb_focus_out_event_t* e) { @@ -451,8 +452,8 @@ void CXWM::handleFocusOut(xcb_focus_out_event_t* e) { if (!XSURF) return; - Debug::log(TRACE, "[xwm] focusOut for {} {} {} surface {}", XSURF->mapped ? "mapped" : "unmapped", XSURF->fullscreen ? "fullscreen" : "windowed", - XSURF == focusedSurface ? "focused" : "unfocused", XSURF->state.title); + Debug::log(TRACE, "[xwm] focusOut for {} {} {} surface {}", XSURF->m_mapped ? "mapped" : "unmapped", XSURF->m_fullscreen ? "fullscreen" : "windowed", + XSURF == m_focusedSurface ? "focused" : "unfocused", XSURF->m_state.title); // do something? } @@ -462,63 +463,63 @@ void CXWM::sendWMMessage(SP<CXWaylandSurface> surf, xcb_client_message_data_t* d .response_type = XCB_CLIENT_MESSAGE, .format = 32, .sequence = 0, - .window = surf->xID, + .window = surf->m_xID, .type = HYPRATOMS["WM_PROTOCOLS"], .data = *data, }; - xcb_send_event(connection, 0, surf->xID, mask, (const char*)&event); - xcb_flush(connection); + xcb_send_event(m_connection, 0, surf->m_xID, mask, (const char*)&event); + xcb_flush(m_connection); } void CXWM::focusWindow(SP<CXWaylandSurface> surf) { - if (surf == focusedSurface) + if (surf == m_focusedSurface) return; - focusedSurface = surf; + m_focusedSurface = surf; // send state to all toplevel surfaces, sometimes we might lose some // that could still stick with the focused atom - for (auto const& s : mappedSurfaces) { - if (!s || s->overrideRedirect) + for (auto const& s : m_mappedSurfaces) { + if (!s || s->m_overrideRedirect) continue; sendState(s.lock()); } if (!surf) { - xcb_set_input_focus_checked(connection, XCB_INPUT_FOCUS_POINTER_ROOT, XCB_NONE, XCB_CURRENT_TIME); + xcb_set_input_focus_checked(m_connection, XCB_INPUT_FOCUS_POINTER_ROOT, XCB_NONE, XCB_CURRENT_TIME); return; } - if (surf->overrideRedirect) + if (surf->m_overrideRedirect) return; xcb_client_message_data_t msg = {{0}}; msg.data32[0] = HYPRATOMS["WM_TAKE_FOCUS"]; msg.data32[1] = XCB_TIME_CURRENT_TIME; - if (surf->hints && !surf->hints->input) + if (surf->m_hints && !surf->m_hints->input) sendWMMessage(surf, &msg, XCB_EVENT_MASK_NO_EVENT); else { sendWMMessage(surf, &msg, XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT); - xcb_void_cookie_t cookie = xcb_set_input_focus(connection, XCB_INPUT_FOCUS_POINTER_ROOT, surf->xID, XCB_CURRENT_TIME); - lastFocusSeq = cookie.sequence; + xcb_void_cookie_t cookie = xcb_set_input_focus(m_connection, XCB_INPUT_FOCUS_POINTER_ROOT, surf->m_xID, XCB_CURRENT_TIME); + m_lastFocusSeq = cookie.sequence; } } void CXWM::handleError(xcb_value_error_t* e) { - const char* major_name = xcb_errors_get_name_for_major_code(errors, e->major_opcode); + const char* major_name = xcb_errors_get_name_for_major_code(m_errors, e->major_opcode); if (!major_name) { Debug::log(ERR, "xcb error happened, but could not get major name"); return; } - const char* minor_name = xcb_errors_get_name_for_minor_code(errors, e->major_opcode, e->minor_opcode); + const char* minor_name = xcb_errors_get_name_for_minor_code(m_errors, e->major_opcode, e->minor_opcode); const char* extension; - const char* error_name = xcb_errors_get_name_for_error(errors, e->error_code, &extension); + const char* error_name = xcb_errors_get_name_for_error(m_errors, e->error_code, &extension); if (!error_name) { Debug::log(ERR, "xcb error happened, but could not get error name"); return; @@ -539,8 +540,8 @@ void CXWM::selectionSendNotify(xcb_selection_request_event_t* e, bool success) { .property = success ? e->property : (uint32_t)XCB_ATOM_NONE, }; - xcb_send_event(connection, 0, e->requestor, XCB_EVENT_MASK_NO_EVENT, (const char*)&selection_notify); - xcb_flush(connection); + xcb_send_event(m_connection, 0, e->requestor, XCB_EVENT_MASK_NO_EVENT, (const char*)&selection_notify); + xcb_flush(m_connection); } xcb_atom_t CXWM::mimeToAtom(const std::string& mime) { @@ -549,8 +550,8 @@ xcb_atom_t CXWM::mimeToAtom(const std::string& mime) { if (mime == "text/plain") return HYPRATOMS["TEXT"]; - xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, 0, mime.length(), mime.c_str()); - xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(connection, cookie, nullptr); + xcb_intern_atom_cookie_t cookie = xcb_intern_atom(m_connection, 0, mime.length(), mime.c_str()); + xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(m_connection, cookie, nullptr); if (!reply) return XCB_ATOM_NONE; xcb_atom_t atom = reply->atom; @@ -564,8 +565,8 @@ std::string CXWM::mimeFromAtom(xcb_atom_t atom) { if (atom == HYPRATOMS["TEXT"]) return "text/plain"; - xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(connection, atom); - xcb_get_atom_name_reply_t* reply = xcb_get_atom_name_reply(connection, cookie, nullptr); + xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(m_connection, atom); + xcb_get_atom_name_reply_t* reply = xcb_get_atom_name_reply(m_connection, cookie, nullptr); if (!reply) return "INVALID"; size_t len = xcb_get_atom_name_name_length(reply); @@ -587,7 +588,7 @@ void CXWM::handleSelectionNotify(xcb_selection_notify_event_t* e) { sel->transfers.erase(it); } } else if (e->target == HYPRATOMS["TARGETS"]) { - if (!focusedSurface) { + if (!m_focusedSurface) { Debug::log(TRACE, "[xwm] denying access to write to clipboard because no X client is in focus"); return; } @@ -601,7 +602,7 @@ bool CXWM::handleSelectionPropertyNotify(xcb_property_notify_event_t* e) { if (e->state != XCB_PROPERTY_DELETE) return false; - for (auto* sel : {&clipboard, &primarySelection}) { + for (auto* sel : {&m_clipboard, &m_primarySelection}) { auto it = std::ranges::find_if(sel->transfers, [e](const auto& t) { return t->incomingWindow == e->window; }); if (it != sel->transfers.end()) { if (!(*it)->getIncomingSelectionProp(true)) { @@ -618,11 +619,11 @@ bool CXWM::handleSelectionPropertyNotify(xcb_property_notify_event_t* e) { SXSelection* CXWM::getSelection(xcb_atom_t atom) { if (atom == HYPRATOMS["CLIPBOARD"]) - return &clipboard; + return &m_clipboard; else if (atom == HYPRATOMS["PRIMARY"]) - return &primarySelection; + return &m_primarySelection; else if (atom == HYPRATOMS["XdndSelection"]) - return &dndSelection; + return &m_dndSelection; return nullptr; } @@ -650,7 +651,7 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) { return; } - if (!g_pSeatManager->m_state.keyboardFocusResource || g_pSeatManager->m_state.keyboardFocusResource->client() != g_pXWayland->pServer->xwaylandClient) { + if (!g_pSeatManager->m_state.keyboardFocusResource || g_pSeatManager->m_state.keyboardFocusResource->client() != g_pXWayland->m_server->m_xwaylandClient) { Debug::log(TRACE, "[xwm] Ignoring clipboard access: xwayland not in focus"); selectionSendNotify(e, false); return; @@ -659,10 +660,10 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) { if (e->target == HYPRATOMS["TARGETS"]) { // send mime types std::vector<std::string> mimes; - if (sel == &clipboard && g_pSeatManager->m_selection.currentSelection) + if (sel == &m_clipboard && g_pSeatManager->m_selection.currentSelection) mimes = g_pSeatManager->m_selection.currentSelection->mimes(); - else if (sel == &dndSelection && !dndDataOffers.empty() && dndDataOffers.at(0)->source) - mimes = dndDataOffers.at(0)->source->mimes(); + else if (sel == &m_dndSelection && !m_dndDataOffers.empty() && m_dndDataOffers.at(0)->m_source) + mimes = m_dndDataOffers.at(0)->m_source->mimes(); if (mimes.empty()) Debug::log(WARN, "[xwm] WARNING: No mimes in TARGETS?"); @@ -677,10 +678,10 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) { atoms.push_back(mimeToAtom(m)); } - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, e->requestor, e->property, XCB_ATOM_ATOM, 32, atoms.size(), atoms.data()); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, e->requestor, e->property, XCB_ATOM_ATOM, 32, atoms.size(), atoms.data()); selectionSendNotify(e, true); } else if (e->target == HYPRATOMS["TIMESTAMP"]) { - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, e->requestor, e->property, XCB_ATOM_INTEGER, 32, 1, &sel->timestamp); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, e->requestor, e->property, XCB_ATOM_INTEGER, 32, 1, &sel->timestamp); selectionSendNotify(e, true); } else if (e->target == HYPRATOMS["DELETE"]) { selectionSendNotify(e, true); @@ -707,14 +708,14 @@ bool CXWM::handleSelectionXFixesNotify(xcb_xfixes_selection_notify_event_t* e) { // IMPORTANT: mind the g_pSeatManager below SXSelection* sel = getSelection(e->selection); - if (sel == &dndSelection) + if (sel == &m_dndSelection) return true; if (e->owner == XCB_WINDOW_NONE) { if (sel->owner != sel->window) { - if (sel == &clipboard) + if (sel == &m_clipboard) g_pSeatManager->setCurrentSelection(nullptr); - else if (sel == &primarySelection) + else if (sel == &m_primarySelection) g_pSeatManager->setCurrentPrimarySelection(nullptr); } @@ -729,11 +730,11 @@ bool CXWM::handleSelectionXFixesNotify(xcb_xfixes_selection_notify_event_t* e) { return true; } - if (sel == &clipboard) - xcb_convert_selection(connection, sel->window, HYPRATOMS["CLIPBOARD"], HYPRATOMS["TARGETS"], HYPRATOMS["_WL_SELECTION"], e->timestamp); - else if (sel == &primarySelection) - xcb_convert_selection(connection, sel->window, HYPRATOMS["PRIMARY"], HYPRATOMS["TARGETS"], HYPRATOMS["_WL_SELECTION"], e->timestamp); - xcb_flush(connection); + if (sel == &m_clipboard) + xcb_convert_selection(m_connection, sel->window, HYPRATOMS["CLIPBOARD"], HYPRATOMS["TARGETS"], HYPRATOMS["_WL_SELECTION"], e->timestamp); + else if (sel == &m_primarySelection) + xcb_convert_selection(m_connection, sel->window, HYPRATOMS["PRIMARY"], HYPRATOMS["TARGETS"], HYPRATOMS["_WL_SELECTION"], e->timestamp); + xcb_flush(m_connection); return true; } @@ -753,7 +754,7 @@ bool CXWM::handleSelectionEvent(xcb_generic_event_t* e) { } } - if (e->response_type - xfixes->first_event == XCB_XFIXES_SELECTION_NOTIFY) + if (e->response_type - m_xfixes->first_event == XCB_XFIXES_SELECTION_NOTIFY) return handleSelectionXFixesNotify((xcb_xfixes_selection_notify_event_t*)e); return 0; @@ -764,8 +765,8 @@ int CXWM::onEvent(int fd, uint32_t mask) { if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) { Debug::log(ERR, "XWayland has yeeten the xwm off?!"); Debug::log(CRIT, "XWayland has yeeten the xwm off?!"); - g_pXWayland->pWM.reset(); - g_pXWayland->pServer.reset(); + g_pXWayland->m_wm.reset(); + g_pXWayland->m_server.reset(); // Attempt to create fresh instance g_pEventLoopManager->doLater([]() { g_pXWayland = makeUnique<CXWayland>(true); }); return 0; @@ -774,7 +775,7 @@ int CXWM::onEvent(int fd, uint32_t mask) { int count = 0; while (42069) { - xcb_generic_event_t* event = xcb_poll_for_event(connection); + xcb_generic_event_t* event = xcb_poll_for_event(m_connection); if (!event) break; @@ -806,19 +807,19 @@ int CXWM::onEvent(int fd, uint32_t mask) { } if (count) - xcb_flush(connection); + xcb_flush(m_connection); return count; } void CXWM::gatherResources() { - xcb_prefetch_extension_data(connection, &xcb_xfixes_id); - xcb_prefetch_extension_data(connection, &xcb_composite_id); - xcb_prefetch_extension_data(connection, &xcb_res_id); + xcb_prefetch_extension_data(m_connection, &xcb_xfixes_id); + xcb_prefetch_extension_data(m_connection, &xcb_composite_id); + xcb_prefetch_extension_data(m_connection, &xcb_res_id); for (auto& ATOM : HYPRATOMS) { - xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, 0, ATOM.first.length(), ATOM.first.c_str()); - xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(connection, cookie, nullptr); + xcb_intern_atom_cookie_t cookie = xcb_intern_atom(m_connection, 0, ATOM.first.length(), ATOM.first.c_str()); + xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(m_connection, cookie, nullptr); if (!reply) { Debug::log(ERR, "[xwm] Atom failed: {}", ATOM.first); @@ -829,33 +830,33 @@ void CXWM::gatherResources() { free(reply); } - xfixes = xcb_get_extension_data(connection, &xcb_xfixes_id); + m_xfixes = xcb_get_extension_data(m_connection, &xcb_xfixes_id); - if (!xfixes || !xfixes->present) + if (!m_xfixes || !m_xfixes->present) Debug::log(WARN, "XFixes not available"); xcb_xfixes_query_version_cookie_t xfixes_cookie; xcb_xfixes_query_version_reply_t* xfixes_reply; - xfixes_cookie = xcb_xfixes_query_version(connection, XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION); - xfixes_reply = xcb_xfixes_query_version_reply(connection, xfixes_cookie, nullptr); + xfixes_cookie = xcb_xfixes_query_version(m_connection, XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION); + xfixes_reply = xcb_xfixes_query_version_reply(m_connection, xfixes_cookie, nullptr); Debug::log(LOG, "xfixes version: {}.{}", xfixes_reply->major_version, xfixes_reply->minor_version); - xfixesMajor = xfixes_reply->major_version; + m_xfixesMajor = xfixes_reply->major_version; free(xfixes_reply); - const xcb_query_extension_reply_t* xresReply1 = xcb_get_extension_data(connection, &xcb_res_id); + const xcb_query_extension_reply_t* xresReply1 = xcb_get_extension_data(m_connection, &xcb_res_id); if (!xresReply1 || !xresReply1->present) return; - xcb_res_query_version_cookie_t xres_cookie = xcb_res_query_version(connection, XCB_RES_MAJOR_VERSION, XCB_RES_MINOR_VERSION); - xcb_res_query_version_reply_t* xres_reply = xcb_res_query_version_reply(connection, xres_cookie, nullptr); + xcb_res_query_version_cookie_t xres_cookie = xcb_res_query_version(m_connection, XCB_RES_MAJOR_VERSION, XCB_RES_MINOR_VERSION); + xcb_res_query_version_reply_t* xres_reply = xcb_res_query_version_reply(m_connection, xres_cookie, nullptr); if (xres_reply == nullptr) return; Debug::log(LOG, "xres version: {}.{}", xres_reply->server_major, xres_reply->server_minor); if (xres_reply->server_major > 1 || (xres_reply->server_major == 1 && xres_reply->server_minor >= 2)) { - xres = xresReply1; + m_xres = xresReply1; } free(xres_reply); } @@ -865,7 +866,7 @@ void CXWM::getVisual() { xcb_visualtype_iterator_t vt_iter; xcb_visualtype_t* visualtype; - d_iter = xcb_screen_allowed_depths_iterator(screen); + d_iter = xcb_screen_allowed_depths_iterator(m_screen); visualtype = nullptr; while (d_iter.rem > 0) { if (d_iter.data->depth == 32) { @@ -882,14 +883,14 @@ void CXWM::getVisual() { return; } - visual_id = visualtype->visual_id; - colormap = xcb_generate_id(connection); - xcb_create_colormap(connection, XCB_COLORMAP_ALLOC_NONE, colormap, screen->root, visual_id); + m_visualID = visualtype->visual_id; + m_colormap = xcb_generate_id(m_connection); + xcb_create_colormap(m_connection, XCB_COLORMAP_ALLOC_NONE, m_colormap, m_screen->root, m_visualID); } void CXWM::getRenderFormat() { - xcb_render_query_pict_formats_cookie_t cookie = xcb_render_query_pict_formats(connection); - xcb_render_query_pict_formats_reply_t* reply = xcb_render_query_pict_formats_reply(connection, cookie, nullptr); + xcb_render_query_pict_formats_cookie_t cookie = xcb_render_query_pict_formats(m_connection); + xcb_render_query_pict_formats_reply_t* reply = xcb_render_query_pict_formats_reply(m_connection, cookie, nullptr); if (!reply) { Debug::log(LOG, "xwm: No xcb_render_query_pict_formats_reply_t reply"); return; @@ -911,30 +912,30 @@ void CXWM::getRenderFormat() { return; } - render_format_id = format->id; + m_renderFormatID = format->id; free(reply); } -CXWM::CXWM() : connection(g_pXWayland->pServer->xwmFDs[0].get()) { +CXWM::CXWM() : m_connection(g_pXWayland->m_server->m_xwmFDs[0].get()) { - if (connection.hasError()) { - Debug::log(ERR, "[xwm] Couldn't start, error {}", connection.hasError()); + if (m_connection.hasError()) { + Debug::log(ERR, "[xwm] Couldn't start, error {}", m_connection.hasError()); return; } - CXCBErrorContext xcbErrCtx(connection); + CXCBErrorContext xcbErrCtx(m_connection); if (!xcbErrCtx.isValid()) { Debug::log(ERR, "[xwm] Couldn't allocate errors context"); return; } - dndDataDevice->self = dndDataDevice; + m_dndDataDevice->m_self = m_dndDataDevice; - xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator(xcb_get_setup(connection)); - screen = screen_iterator.data; + xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator(xcb_get_setup(m_connection)); + m_screen = screen_iterator.data; - eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, g_pXWayland->pServer->xwmFDs[0].get(), WL_EVENT_READABLE, ::onX11Event, nullptr); - wl_event_source_check(eventSource); + m_eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, g_pXWayland->m_server->m_xwmFDs[0].get(), WL_EVENT_READABLE, ::onX11Event, nullptr); + wl_event_source_check(m_eventSource); gatherResources(); getVisual(); @@ -943,114 +944,115 @@ CXWM::CXWM() : connection(g_pXWayland->pServer->xwmFDs[0].get()) { uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_PROPERTY_CHANGE, }; - xcb_change_window_attributes(connection, screen->root, XCB_CW_EVENT_MASK, values); + xcb_change_window_attributes(m_connection, m_screen->root, XCB_CW_EVENT_MASK, values); - xcb_composite_redirect_subwindows(connection, screen->root, XCB_COMPOSITE_REDIRECT_MANUAL); + xcb_composite_redirect_subwindows(m_connection, m_screen->root, XCB_COMPOSITE_REDIRECT_MANUAL); xcb_atom_t supported[] = { HYPRATOMS["_NET_WM_STATE"], HYPRATOMS["_NET_ACTIVE_WINDOW"], HYPRATOMS["_NET_WM_MOVERESIZE"], HYPRATOMS["_NET_WM_STATE_FOCUSED"], HYPRATOMS["_NET_WM_STATE_MODAL"], HYPRATOMS["_NET_WM_STATE_FULLSCREEN"], HYPRATOMS["_NET_WM_STATE_MAXIMIZED_VERT"], HYPRATOMS["_NET_WM_STATE_MAXIMIZED_HORZ"], HYPRATOMS["_NET_WM_STATE_HIDDEN"], HYPRATOMS["_NET_CLIENT_LIST"], HYPRATOMS["_NET_CLIENT_LIST_STACKING"], }; - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_SUPPORTED"], XCB_ATOM_ATOM, 32, sizeof(supported) / sizeof(*supported), supported); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_SUPPORTED"], XCB_ATOM_ATOM, 32, sizeof(supported) / sizeof(*supported), supported); setActiveWindow(XCB_WINDOW_NONE); initSelection(); - listeners.newWLSurface = PROTO::compositor->m_events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast<SP<CWLSurfaceResource>>(d)); }); - listeners.newXShellSurface = PROTO::xwaylandShell->m_events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast<SP<CXWaylandSurfaceResource>>(d)); }); + m_listeners.newWLSurface = PROTO::compositor->m_events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast<SP<CWLSurfaceResource>>(d)); }); + m_listeners.newXShellSurface = + PROTO::xwaylandShell->m_events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast<SP<CXWaylandSurfaceResource>>(d)); }); createWMWindow(); - xcb_flush(connection); + xcb_flush(m_connection); } CXWM::~CXWM() { - if (eventSource) - wl_event_source_remove(eventSource); + if (m_eventSource) + wl_event_source_remove(m_eventSource); - for (auto const& sr : surfaces) { - sr->events.destroy.emit(); + for (auto const& sr : m_surfaces) { + sr->m_events.destroy.emit(); } } void CXWM::setActiveWindow(xcb_window_t window) { - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_ACTIVE_WINDOW"], HYPRATOMS["WINDOW"], 32, 1, &window); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_ACTIVE_WINDOW"], HYPRATOMS["WINDOW"], 32, 1, &window); } void CXWM::createWMWindow() { constexpr const char* wmName = "Hyprland :D"; - wmWindow = xcb_generate_id(connection); - xcb_create_window(connection, XCB_COPY_FROM_PARENT, wmWindow, screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, 0, nullptr); - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, wmWindow, HYPRATOMS["_NET_WM_NAME"], HYPRATOMS["UTF8_STRING"], + m_wmWindow = xcb_generate_id(m_connection); + xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_wmWindow, m_screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_screen->root_visual, 0, nullptr); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_wmWindow, HYPRATOMS["_NET_WM_NAME"], HYPRATOMS["UTF8_STRING"], 8, // format strlen(wmName), wmName); - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, 32, // format - 1, &wmWindow); - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, wmWindow, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, + 1, &m_wmWindow); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_wmWindow, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, 32, // format - 1, &wmWindow); - xcb_set_selection_owner(connection, wmWindow, HYPRATOMS["WM_S0"], XCB_CURRENT_TIME); - xcb_set_selection_owner(connection, wmWindow, HYPRATOMS["_NET_WM_CM_S0"], XCB_CURRENT_TIME); + 1, &m_wmWindow); + xcb_set_selection_owner(m_connection, m_wmWindow, HYPRATOMS["WM_S0"], XCB_CURRENT_TIME); + xcb_set_selection_owner(m_connection, m_wmWindow, HYPRATOMS["_NET_WM_CM_S0"], XCB_CURRENT_TIME); } void CXWM::activateSurface(SP<CXWaylandSurface> surf, bool activate) { - if ((surf == focusedSurface && activate) || (surf && surf->overrideRedirect)) + if ((surf == m_focusedSurface && activate) || (surf && surf->m_overrideRedirect)) return; if (!surf || (!activate && g_pCompositor->m_lastWindow && !g_pCompositor->m_lastWindow->m_isX11)) { setActiveWindow((uint32_t)XCB_WINDOW_NONE); focusWindow(nullptr); } else { - setActiveWindow(surf ? surf->xID : (uint32_t)XCB_WINDOW_NONE); + setActiveWindow(surf ? surf->m_xID : (uint32_t)XCB_WINDOW_NONE); focusWindow(surf); } - xcb_flush(connection); + xcb_flush(m_connection); } void CXWM::sendState(SP<CXWaylandSurface> surf) { - Debug::log(TRACE, "[xwm] sendState for {} {} {} surface {}", surf->mapped ? "mapped" : "unmapped", surf->fullscreen ? "fullscreen" : "windowed", - surf == focusedSurface ? "focused" : "unfocused", surf->state.title); - if (surf->fullscreen && surf->mapped && surf == focusedSurface) + Debug::log(TRACE, "[xwm] sendState for {} {} {} surface {}", surf->m_mapped ? "mapped" : "unmapped", surf->m_fullscreen ? "fullscreen" : "windowed", + surf == m_focusedSurface ? "focused" : "unfocused", surf->m_state.title); + if (surf->m_fullscreen && surf->m_mapped && surf == m_focusedSurface) surf->setWithdrawn(false); // resend normal state - if (surf->withdrawn) { - xcb_delete_property(connection, surf->xID, HYPRATOMS["_NET_WM_STATE"]); + if (surf->m_withdrawn) { + xcb_delete_property(m_connection, surf->m_xID, HYPRATOMS["_NET_WM_STATE"]); return; } std::vector<uint32_t> props; // reserve to avoid reallocations props.reserve(6); // props below - if (surf->modal) + if (surf->m_modal) props.push_back(HYPRATOMS["_NET_WM_STATE_MODAL"]); - if (surf->fullscreen) + if (surf->m_fullscreen) props.push_back(HYPRATOMS["_NET_WM_STATE_FULLSCREEN"]); - if (surf->maximized) { + if (surf->m_maximized) { props.push_back(HYPRATOMS["NET_WM_STATE_MAXIMIZED_VERT"]); props.push_back(HYPRATOMS["NET_WM_STATE_MAXIMIZED_HORZ"]); } - if (surf->minimized) + if (surf->m_minimized) props.push_back(HYPRATOMS["_NET_WM_STATE_HIDDEN"]); - if (surf == focusedSurface) + if (surf == m_focusedSurface) props.push_back(HYPRATOMS["_NET_WM_STATE_FOCUSED"]); - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, surf->xID, HYPRATOMS["_NET_WM_STATE"], XCB_ATOM_ATOM, 32, props.size(), props.data()); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, surf->m_xID, HYPRATOMS["_NET_WM_STATE"], XCB_ATOM_ATOM, 32, props.size(), props.data()); } void CXWM::onNewSurface(SP<CWLSurfaceResource> surf) { - if (surf->client() != g_pXWayland->pServer->xwaylandClient) + if (surf->client() != g_pXWayland->m_server->m_xwaylandClient) return; Debug::log(LOG, "[xwm] New XWayland surface at {:x}", (uintptr_t)surf.get()); const auto WLID = surf->id(); - for (auto const& sr : surfaces) { - if (sr->surface || sr->wlID != WLID) + for (auto const& sr : m_surfaces) { + if (sr->m_surface || sr->m_wlID != WLID) continue; associate(sr, surf); @@ -1063,11 +1065,11 @@ void CXWM::onNewSurface(SP<CWLSurfaceResource> surf) { void CXWM::onNewResource(SP<CXWaylandSurfaceResource> resource) { Debug::log(LOG, "[xwm] New XWayland resource at {:x}", (uintptr_t)resource.get()); - std::erase_if(shellResources, [](const auto& e) { return e.expired(); }); - shellResources.emplace_back(resource); + std::erase_if(m_shellResources, [](const auto& e) { return e.expired(); }); + m_shellResources.emplace_back(resource); - for (auto const& surf : surfaces) { - if (surf->resource || surf->wlSerial != resource->m_serial) + for (auto const& surf : m_surfaces) { + if (surf->m_resource || surf->m_wlSerial != resource->m_serial) continue; associate(surf, resource->m_surface.lock()); @@ -1083,8 +1085,8 @@ void CXWM::readWindowData(SP<CXWaylandSurface> surf) { }; for (size_t i = 0; i < interestingProps.size(); i++) { - xcb_get_property_cookie_t cookie = xcb_get_property(connection, 0, surf->xID, interestingProps[i], XCB_ATOM_ANY, 0, 2048); - xcb_get_property_reply_t* reply = xcb_get_property_reply(connection, cookie, nullptr); + xcb_get_property_cookie_t cookie = xcb_get_property(m_connection, 0, surf->m_xID, interestingProps[i], XCB_ATOM_ANY, 0, 2048); + xcb_get_property_reply_t* reply = xcb_get_property_reply(m_connection, cookie, nullptr); if (!reply) { Debug::log(ERR, "[xwm] Failed to get window property"); continue; @@ -1095,8 +1097,8 @@ void CXWM::readWindowData(SP<CXWaylandSurface> surf) { } SP<CXWaylandSurface> CXWM::windowForWayland(SP<CWLSurfaceResource> surf) { - for (auto& s : surfaces) { - if (s->surface == surf) + for (auto& s : m_surfaces) { + if (s->m_surface == surf) return s; } @@ -1104,100 +1106,100 @@ SP<CXWaylandSurface> CXWM::windowForWayland(SP<CWLSurfaceResource> surf) { } void CXWM::associate(SP<CXWaylandSurface> surf, SP<CWLSurfaceResource> wlSurf) { - if (surf->surface) + if (surf->m_surface) return; - auto existing = std::find_if(surfaces.begin(), surfaces.end(), [wlSurf](const auto& e) { return e->surface == wlSurf; }); + auto existing = std::find_if(m_surfaces.begin(), m_surfaces.end(), [wlSurf](const auto& e) { return e->m_surface == wlSurf; }); - if (existing != surfaces.end()) { + if (existing != m_surfaces.end()) { Debug::log(WARN, "[xwm] associate() called but surface is already associated to {:x}, ignoring...", (uintptr_t)surf.get()); return; } - surf->surface = wlSurf; + surf->m_surface = wlSurf; surf->ensureListeners(); readWindowData(surf); - surf->events.resourceChange.emit(); + surf->m_events.resourceChange.emit(); } void CXWM::dissociate(SP<CXWaylandSurface> surf) { - if (!surf->surface) + if (!surf->m_surface) return; - if (surf->mapped) + if (surf->m_mapped) surf->unmap(); - surf->surface.reset(); - surf->events.resourceChange.emit(); + surf->m_surface.reset(); + surf->m_events.resourceChange.emit(); Debug::log(LOG, "Dissociate for {:x}", (uintptr_t)surf.get()); } void CXWM::updateClientList() { std::vector<xcb_window_t> windows; - windows.reserve(mappedSurfaces.size()); + windows.reserve(m_mappedSurfaces.size()); - for (auto const& s : mappedSurfaces) { + for (auto const& s : m_mappedSurfaces) { if (auto surf = s.lock(); surf) - windows.push_back(surf->xID); + windows.push_back(surf->m_xID); } - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_CLIENT_LIST"], XCB_ATOM_WINDOW, 32, windows.size(), windows.data()); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_CLIENT_LIST"], XCB_ATOM_WINDOW, 32, windows.size(), windows.data()); windows.clear(); - windows.reserve(mappedSurfacesStacking.size()); + windows.reserve(m_mappedSurfacesStacking.size()); - for (auto const& s : mappedSurfacesStacking) { + for (auto const& s : m_mappedSurfacesStacking) { if (auto surf = s.lock(); surf) - windows.push_back(surf->xID); + windows.push_back(surf->m_xID); } - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, screen->root, HYPRATOMS["_NET_CLIENT_LIST_STACKING"], XCB_ATOM_WINDOW, 32, windows.size(), windows.data()); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_screen->root, HYPRATOMS["_NET_CLIENT_LIST_STACKING"], XCB_ATOM_WINDOW, 32, windows.size(), windows.data()); } bool CXWM::isWMWindow(xcb_window_t w) { - return w == wmWindow || w == clipboard.window || w == dndSelection.window; + return w == m_wmWindow || w == m_clipboard.window || w == m_dndSelection.window; } void CXWM::updateOverrideRedirect(SP<CXWaylandSurface> surf, bool overrideRedirect) { - if (!surf || surf->overrideRedirect == overrideRedirect) + if (!surf || surf->m_overrideRedirect == overrideRedirect) return; - surf->overrideRedirect = overrideRedirect; + surf->m_overrideRedirect = overrideRedirect; } void CXWM::initSelection() { - clipboard.window = xcb_generate_id(connection); - uint32_t mask[1] = {XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE}; - xcb_create_window(connection, XCB_COPY_FROM_PARENT, clipboard.window, screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, XCB_CW_EVENT_MASK, - mask); - xcb_set_selection_owner(connection, clipboard.window, HYPRATOMS["CLIPBOARD_MANAGER"], XCB_TIME_CURRENT_TIME); + m_clipboard.window = xcb_generate_id(m_connection); + uint32_t mask[1] = {XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE}; + xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_clipboard.window, m_screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_screen->root_visual, + XCB_CW_EVENT_MASK, mask); + xcb_set_selection_owner(m_connection, m_clipboard.window, HYPRATOMS["CLIPBOARD_MANAGER"], XCB_TIME_CURRENT_TIME); uint32_t mask2 = XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE; - xcb_xfixes_select_selection_input(connection, clipboard.window, HYPRATOMS["CLIPBOARD"], mask2); + xcb_xfixes_select_selection_input(m_connection, m_clipboard.window, HYPRATOMS["CLIPBOARD"], mask2); - clipboard.listeners.setSelection = g_pSeatManager->m_events.setSelection.registerListener([this](std::any d) { clipboard.onSelection(); }); - clipboard.listeners.keyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { clipboard.onKeyboardFocus(); }); + m_clipboard.listeners.setSelection = g_pSeatManager->m_events.setSelection.registerListener([this](std::any d) { m_clipboard.onSelection(); }); + m_clipboard.listeners.keyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { m_clipboard.onKeyboardFocus(); }); - primarySelection.window = xcb_generate_id(connection); - xcb_create_window(connection, XCB_COPY_FROM_PARENT, primarySelection.window, screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, + m_primarySelection.window = xcb_generate_id(m_connection); + xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_primarySelection.window, m_screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_screen->root_visual, XCB_CW_EVENT_MASK, mask); - xcb_set_selection_owner(connection, primarySelection.window, HYPRATOMS["PRIMARY"], XCB_TIME_CURRENT_TIME); + xcb_set_selection_owner(m_connection, m_primarySelection.window, HYPRATOMS["PRIMARY"], XCB_TIME_CURRENT_TIME); - xcb_xfixes_select_selection_input(connection, primarySelection.window, HYPRATOMS["PRIMARY"], mask2); + xcb_xfixes_select_selection_input(m_connection, m_primarySelection.window, HYPRATOMS["PRIMARY"], mask2); - primarySelection.listeners.setSelection = g_pSeatManager->m_events.setPrimarySelection.registerListener([this](std::any d) { primarySelection.onSelection(); }); - primarySelection.listeners.keyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { primarySelection.onKeyboardFocus(); }); + m_primarySelection.listeners.setSelection = g_pSeatManager->m_events.setPrimarySelection.registerListener([this](std::any d) { m_primarySelection.onSelection(); }); + m_primarySelection.listeners.keyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { m_primarySelection.onKeyboardFocus(); }); - dndSelection.window = xcb_generate_id(connection); - xcb_create_window(connection, XCB_COPY_FROM_PARENT, dndSelection.window, screen->root, 0, 0, 8192, 8192, 0, XCB_WINDOW_CLASS_INPUT_ONLY, screen->root_visual, XCB_CW_EVENT_MASK, - mask); + m_dndSelection.window = xcb_generate_id(m_connection); + xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_dndSelection.window, m_screen->root, 0, 0, 8192, 8192, 0, XCB_WINDOW_CLASS_INPUT_ONLY, m_screen->root_visual, + XCB_CW_EVENT_MASK, mask); uint32_t val1 = XDND_VERSION; - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, dndSelection.window, HYPRATOMS["XdndAware"], XCB_ATOM_ATOM, 32, 1, &val1); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_dndSelection.window, HYPRATOMS["XdndAware"], XCB_ATOM_ATOM, 32, 1, &val1); } void CXWM::setClipboardToWayland(SXSelection& sel) { @@ -1209,11 +1211,11 @@ void CXWM::setClipboardToWayland(SXSelection& sel) { sel.dataSource = source; - Debug::log(LOG, "[xwm] X selection at {:x} takes {}", (uintptr_t)sel.dataSource.get(), (&sel == &clipboard) ? "clipboard" : "primary selection"); + Debug::log(LOG, "[xwm] X selection at {:x} takes {}", (uintptr_t)sel.dataSource.get(), (&sel == &m_clipboard) ? "clipboard" : "primary selection"); - if (&sel == &clipboard) + if (&sel == &m_clipboard) g_pSeatManager->setCurrentSelection(sel.dataSource); - else if (&sel == &primarySelection) + else if (&sel == &m_primarySelection) g_pSeatManager->setCurrentPrimarySelection(sel.dataSource); } @@ -1274,40 +1276,40 @@ void CXWM::getTransferData(SXSelection& sel) { } void CXWM::setCursor(unsigned char* pixData, uint32_t stride, const Vector2D& size, const Vector2D& hotspot) { - if (!render_format_id) { + if (!m_renderFormatID) { Debug::log(ERR, "[xwm] can't set cursor: no render format"); return; } - if (cursorXID) - xcb_free_cursor(connection, cursorXID); + if (m_cursorXID) + xcb_free_cursor(m_connection, m_cursorXID); constexpr int CURSOR_DEPTH = 32; - xcb_pixmap_t pix = xcb_generate_id(connection); - xcb_create_pixmap(connection, CURSOR_DEPTH, pix, screen->root, size.x, size.y); + xcb_pixmap_t pix = xcb_generate_id(m_connection); + xcb_create_pixmap(m_connection, CURSOR_DEPTH, pix, m_screen->root, size.x, size.y); - xcb_render_picture_t pic = xcb_generate_id(connection); - xcb_render_create_picture(connection, pic, pix, render_format_id, 0, 0); + xcb_render_picture_t pic = xcb_generate_id(m_connection); + xcb_render_create_picture(m_connection, pic, pix, m_renderFormatID, 0, 0); - xcb_gcontext_t gc = xcb_generate_id(connection); - xcb_create_gc(connection, gc, pix, 0, nullptr); + xcb_gcontext_t gc = xcb_generate_id(m_connection); + xcb_create_gc(m_connection, gc, pix, 0, nullptr); - xcb_put_image(connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, size.x, size.y, 0, 0, 0, CURSOR_DEPTH, stride * size.y * sizeof(uint8_t), pixData); - xcb_free_gc(connection, gc); + xcb_put_image(m_connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, size.x, size.y, 0, 0, 0, CURSOR_DEPTH, stride * size.y * sizeof(uint8_t), pixData); + xcb_free_gc(m_connection, gc); - cursorXID = xcb_generate_id(connection); - xcb_render_create_cursor(connection, cursorXID, pic, hotspot.x, hotspot.y); - xcb_free_pixmap(connection, pix); - xcb_render_free_picture(connection, pic); + m_cursorXID = xcb_generate_id(m_connection); + xcb_render_create_cursor(m_connection, m_cursorXID, pic, hotspot.x, hotspot.y); + xcb_free_pixmap(m_connection, pix); + xcb_render_free_picture(m_connection, pic); - uint32_t values[] = {cursorXID}; - xcb_change_window_attributes(connection, screen->root, XCB_CW_CURSOR, values); - xcb_flush(connection); + uint32_t values[] = {m_cursorXID}; + xcb_change_window_attributes(m_connection, m_screen->root, XCB_CW_CURSOR, values); + xcb_flush(m_connection); } SP<CX11DataDevice> CXWM::getDataDevice() { - return dndDataDevice; + return m_dndDataDevice; } SP<IDataOffer> CXWM::createX11DataOffer(SP<CWLSurfaceResource> surf, SP<IDataSource> source) { @@ -1319,43 +1321,43 @@ SP<IDataOffer> CXWM::createX11DataOffer(SP<CWLSurfaceResource> surf, SP<IDataSou } // invalidate old - g_pXWayland->pWM->dndDataOffers.clear(); + g_pXWayland->m_wm->m_dndDataOffers.clear(); - auto offer = dndDataOffers.emplace_back(makeShared<CX11DataOffer>()); - offer->self = offer; - offer->xwaylandSurface = XSURF; - offer->source = source; + auto offer = m_dndDataOffers.emplace_back(makeShared<CX11DataOffer>()); + offer->m_self = offer; + offer->m_xwaylandSurface = XSURF; + offer->m_source = source; return offer; } void SXSelection::onSelection() { - if ((this == &g_pXWayland->pWM->clipboard && g_pSeatManager->m_selection.currentSelection && g_pSeatManager->m_selection.currentSelection->type() == DATA_SOURCE_TYPE_X11) || - (this == &g_pXWayland->pWM->primarySelection && g_pSeatManager->m_selection.currentPrimarySelection && + if ((this == &g_pXWayland->m_wm->m_clipboard && g_pSeatManager->m_selection.currentSelection && g_pSeatManager->m_selection.currentSelection->type() == DATA_SOURCE_TYPE_X11) || + (this == &g_pXWayland->m_wm->m_primarySelection && g_pSeatManager->m_selection.currentPrimarySelection && g_pSeatManager->m_selection.currentPrimarySelection->type() == DATA_SOURCE_TYPE_X11)) return; - if (this == &g_pXWayland->pWM->clipboard && g_pSeatManager->m_selection.currentSelection) { - xcb_set_selection_owner(g_pXWayland->pWM->connection, g_pXWayland->pWM->clipboard.window, HYPRATOMS["CLIPBOARD"], XCB_TIME_CURRENT_TIME); - xcb_flush(g_pXWayland->pWM->connection); - g_pXWayland->pWM->clipboard.notifyOnFocus = true; - } else if (this == &g_pXWayland->pWM->primarySelection && g_pSeatManager->m_selection.currentPrimarySelection) { - xcb_set_selection_owner(g_pXWayland->pWM->connection, g_pXWayland->pWM->primarySelection.window, HYPRATOMS["PRIMARY"], XCB_TIME_CURRENT_TIME); - xcb_flush(g_pXWayland->pWM->connection); - g_pXWayland->pWM->primarySelection.notifyOnFocus = true; + if (this == &g_pXWayland->m_wm->m_clipboard && g_pSeatManager->m_selection.currentSelection) { + xcb_set_selection_owner(g_pXWayland->m_wm->m_connection, g_pXWayland->m_wm->m_clipboard.window, HYPRATOMS["CLIPBOARD"], XCB_TIME_CURRENT_TIME); + xcb_flush(g_pXWayland->m_wm->m_connection); + g_pXWayland->m_wm->m_clipboard.notifyOnFocus = true; + } else if (this == &g_pXWayland->m_wm->m_primarySelection && g_pSeatManager->m_selection.currentPrimarySelection) { + xcb_set_selection_owner(g_pXWayland->m_wm->m_connection, g_pXWayland->m_wm->m_primarySelection.window, HYPRATOMS["PRIMARY"], XCB_TIME_CURRENT_TIME); + xcb_flush(g_pXWayland->m_wm->m_connection); + g_pXWayland->m_wm->m_primarySelection.notifyOnFocus = true; } } void SXSelection::onKeyboardFocus() { - if (!g_pSeatManager->m_state.keyboardFocusResource || g_pSeatManager->m_state.keyboardFocusResource->client() != g_pXWayland->pServer->xwaylandClient) + if (!g_pSeatManager->m_state.keyboardFocusResource || g_pSeatManager->m_state.keyboardFocusResource->client() != g_pXWayland->m_server->m_xwaylandClient) return; - if (this == &g_pXWayland->pWM->clipboard && g_pXWayland->pWM->clipboard.notifyOnFocus) { + if (this == &g_pXWayland->m_wm->m_clipboard && g_pXWayland->m_wm->m_clipboard.notifyOnFocus) { onSelection(); - g_pXWayland->pWM->clipboard.notifyOnFocus = false; - } else if (this == &g_pXWayland->pWM->primarySelection && g_pXWayland->pWM->primarySelection.notifyOnFocus) { + g_pXWayland->m_wm->m_clipboard.notifyOnFocus = false; + } else if (this == &g_pXWayland->m_wm->m_primarySelection && g_pXWayland->m_wm->m_primarySelection.notifyOnFocus) { onSelection(); - g_pXWayland->pWM->primarySelection.notifyOnFocus = false; + g_pXWayland->m_wm->m_primarySelection.notifyOnFocus = false; } } @@ -1373,7 +1375,7 @@ int SXSelection::onRead(int fd, uint32_t mask) { auto len = read(fd, transfer->data.data() + pre, INCR_CHUNK_SIZE - 1); if (len < 0) { Debug::log(ERR, "[xwm] readDataSource died"); - g_pXWayland->pWM->selectionSendNotify(&transfer->request, false); + g_pXWayland->m_wm->selectionSendNotify(&transfer->request, false); transfers.erase(it); return 0; } @@ -1382,10 +1384,10 @@ int SXSelection::onRead(int fd, uint32_t mask) { if (len == 0) { Debug::log(LOG, "[xwm] Received all the bytes, final length {}", transfer->data.size()); - xcb_change_property(g_pXWayland->pWM->connection, XCB_PROP_MODE_REPLACE, transfer->request.requestor, transfer->request.property, transfer->request.target, 8, + xcb_change_property(g_pXWayland->m_wm->m_connection, XCB_PROP_MODE_REPLACE, transfer->request.requestor, transfer->request.property, transfer->request.target, 8, transfer->data.size(), transfer->data.data()); - xcb_flush(g_pXWayland->pWM->connection); - g_pXWayland->pWM->selectionSendNotify(&transfer->request, true); + xcb_flush(g_pXWayland->m_wm->m_connection); + g_pXWayland->m_wm->selectionSendNotify(&transfer->request, true); transfers.erase(it); } else Debug::log(LOG, "[xwm] Received {} bytes, waiting...", len); @@ -1403,12 +1405,12 @@ static int readDataSource(int fd, uint32_t mask, void* data) { bool SXSelection::sendData(xcb_selection_request_event_t* e, std::string mime) { WP<IDataSource> selection; - if (this == &g_pXWayland->pWM->clipboard) + if (this == &g_pXWayland->m_wm->m_clipboard) selection = g_pSeatManager->m_selection.currentSelection; - else if (this == &g_pXWayland->pWM->primarySelection) + else if (this == &g_pXWayland->m_wm->m_primarySelection) selection = g_pSeatManager->m_selection.currentPrimarySelection; - else if (!g_pXWayland->pWM->dndDataOffers.empty()) - selection = g_pXWayland->pWM->dndDataOffers.at(0)->getSource(); + else if (!g_pXWayland->m_wm->m_dndDataOffers.empty()) + selection = g_pXWayland->m_wm->m_dndDataOffers.at(0)->getSource(); if (!selection) return false; @@ -1491,16 +1493,17 @@ SXTransfer::~SXTransfer() { if (eventSource) wl_event_source_remove(eventSource); if (incomingWindow) - xcb_destroy_window(g_pXWayland->pWM->connection, incomingWindow); + xcb_destroy_window(g_pXWayland->m_wm->m_connection, incomingWindow); if (propertyReply) free(propertyReply); } bool SXTransfer::getIncomingSelectionProp(bool erase) { - xcb_get_property_cookie_t cookie = xcb_get_property(g_pXWayland->pWM->connection, erase, incomingWindow, HYPRATOMS["_WL_SELECTION"], XCB_GET_PROPERTY_TYPE_ANY, 0, 0x1fffffff); + xcb_get_property_cookie_t cookie = + xcb_get_property(g_pXWayland->m_wm->m_connection, erase, incomingWindow, HYPRATOMS["_WL_SELECTION"], XCB_GET_PROPERTY_TYPE_ANY, 0, 0x1fffffff); propertyStart = 0; - propertyReply = xcb_get_property_reply(g_pXWayland->pWM->connection, cookie, nullptr); + propertyReply = xcb_get_property_reply(g_pXWayland->m_wm->m_connection, cookie, nullptr); if (!propertyReply) { Debug::log(ERR, "[SXTransfer] couldn't get a prop reply"); |
