on xenial help sign in
plugins/Cursor: Do not force loading a specific cursor size
commitbde7296828e37cc59b3eee7e37981189858a18ec authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 27 Nov 2015, 18:18 (11 years ago) parenta5fd11a
1 file changed+14−12
plugins/Cursor/CursorImageProvider.cpp+14−12
plugins/Cursor/CursorImageProvider.cpp+14−12
@@ -76,24 +76,26 @@ CustomCursorImage::CustomCursorImage(const QCursor &cursor)
7676XCursorImage::XCursorImage(const QString &theme, const QString &file)
7777 : xcursorImages(nullptr)
7878{
79− xcursorImages = XcursorLibraryLoadImages(QFile::encodeName(file), QFile::encodeName(theme), 32);
79+ // TODO: Consider grid unit value
80+ // Hardcoding to a medium size for now
81+ int preferredCursorHeightPx = 32;
82+
83+ xcursorImages = XcursorLibraryLoadImages(QFile::encodeName(file), QFile::encodeName(theme),
84+ preferredCursorHeightPx);
8085 if (!xcursorImages) {
8186 return;
8287 }
8388
84− bool loaded = false;
85− for (int i = 0; i < xcursorImages->nimage && !loaded; ++i) {
86− XcursorImage *xcursorImage = xcursorImages->images[i];
87− if (xcursorImage->size == 32) {
88−
89− qimage = QImage((uchar*)xcursorImage->pixels,
90− xcursorImage->width, xcursorImage->height, QImage::Format_ARGB32);
89+ // Just take the first one. It will have multiple images in case of an animated cursor.
90+ // TODO: Support animated cursors
91+ if ( xcursorImages->nimage > 0) {
92+ XcursorImage *xcursorImage = xcursorImages->images[0];
9193
92− hotspot.setX(xcursorImage->xhot);
93− hotspot.setY(xcursorImage->yhot);
94+ qimage = QImage((uchar*)xcursorImage->pixels,
95+ xcursorImage->width, xcursorImage->height, QImage::Format_ARGB32);
9496
95− loaded = true;
96− }
97+ hotspot.setX(xcursorImage->xhot);
98+ hotspot.setY(xcursorImage->yhot);
9799 }
98100}
99101