112 currentCursor = 0; |
112 currentCursor = 0; |
113 return; |
113 return; |
114 } |
114 } |
115 c->handle(); //force the cursor to get loaded, if it's not |
115 c->handle(); //force the cursor to get loaded, if it's not |
116 |
116 |
117 if(1 || currentCursor != c->d) { |
117 if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor |
118 if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor |
118 && currentCursor->curs.tc.anim) |
119 && currentCursor->curs.tc.anim) |
119 currentCursor->curs.tc.anim->stop(); |
120 currentCursor->curs.tc.anim->stop(); |
120 if(c->d->type == QCursorData::TYPE_ImageCursor) { |
121 QMacCocoaAutoReleasePool pool; |
121 [static_cast<NSCursor *>(c->d->curs.cp.nscursor) set]; |
122 if(c->d->type == QCursorData::TYPE_ImageCursor) { |
122 } else if(c->d->type == QCursorData::TYPE_ThemeCursor) { |
123 [static_cast<NSCursor *>(c->d->curs.cp.nscursor) set]; |
123 if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) { |
124 } else if(c->d->type == QCursorData::TYPE_ThemeCursor) { |
124 SetThemeCursor(c->d->curs.tc.curs); |
125 #ifdef QT_MAC_USE_COCOA |
125 } else { |
126 if (c->d->curs.cp.nscursor == 0) |
126 if(!c->d->curs.tc.anim) |
127 [[NSCursor arrowCursor] set]; |
127 c->d->curs.tc.anim = new QMacAnimateCursor; |
128 [static_cast<NSCursor *>(c->d->curs.cp.nscursor) set]; |
128 c->d->curs.tc.anim->start(c->d->curs.tc.curs); |
129 #else |
|
130 if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) { |
|
131 SetThemeCursor(c->d->curs.tc.curs); |
|
132 } else { |
|
133 if(!c->d->curs.tc.anim) |
|
134 c->d->curs.tc.anim = new QMacAnimateCursor; |
|
135 c->d->curs.tc.anim->start(c->d->curs.tc.curs); |
|
136 } |
|
137 #endif |
|
138 } |
129 } |
139 } |
130 } |
140 currentCursor = c->d; |
131 currentCursor = c->d; |
141 #endif |
132 #endif |
142 } |
133 } |
231 return flipPoint([NSEvent mouseLocation]).toPoint(); |
222 return flipPoint([NSEvent mouseLocation]).toPoint(); |
232 } |
223 } |
233 |
224 |
234 void QCursor::setPos(int x, int y) |
225 void QCursor::setPos(int x, int y) |
235 { |
226 { |
|
227 #ifdef QT_MAC_USE_COCOA |
|
228 CGPoint pos; |
|
229 pos.x = x; |
|
230 pos.y = y; |
|
231 |
|
232 CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0); |
|
233 CGEventPost(kCGHIDEventTap, e); |
|
234 CFRelease(e); |
|
235 #else |
236 CGWarpMouseCursorPosition(CGPointMake(x, y)); |
236 CGWarpMouseCursorPosition(CGPointMake(x, y)); |
237 |
237 |
238 /* I'm not too keen on doing this, but this makes it a lot easier, so I just |
238 /* I'm not too keen on doing this, but this makes it a lot easier, so I just |
239 send the event back through the event system and let it get propagated correctly |
239 send the event back through the event system and let it get propagated correctly |
240 ideally this would not really need to be faked --Sam |
240 ideally this would not really need to be faked --Sam |
247 if(widget) { |
247 if(widget) { |
248 QMouseEvent me(QMouseEvent::MouseMove, widget->mapFromGlobal(QPoint(x, y)), Qt::NoButton, |
248 QMouseEvent me(QMouseEvent::MouseMove, widget->mapFromGlobal(QPoint(x, y)), Qt::NoButton, |
249 QApplication::mouseButtons(), QApplication::keyboardModifiers()); |
249 QApplication::mouseButtons(), QApplication::keyboardModifiers()); |
250 qt_sendSpontaneousEvent(widget, &me); |
250 qt_sendSpontaneousEvent(widget, &me); |
251 } |
251 } |
|
252 #endif |
252 } |
253 } |
253 |
254 |
254 void QCursorData::initCursorFromBitmap() |
255 void QCursorData::initCursorFromBitmap() |
255 { |
256 { |
256 NSImage *nsimage; |
257 NSImage *nsimage; |
422 break; |
423 break; |
423 case Qt::ClosedHandCursor: |
424 case Qt::ClosedHandCursor: |
424 type = QCursorData::TYPE_ThemeCursor; |
425 type = QCursorData::TYPE_ThemeCursor; |
425 curs.cp.nscursor = [NSCursor closedHandCursor]; |
426 curs.cp.nscursor = [NSCursor closedHandCursor]; |
426 break; |
427 break; |
|
428 case Qt::DragCopyCursor: |
|
429 type = QCursorData::TYPE_ThemeCursor; |
|
430 curs.cp.nscursor = [NSCursor dragCopyCursor]; |
|
431 break; |
|
432 case Qt::DragMoveCursor: |
|
433 type = QCursorData::TYPE_ThemeCursor; |
|
434 curs.cp.nscursor = [NSCursor arrowCursor]; |
|
435 break; |
|
436 case Qt::DragLinkCursor: |
|
437 type = QCursorData::TYPE_ThemeCursor; |
|
438 curs.cp.nscursor = [NSCursor dragLinkCursor]; |
|
439 break; |
427 #define QT_USE_APPROXIMATE_CURSORS |
440 #define QT_USE_APPROXIMATE_CURSORS |
428 #ifdef QT_USE_APPROXIMATE_CURSORS |
441 #ifdef QT_USE_APPROXIMATE_CURSORS |
429 case Qt::SizeVerCursor: |
442 case Qt::SizeVerCursor: |
430 cursorData = cur_ver_bits; |
443 cursorData = cur_ver_bits; |
431 cursorMaskData = mcur_ver_bits; |
444 cursorMaskData = mcur_ver_bits; |
517 break; |
530 break; |
518 case Qt::ClosedHandCursor: |
531 case Qt::ClosedHandCursor: |
519 type = QCursorData::TYPE_ThemeCursor; |
532 type = QCursorData::TYPE_ThemeCursor; |
520 curs.tc.curs = kThemeClosedHandCursor; |
533 curs.tc.curs = kThemeClosedHandCursor; |
521 break; |
534 break; |
|
535 case Qt::DragMoveCursor: |
|
536 type = QCursorData::TYPE_ThemeCursor; |
|
537 curs.tc.curs = kThemeArrowCursor; |
|
538 break; |
|
539 case Qt::DragCopyCursor: |
|
540 type = QCursorData::TYPE_ThemeCursor; |
|
541 curs.tc.curs = kThemeCopyArrowCursor; |
|
542 break; |
|
543 case Qt::DragLinkCursor: |
|
544 type = QCursorData::TYPE_ThemeCursor; |
|
545 curs.tc.curs = kThemeAliasArrowCursor; |
|
546 break; |
522 #define QT_USE_APPROXIMATE_CURSORS |
547 #define QT_USE_APPROXIMATE_CURSORS |
523 #ifdef QT_USE_APPROXIMATE_CURSORS |
548 #ifdef QT_USE_APPROXIMATE_CURSORS |
524 case Qt::SizeVerCursor: |
549 case Qt::SizeVerCursor: |
525 cursorData = cur_ver_bits; |
550 cursorData = cur_ver_bits; |
526 cursorMaskData = mcur_ver_bits; |
551 cursorMaskData = mcur_ver_bits; |