xwayland: Fix crash when copying from wayland to xwayland (#10786)

This commit is contained in:
Jasson 2025-06-19 13:44:38 -04:00 committed by GitHub
parent 86b5e3bfbc
commit b49d0ca20e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 151 additions and 128 deletions

View file

@ -13,15 +13,15 @@ CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_x
xcb_res_query_client_ids_cookie_t client_id_cookie = {0};
if (g_pXWayland->m_wm->m_xres) {
xcb_res_client_id_spec_t spec = {.client = m_xID, .mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID};
client_id_cookie = xcb_res_query_client_ids(g_pXWayland->m_wm->m_connection, 1, &spec);
client_id_cookie = xcb_res_query_client_ids(g_pXWayland->m_wm->getConnection(), 1, &spec);
}
uint32_t values[1];
values[0] = XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE;
xcb_change_window_attributes(g_pXWayland->m_wm->m_connection, m_xID, XCB_CW_EVENT_MASK, values);
xcb_change_window_attributes(g_pXWayland->m_wm->getConnection(), m_xID, XCB_CW_EVENT_MASK, values);
if (g_pXWayland->m_wm->m_xres) {
xcb_res_query_client_ids_reply_t* reply = xcb_res_query_client_ids_reply(g_pXWayland->m_wm->m_connection, client_id_cookie, nullptr);
xcb_res_query_client_ids_reply_t* reply = xcb_res_query_client_ids_reply(g_pXWayland->m_wm->getConnection(), client_id_cookie, nullptr);
if (!reply)
return;
@ -169,7 +169,7 @@ void CXWaylandSurface::configure(const CBox& box) {
uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH;
uint32_t values[] = {box.x, box.y, box.width, box.height, 0};
xcb_configure_window(g_pXWayland->m_wm->m_connection, m_xID, mask, values);
xcb_configure_window(g_pXWayland->m_wm->getConnection(), m_xID, mask, values);
if (m_geometry.width == box.width && m_geometry.height == box.height) {
// ICCCM requires a synthetic event when window size is not changed
@ -184,12 +184,12 @@ void CXWaylandSurface::configure(const CBox& box) {
e.border_width = 0;
e.above_sibling = XCB_NONE;
e.override_redirect = m_overrideRedirect;
xcb_send_event(g_pXWayland->m_wm->m_connection, false, m_xID, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char*)&e);
xcb_send_event(g_pXWayland->m_wm->getConnection(), false, m_xID, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char*)&e);
}
g_pXWayland->m_wm->updateClientList();
xcb_flush(g_pXWayland->m_wm->m_connection);
xcb_flush(g_pXWayland->m_wm->getConnection());
}
void CXWaylandSurface::activate(bool activate) {
@ -211,7 +211,7 @@ void CXWaylandSurface::setMinimized(bool mz) {
void CXWaylandSurface::restackToTop() {
uint32_t values[1] = {XCB_STACK_MODE_ABOVE};
xcb_configure_window(g_pXWayland->m_wm->m_connection, m_xID, XCB_CONFIG_WINDOW_STACK_MODE, values);
xcb_configure_window(g_pXWayland->m_wm->getConnection(), m_xID, XCB_CONFIG_WINDOW_STACK_MODE, values);
auto& stack = g_pXWayland->m_wm->m_mappedSurfacesStacking;
auto it = std::ranges::find(stack, m_self);
@ -221,7 +221,7 @@ void CXWaylandSurface::restackToTop() {
g_pXWayland->m_wm->updateClientList();
xcb_flush(g_pXWayland->m_wm->m_connection);
xcb_flush(g_pXWayland->m_wm->getConnection());
}
void CXWaylandSurface::close() {
@ -242,7 +242,7 @@ void CXWaylandSurface::setWithdrawn(bool withdrawn_) {
else
props[0] = XCB_ICCCM_WM_STATE_NORMAL;
xcb_change_property(g_pXWayland->m_wm->m_connection, XCB_PROP_MODE_REPLACE, m_xID, HYPRATOMS["WM_STATE"], HYPRATOMS["WM_STATE"], 32, props.size(), props.data());
xcb_change_property(g_pXWayland->m_wm->getConnection(), XCB_PROP_MODE_REPLACE, m_xID, HYPRATOMS["WM_STATE"], HYPRATOMS["WM_STATE"], 32, props.size(), props.data());
}
void CXWaylandSurface::ping() {