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