summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qcocoaview_mac.mm
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-04-14 15:02:34 +0200
committerNorwegian Rock Cat <qt-info@nokia.com>2009-04-14 15:35:39 +0200
commit56feb92927d48edffcd09491091ec735b86a820d (patch)
tree114a4e229ab0f46a4ea56a7031e20456bf7f9260 /src/gui/kernel/qcocoaview_mac.mm
parent9a41b437be6014c7a671591e2741c5ca7d8c8be8 (diff)
Fix a bug where a widget would not always get the correct Cursor in Cocoa
Cocoa has a different way of dealing with cursors than our heavy handed approach that we used in Carbon. We simply need to re-implement the proper function in NSView and set up the rectangles for the cursor correctly. We also need to expose an QCursor2NSCursor type functions since the current QCursor::handle() is useless for doing this and we shouldn't change that. With this change things seem to work much more like the native stuff for both Carbon and Cocoa.
Diffstat (limited to 'src/gui/kernel/qcocoaview_mac.mm')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 9b581c5742..bcbd1bfc90 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -181,6 +181,7 @@ QT_FORWARD_DECLARE_CLASS(QAbstractScrollAreaPrivate)
QT_FORWARD_DECLARE_CLASS(QPaintEvent)
QT_FORWARD_DECLARE_CLASS(QPainter)
QT_FORWARD_DECLARE_CLASS(QHoverEvent)
+QT_FORWARD_DECLARE_CLASS(QCursor)
QT_USE_NAMESPACE
extern "C" {
extern NSString *NSTextInputReplacementRangeAttributeName;
@@ -236,6 +237,34 @@ extern "C" {
}
}
+- (void)resetCursorRects
+{
+ QWidget *cursorWidget = qwidget;
+
+ if (cursorWidget->testAttribute(Qt::WA_TransparentForMouseEvents))
+ cursorWidget = QApplication::widgetAt(qwidget->mapToGlobal(qwidget->rect().center()));
+
+ if (cursorWidget == 0)
+ return;
+
+ if (!cursorWidget->testAttribute(Qt::WA_SetCursor)) {
+ [super resetCursorRects];
+ return;
+ }
+
+ QRegion mask = qt_widget_private(cursorWidget)->extra->mask;
+ NSCursor *nscursor = static_cast<NSCursor *>(nsCursorForQCursor(cursorWidget->cursor()));
+ if (mask.isEmpty()) {
+ [self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor];
+ } else {
+ const QVector<QRect> &rects = mask.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect &rect = rects.at(i);
+ [self addCursorRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()) cursor:nscursor];
+ }
+ }
+}
+
- (void)removeDropData
{
if (dropData) {