diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-02-05 14:25:23 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-02-05 15:22:43 (GMT) |
commit | 1efb2693b15f23f269be1db393a83af132924e06 (patch) | |
tree | 8ed2801a64ca3e37233b984d252e44c59841d96e /src/gui/kernel/qcursor_x11.cpp | |
parent | 00d08740a1a5234c7f73eb634dcd45092b97dacd (diff) | |
download | Qt-1efb2693b15f23f269be1db393a83af132924e06.zip Qt-1efb2693b15f23f269be1db393a83af132924e06.tar.gz Qt-1efb2693b15f23f269be1db393a83af132924e06.tar.bz2 |
Added new mouse cursor types.
Added Qt::DragCopyCursor, DragMoveCursor and DragLinkCursor that are already
used internally for drag-n-drop, but were not exposed before. On X11 made them
use themed cursors through the Xcursor library.
Drag-n-drop now use these new cursors.
Inspired-by: David Benjamin MR#2215
Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'src/gui/kernel/qcursor_x11.cpp')
-rw-r--r-- | src/gui/kernel/qcursor_x11.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/gui/kernel/qcursor_x11.cpp b/src/gui/kernel/qcursor_x11.cpp index 3e83363..4e871a6 100644 --- a/src/gui/kernel/qcursor_x11.cpp +++ b/src/gui/kernel/qcursor_x11.cpp @@ -39,9 +39,11 @@ ** ****************************************************************************/ +#include <qdebug.h> #include <qdatastream.h> #include <private/qcursor_p.h> #include <private/qt_x11_p.h> +#include <private/qapplication_p.h> #include <qbitmap.h> #include <qcursor.h> #include <X11/cursorfont.h> @@ -57,6 +59,7 @@ #endif // QT_NO_XFIXES #include "qx11info_x11.h" +#include <private/qpixmap_x11_p.h> QT_BEGIN_NAMESPACE @@ -262,12 +265,31 @@ void QCursorData::update() "whats_this", "left_ptr_watch", "openhand", - "closedhand" + "closedhand", + "copy", + "move", + "link" }; #ifndef QT_NO_XCURSOR - if (X11->ptrXcursorLibraryLoadCursor) - hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, cursorNames[cshape]); + if (X11->ptrXcursorLibraryLoadCursor) { + // special case for non-standard dnd-* cursors + switch (cshape) { + case Qt::DragCopyCursor: + hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-copy"); + break; + case Qt::DragMoveCursor: + hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-move"); + break; + case Qt::DragLinkCursor: + hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-link"); + break; + default: + break; + } + if (!hcurs) + hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, cursorNames[cshape]); + } if (hcurs) return; #endif // QT_NO_XCURSOR @@ -504,6 +526,19 @@ void QCursorData::update() pm = XCreateBitmapFromData(dpy, rootwin, open ? openhand_bits : closedhand_bits, 16, 16); pmm = XCreateBitmapFromData(dpy, rootwin, open ? openhandm_bits : closedhandm_bits, 16, 16); hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); + } else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor + || cshape == Qt::DragLinkCursor) { + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + QImage image = QApplicationPrivate::instance()->getPixmapCursor(cshape).toImage(); + pm = QX11PixmapData::createBitmapFromImage(image); + pmm = QX11PixmapData::createBitmapFromImage(image.createAlphaMask().convertToFormat(QImage::Format_MonoLSB)); + hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); } if (hcurs) @@ -577,6 +612,15 @@ void QCursorData::update() case Qt::BusyCursor: sh = XC_watch; break; + case Qt::DragCopyCursor: + sh = XC_tcross; + break; + case Qt::DragLinkCursor: + sh = XC_center_ptr; + break; + case Qt::DragMoveCursor: + sh = XC_top_left_arrow; + break; #endif /* QT_USE_APPROXIMATE_CURSORS */ default: qWarning("QCursor::update: Invalid cursor shape %d", cshape); |