on xenial help sign in
plugins/Cursor: Do not force loading a specific cursor size Fixes: #1517878

Approved by: Lukáš Tinkl

commitb0560e0d6a1f8a93c1ed7fbc1e25dc9eb56c12a0 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateTue 8 Dec 2015, 15:37 (11 years ago) parent1e594bb1f6eb18
1 file changed+14−12
plugins/Cursor/CursorImageProvider.cpp+14−12
plugins/Cursor/CursorImageProvider.cpp+14−12
@@ -77,24 +77,26 @@ CustomCursorImage::CustomCursorImage(const QCursor &cursor)
7777XCursorImage::XCursorImage(const QString &theme, const QString &file)
7878 : xcursorImages(nullptr)
7979{
80− xcursorImages = XcursorLibraryLoadImages(QFile::encodeName(file), QFile::encodeName(theme), 32);
80+ // TODO: Consider grid unit value
81+ // Hardcoding to a medium size for now
82+ int preferredCursorHeightPx = 32;
83+
84+ xcursorImages = XcursorLibraryLoadImages(QFile::encodeName(file), QFile::encodeName(theme),
85+ preferredCursorHeightPx);
8186 if (!xcursorImages) {
8287 return;
8388 }
8489
85− bool loaded = false;
86− for (int i = 0; i < xcursorImages->nimage && !loaded; ++i) {
87− XcursorImage *xcursorImage = xcursorImages->images[i];
88− if (xcursorImage->size == 32) {
89−
90− qimage = QImage((uchar*)xcursorImage->pixels,
91− xcursorImage->width, xcursorImage->height, QImage::Format_ARGB32);
90+ // Just take the first one. It will have multiple images in case of an animated cursor.
91+ // TODO: Support animated cursors
92+ if ( xcursorImages->nimage > 0) {
93+ XcursorImage *xcursorImage = xcursorImages->images[0];
9294
93− hotspot.setX(xcursorImage->xhot);
94− hotspot.setY(xcursorImage->yhot);
95+ qimage = QImage((uchar*)xcursorImage->pixels,
96+ xcursorImage->width, xcursorImage->height, QImage::Format_ARGB32);
9597
96− loaded = true;
97− }
98+ hotspot.setX(xcursorImage->xhot);
99+ hotspot.setY(xcursorImage->yhot);
98100 }
99101}
100102