on xenial help sign in
plugins/Cursor: Do not force loading a specific cursor size
bde7296Daniel d'Andrada
plugins/Cursor/CursorImageProvider.cpp+14−12
@@ -76,24 +76,26 @@ CustomCursorImage::CustomCursorImage(const QCursor &cursor)
76XCursorImage::XCursorImage(const QString &theme, const QString &file)
76XCursorImage::XCursorImage(const QString &theme, const QString &file)
77 : xcursorImages(nullptr)
77 : xcursorImages(nullptr)
78{
78{
79+ // TODO: Consider grid unit value
80+ // Hardcoding to a medium size for now
81+ int preferredCursorHeightPx = 32;
82+
79− xcursorImages = XcursorLibraryLoadImages(QFile::encodeName(file), QFile::encodeName(theme), 32);
83+ xcursorImages = XcursorLibraryLoadImages(QFile::encodeName(file), QFile::encodeName(theme),
84+ preferredCursorHeightPx);
80 if (!xcursorImages) {
85 if (!xcursorImages) {
81 return;
86 return;
82 }
87 }
83
88
84− bool loaded = false;
89+ // Just take the first one. It will have multiple images in case of an animated cursor.
90+ // TODO: Support animated cursors
85− for (int i = 0; i < xcursorImages->nimage && !loaded; ++i) {
91+ if ( xcursorImages->nimage > 0) {
86− XcursorImage *xcursorImage = xcursorImages->images[i];
92+ XcursorImage *xcursorImage = xcursorImages->images[0];
87− if (xcursorImage->size == 32) {
88−
89− qimage = QImage((uchar*)xcursorImage->pixels,
90− xcursorImage->width, xcursorImage->height, QImage::Format_ARGB32);
91
93
92− hotspot.setX(xcursorImage->xhot);
94+ qimage = QImage((uchar*)xcursorImage->pixels,
93− hotspot.setY(xcursorImage->yhot);
95+ xcursorImage->width, xcursorImage->height, QImage::Format_ARGB32);
94
96
95− loaded = true;
97+ hotspot.setX(xcursorImage->xhot);
96− }
98+ hotspot.setY(xcursorImage->yhot);
97 }
99 }
98}
100}
99
101