Provide hotspot in the device independent pixels
Currently, the trend is to get the coordinates of the hotspot and map it to the device independent pixels at the call site. This change makes the KXcursorSprite return the coordinates of the hotspot in the device independent pixels to reduce the amount of duplicated code.
This commit is contained in:
parent
487e2d9fb6
commit
1330abc93d
4 changed files with 2 additions and 4 deletions
|
@ -64,7 +64,6 @@ static PlatformCursorImage loadReferenceThemeCursor_helper(const KXcursorTheme &
|
|||
cursorImage.setDevicePixelRatio(theme.devicePixelRatio());
|
||||
|
||||
QPoint cursorHotspot = sprites.first().hotspot();
|
||||
cursorHotspot /= theme.devicePixelRatio();
|
||||
|
||||
return PlatformCursorImage(cursorImage, cursorHotspot);
|
||||
}
|
||||
|
|
|
@ -1322,7 +1322,6 @@ bool WaylandCursorImage::loadThemeCursor_helper(const QByteArray &name, Image *c
|
|||
cursorImage->image.setDevicePixelRatio(m_cursorTheme.devicePixelRatio());
|
||||
|
||||
cursorImage->hotspot = sprites.first().hotspot();
|
||||
cursorImage->hotspot /= m_cursorTheme.devicePixelRatio();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ static void load_callback(XcursorImages *images, void *data)
|
|||
QImage data(nativeCursorImage->width, nativeCursorImage->height, QImage::Format_ARGB32);
|
||||
memcpy(data.bits(), nativeCursorImage->pixels, data.sizeInBytes());
|
||||
|
||||
sprites.append(KXcursorSprite(data, hotspot, delay));
|
||||
sprites.append(KXcursorSprite(data, hotspot / themePrivate->devicePixelRatio, delay));
|
||||
}
|
||||
|
||||
themePrivate->registry.insert(images->name, sprites);
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
/**
|
||||
* Returns the hotspot for this sprite. (0, 0) corresponds to the upper left corner.
|
||||
*
|
||||
* The coordinates of the hotspot are in device pixels.
|
||||
* The coordinates of the hotspot are in device independent pixels.
|
||||
*/
|
||||
QPoint hotspot() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue