MCPcopy Create free account
hub / github.com/ckaiser/Lightscreen / cursor

Method cursor

tools/os.cpp:63–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61#include <tools/os.h>
62
63QPair<QPixmap, QPoint> os::cursor()
64{
65#ifdef Q_OS_WIN
66 /*
67 * Taken from: git://github.com/arrai/mumble-record.git > src > mumble > Overlay.cpp
68 * BSD License.
69 */
70
71 QPixmap pixmap;
72 QPoint hotspot;
73
74 CURSORINFO cursorInfo;
75 cursorInfo.cbSize = sizeof(cursorInfo);
76 ::GetCursorInfo(&cursorInfo);
77
78 HICON cursor = cursorInfo.hCursor;
79
80 ICONINFO iconInfo;
81 ::GetIconInfo(cursor, &iconInfo);
82
83 ICONINFO info;
84 ZeroMemory(&info, sizeof(info));
85
86 if (::GetIconInfo(cursor, &info)) {
87 if (info.hbmColor) {
88 pixmap = QtWin::fromHBITMAP(info.hbmColor, QtWin::HBitmapAlpha);
89 } else {
90 QBitmap orig(QtWin::fromHBITMAP(info.hbmMask));
91 QImage img = orig.toImage();
92
93 int h = img.height() / 2;
94 int w = static_cast<uint>(img.bytesPerLine()) / sizeof(quint32);
95
96 QImage out(img.width(), h, QImage::Format_MonoLSB);
97 QImage outmask(img.width(), h, QImage::Format_MonoLSB);
98
99 for (int i = 0; i < h; ++i) {
100 const quint32 *srcimg = reinterpret_cast<const quint32 *>(img.scanLine(i + h));
101 const quint32 *srcmask = reinterpret_cast<const quint32 *>(img.scanLine(i));
102
103 quint32 *dstimg = reinterpret_cast<quint32 *>(out.scanLine(i));
104 quint32 *dstmask = reinterpret_cast<quint32 *>(outmask.scanLine(i));
105
106 for (int j = 0; j < w; ++j) {
107 dstmask[j] = srcmask[j];
108 dstimg[j] = srcimg[j];
109 }
110 }
111
112 pixmap = QBitmap::fromImage(out, Qt::ColorOnly);
113 }
114
115 hotspot.setX(static_cast<int>(info.xHotspot));
116 hotspot.setY(static_cast<int>(info.yHotspot));
117
118 if (info.hbmMask) {
119 ::DeleteObject(info.hbmMask);
120 }

Callers

nothing calls this directly

Calls 2

QPixmapClass · 0.85
QPointClass · 0.85

Tested by

no test coverage detected