Qt 4.8
Classes | Macros | Functions | Variables
qt_cocoa_helpers_mac.mm File Reference
#include <private/qcore_mac_p.h>
#include <qaction.h>
#include <qwidget.h>
#include <qdesktopwidget.h>
#include <qevent.h>
#include <qpixmapcache.h>
#include <qvarlengtharray.h>
#include <private/qevent_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
#include <private/qapplication_p.h>
#include <private/qcocoaapplication_mac_p.h>
#include <private/qcocoawindow_mac_p.h>
#include <private/qcocoaview_mac_p.h>
#include <private/qkeymapper_p.h>
#include <private/qwidget_p.h>

Go to the source code of this file.

Classes

struct  dndenum_mapper
 
struct  KeyPair
 
struct  qt_mac_enum_mapper
 

Macros

#define QT_MAC_MAP_ENUM(x)   x
 

Functions

Qt::MouseButton cocoaButton2QtButton (NSInteger buttonNum)
 
QPointF flipPoint (const NSPoint &p)
 
NSPoint flipPoint (const QPoint &p)
 
NSPoint flipPoint (const QPointF &p)
 
void macSendToolbarChangeEvent (QWidget *widget)
 
void macWindowFade (void *window, float durationSeconds)
 
void macWindowFlush (void *window)
 
bool macWindowIsTextured (void *window)
 
void macWindowSetHasShadow (void *window, bool hasShadow)
 
bool macWindowToolbarIsVisible (void *window)
 
void macWindowToolbarSet (void *window, void *toolbarRef)
 
void macWindowToolbarShow (const QWidget *widget, bool show)
 
bool operator< (const KeyPair &entry, QChar qchar)
 
bool operator< (QChar qchar, const KeyPair &entry)
 
bool operator< (const Qt::Key &key, const KeyPair &entry)
 
bool operator< (const KeyPair &entry, const Qt::Key &key)
 
bool operator== (const KeyPair &entry, QChar qchar)
 
 Q_GLOBAL_STATIC (QMacWindowFader, macwindowFader)
 
bool qt_dispatchKeyEvent (void *keyEvent, QWidget *widgetToGetEvent)
 
void qt_dispatchModifiersChanged (void *flagsChangedEvent, QWidget *widgetToGetEvent)
 
void qt_dispatchTabletProximityEvent (const ::TabletProximityRec &proxRec)
 
bool qt_mac_checkForNativeSizeGrip (const QWidget *widget)
 
void qt_mac_constructQIconFromIconRef (const IconRef icon, const IconRef overlayIcon, QIcon *retIcon, QStyle::StandardPixmap standardIcon)
 
QPixmap qt_mac_convert_iconref (const IconRef icon, int width, int height)
 
void * qt_mac_create_nsimage (const QPixmap &pm)
 
void qt_mac_dispatchPendingUpdateRequests (QWidget *widget)
 
OSStatus qt_mac_drawCGImage (CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
 
OSViewRef qt_mac_effectiveview_for (const QWidget *w)
 
Qt::MouseButton qt_mac_get_button (EventMouseButton button)
 
Qt::MouseButtons qt_mac_get_buttons (int buttons)
 
QString qt_mac_get_pasteboardString (OSPasteboardRef paste)
 
CGFloat qt_mac_get_scalefactor ()
 
CGContextRef qt_mac_graphicsContextFor (QWidget *widget)
 
bool qt_mac_handleTabletEvent (void *view, void *tabletEvent)
 
QStringList qt_mac_NSArrayToQStringList (void *nsarray)
 
void qt_mac_post_retranslateAppMenu ()
 
void * qt_mac_QStringListToNSMutableArrayVoid (const QStringList &list)
 
QMacTabletHashqt_mac_tablet_hash ()
 
void qt_mac_update_mouseTracking (QWidget *widget)
 
void qt_mac_updateContentBorderMetricts (void *window, const ::HIContentBorderMetrics &metrics)
 
void qt_mac_updateCursorWithWidgetUnderMouse (QWidget *widgetUnderMouse)
 
bool qt_sendSpontaneousEvent (QObject *receiver, QEvent *event)
 
QChar qtKey2CocoaKey (Qt::Key key)
 
static bool qtKey2CocoaKeySortLessThan (const KeyPair &entry1, const KeyPair &entry2)
 

Variables

static const KeyPair *const end = entries + NumEntries
 
static const KeyPair entries [NumEntries]
 
QWidgetmac_mouse_grabber
 
static const int NumEntries = 59
 
QWidgetqt_button_down
 
QPointer< QWidgetqt_last_mouse_receiver
 
static qt_mac_enum_mapper qt_mac_mouse_symbols []
 

Macro Definition Documentation

◆ QT_MAC_MAP_ENUM

#define QT_MAC_MAP_ENUM (   x)    x

Definition at line 389 of file qt_cocoa_helpers_mac.mm.

Function Documentation

◆ cocoaButton2QtButton()

Qt::MouseButton cocoaButton2QtButton ( NSInteger  buttonNum)

Definition at line 797 of file qt_cocoa_helpers_mac.mm.

Referenced by flipPoint().

798 {
799  if (buttonNum == 0)
800  return Qt::LeftButton;
801  if (buttonNum == 1)
802  return Qt::RightButton;
803  if (buttonNum == 2)
804  return Qt::MidButton;
805  if (buttonNum == 3)
806  return Qt::XButton1;
807  if (buttonNum == 4)
808  return Qt::XButton2;
809  return Qt::NoButton;
810 }

◆ flipPoint() [1/3]

QPointF flipPoint ( const NSPoint p)

Definition at line 862 of file qt_cocoa_helpers_mac.mm.

Referenced by flipPoint(), flipYCoordinate(), QWidget::mapToGlobal(), QCursor::pos(), qt_mac_handleTabletEvent(), and QApplication::topLevelAt().

863 {
864  return QPointF(p.x, flipYCoordinate(p.y));
865 }
int flipYCoordinate(int y)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214

◆ flipPoint() [2/3]

NSPoint flipPoint ( const QPoint p)

Definition at line 867 of file qt_cocoa_helpers_mac.mm.

868 {
869  return NSMakePoint(p.x(), flipYCoordinate(p.y()));
870 }
int flipYCoordinate(int y)
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ flipPoint() [3/3]

NSPoint flipPoint ( const QPointF p)

Definition at line 872 of file qt_cocoa_helpers_mac.mm.

873 {
874  return NSMakePoint(p.x(), flipYCoordinate(p.y()));
875 }
int flipYCoordinate(int y)
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ macSendToolbarChangeEvent()

void macSendToolbarChangeEvent ( QWidget widget)

Definition at line 435 of file qt_cocoa_helpers_mac.mm.

Referenced by make_win_eventUPP().

436 {
437  QToolBarChangeEvent ev(!(GetCurrentKeyModifiers() & cmdKey));
438  qt_sendSpontaneousEvent(widget, &ev);
439 }
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
The QToolBarChangeEvent class provides an event that is sent whenever a the toolbar button is clicked...
Definition: qevent.h:662

◆ macWindowFade()

void macWindowFade ( void *  window,
float  durationSeconds 
)

Definition at line 155 of file qt_cocoa_helpers_mac.mm.

Referenced by QMenuPrivate::hideMenu(), QComboBox::hidePopup(), and QTipLabel::timerEvent().

156 {
157 #ifdef QT_MAC_USE_COCOA
159 #endif
160  OSWindowRef wnd = static_cast<OSWindowRef>(window);
161  if (wnd) {
162  QWidget *widget;
163 #if QT_MAC_USE_COCOA
164  widget = [wnd QT_MANGLE_NAMESPACE(qt_qwidget)];
165 #else
166  const UInt32 kWidgetCreatorQt = kEventClassQt;
167  enum {
168  kWidgetPropertyQWidget = 'QWId' //QWidget *
169  };
170  if (GetWindowProperty(static_cast<WindowRef>(window), kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(widget), 0, &widget) != noErr)
171  widget = 0;
172 #endif
173  if (widget) {
177  }
178  }
179 }
QPointer< QWidget > widget
const UInt32 kWidgetCreatorQt
Definition: qwidget_mac.mm:148
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
NSWindow * window
static QMacWindowFader * currentFader()
WindowRef OSWindowRef
void setFadeDuration(float durationInSecs)
Definition: qt_mac_p.h:136
void registerWindowToFade(QWidget *window)
#define QT_MANGLE_NAMESPACE(name)
Definition: qglobal.h:106
const UInt32 kEventClassQt
Definition: qt_mac_p.h:92

◆ macWindowFlush()

void macWindowFlush ( void *  window)

Definition at line 312 of file qt_cocoa_helpers_mac.mm.

Referenced by QEventDispatcherMac::flush().

313 {
314  OSWindowRef wnd = static_cast<OSWindowRef>(window);
315 #if QT_MAC_USE_COCOA
316  [wnd flushWindowIfNeeded];
317 #else
318  HIWindowFlush(wnd);
319 #endif
320 }
NSWindow * window
WindowRef OSWindowRef

◆ macWindowIsTextured()

bool macWindowIsTextured ( void *  window)

Definition at line 245 of file qt_cocoa_helpers_mac.mm.

Referenced by qt_mac_is_metal().

246 {
247  OSWindowRef wnd = static_cast<OSWindowRef>(window);
248 #if QT_MAC_USE_COCOA
249  return ( [wnd styleMask] & NSTexturedBackgroundWindowMask ) ? true : false;
250 #else
251  WindowAttributes currentAttributes;
252  GetWindowAttributes(wnd, &currentAttributes);
253  return (currentAttributes & kWindowMetalAttribute) ? true : false;
254 #endif
255 }
NSWindow * window
WindowRef OSWindowRef

◆ macWindowSetHasShadow()

void macWindowSetHasShadow ( void *  window,
bool  hasShadow 
)

Definition at line 299 of file qt_cocoa_helpers_mac.mm.

Referenced by QRubberBand::QRubberBand().

300 {
301  OSWindowRef wnd = static_cast<OSWindowRef>(window);
302 #if QT_MAC_USE_COCOA
303  [wnd setHasShadow:BOOL(hasShadow)];
304 #else
305  if (hasShadow)
306  ChangeWindowAttributes(wnd, 0, kWindowNoShadowAttribute);
307  else
308  ChangeWindowAttributes(wnd, kWindowNoShadowAttribute, 0);
309 #endif
310 }
NSWindow * window
WindowRef OSWindowRef

◆ macWindowToolbarIsVisible()

bool macWindowToolbarIsVisible ( void *  window)

Definition at line 287 of file qt_cocoa_helpers_mac.mm.

Referenced by QToolBar::event(), and QMainWindowLayout::toggleToolBarsVisible().

288 {
289  OSWindowRef wnd = static_cast<OSWindowRef>(window);
290 #if QT_MAC_USE_COCOA
291  if (NSToolbar *toolbar = [wnd toolbar])
292  return [toolbar isVisible];
293  return false;
294 #else
295  return IsWindowToolbarVisible(wnd);
296 #endif
297 }
NSToolbar * toolbar
NSWindow * window
WindowRef OSWindowRef

◆ macWindowToolbarSet()

void macWindowToolbarSet ( void *  window,
void *  toolbarRef 
)

Definition at line 277 of file qt_cocoa_helpers_mac.mm.

Referenced by QMainWindowLayout::insertIntoMacToolbar(), and QMainWindowLayout::updateHIToolBarStatus().

278 {
279  OSWindowRef wnd = static_cast<OSWindowRef>(window);
280 #if QT_MAC_USE_COCOA
281  [wnd setToolbar:static_cast<NSToolbar *>(toolbarRef)];
282 #else
283  SetWindowToolbar(wnd, static_cast<HIToolbarRef>(toolbarRef));
284 #endif
285 }
NSWindow * window
WindowRef OSWindowRef

◆ macWindowToolbarShow()

void macWindowToolbarShow ( const QWidget widget,
bool  show 
)

Definition at line 257 of file qt_cocoa_helpers_mac.mm.

Referenced by QToolBar::event(), QToolBarPrivate::init(), QMainWindowLayout::insertIntoMacToolbar(), QMainWindowLayout::syncUnifiedToolbarVisibility(), QMainWindowLayout::updateHIToolBarStatus(), and QToolBar::~QToolBar().

258 {
259  OSWindowRef wnd = qt_mac_window_for(widget);
260 #if QT_MAC_USE_COCOA
261  if (NSToolbar *toolbar = [wnd toolbar]) {
263  if (show != [toolbar isVisible]) {
264  [toolbar setVisible:show];
265  } else {
266  // The toolbar may be in sync, but we are not, update our framestrut.
267  qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut();
268  }
269  }
270 #else
271  qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut();
272  ShowHideWindowToolbar(wnd, show, false);
273 #endif
274 }
NSToolbar * toolbar
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
WindowRef OSWindowRef
void updateFrameStrut()
Computes the frame rectangle when needed.
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920

◆ operator<() [1/4]

bool operator< ( const KeyPair entry,
QChar  qchar 
)

Definition at line 561 of file qt_cocoa_helpers_mac.mm.

562 {
563  return entry.cocoaKey < qchar;
564 }

◆ operator<() [2/4]

bool operator< ( QChar  qchar,
const KeyPair entry 
)

Definition at line 566 of file qt_cocoa_helpers_mac.mm.

567 {
568  return qchar < entry.cocoaKey;
569 }

◆ operator<() [3/4]

bool operator< ( const Qt::Key key,
const KeyPair entry 
)

Definition at line 571 of file qt_cocoa_helpers_mac.mm.

572 {
573  return key < entry.qtKey;
574 }
int key

◆ operator<() [4/4]

bool operator< ( const KeyPair entry,
const Qt::Key key 
)

Definition at line 576 of file qt_cocoa_helpers_mac.mm.

577 {
578  return entry.qtKey < key;
579 }
int key

◆ operator==()

bool operator== ( const KeyPair entry,
QChar  qchar 
)

Definition at line 556 of file qt_cocoa_helpers_mac.mm.

557 {
558  return entry.cocoaKey == qchar;
559 }

◆ Q_GLOBAL_STATIC()

Q_GLOBAL_STATIC ( QMacWindowFader  ,
macwindowFader   
)

◆ qt_dispatchKeyEvent()

bool qt_dispatchKeyEvent ( void *  keyEvent,
QWidget widgetToGetEvent 
)

Definition at line 812 of file qt_cocoa_helpers_mac.mm.

813 {
814 #ifndef QT_MAC_USE_COCOA
816  Q_UNUSED(widgetToGetEvent);
817  return false;
818 #else
819  NSEvent *event = static_cast<NSEvent *>(keyEvent);
820  EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef]));
821  Q_ASSERT(key_event);
822  unsigned int info = 0;
823 
824  if ([event type] == NSKeyDown) {
825  NSString *characters = [event characters];
826  if ([characters length]) {
827  unichar value = [characters characterAtIndex:0];
828  qt_keymapper_private()->updateKeyMap(0, key_event, (void *)&value);
829  info = value;
830  }
831  }
832 
833  if (qt_mac_sendMacEventToWidget(widgetToGetEvent, key_event))
834  return true;
835 
836  if (mustUseCocoaKeyEvent())
837  return qt_dispatchKeyEventWithCocoa(keyEvent, widgetToGetEvent);
838 
839  bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &info, true);
840  return consumed && (info != 0);
841 #endif
842 }
int type
Definition: qmetatype.cpp:239
static mach_timebase_info_data_t info
EventRef event
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
void updateKeyMap(const MSG &msg)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab)
bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref)
Definition: qwidget_mac.mm:448
struct OpaqueEventRef * EventRef
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ qt_dispatchModifiersChanged()

void qt_dispatchModifiersChanged ( void *  flagsChangedEvent,
QWidget widgetToGetEvent 
)

Definition at line 844 of file qt_cocoa_helpers_mac.mm.

845 {
846 #ifndef QT_MAC_USE_COCOA
847  Q_UNUSED(flagsChangedEvent);
848  Q_UNUSED(widgetToGetEvent);
849 #else
850  UInt32 modifiers = 0;
851  // Sync modifiers with Qt
852  NSEvent *event = static_cast<NSEvent *>(flagsChangedEvent);
853  EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef]));
854  Q_ASSERT(key_event);
855  GetEventParameter(key_event, kEventParamKeyModifiers, typeUInt32, 0,
856  sizeof(modifiers), 0, &modifiers);
857  extern void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object);
858  qt_mac_send_modifiers_changed(modifiers, widgetToGetEvent);
859 #endif
860 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
struct OpaqueEventRef * EventRef
unsigned int quint32
Definition: qglobal.h:938
void qt_mac_send_modifiers_changed(quint32, QObject *)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ qt_dispatchTabletProximityEvent()

void qt_dispatchTabletProximityEvent ( const ::TabletProximityRec &  proxRec)

Definition at line 477 of file qt_cocoa_helpers_mac.mm.

Referenced by QApplicationPrivate::globalEventProcessor(), qt_mac_tablet_hash(), and QApplicationPrivate::tabletProximityCallback().

478 {
479  QTabletDeviceData proximityDevice;
480  proximityDevice.tabletUniqueID = proxRec.uniqueID;
481  proximityDevice.capabilityMask = proxRec.capabilityMask;
482 
483  switch (proxRec.pointerType) {
484  case NSUnknownPointingDevice:
485  default:
486  proximityDevice.tabletPointerType = QTabletEvent::UnknownPointer;
487  break;
488  case NSPenPointingDevice:
489  proximityDevice.tabletPointerType = QTabletEvent::Pen;
490  break;
491  case NSCursorPointingDevice:
492  proximityDevice.tabletPointerType = QTabletEvent::Cursor;
493  break;
494  case NSEraserPointingDevice:
495  proximityDevice.tabletPointerType = QTabletEvent::Eraser;
496  break;
497  }
498  uint bits = proxRec.vendorPointerType;
499  if (bits == 0 && proximityDevice.tabletUniqueID != 0) {
500  // Fallback. It seems that the driver doesn't always include all the information.
501  // High-End Wacom devices store their "type" in the uper bits of the Unique ID.
502  // I'm not sure how to handle it for consumer devices, but I'll test that in a bit.
503  bits = proximityDevice.tabletUniqueID >> 32;
504  }
505  // Defined in the "EN0056-NxtGenImpGuideX"
506  // on Wacom's Developer Website (www.wacomeng.com)
507  if (((bits & 0x0006) == 0x0002) && ((bits & 0x0F06) != 0x0902)) {
508  proximityDevice.tabletDeviceType = QTabletEvent::Stylus;
509  } else {
510  switch (bits & 0x0F06) {
511  case 0x0802:
512  proximityDevice.tabletDeviceType = QTabletEvent::Stylus;
513  break;
514  case 0x0902:
515  proximityDevice.tabletDeviceType = QTabletEvent::Airbrush;
516  break;
517  case 0x0004:
518  proximityDevice.tabletDeviceType = QTabletEvent::FourDMouse;
519  break;
520  case 0x0006:
521  proximityDevice.tabletDeviceType = QTabletEvent::Puck;
522  break;
523  case 0x0804:
524  proximityDevice.tabletDeviceType = QTabletEvent::RotationStylus;
525  break;
526  default:
527  proximityDevice.tabletDeviceType = QTabletEvent::NoDevice;
528  }
529  }
530  // The deviceID is "unique" while in the proximity, it's a key that we can use for
531  // linking up TabletDeviceData to an event (especially if there are two devices in action).
532  bool entering = proxRec.enterProximity;
533  if (entering) {
534  qt_mac_tablet_hash()->insert(proxRec.deviceID, proximityDevice);
535  } else {
536  qt_mac_tablet_hash()->remove(proxRec.deviceID);
537  }
538 
539  QTabletEvent qtabletProximity(entering ? QEvent::TabletEnterProximity
541  QPoint(), QPoint(), QPointF(), proximityDevice.tabletDeviceType,
542  proximityDevice.tabletPointerType, 0., 0, 0, 0., 0., 0, 0,
543  proximityDevice.tabletUniqueID);
544 
545  qt_sendSpontaneousEvent(qApp, &qtabletProximity);
546 }
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
QMacTabletHash * qt_mac_tablet_hash()
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define qApp
unsigned int uint
Definition: qglobal.h:996
The QTabletEvent class contains parameters that describe a Tablet event.
Definition: qevent.h:179
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ qt_mac_checkForNativeSizeGrip()

bool qt_mac_checkForNativeSizeGrip ( const QWidget widget)

Definition at line 371 of file qt_cocoa_helpers_mac.mm.

Referenced by QAbstractScrollAreaPrivate::layoutChildren().

372 {
373 #ifndef QT_MAC_USE_COCOA
374  OSViewRef nativeSizeGrip = 0;
375  HIViewFindByID(HIViewGetRoot(HIViewGetWindow(HIViewRef(widget->winId()))), kHIViewWindowGrowBoxID, &nativeSizeGrip);
376  return (nativeSizeGrip != 0);
377 #else
378  return [[reinterpret_cast<NSView *>(widget->effectiveWinId()) window] showsResizeIndicator];
379 #endif
380 }
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
NSWindow * window
struct OpaqueControlRef * HIViewRef
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
HIViewRef OSViewRef

◆ qt_mac_constructQIconFromIconRef()

void qt_mac_constructQIconFromIconRef ( const IconRef  icon,
const IconRef  overlayIcon,
QIcon retIcon,
QStyle::StandardPixmap  standardIcon 
)

Definition at line 1610 of file qt_cocoa_helpers_mac.mm.

Referenced by QFileIconProviderPrivate::getWinIcon(), qAppInstance(), and QCommonStyle::standardIconImplementation().

1611 {
1612  int size = 16;
1613  while (size <= 128) {
1614 
1615  const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size);
1616  QPixmap mainIcon;
1617  if (standardIcon >= QStyle::SP_CustomBase) {
1618  mainIcon = qt_mac_convert_iconref(icon, size, size);
1619  } else if (QPixmapCache::find(cacheKey, mainIcon) == false) {
1620  mainIcon = qt_mac_convert_iconref(icon, size, size);
1621  QPixmapCache::insert(cacheKey, mainIcon);
1622  }
1623 
1624  if (overlayIcon) {
1625  int littleSize = size / 2;
1626  QPixmap overlayPix = qt_mac_convert_iconref(overlayIcon, littleSize, littleSize);
1627  QPainter painter(&mainIcon);
1628  painter.drawPixmap(size - littleSize, size - littleSize, overlayPix);
1629  }
1630 
1631  retIcon->addPixmap(mainIcon);
1632  size += size; // 16 -> 32 -> 64 -> 128
1633  }
1634 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Definition: qicon.cpp:814
QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71

◆ qt_mac_convert_iconref()

QPixmap qt_mac_convert_iconref ( const IconRef  icon,
int  width,
int  height 
)

Definition at line 1591 of file qt_cocoa_helpers_mac.mm.

Referenced by qAppInstance(), and qt_mac_constructQIconFromIconRef().

1592 {
1593  QPixmap ret(width, height);
1594  ret.fill(QColor(0, 0, 0, 0));
1595 
1596  CGRect rect = CGRectMake(0, 0, width, height);
1597 
1599  CGAffineTransform old_xform = CGContextGetCTM(ctx);
1600  CGContextConcatCTM(ctx, CGAffineTransformInvert(old_xform));
1601  CGContextConcatCTM(ctx, CGAffineTransformIdentity);
1602 
1603  ::RGBColor b;
1604  b.blue = b.green = b.red = 255*255;
1605  PlotIconRefInContext(ctx, &rect, kAlignNone, kTransformNone, &b, kPlotIconRefNormalFlags, icon);
1606  CGContextRelease(ctx);
1607  return ret;
1608 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
Returns the CoreGraphics CGContextRef of the paint device.
struct CGRect CGRect
#define ctx
Definition: qgl.cpp:6094
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
struct CGContext * CGContextRef

◆ qt_mac_create_nsimage()

void* qt_mac_create_nsimage ( const QPixmap pm)

Definition at line 322 of file qt_cocoa_helpers_mac.mm.

Referenced by qt_mac_set_app_icon(), QCursor::setPos(), QWidgetPrivate::setWindowIcon_sys(), QMenuPrivate::QMacMenuPrivate::syncAction(), and QSystemTrayIconPrivate::updateIcon_sys().

323 {
325  if(QCFType<CGImageRef> image = pm.toMacCGImageRef()) {
326  NSImage *newImage = 0;
327  NSRect imageRect = NSMakeRect(0.0, 0.0, CGImageGetWidth(image), CGImageGetHeight(image));
328  newImage = [[NSImage alloc] initWithSize:imageRect.size];
329  [newImage lockFocus];
330  {
331  CGContextRef imageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
332  CGContextDrawImage(imageContext, *(CGRect*)&imageRect, image);
333  }
334  [newImage unlockFocus];
335  return newImage;
336  }
337  return 0;
338 }
struct CGRect CGRect
struct CGContext * CGContextRef
CGImageRef toMacCGImageRef() const
Creates a CGImageRef equivalent to the QPixmap.

◆ qt_mac_dispatchPendingUpdateRequests()

void qt_mac_dispatchPendingUpdateRequests ( QWidget widget)

Definition at line 1547 of file qt_cocoa_helpers_mac.mm.

Referenced by QGraphicsViewPrivate::dispatchPendingUpdateRequests().

1548 {
1549  if (!widget)
1550  return;
1551 #ifndef QT_MAC_USE_COCOA
1552  HIViewRender(qt_mac_nativeview_for(widget));
1553 #else
1554  [qt_mac_nativeview_for(widget) displayIfNeeded];
1555 #endif
1556 }
OSViewRef qt_mac_nativeview_for(const QWidget *)
Definition: qwidget_mac.mm:419

◆ qt_mac_drawCGImage()

OSStatus qt_mac_drawCGImage ( CGContextRef  inContext,
const CGRect inBounds,
CGImageRef  inImage 
)

Definition at line 349 of file qt_cocoa_helpers_mac.mm.

Referenced by QCoreGraphicsPaintEngine::drawImage(), QCoreGraphicsPaintEngine::drawPixmap(), QMacWindowSurface::flush(), QRasterWindowSurface::flush(), QPixmap::fromMacCGImageRef(), qt_mac_draw_pattern(), and QMacWindowSurface::scroll().

350 {
351  // Verbatim copy if HIViewDrawCGImage (as shown on Carbon-Dev)
352  OSStatus err = noErr;
353 
354  require_action(inContext != NULL, InvalidContext, err = paramErr);
355  require_action(inBounds != NULL, InvalidBounds, err = paramErr);
356  require_action(inImage != NULL, InvalidImage, err = paramErr);
357 
358  CGContextSaveGState( inContext );
359  CGContextTranslateCTM (inContext, 0, inBounds->origin.y + CGRectGetMaxY(*inBounds));
360  CGContextScaleCTM(inContext, 1, -1);
361 
362  CGContextDrawImage(inContext, *inBounds, inImage);
363 
364  CGContextRestoreGState(inContext);
365 InvalidImage:
366 InvalidBounds:
367 InvalidContext:
368  return err;
369 }
signed long OSStatus

◆ qt_mac_effectiveview_for()

OSViewRef qt_mac_effectiveview_for ( const QWidget w)

Definition at line 424 of file qwidget_mac.mm.

Referenced by flipPoint(), QMacWindowFader::performFade(), qt_mac_window_for(), QWidgetPrivate::registerDropSite(), and QWidgetPrivate::setFocus_sys().

425 {
426  // Get the first non-alien (parent) widget for
427  // w, and return its NSView (if it has one):
428  return reinterpret_cast<OSViewRef>(w->effectiveWinId());
429 }
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
HIViewRef OSViewRef

◆ qt_mac_get_button()

Qt::MouseButton qt_mac_get_button ( EventMouseButton  button)

Definition at line 418 of file qt_cocoa_helpers_mac.mm.

Referenced by QApplicationPrivate::globalEventProcessor().

419 {
420 #ifdef DEBUG_MOUSE_MAPS
421  qDebug("Qt: internal: **Mapping button: %d (0x%04x)", button, button);
422 #endif
423  Qt::MouseButtons ret = 0;
424  for(int i = 0; qt_mac_mouse_symbols[i].qt_code; i++) {
425  if (button == qt_mac_mouse_symbols[i].mac_code) {
426 #ifdef DEBUG_MOUSE_MAPS
427  qDebug("Qt: internal: got button: %s", qt_mac_mouse_symbols[i].desc);
428 #endif
429  return Qt::MouseButton(qt_mac_mouse_symbols[i].qt_code);
430  }
431  }
432  return Qt::NoButton;
433 }
static qt_mac_enum_mapper qt_mac_mouse_symbols[]
Q_CORE_EXPORT void qDebug(const char *,...)
MouseButton
Definition: qnamespace.h:150

◆ qt_mac_get_buttons()

Qt::MouseButtons qt_mac_get_buttons ( int  buttons)

Definition at line 402 of file qt_cocoa_helpers_mac.mm.

Referenced by flipPoint(), and QApplicationPrivate::globalEventProcessor().

403 {
404 #ifdef DEBUG_MOUSE_MAPS
405  qDebug("Qt: internal: **Mapping buttons: %d (0x%04x)", buttons, buttons);
406 #endif
407  Qt::MouseButtons ret = Qt::NoButton;
408  for(int i = 0; qt_mac_mouse_symbols[i].qt_code; i++) {
409  if (buttons & (0x01<<(qt_mac_mouse_symbols[i].mac_code-1))) {
410 #ifdef DEBUG_MOUSE_MAPS
411  qDebug("Qt: internal: got button: %s", qt_mac_mouse_symbols[i].desc);
412 #endif
413  ret |= Qt::MouseButtons(qt_mac_mouse_symbols[i].qt_code);
414  }
415  }
416  return ret;
417 }
static Qt::MouseButtons buttons
static qt_mac_enum_mapper qt_mac_mouse_symbols[]
Q_CORE_EXPORT void qDebug(const char *,...)

◆ qt_mac_get_pasteboardString()

QString qt_mac_get_pasteboardString ( OSPasteboardRef  paste)

Definition at line 1572 of file qt_cocoa_helpers_mac.mm.

Referenced by flipYCoordinate(), and QMacPasteboard::retrieveData().

1573 {
1575  NSPasteboard *pb = nil;
1576  CFStringRef pbname;
1577  if (PasteboardCopyName(paste, &pbname) == noErr) {
1578  pb = [NSPasteboard pasteboardWithName:const_cast<NSString *>(reinterpret_cast<const NSString *>(pbname))];
1579  CFRelease(pbname);
1580  } else {
1581  pb = [NSPasteboard generalPasteboard];
1582  }
1583  if (pb) {
1584  NSString *text = [pb stringForType:NSStringPboardType];
1585  if (text)
1586  return qt_mac_NSStringToQString(text);
1587  }
1588  return QString();
1589 }
const struct __CFString * CFStringRef
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define text
Definition: qobjectdefs.h:80

◆ qt_mac_get_scalefactor()

CGFloat qt_mac_get_scalefactor ( )

Definition at line 1558 of file qt_cocoa_helpers_mac.mm.

Referenced by QStyleHelper::dpiScaled(), flipYCoordinate(), QPixmapIconEngine::paint(), QIconLoaderEngine::paint(), qt_mac_grabDisplayRect(), QToolButton::sizeHint(), and QCoreGraphicsPaintEngine::updateRenderHints().

1559 {
1560 #ifndef QT_MAC_USE_COCOA
1561  return HIGetScaleFactor();
1562 #endif
1563 
1564 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
1565  NSScreen *mainScreen = [NSScreen mainScreen];
1566  if ([mainScreen respondsToSelector:@selector(backingScaleFactor)])
1567  return [mainScreen backingScaleFactor];
1568 #endif
1569  return 1.0;
1570 }

◆ qt_mac_graphicsContextFor()

CGContextRef qt_mac_graphicsContextFor ( QWidget widget)

Definition at line 1532 of file qt_cocoa_helpers_mac.mm.

Referenced by QMacWindowSurface::flush().

1533 {
1534  if (!widget)
1535  return 0;
1536 
1537 #ifndef QT_MAC_USE_COCOA
1538  CGContextRef context;
1539  CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
1540  QDBeginCGContext(port, &context);
1541 #else
1542  CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithWindow:qt_mac_window_for(widget)] graphicsPort];
1543 #endif
1544  return context;
1545 }
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
struct CGContext * CGContextRef

◆ qt_mac_handleTabletEvent()

bool qt_mac_handleTabletEvent ( void *  view,
void *  tabletEvent 
)

Definition at line 1292 of file qt_cocoa_helpers_mac.mm.

Referenced by flipPoint().

1293 {
1294 #ifndef QT_MAC_USE_COCOA
1295  Q_UNUSED(view);
1296  Q_UNUSED(tabletEvent);
1297  return false;
1298 #else
1299  QT_MANGLE_NAMESPACE(QCocoaView) *theView = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(view);
1300  NSView *theNSView = static_cast<NSView *>(view);
1301  NSEvent *theTabletEvent = static_cast<NSEvent *>(tabletEvent);
1302 
1303  NSEventType eventType = [theTabletEvent type];
1304  if (eventType != NSTabletPoint && [theTabletEvent subtype] != NSTabletPointEventSubtype)
1305  return false; // Not a tablet event.
1306 
1307  NSPoint windowPoint = [theTabletEvent locationInWindow];
1308  NSPoint globalPoint = [[theTabletEvent window] convertBaseToScreen:windowPoint];
1309 
1310  QWidget *qwidget = [theView qt_qwidget];
1311  QWidget *widgetToGetMouse = qwidget;
1312  QWidget *popup = qAppInstance()->activePopupWidget();
1313  if (popup && popup != qwidget->window())
1314  widgetToGetMouse = popup;
1315 
1316  if (qt_mac_sendMacEventToWidget(widgetToGetMouse,
1317  static_cast<EventRef>(const_cast<void *>([theTabletEvent eventRef]))))
1318  return true;
1319  if (widgetToGetMouse != qwidget) {
1320  theNSView = qt_mac_nativeview_for(widgetToGetMouse);
1321  windowPoint = [[theNSView window] convertScreenToBase:globalPoint];
1322  }
1323  NSPoint localPoint = [theNSView convertPoint:windowPoint fromView:nil];
1324  // Tablet events do not handle WA_TransparentForMouseEvents ATM
1325  // In theory, people who set the WA_TransparentForMouseEvents attribute won't handle
1326  // tablet events either in which case they will fall into the mouse event case and get
1327  // them passed on. This will NOT handle the raw events, but that might not be a big problem.
1328 
1329  const QMacTabletHash *tabletHash = qt_mac_tablet_hash();
1330  if (!tabletHash->contains([theTabletEvent deviceID])) {
1331  qWarning("QCocoaView handleTabletEvent: This tablet device is unknown"
1332  " (received no proximity event for it). Discarding event.");
1333  return false;
1334  }
1335  const QTabletDeviceData &deviceData = tabletHash->value([theTabletEvent deviceID]);
1336 
1337 
1338  QEvent::Type qType;
1339  switch (eventType) {
1340  case NSLeftMouseDown:
1341  case NSRightMouseDown:
1342  qType = QEvent::TabletPress;
1343  break;
1344  case NSLeftMouseUp:
1345  case NSRightMouseUp:
1346  qType = QEvent::TabletRelease;
1347  break;
1348  case NSMouseMoved:
1349  case NSTabletPoint:
1350  case NSLeftMouseDragged:
1351  case NSRightMouseDragged:
1352  default:
1353  qType = QEvent::TabletMove;
1354  break;
1355  }
1356 
1357  qreal pressure;
1358  if (eventType != NSMouseMoved) {
1359  pressure = [theTabletEvent pressure];
1360  } else {
1361  pressure = 0.0;
1362  }
1363 
1364  NSPoint tilt = [theTabletEvent tilt];
1365  int xTilt = qRound(tilt.x * 60.0);
1366  int yTilt = qRound(tilt.y * -60.0);
1367  qreal tangentialPressure = 0;
1368  qreal rotation = 0;
1369  int z = 0;
1370  if (deviceData.capabilityMask & 0x0200)
1371  z = [theTabletEvent absoluteZ];
1372 
1373  if (deviceData.capabilityMask & 0x0800)
1374  tangentialPressure = [theTabletEvent tangentialPressure];
1375 
1376  rotation = [theTabletEvent rotation];
1377  QPointF hiRes = flipPoint(globalPoint);
1378  QTabletEvent qtabletEvent(qType, QPoint(localPoint.x, localPoint.y),
1379  hiRes.toPoint(), hiRes,
1380  deviceData.tabletDeviceType, deviceData.tabletPointerType,
1381  pressure, xTilt, yTilt, tangentialPressure, rotation, z,
1382  qt_cocoaModifiers2QtModifiers([theTabletEvent modifierFlags]),
1383  deviceData.tabletUniqueID);
1384 
1385  qt_sendSpontaneousEvent(widgetToGetMouse, &qtabletEvent);
1386  return qtabletEvent.isAccepted();
1387 #endif
1388 }
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
QPointF flipPoint(const NSPoint &p)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QMacTabletHash * qt_mac_tablet_hash()
Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags)
NSWindow * window
Q_CORE_EXPORT void qWarning(const char *,...)
bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref)
Definition: qwidget_mac.mm:448
The QTabletEvent class contains parameters that describe a Tablet event.
Definition: qevent.h:179
QApplication * qAppInstance()
static QWidget * activePopupWidget()
Returns the active popup widget.
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
#define QT_MANGLE_NAMESPACE(name)
Definition: qglobal.h:106
struct CGPoint NSPoint
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
OSViewRef qt_mac_nativeview_for(const QWidget *)
Definition: qwidget_mac.mm:419
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ qt_mac_NSArrayToQStringList()

QStringList qt_mac_NSArrayToQStringList ( void *  nsarray)

Definition at line 1486 of file qt_cocoa_helpers_mac.mm.

Referenced by flipYCoordinate().

1487 {
1488  QStringList result;
1489  NSArray *array = static_cast<NSArray *>(nsarray);
1490  for (NSUInteger i=0; i<[array count]; ++i)
1491  result << qt_mac_NSStringToQString([array objectAtIndex:i]);
1492  return result;
1493 }
The QStringList class provides a list of strings.
Definition: qstringlist.h:66

◆ qt_mac_post_retranslateAppMenu()

void qt_mac_post_retranslateAppMenu ( )

Definition at line 1726 of file qt_cocoa_helpers_mac.mm.

Referenced by QApplication::event(), and QMacScrollOptimization::performDelayedScroll().

1727 {
1728 #ifdef QT_MAC_USE_COCOA
1730  qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
1731 #endif
1732 }
#define QT_MANGLE_NAMESPACE(name)
Definition: qglobal.h:106

◆ qt_mac_QStringListToNSMutableArrayVoid()

void* qt_mac_QStringListToNSMutableArrayVoid ( const QStringList list)

Definition at line 1495 of file qt_cocoa_helpers_mac.mm.

Referenced by flipYCoordinate().

1496 {
1497  NSMutableArray *result = [NSMutableArray arrayWithCapacity:list.size()];
1498  for (int i=0; i<list.size(); ++i){
1499  [result addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(list[i]))];
1500  }
1501  return result;
1502 }
static CFStringRef toCFStringRef(const QString &str)
Definition: qcore_mac.cpp:69
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ qt_mac_tablet_hash()

QMacTabletHash* qt_mac_tablet_hash ( )

Definition at line 442 of file qt_cocoa_helpers_mac.mm.

Referenced by QApplicationPrivate::globalEventProcessor(), qt_dispatchTabletProximityEvent(), and qt_mac_handleTabletEvent().

443 {
444  return tablet_hash();
445 }

◆ qt_mac_update_mouseTracking()

void qt_mac_update_mouseTracking ( QWidget widget)

Definition at line 340 of file qt_cocoa_helpers_mac.mm.

Referenced by QWidget::changeEvent(), and QWidget::setAttribute().

341 {
342 #ifdef QT_MAC_USE_COCOA
343  [qt_mac_nativeview_for(widget) updateTrackingAreas];
344 #else
345  Q_UNUSED(widget);
346 #endif
347 }
OSViewRef qt_mac_nativeview_for(const QWidget *)
Definition: qwidget_mac.mm:419
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ qt_mac_updateContentBorderMetricts()

void qt_mac_updateContentBorderMetricts ( void *  window,
const ::HIContentBorderMetrics &  metrics 
)

Definition at line 1390 of file qt_cocoa_helpers_mac.mm.

Referenced by QTabBarPrivate::updateMacBorderMetrics().

1391 {
1392  OSWindowRef theWindow = static_cast<OSWindowRef>(window);
1393 #if !defined(QT_MAC_USE_COCOA)
1394 # if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
1396  ::HIWindowSetContentBorderThickness(theWindow, &metrics);
1397  }
1398 # else
1399  Q_UNUSED(window);
1400  Q_UNUSED(metrics);
1401 # endif
1402 #else
1403  if ([theWindow styleMask] & NSTexturedBackgroundWindowMask)
1404  [theWindow setContentBorderThickness:metrics.top forEdge:NSMaxYEdge];
1405  [theWindow setContentBorderThickness:metrics.bottom forEdge:NSMinYEdge];
1406 #endif
1407 }
NSWindow * window
WindowRef OSWindowRef
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ qt_mac_updateCursorWithWidgetUnderMouse()

void qt_mac_updateCursorWithWidgetUnderMouse ( QWidget widgetUnderMouse)

Definition at line 144 of file qcursor_mac.mm.

Referenced by flipPoint(), QMacWindowFader::performFade(), qt_mac_update_cursor(), and qt_mac_update_cursor_at_global_pos().

145 {
146  QCursor cursor(Qt::ArrowCursor);
147  if (qt_button_down) {
148  // The widget that is currently pressed
149  // grabs the mouse cursor:
150  widgetUnderMouse = qt_button_down;
152  } else if (qt_button_down_on_prev_call) {
153  // Grab has been released, so do
154  // a full check:
158  }
159 
161  cursor = *QApplication::overrideCursor();
162  } else if (grabCursor) {
163  cursor = *grabCursor;
164  } else if (widgetUnderMouse) {
165  if (widgetUnderMouse == lastWidgetUnderMouse) {
166  // Optimization that should hit when the widget under
167  // the mouse does not change as the mouse moves:
169  cursor = lastMouseCursorWidget->cursor();
170  } else {
171  QWidget *w = widgetUnderMouse;
172  for (; w; w = w->parentWidget()) {
174  cursor = w->cursor();
175  break;
176  }
177  if (w->isWindow())
178  break;
179  }
180  // One final check in case we ran out of parents in the loop:
181  if (w && !w->testAttribute(Qt::WA_SetCursor))
182  w = 0;
183 
184  lastWidgetUnderMouse = widgetUnderMouse;
186  }
187  }
188 
189 #ifdef QT_MAC_USE_COCOA
190  cursor.d->update();
191  NSCursor *nsCursor = static_cast<NSCursor *>(cursor.d->curs.cp.nscursor);
192  if ([NSCursor currentCursor] != nsCursor) {
194  [nsCursor set];
195  }
196 #else
197  qt_mac_set_cursor(&cursor);
198 #endif
199 }
void qt_mac_set_cursor(const QCursor *c)
Definition: qcursor_mac.mm:108
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
static QPointer< QWidget > lastWidgetUnderMouse
Definition: qcursor_mac.mm:139
static QPointer< QWidget > lastMouseCursorWidget
Definition: qcursor_mac.mm:140
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
static QCursor * overrideCursor()
Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::Align...
static QCursorData * currentCursor
Definition: qcursor_mac.mm:106
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
static bool qt_button_down_on_prev_call
Definition: qcursor_mac.mm:141
static QCursor * grabCursor
Definition: qcursor_mac.mm:142
QPointer< QWidget > qt_button_down

◆ qt_sendSpontaneousEvent()

bool qt_sendSpontaneousEvent ( QObject receiver,
QEvent event 
)

Definition at line 5779 of file qapplication.cpp.

Referenced by flipPoint(), macSendToolbarChangeEvent(), QMacWindowFader::performFade(), qt_dispatchTabletProximityEvent(), qt_mac_handleTabletEvent(), and qtKey2CocoaKey().

5780 {
5781  return QCoreApplication::sendSpontaneousEvent(receiver, event);
5782 }
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)

◆ qtKey2CocoaKey()

QChar qtKey2CocoaKey ( Qt::Key  key)

Definition at line 654 of file qt_cocoa_helpers_mac.mm.

Referenced by keySequenceToKeyEqivalent().

655 {
656  // The first time this function is called, create a reverse
657  // looup table sorted on Qt Key rather than Cocoa key:
658  static QVector<KeyPair> rev_entries(NumEntries);
659  static bool mustInit = true;
660  if (mustInit){
661  mustInit = false;
662  for (int i=0; i<NumEntries; ++i)
663  rev_entries[i] = entries[i];
664  qSort(rev_entries.begin(), rev_entries.end(), qtKey2CocoaKeySortLessThan);
665  }
667  = qBinaryFind(rev_entries.begin(), rev_entries.end(), key);
668  if (i == rev_entries.end())
669  return QChar();
670  return i->cocoaKey;
671 }
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:295
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static const KeyPair entries[NumEntries]
static bool qtKey2CocoaKeySortLessThan(const KeyPair &entry1, const KeyPair &entry2)
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
static const int NumEntries
int key
The QTableWidgetItem class provides an item for use with the QTableWidget class.
Definition: qtablewidget.h:82

◆ qtKey2CocoaKeySortLessThan()

static bool qtKey2CocoaKeySortLessThan ( const KeyPair entry1,
const KeyPair entry2 
)
static

Definition at line 581 of file qt_cocoa_helpers_mac.mm.

Referenced by qtKey2CocoaKey().

582 {
583  return entry1.qtKey < entry2.qtKey;
584 }

Variable Documentation

◆ end

const KeyPair* const end = entries + NumEntries
static

Definition at line 652 of file qt_cocoa_helpers_mac.mm.

Referenced by QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(), QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), _q_dupEnvironment(), QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(), QHttpPrivate::_q_slotReadyRead(), QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeInserted(), QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved(), QSortFilterProxyModelPrivate::_q_sourceDataChanged(), QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeInserted(), QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeRemoved(), QDBusConnectionPrivate::activateObject(), QDialogButtonBoxPrivate::addButtonsToLayout(), QTessellatorPrivate::addEdges(), QPostEventList::addEvent(), QComboBox::addItems(), QFontEngineMulti::addOutlineToPath(), QWindowsFileSystemWatcherEngine::addPaths(), QNetworkConfigurationManagerPrivate::allConfigurations(), QUrl::allEncodedQueryItemValues(), QUrl::allQueryItemValues(), QDBusMarshaller::append(), QConcatenable< QByteArray >::appendTo(), QSvgAnimateColor::apply(), QPatternist::DelegatingNamespaceResolver::bindings(), QPatternist::UserFunctionCallsite::bindVariables(), blend_color_rgb16(), blend_transformed_argb(), blend_transformed_tiled_argb(), blendColor(), blendTransformed(), blendTransformedBilinear(), blendTransformedTiled(), bm_find(), QFontEngineMulti::boundingBox(), QTabBarPrivate::calculateNewPosition(), QTextEngine::calculateTabWidth(), QTessellatorPrivate::cancelCoincidingEdges(), cgColorForQColor(), QDialogButtonBox::changeEvent(), QMetaObject::changeGuard(), QPatternist::CallTargetDescription::checkArgumentsCircularity(), QPatternist::CallTargetDescription::checkCallsiteCircularity(), QPatternist::checkVariableCircularity(), QWizardPrivate::cleanupPagesNotInHistory(), QFontCache::cleanupPrinterFonts(), QNetworkAccessCache::clear(), QFontCache::clear(), QObjectPrivate::clearGuards(), QTreeViewPrivate::columnRanges(), comp_func_DestinationAtop(), comp_func_DestinationIn(), comp_func_DestinationOut(), comp_func_DestinationOver(), comp_func_solid_DestinationAtop(), comp_func_solid_DestinationIn(), comp_func_solid_DestinationOut(), comp_func_solid_DestinationOver(), comp_func_solid_Source(), comp_func_solid_SourceAtop(), comp_func_solid_SourceIn(), comp_func_solid_SourceOut(), comp_func_solid_SourceOver(), comp_func_solid_XOR(), comp_func_Source(), comp_func_SourceAtop(), comp_func_SourceIn(), comp_func_SourceOut(), comp_func_SourceOver(), comp_func_XOR(), QPatternist::TemplateInvoker::compress(), QPatternist::ExpressionSequence::compress(), QPatternist::UnlimitedContainer::compressOperands(), QBearerEngine::configurationsInUse(), QFutureInterfaceBasePrivate::connectOutputInterface(), QDBusConnectionPrivate::connectRelay(), QDBusConnectionPrivate::connectSignal(), QPatternist::ConstructorFunctionsFactory::ConstructorFunctionsFactory(), QRowsRemoval::contains(), QPatternist::VariableDeclaration::contains(), QItemSelection::contains(), containsProhibitedOuptut(), QHttpNetworkHeaderPrivate::contentLength(), convert_ARGB_PM_to_ARGB(), convert_ARGB_PM_to_RGB(), convert_ARGB_to_ARGB_PM(), convert_ARGB_to_ARGB_PM_inplace(), convert_Indexed8_to_X32(), convert_RGB_to_Indexed8(), QUtf8::convertFromUnicode(), convertPath(), QWindowsMimeHtml::convertToMime(), QUtf32::convertToUnicode(), QNetworkCookieJar::cookiesForUrl(), QTextCopyHelper::copy(), QPatternist::AccelTree::copyNodeTo(), QMultiHash< const QGLContext *, GLProgram >::count(), QMultiMap< QString, Method >::count(), QSortFilterProxyModelPrivate::create_index(), QPatternist::Template::createContext(), QPatternist::ExpressionFactory::createExpression(), QDBusMetaObject::createMetaObject(), QVNCIntegration::createPlatformWindow(), QHeaderViewPrivate::createSectionSpan(), QTextLine::cursorToX(), QDashStroker::dashOffset(), debugVariantList(), QNetworkConfigurationManagerPrivate::defaultConfiguration(), QPatternist::Template::dependencies(), destFetchMono(), destFetchMonoLsb(), QPatternist::AccelTreeResourceLoader::deviceURIs(), QDBusConnectionPrivate::disconnectRelay(), QDBusConnectionPrivate::disconnectSignal(), QPatternist::FunctionSignature::displayName(), distributeMultiBox(), QGridLayoutRowData::distributeMultiCells(), dither_to_Mono(), QTranslatorPrivate::do_load(), QTranslatorPrivate::do_translate(), QFontEngineMulti::doKerning(), QDeclarativeRow::doPositioning(), QDeclarativeGrid::doPositioning(), QDeclarativeFlow::doPositioning(), QTreeViewPrivate::drawAnimatedOperation(), QWindowsStyle::drawComplexControl(), QWindowsCEStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), QMacStyle::drawControl(), QItemDelegate::drawDisplay(), QCosmeticStroker::drawLine(), drawMenuText(), QCosmeticStroker::drawPath(), QCosmeticStroker::drawPoints(), QPdfBaseEnginePrivate::drawTextItem(), QTessellatorPrivate::edgeInChain(), QUrl::encodedQueryItems(), QUrl::encodedQueryItemValue(), QTriangulatingStroker::endCap(), QConfFileSettingsPrivate::ensureAllSectionsParsed(), QTableModel::ensureSorted(), QMap< int, QFrameInfo >::erase(), QPatternist::GeneralComparison::evaluateEBV(), QPatternist::RangeExpression::evaluateSequence(), QPatternist::ConcatFN::evaluateSingleton(), QPatternist::ExpressionSequence::evaluateToSequenceReceiver(), QBBInputContext::eventFilter(), QPatternist::FunctionCall::expectedOperandTypes(), QPatternist::TemplateInvoker::expectedOperandTypes(), QPatternist::UserFunctionCallsite::expectedOperandTypes(), familyList(), fetchTransformed(), fetchTransformedBilinear(), QIconModeViewBase::filterDropEvent(), QGraphicsScenePrivate::filterEvent(), QMultiHash< const QGLContext *, GLProgram >::find(), QMultiMap< QString, Method >::find(), findChildObject(), QFontCache::findEngine(), QFontCache::findEngineData(), QFontDatabase::findFont(), findKnownValue(), findObject(), QNetworkHeadersPrivate::findRawHeader(), fontFile(), fontPath(), QSqlDriver::formatValue(), QTextDocumentLayoutPrivate::frameIteratorForTextPosition(), QX11PixmapData::fromImage(), QProcessEnvironmentPrivate::fromList(), generateSubObjectXml(), QStaticTextPrivate::get(), QDeclarativeVisualDataModelPrivate::Cache::getItem(), getLocaleListData(), getMessage(), QMenuBarPrivate::getNextAction(), getXDefault(), QFontEngine::glyphCache(), QTextLine::glyphs(), QDBusConnectionPrivate::handleSignal(), QWindowSystemInterface::handleTouchEvent(), QUrl::hasEncodedQueryItem(), QPatternist::FunctionFactory::hasSignature(), QHttpNetworkHeaderPrivate::headerFieldValues(), huntAndDestroy(), huntAndEmit(), QTableModel::index(), QItemSelection::indexes(), QRingBuffer< T >::indexOf(), indexOfMethodRelative(), QTreeView::indexRowSizeHint(), initEmptyMultiBox(), QHeaderView::initializeSections(), QSettingsPrivate::iniUnescapedStringList(), QWaylandInputDevice::inputHandleKeyboardFocus(), QProcessEnvironmentPrivate::insert(), QVector< QPoint >::insert(), QLinuxFbScreen::insert_entry(), QCalendarModel::internalUpdate(), QImage::invertPixels(), QAccessibleTable2::invokeMethodEx(), QPatternist::Expression::invokeOptimizers(), QFontDatabase::isBitmapScalable(), QAbstractXmlNodeModel::isDeepEqual(), isKeyword(), QFontDatabase::isSmoothlyScalable(), QTableViewPrivate::isVisualColumnHiddenOrDisabled(), QDeclarativeVisualDataModelPrivate::Cache::item(), QStandardItemModelPrivate::itemFromIndex(), QAbstractItemModelPrivate::itemsAboutToBeMoved(), QTextEngine::justify(), QMap< int, QFrameInfo >::key(), QHash< QExplicitlySharedDataPointer, QHash >::key(), QProcessEnvironmentPrivate::keys(), QMap< int, QFrameInfo >::keys(), QHash< QExplicitlySharedDataPointer, QHash >::keys(), QLinkedList< JSC::Identifier >::last(), QVector< QPoint >::last(), QList< QPostEvent >::last(), QTextLine::layout_helper(), QTextEngine::length(), QTessellatorPrivate::Scanline::lineDone(), QSvgHandler::lineNumber(), QFontEngine::loadKerningPairs(), lookupElementHelper(), QFbWindow::lower(), macQuoteString(), QDBusMessagePrivate::makeLocal(), QTabBarPrivate::makeVisible(), QIdentityProxyModel::mapSelectionFromSource(), QIdentityProxyModel::mapSelectionToSource(), markFrames(), mask_alpha_converter(), QIdentityProxyModel::match(), QDirIteratorPrivate::matchesFilters(), QCalendarWidget::minimumSizeHint(), QAbstractItemModelPrivate::movePersistentIndexes(), QTabBar::moveTab(), QTriangulatingStroker::moveTo(), QPatternist::DistinctIterator::next(), QWizardPage::nextId(), QPatternist::UnlimitedContainer::operandsUnionType(), QTextTableCell::operator!=(), operator+=(), QStringList::operator<<(), operator<<(), QMap< int, QFrameInfo >::operator==(), QHash< QExplicitlySharedDataPointer, QHash >::operator==(), QLineF::operator>>(), QListView::paintEvent(), QHeaderView::paintEvent(), QColorLuminancePicker::paintEvent(), QDateTimeParser::parse(), parseAnimateColorNode(), parseAnimateTransformNode(), parseDateString(), QAuthenticatorPrivate::parseDigestAuthenticationChallenge(), QTextHtmlParser::parseExclamationTag(), QPatternist::PatternPlatform::parseFlags(), parseHttpOptionHeader(), QAuthenticatorPrivate::parseHttpResponse(), parsePathDataFast(), QNetworkCookiePrivate::parseSetCookieHeaderLine(), parseTransformationMatrix(), QRingBuffer< T >::peek(), QFontDatabase::pointSizes(), QDBusAdaptorConnector::polish(), QVector< QPoint >::pop_back(), QTextEngine::positionInLigature(), postProcess(), QTessellatorPrivate::Scanline::prepareLine(), QTriangulatingStroker::process(), QPaintBuffer::processCommands(), QPatternist::ExpressionSequence::properties(), QPatternist::Template::properties(), QAccessibleTable2Interface::qAccessibleTable2CastHelper(), qAverage(), qBinaryFind(), QAlgorithmsPrivate::qBinaryFindHelper(), qCopyBackward(), qDBusFindAdaptorConnector(), qDBusIntrospectObject(), qDBusParametersForMethod(), qDBusPropertyGet(), qDBusPropertyGetAll(), qDBusPropertySet(), qFindByteArray(), QGLOffscreen::QGLOffscreen(), QTestLiteStaticInfoPrivate::qimageFromXImage(), QItemSelectionModelPrivate::QItemSelectionModelPrivate(), QKdPointTree::QKdPointTree(), qRemoveDuplicates(), QAlgorithmsPrivate::qReverse(), qScriptValueFromSequence(), QAlgorithmsPrivate::qSortHelper(), QSvgPaintEngine::QSvgPaintEngine(), qt_alphamapblit_quint32(), qt_alphargbblit_quint32(), qt_Big5ToUnicode(), qt_blend_color_argb_x86(), qt_create_commandline(), qt_fetch_conical_gradient(), qt_fetch_linear_gradient(), qt_intersect_spans(), qt_mac_post_retranslateAppMenu(), qt_mac_send_posted_gl_updates(), qt_mac_update_child_gl_widgets(), qt_mac_update_intersected_gl_widgets(), qt_qimageScaleAARGB(), qt_qimageScaleAARGBA(), qt_read_dibv5(), qt_regionToPath(), qt_span_clip(), qt_span_fill_clipped(), qt_UnicodeToBig5(), qt_write_dib(), qt_write_dibv5(), QUrl::queryItems(), QXIMInputContext::QXIMInputContext(), QFbWindow::raise(), rasterop_solid_SourceAndDestination(), rasterop_solid_SourceAndNotDestination(), rasterop_solid_SourceOrDestination(), rasterop_solid_SourceXorDestination(), QNetworkHeadersPrivate::rawHeadersKeys(), ICOReader::read16_24_32BMP(), read_dib_body(), read_pbm_body(), read_xpm_body(), QInotifyFileSystemWatcherEngine::readFromInotify(), QPngHandlerPrivate::readPngImage(), QFontEngineMulti::recalcAdvances(), registerFont(), QDeclarativeVisualDataModelPrivate::Cache::releaseItem(), QMultiHash< const QGLContext *, GLProgram >::remove(), QMultiMap< QString, Method >::remove(), QUrl::removeAllEncodedQueryItems(), QHttpNetworkReplyPrivate::removeAutoDecompressHeader(), removeDotsFromPath(), QUrl::removeEncodedQueryItem(), QMetaObject::removeGuard(), QLinkedList< JSC::Identifier >::removeLast(), QList< QPostEvent >::removeLast(), QLinkedList< JSC::Identifier >::removeOne(), QWindowsFileSystemWatcherEngine::removePaths(), QGraphicsScenePrivate::removeSceneEventFilter(), QFbWindow::repaint(), QNetworkAccessHttpBackend::replyDownloadMetaData(), QColorPicker::resizeEvent(), resolveEntity(), QFutureInterface< T >::results(), QImage::rgbSwapped(), QPatternist::XQueryTokenizer::scanUntil(), QNetworkAccessCacheBackend::sendCacheContents(), QNetworkAccessHttpBackend::sendCacheContents(), QPaintEngine::setActive(), QNetmaskAddress::setAddress(), QNetworkHeadersPrivate::setAllRawHeaders(), setBlockCharFormatHelper(), QStrokerOps::setCubicToHook(), QSyntaxHighlighter::setFormat(), QFbWindow::setGeometry(), QDeclarativePathViewPrivate::setHighlightPosition(), QImage::setPixel(), QDeclarativePathView::setPreferredHighlightEnd(), QDeclarativeGridView::setPreferredHighlightEnd(), QDeclarativeListView::setPreferredHighlightEnd(), QFbWindow::setVisible(), QFbWindow::setWindowFlags(), QAbstractItemModel::sibling(), QTreeView::sizeHintForColumn(), QFontDatabase::smoothSizes(), QSortFilterProxyModelPrivate::source_items_inserted(), splitPolygon(), splitSpaceSemicolon(), QTreeViewPrivate::startAndEndColumns(), QPatternist::LiteralSequence::staticType(), QGridLayoutRowData::stealBox(), QThreadPoolPrivate::stealRunnable(), QSystemLocalePrivate::substituteDigits(), swap_bit_order(), QX11PixmapData::takeQImageFromXImage(), QPatternist::TemplateInvoker::TemplateInvoker(), QFontCache::timerEvent(), QX11PixmapData::toImage(), QProcessEnvironmentPrivate::toList(), QLinkedList< JSC::Identifier >::toStdList(), QMap< int, QFrameInfo >::toStdMap(), QKeySequence::toString(), QGridLayoutRowData::totalBox(), QGraphicsScenePrivate::touchEventHandler(), QApplicationPrivate::translateRawTouchEvent(), trimRef(), QPatternist::CallTemplate::typeCheck(), QPatternist::ExpressionSequence::typeCheck(), QPatternist::Expression::typeCheckOperands(), QMap< int, QFrameInfo >::uniqueKeys(), QHash< QExplicitlySharedDataPointer, QHash >::uniqueKeys(), QEventDispatcherMac::unregisterTimers(), QGLContextPrivate::updateFormatVersion(), QSpanCollection::updateInsertedColumns(), QSpanCollection::updateInsertedRows(), QCalendarWidgetPrivate::updateMonthMenu(), QSpanCollection::updateRemovedColumns(), QSpanCollection::updateRemovedRows(), QDoubleSpinBoxPrivate::validateAndInterpret(), QMap< int, QFrameInfo >::values(), QHash< QExplicitlySharedDataPointer, QHash >::values(), QTreeModel::view(), winLangCodeToIsoName(), ICOReader::write(), write_pbm_image(), QXmlTestLogger::xmlCdata(), QXmlTestLogger::xmlQuote(), QTextLine::xToCursor(), QPatternist::yyparse(), QBearerEngine::~QBearerEngine(), QComboBoxPrivate::~QComboBoxPrivate(), QEventDispatcherMac::~QEventDispatcherMac(), QFbWindow::~QFbWindow(), QFontCache::~QFontCache(), QMenuPrivate::QMacMenuPrivate::~QMacMenuPrivate(), QPainterReplayer::~QPainterReplayer(), QPdfBaseEngine::~QPdfBaseEngine(), QSpanCollection::~QSpanCollection(), and QUndoGroup::~QUndoGroup().

◆ entries

const KeyPair entries[NumEntries]
static

Definition at line 587 of file qt_cocoa_helpers_mac.mm.

◆ mac_mouse_grabber

QWidget* mac_mouse_grabber

Definition at line 156 of file qwidget_mac.mm.

Referenced by flipPoint(), QWidget::mouseGrabber(), and QMacWindowFader::performFade().

◆ NumEntries

const int NumEntries = 59
static

Definition at line 586 of file qt_cocoa_helpers_mac.mm.

Referenced by qtKey2CocoaKey().

◆ qt_button_down

QWidget* qt_button_down

Definition at line 188 of file qapplication_mac.mm.

Referenced by flipPoint(), and QMacWindowFader::performFade().

◆ qt_last_mouse_receiver

QPointer<QWidget> qt_last_mouse_receiver

Definition at line 189 of file qapplication_mac.mm.

Referenced by QMacWindowFader::performFade().

◆ qt_mac_mouse_symbols

qt_mac_enum_mapper qt_mac_mouse_symbols[]
static
Initial value:
= {
{ kEventMouseButtonPrimary, QT_MAC_MAP_ENUM(Qt::LeftButton) },
{ kEventMouseButtonSecondary, QT_MAC_MAP_ENUM(Qt::RightButton) },
{ kEventMouseButtonTertiary, QT_MAC_MAP_ENUM(Qt::MidButton) },
{ 0, QT_MAC_MAP_ENUM(0) }
}
#define QT_MAC_MAP_ENUM(x)

Definition at line 394 of file qt_cocoa_helpers_mac.mm.