Commit 9ff1f77e authored by David Edmundson's avatar David Edmundson

Support cursor scaling in X windowed backend

Test Plan:
Ran kwin_wayland --windowed  --scale2

Hovered over deco. Got massive and detailed cursor
Hovered over a wayland client (Qt 5.11 not dev)
Got a massive, but slightly blocky cursor

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13642
parent 263503f8
......@@ -404,19 +404,24 @@ void X11WindowedBackend::updateSize(xcb_configure_notify_event_t *event)
}
}
void X11WindowedBackend::createCursor(const QImage &img, const QPoint &hotspot)
void X11WindowedBackend::createCursor(const QImage &srcImage, const QPoint &hotspot)
{
const xcb_pixmap_t pix = xcb_generate_id(m_connection);
const xcb_gcontext_t gc = xcb_generate_id(m_connection);
const xcb_cursor_t cid = xcb_generate_id(m_connection);
//right now on X we only have one scale between all screens, and we know we will have at least one screen
const qreal outputScale = screenScales().first();
const QSize targetSize = srcImage.size() * outputScale / srcImage.devicePixelRatio();
const QImage img = srcImage.scaled(targetSize, Qt::KeepAspectRatio);
xcb_create_pixmap(m_connection, 32, pix, m_screen->root, img.width(), img.height());
xcb_create_gc(m_connection, gc, pix, 0, nullptr);
xcb_put_image(m_connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, img.width(), img.height(), 0, 0, 0, 32, img.byteCount(), img.constBits());
XRenderPicture pic(pix, 32);
xcb_render_create_cursor(m_connection, cid, pic, hotspot.x(), hotspot.y());
xcb_render_create_cursor(m_connection, cid, pic, qRound(hotspot.x() * outputScale), qRound(hotspot.y() * outputScale));
for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) {
xcb_change_window_attributes(m_connection, (*it).window, XCB_CW_CURSOR, &cid);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment