mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 21:09:48 +01:00
cursormgr: fix invalid access to hyprcursor in xwayland init
fixes #5048
This commit is contained in:
parent
26cd1bf949
commit
739c5bc98c
3 changed files with 19 additions and 5 deletions
|
@ -70,11 +70,7 @@ void Events::listener_readyXWayland(wl_listener* listener, void* data) {
|
|||
|
||||
wlr_xwayland_set_seat(g_pXWaylandManager->m_sWLRXWayland, g_pCompositor->m_sSeat.seat);
|
||||
|
||||
const auto CURSOR = g_pCursorManager->dataFor("left_ptr");
|
||||
if (CURSOR.surface) {
|
||||
wlr_xwayland_set_cursor(g_pXWaylandManager->m_sWLRXWayland, cairo_image_surface_get_data(CURSOR.surface), cairo_image_surface_get_stride(CURSOR.surface), CURSOR.size,
|
||||
CURSOR.size, CURSOR.hotspotX, CURSOR.hotspotY);
|
||||
}
|
||||
g_pCursorManager->setXWaylandCursor(g_pXWaylandManager->m_sWLRXWayland);
|
||||
|
||||
const auto ROOT = xcb_setup_roots_iterator(xcb_get_setup(XCBCONNECTION)).data->root;
|
||||
auto cookie = xcb_get_property(XCBCONNECTION, 0, ROOT, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_ANY, 0, 2048);
|
||||
|
|
|
@ -167,6 +167,10 @@ void CCursorManager::tickAnimatedCursor() {
|
|||
}
|
||||
|
||||
SCursorImageData CCursorManager::dataFor(const std::string& name) {
|
||||
|
||||
if (!m_pHyprcursor->valid())
|
||||
return {};
|
||||
|
||||
const auto IMAGES = m_pHyprcursor->getShape(name.c_str(), m_sCurrentStyleInfo);
|
||||
|
||||
if (IMAGES.images.empty())
|
||||
|
@ -175,6 +179,18 @@ SCursorImageData CCursorManager::dataFor(const std::string& name) {
|
|||
return IMAGES.images[0];
|
||||
}
|
||||
|
||||
void CCursorManager::setXWaylandCursor(wlr_xwayland* xwayland) {
|
||||
const auto CURSOR = dataFor("left_ptr");
|
||||
if (CURSOR.surface) {
|
||||
wlr_xwayland_set_cursor(xwayland, cairo_image_surface_get_data(CURSOR.surface), cairo_image_surface_get_stride(CURSOR.surface), CURSOR.size, CURSOR.size, CURSOR.hotspotX,
|
||||
CURSOR.hotspotY);
|
||||
} else if (const auto XCURSOR = wlr_xcursor_manager_get_xcursor(m_pWLRXCursorMgr, "left_ptr", 1); XCURSOR) {
|
||||
wlr_xwayland_set_cursor(xwayland, XCURSOR->images[0]->buffer, XCURSOR->images[0]->width * 4, XCURSOR->images[0]->width, XCURSOR->images[0]->height,
|
||||
XCURSOR->images[0]->hotspot_x, XCURSOR->images[0]->hotspot_y);
|
||||
} else
|
||||
Debug::log(ERR, "CursorManager: no valid cursor for xwayland");
|
||||
}
|
||||
|
||||
void CCursorManager::updateTheme() {
|
||||
float highestScale = 1.0;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
struct wlr_buffer;
|
||||
struct wlr_xcursor_manager;
|
||||
struct wlr_xwayland;
|
||||
|
||||
class CCursorManager {
|
||||
public:
|
||||
|
@ -21,6 +22,7 @@ class CCursorManager {
|
|||
void changeTheme(const std::string& name, const int size);
|
||||
void updateTheme();
|
||||
SCursorImageData dataFor(const std::string& name); // for xwayland
|
||||
void setXWaylandCursor(wlr_xwayland* xwayland);
|
||||
|
||||
void tickAnimatedCursor();
|
||||
|
||||
|
|
Loading…
Reference in a new issue