Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/x11/windowed/x11windowed_backend.cpp
Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Line(s) | 395 | if (s != (*it).size) { | |||
---|---|---|---|---|---|
399 | for (; it != m_windows.end(); ++it) { | 399 | for (; it != m_windows.end(); ++it) { | ||
400 | (*it).internalPosition.setX(x); | 400 | (*it).internalPosition.setX(x); | ||
401 | x += (*it).size.width() / (*it).scale; | 401 | x += (*it).size.width() / (*it).scale; | ||
402 | } | 402 | } | ||
403 | emit sizeChanged(); | 403 | emit sizeChanged(); | ||
404 | } | 404 | } | ||
405 | } | 405 | } | ||
406 | 406 | | |||
407 | void X11WindowedBackend::createCursor(const QImage &img, const QPoint &hotspot) | 407 | void X11WindowedBackend::createCursor(const QImage &srcImage, const QPoint &hotspot) | ||
408 | { | 408 | { | ||
409 | const xcb_pixmap_t pix = xcb_generate_id(m_connection); | 409 | const xcb_pixmap_t pix = xcb_generate_id(m_connection); | ||
410 | const xcb_gcontext_t gc = xcb_generate_id(m_connection); | 410 | const xcb_gcontext_t gc = xcb_generate_id(m_connection); | ||
411 | const xcb_cursor_t cid = xcb_generate_id(m_connection); | 411 | const xcb_cursor_t cid = xcb_generate_id(m_connection); | ||
412 | 412 | | |||
413 | //right now on X we only have one scale between all screens, and we know we will have at least one screen | ||||
414 | const qreal outputScale = screenScales().first(); | ||||
415 | const QSize targetSize = srcImage.size() * outputScale / srcImage.devicePixelRatio(); | ||||
416 | const QImage img = srcImage.scaled(targetSize, Qt::KeepAspectRatio); | ||||
417 | | ||||
zzag: How about
```lang=cpp
const qreal outputScale = screenScales().first();
const QSize… | |||||
413 | xcb_create_pixmap(m_connection, 32, pix, m_screen->root, img.width(), img.height()); | 418 | xcb_create_pixmap(m_connection, 32, pix, m_screen->root, img.width(), img.height()); | ||
414 | xcb_create_gc(m_connection, gc, pix, 0, nullptr); | 419 | xcb_create_gc(m_connection, gc, pix, 0, nullptr); | ||
415 | 420 | | |||
416 | xcb_put_image(m_connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, img.width(), img.height(), 0, 0, 0, 32, img.byteCount(), img.constBits()); | 421 | xcb_put_image(m_connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, img.width(), img.height(), 0, 0, 0, 32, img.byteCount(), img.constBits()); | ||
417 | 422 | | |||
418 | XRenderPicture pic(pix, 32); | 423 | XRenderPicture pic(pix, 32); | ||
419 | xcb_render_create_cursor(m_connection, cid, pic, hotspot.x(), hotspot.y()); | 424 | xcb_render_create_cursor(m_connection, cid, pic, qRound(hotspot.x() * outputScale), qRound(hotspot.y() * outputScale)); | ||
Just a question: should hotspot.x() * outputScale be rounded?, e.g. xcb_render_create_cursor(m_connection, cid, pic, qRound(hotspot.x() * outputScale), qRound(hotspot.y() * outputScale)); zzag: Just a question: should `hotspot.x() * outputScale` be rounded?, e.g.
```lang=cpp… | |||||
420 | for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) { | 425 | for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) { | ||
421 | xcb_change_window_attributes(m_connection, (*it).window, XCB_CW_CURSOR, &cid); | 426 | xcb_change_window_attributes(m_connection, (*it).window, XCB_CW_CURSOR, &cid); | ||
422 | } | 427 | } | ||
423 | 428 | | |||
424 | xcb_free_pixmap(m_connection, pix); | 429 | xcb_free_pixmap(m_connection, pix); | ||
425 | xcb_free_gc(m_connection, gc); | 430 | xcb_free_gc(m_connection, gc); | ||
426 | if (m_cursor) { | 431 | if (m_cursor) { | ||
427 | xcb_free_cursor(m_connection, m_cursor); | 432 | xcb_free_cursor(m_connection, m_cursor); | ||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |
How about