Qt 4.8
qapplication_mac.mm
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 /****************************************************************************
43 **
44 ** Copyright (c) 2007-2008, Apple, Inc.
45 **
46 ** All rights reserved.
47 **
48 ** Redistribution and use in source and binary forms, with or without
49 ** modification, are permitted provided that the following conditions are met:
50 **
51 ** * Redistributions of source code must retain the above copyright notice,
52 ** this list of conditions and the following disclaimer.
53 **
54 ** * Redistributions in binary form must reproduce the above copyright notice,
55 ** this list of conditions and the following disclaimer in the documentation
56 ** and/or other materials provided with the distribution.
57 **
58 ** * Neither the name of Apple, Inc. nor the names of its contributors
59 ** may be used to endorse or promote products derived from this software
60 ** without specific prior written permission.
61 **
62 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
63 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
64 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
65 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
66 ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
67 ** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
68 ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
69 ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
70 ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
71 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
72 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73 **
74 ****************************************************************************/
75 
76 #include <Cocoa/Cocoa.h>
77 
78 #include "qapplication.h"
79 #include "qbitarray.h"
80 #include "qclipboard.h"
81 #include "qcursor.h"
82 #include "qdatastream.h"
83 #include "qdatetime.h"
84 #include "qdesktopwidget.h"
85 #include "qdockwidget.h"
86 #include "qevent.h"
87 #include "qhash.h"
88 #include "qlayout.h"
89 #include "qmenubar.h"
90 #include "qmessagebox.h"
91 #include "qmime.h"
92 #include "qpixmapcache.h"
93 #include "qpointer.h"
94 #include "qsessionmanager.h"
95 #include "qsettings.h"
96 #include "qsocketnotifier.h"
97 #include "qstyle.h"
98 #include "qstylefactory.h"
99 #include "qtextcodec.h"
100 #include "qtoolbar.h"
101 #include "qvariant.h"
102 #include "qwidget.h"
103 #include "qcolormap.h"
104 #include "qdir.h"
105 #include "qdebug.h"
106 #include "qtimer.h"
107 #include "qurl.h"
108 #include "private/qmacinputcontext_p.h"
109 #include "private/qpaintengine_mac_p.h"
110 #include "private/qcursor_p.h"
111 #include "private/qapplication_p.h"
112 #include "private/qcolor_p.h"
113 #include "private/qwidget_p.h"
114 #include "private/qkeymapper_p.h"
115 #include "private/qeventdispatcher_mac_p.h"
116 #include "private/qeventdispatcher_unix_p.h"
117 #include <private/qcocoamenuloader_mac_p.h>
118 #include <private/qcocoaapplication_mac_p.h>
119 #include <private/qcocoaapplicationdelegate_mac_p.h>
120 #include <private/qt_cocoa_helpers_mac_p.h>
121 #include <private/qcocoawindow_mac_p.h>
122 #include <private/qpixmap_mac_p.h>
123 #include <private/qdesktopwidget_mac_p.h>
124 #include <private/qeventdispatcher_mac_p.h>
125 #include <qvarlengtharray.h>
126 
127 #ifndef QT_NO_ACCESSIBILITY
128 # include "qaccessible.h"
129 #endif
130 
131 #ifndef QT_NO_THREAD
132 # include "qmutex.h"
133 #endif
134 
135 #include <unistd.h>
136 #include <string.h>
137 #include <sys/time.h>
138 #include <sys/select.h>
139 
140 /*****************************************************************************
141  QApplication debug facilities
142  *****************************************************************************/
143 //#define DEBUG_EVENTS //like EventDebug but more specific to Qt
144 //#define DEBUG_DROPPED_EVENTS
145 //#define DEBUG_MOUSE_MAPS
146 //#define DEBUG_MODAL_EVENTS
147 //#define DEBUG_PLATFORM_SETTINGS
148 
149 #define QMAC_SPEAK_TO_ME
150 #ifdef QMAC_SPEAK_TO_ME
151 #include "qregexp.h"
152 #endif
153 
154 #ifndef kThemeBrushAlternatePrimaryHighlightColor
155 #define kThemeBrushAlternatePrimaryHighlightColor -5
156 #endif
157 
158 #define kCMDeviceUnregisteredNotification CFSTR("CMDeviceUnregisteredNotification")
159 #define kCMDefaultDeviceNotification CFSTR("CMDefaultDeviceNotification")
160 #define kCMDeviceProfilesNotification CFSTR("CMDeviceProfilesNotification")
161 #define kCMDefaultDeviceProfileNotification CFSTR("CMDefaultDeviceProfileNotification")
162 
164 
165 //for qt_mac.h
169 
170 /*****************************************************************************
171  Internal variables and functions
172  *****************************************************************************/
173 static struct {
178  EventTime last_time;
179 } qt_mac_dblclick = { false, 0, -1, -1, 0, 0, -2 };
180 
181 static bool app_do_modal = false; // modal mode
182 extern QWidgetList *qt_modal_stack; // stack of modal widgets
183 extern bool qt_tab_all_widgets; // from qapplication.cpp
186 static bool qt_mac_collapse_on_dblclick = true;
187 extern int qt_antialiasing_threshold; // from qapplication.cpp
188 QWidget * qt_button_down; // widget got last button-down
190 #ifndef QT_MAC_USE_COCOA
191 static bool qt_button_down_in_content; // whether the button_down was in the content area.
193 static bool qt_mac_no_click_through_mode = false;
194 static int tablet_button_state = 0;
195 #endif
196 #if defined(QT_DEBUG)
197 static bool appNoGrab = false; // mouse/keyboard grabbing
198 #endif
199 #ifndef QT_MAC_USE_COCOA
200 static EventHandlerRef app_proc_handler = 0;
201 static EventHandlerUPP app_proc_handlerUPP = 0;
202 #endif
203 static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL;
204 static EventHandlerRef tablet_proximity_handler = 0;
205 static EventHandlerUPP tablet_proximity_UPP = 0;
207 
209 
210 /*****************************************************************************
211  External functions
212  *****************************************************************************/
213 extern void qt_mac_beep(); //qsound_mac.mm
214 extern Qt::KeyboardModifiers qt_mac_get_modifiers(int keys); //qkeymapper_mac.cpp
215 extern bool qt_mac_can_clickThrough(const QWidget *); //qwidget_mac.cpp
216 extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
217 extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.cpp
218 extern QWidget *qt_mac_find_window(OSWindowRef); //qwidget_mac.cpp
219 extern void qt_mac_set_cursor(const QCursor *); //qcursor_mac.cpp
220 extern bool qt_mac_is_macsheet(const QWidget *); //qwidget_mac.cpp
221 extern void qt_mac_command_set_enabled(MenuRef, UInt32, bool); //qmenu_mac.cpp
222 extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); // qapplication.cpp
223 extern void qt_mac_update_cursor(); // qcursor_mac.mm
224 
225 // Forward Decls
226 void onApplicationWindowChangedActivation( QWidget*widget, bool activated );
227 void onApplicationChangedActivation( bool activated );
228 
229 #ifdef QT_MAC_USE_COCOA
230 void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader)
231 {
232  // Create qt_menu.nib dir in temp.
233  QDir temp = QDir::temp();
234  temp.mkdir("qt_menu.nib");
235  QString nibDir = temp.canonicalPath() + QLatin1String("/") + QLatin1String("qt_menu.nib/");
236  if (!QDir(nibDir).exists()) {
237  qWarning("qt_mac_loadMenuNib: could not create nib directory in temp");
238  return;
239  }
240 
241  // Copy nib files from resources to temp.
242  QDir nibResource(":/trolltech/mac/qt_menu.nib/");
243  if (!nibResource.exists()) {
244  qWarning("qt_mac_loadMenuNib: could not load nib from resources");
245  return;
246  }
247  foreach (const QFileInfo &file, nibResource.entryInfoList())
248  QFile::copy(file.absoluteFilePath(), nibDir + QLatin1String("/") + file.fileName());
249 
250  // Load and instantiate nib file from temp
251  NSURL *nibUrl = [NSURL fileURLWithPath : const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(nibDir)))];
252  NSNib *nib = [[NSNib alloc] initWithContentsOfURL : nibUrl];
253  [nib autorelease];
254  if (!nib) {
255  qWarning("qt_mac_loadMenuNib: could not load nib from temp");
256  return;
257  }
258  bool ok = [nib instantiateNibWithOwner : qtMenuLoader topLevelObjects : nil];
259  if (!ok)
260  qWarning("qt_mac_loadMenuNib: could not instantiate nib");
261 }
262 #endif
263 
265 {
267  int w = 10, h = 10;
268  QImage image(w, h, QImage::Format_RGB32);
269  image.fill(0xffffffff);
270  QPainter p(&image);
271  p.drawText(0, h, "X\\");
272  p.end();
273 
274  const int *bits = (const int *) ((const QImage &) image).bits();
275  int bpl = image.bytesPerLine() / 4;
276  for (int y=0; y<w; ++y) {
277  for (int x=0; x<h; ++x) {
278  int r = qRed(bits[x]);
279  int g = qGreen(bits[x]);
280  int b = qBlue(bits[x]);
281  if (r != g || r != b) {
283  return;
284  }
285  }
286  bits += bpl;
287  }
289 }
290 
291 Q_GUI_EXPORT bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) {
292  OSStatus err;
293  AEDesc scriptTextDesc;
294  ComponentInstance theComponent = 0;
295  OSAID scriptID = kOSANullScript, resultID = kOSANullScript;
296 
297  // set up locals to a known state
298  AECreateDesc(typeNull, 0, 0, &scriptTextDesc);
299  scriptID = kOSANullScript;
300  resultID = kOSANullScript;
301 
302  // open the scripting component
303  theComponent = OpenDefaultComponent(kOSAComponentType, typeAppleScript);
304  if (!theComponent) {
305  err = paramErr;
306  goto bail;
307  }
308 
309  // put the script text into an aedesc
310  err = AECreateDesc(typeUTF8Text, script, script_len, &scriptTextDesc);
311  if (err != noErr)
312  goto bail;
313 
314  // compile the script
315  err = OSACompile(theComponent, &scriptTextDesc, kOSAModeNull, &scriptID);
316  if (err != noErr)
317  goto bail;
318 
319  // run the script
320  err = OSAExecute(theComponent, scriptID, kOSANullScript, kOSAModeNull, &resultID);
321 
322  // collect the results - if any
323  if (ret) {
324  AECreateDesc(typeNull, 0, 0, ret);
325  if (err == errOSAScriptError)
326  OSAScriptError(theComponent, kOSAErrorMessage, typeChar, ret);
327  else if (err == noErr && resultID != kOSANullScript)
328  OSADisplay(theComponent, resultID, typeChar, kOSAModeNull, ret);
329  }
330 bail:
331  AEDisposeDesc(&scriptTextDesc);
332  if (scriptID != kOSANullScript)
333  OSADispose(theComponent, scriptID);
334  if (resultID != kOSANullScript)
335  OSADispose(theComponent, resultID);
336  if (theComponent)
337  CloseComponent(theComponent);
338  return err == noErr;
339 }
340 
341 Q_GUI_EXPORT bool qt_mac_execute_apple_script(const char *script, AEDesc *ret)
342 {
343  return qt_mac_execute_apple_script(script, qstrlen(script), ret);
344 }
345 
347 {
348  const QByteArray l = script.toUtf8(); return qt_mac_execute_apple_script(l.constData(), l.size(), ret);
349 }
350 
351 /* Resolution change magic */
352 void qt_mac_display_change_callbk(CGDirectDisplayID, CGDisplayChangeSummaryFlags flags, void *)
353 {
354 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
355  const bool resized = flags & kCGDisplayDesktopShapeChangedFlag;
356 #else
357  Q_UNUSED(flags);
358  const bool resized = true;
359 #endif
360  if (resized && qApp) {
361  if (QDesktopWidget *dw = qApp->desktop()) {
362  QResizeEvent *re = new QResizeEvent(dw->size(), dw->size());
363  QApplication::postEvent(dw, re);
365  }
366  }
367 }
368 
369 #ifdef DEBUG_PLATFORM_SETTINGS
370 static void qt_mac_debug_palette(const QPalette &pal, const QPalette &pal2, const QString &where)
371 {
372  const char *const groups[] = {"Active", "Disabled", "Inactive" };
373  const char *const roles[] = { "WindowText", "Button", "Light", "Midlight", "Dark", "Mid",
374  "Text", "BrightText", "ButtonText", "Base", "Window", "Shadow",
375  "Highlight", "HighlightedText", "Link", "LinkVisited" };
376  if (!where.isNull())
377  qDebug("qt-internal: %s", where.toLatin1().constData());
378  for(int grp = 0; grp < QPalette::NColorGroups; grp++) {
379  for(int role = 0; role < QPalette::NColorRoles; role++) {
381  QPixmap pm = b.texture();
382  qDebug(" %s::%s %d::%d::%d [%p]%s", groups[grp], roles[role], b.color().red(),
383  b.color().green(), b.color().blue(), pm.isNull() ? 0 : &pm,
384  pal2.brush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role) != b ? " (*)" : "");
385  }
386  }
387 
388 }
389 #else
390 #define qt_mac_debug_palette(x, y, z)
391 #endif
392 
393 //raise a notification
394 #ifndef QT_MAC_USE_COCOA
395 static NMRec qt_mac_notification = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
396 #endif
398 {
399 #ifndef QT_MAC_USE_COCOA
400  //send it
401  qt_mac_notification.nmMark = 1; //non-zero magic number
402  qt_mac_notification.qType = nmType;
403  NMInstall(&qt_mac_notification);
404 #else
406  [[NSApplication sharedApplication] requestUserAttention:NSInformationalRequest];
407 #endif
408 }
409 
411 {
412 #ifndef QT_MAC_USE_COCOA
413  NMRemove(&qt_mac_notification);
414 #else
416  [[NSApplication sharedApplication] cancelUserAttentionRequest:NSInformationalRequest];
417 #endif
418 }
419 
420 #ifndef QT_MAC_USE_COCOA
421 //find widget (and part) at a given point
422 static short qt_mac_window_at(int x, int y, QWidget **w=0)
423 {
424  Point p;
425  p.h = x;
426  p.v = y;
427  OSWindowRef wp;
428  WindowPartCode wpc;
429  OSStatus err = FindWindowOfClass(&p, kAllWindowClasses, &wp, &wpc);
430  if(err != noErr) {
431  if(w)
432  (*w) = 0;
433  return wpc;
434  }
435  if(w) {
436  if(wp) {
437  *w = qt_mac_find_window(wp);
438 #if 0
439  if(!*w)
440  qWarning("QApplication: qt_mac_window_at: Couldn't find %d",(int)wp);
441 #endif
442  } else {
443  *w = 0;
444  }
445  }
446  return wpc;
447 }
448 
449 #endif
450 
451 void qt_mac_set_app_icon(const QPixmap &pixmap)
452 {
453 #ifndef QT_MAC_USE_COCOA
454  if(pixmap.isNull()) {
455  RestoreApplicationDockTileImage();
456  } else {
457  CGImageRef img = (CGImageRef)pixmap.macCGHandle();
458  SetApplicationDockTileImage(img);
459  CGImageRelease(img);
460  }
461 #else
463  NSImage *image = NULL;
464  if (pixmap.isNull()) {
465  // Get Application icon from bundle
466  image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; // released below
467  } else {
468  image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
469  }
470 
471  [NSApp setApplicationIconImage:image];
472  [image release];
473 #endif
474 }
475 
477 {
478  Q_UNUSED(b);
479  qWarning("qt_mac_set_press_and_hold_context: This functionality is no longer available");
480 }
481 
482 bool qt_nograb() // application no-grab option
483 {
484 #if defined(QT_DEBUG)
485  return appNoGrab;
486 #else
487  return false;
488 #endif
489 }
490 
492 {
493  if (!qApp)
494  return;
495  if (!QApplication::startingUp()) {
496  static bool needToPolish = true;
497  if (needToPolish) {
499  needToPolish = false;
500  }
501  }
502  //focus mode
503  /* First worked as of 10.2.3 */
504  QSettings appleSettings(QLatin1String("apple.com"));
505  QVariant appleValue = appleSettings.value(QLatin1String("AppleKeyboardUIMode"), 0);
506  qt_tab_all_widgets = (appleValue.toInt() & 0x2);
507  //paging mode
508  /* First worked as of 10.2.3 */
509  appleValue = appleSettings.value(QLatin1String("AppleScrollerPagingBehavior"), false);
510  qt_scrollbar_jump_to_pos = appleValue.toBool();
511  //collapse
512  /* First worked as of 10.3.3 */
513  appleValue = appleSettings.value(QLatin1String("AppleMiniaturizeOnDoubleClick"), true);
514  qt_mac_collapse_on_dblclick = appleValue.toBool();
515 
516  // Anti-aliasing threshold
517  appleValue = appleSettings.value(QLatin1String("AppleAntiAliasingThreshold"));
518  if (appleValue.isValid())
519  qt_antialiasing_threshold = appleValue.toInt();
520 
521 #ifdef DEBUG_PLATFORM_SETTINGS
522  qDebug("qt_mac_update_os_settings *********************************************************************");
523 #endif
524  { // setup the global palette
525  QColor qc;
526  (void) QApplication::style(); // trigger creation of application style and system palettes
528 
529  pal.setBrush( QPalette::Active, QPalette::Highlight, qcolorForTheme(kThemeBrushPrimaryHighlightColor) );
530  pal.setBrush( QPalette::Inactive, QPalette::Highlight, qcolorForTheme(kThemeBrushSecondaryHighlightColor) );
531 
532  pal.setBrush( QPalette::Disabled, QPalette::Highlight, qcolorForTheme(kThemeBrushSecondaryHighlightColor) );
533  pal.setBrush( QPalette::Active, QPalette::Shadow, qcolorForTheme(kThemeBrushButtonActiveDarkShadow) );
534 
535  pal.setBrush( QPalette::Inactive, QPalette::Shadow, qcolorForTheme(kThemeBrushButtonInactiveDarkShadow) );
536  pal.setBrush( QPalette::Disabled, QPalette::Shadow, qcolorForTheme(kThemeBrushButtonInactiveDarkShadow) );
537 
538  qc = qcolorForThemeTextColor(kThemeTextColorDialogActive);
542 
543  qc = qcolorForThemeTextColor(kThemeTextColorDialogInactive);
550  pal.setBrush(QPalette::ToolTipBase, QColor(255, 255, 199));
551 
555  }
556 #ifdef DEBUG_PLATFORM_SETTINGS
557  qt_mac_debug_palette(pal, QApplication::palette(), "Global Palette");
558 #endif
559  }
560 
561  QFont fnt = qfontForThemeFont(kThemeApplicationFont);
562 #ifdef DEBUG_PLATFORM_SETTINGS
563  qDebug("qt-internal: Font for Application [%s::%d::%d::%d]",
564  fnt.family().toLatin1().constData(), fnt.pointSize(), fnt.bold(), fnt.italic());
565 #endif
568 
569  { //setup the fonts
570  struct FontMap {
571  FontMap(const char *qc, short fk) : qt_class(qc), font_key(fk) { }
572  const char *const qt_class;
573  short font_key;
574  } mac_widget_fonts[] = {
575  FontMap("QPushButton", kThemePushButtonFont),
576  FontMap("QListView", kThemeViewsFont),
577  FontMap("QListBox", kThemeViewsFont),
578  FontMap("QTitleBar", kThemeWindowTitleFont),
579  FontMap("QMenuBar", kThemeMenuTitleFont),
580  FontMap("QMenu", kThemeMenuItemFont),
581  FontMap("QComboMenuItem", kThemeSystemFont),
582  FontMap("QHeaderView", kThemeSmallSystemFont),
583  FontMap("Q3Header", kThemeSmallSystemFont),
584  FontMap("QTipLabel", kThemeSmallSystemFont),
585  FontMap("QLabel", kThemeSystemFont),
586  FontMap("QToolButton", kThemeSmallSystemFont),
587  FontMap("QMenuItem", kThemeMenuItemFont), // It doesn't exist, but its unique.
588  FontMap("QComboLineEdit", kThemeViewsFont), // It doesn't exist, but its unique.
589  FontMap("QSmallFont", kThemeSmallSystemFont), // It doesn't exist, but its unique.
590  FontMap("QMiniFont", kThemeMiniSystemFont), // It doesn't exist, but its unique.
591  FontMap(0, 0) };
592  for(int i = 0; mac_widget_fonts[i].qt_class; i++) {
593  QFont fnt = qfontForThemeFont(mac_widget_fonts[i].font_key);
594  bool set_font = true;
596  if (!hash->isEmpty()) {
598  = hash->constFind(mac_widget_fonts[i].qt_class);
599  if (it != hash->constEnd())
600  set_font = (fnt != *it);
601  }
602  if (set_font) {
603  QApplication::setFont(fnt, mac_widget_fonts[i].qt_class);
604 #ifdef DEBUG_PLATFORM_SETTINGS
605  qDebug("qt-internal: Font for %s [%s::%d::%d::%d]", mac_widget_fonts[i].qt_class,
606  fnt.family().toLatin1().constData(), fnt.pointSize(), fnt.bold(), fnt.italic());
607 #endif
608  }
609  }
610  }
612 #ifdef DEBUG_PLATFORM_SETTINGS
613  qDebug("qt_mac_update_os_settings END !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
614 #endif
615 }
616 
618 {
619  { //setup the palette
620  struct PaletteMap {
621  inline PaletteMap(const char *qc, ThemeBrush a, ThemeBrush i) :
622  qt_class(qc), active(a), inactive(i) { }
623  const char *const qt_class;
624  ThemeBrush active, inactive;
625  } mac_widget_colors[] = {
626  PaletteMap("QToolButton", kThemeTextColorBevelButtonActive, kThemeTextColorBevelButtonInactive),
627  PaletteMap("QAbstractButton", kThemeTextColorPushButtonActive, kThemeTextColorPushButtonInactive),
628  PaletteMap("QHeaderView", kThemeTextColorPushButtonActive, kThemeTextColorPushButtonInactive),
629  PaletteMap("Q3Header", kThemeTextColorPushButtonActive, kThemeTextColorPushButtonInactive),
630  PaletteMap("QComboBox", kThemeTextColorPopupButtonActive, kThemeTextColorPopupButtonInactive),
631  PaletteMap("QAbstractItemView", kThemeTextColorListView, kThemeTextColorDialogInactive),
632  PaletteMap("QMessageBoxLabel", kThemeTextColorAlertActive, kThemeTextColorAlertInactive),
633  PaletteMap("QTabBar", kThemeTextColorTabFrontActive, kThemeTextColorTabFrontInactive),
634  PaletteMap("QLabel", kThemeTextColorPlacardActive, kThemeTextColorPlacardInactive),
635  PaletteMap("QGroupBox", kThemeTextColorPlacardActive, kThemeTextColorPlacardInactive),
636  PaletteMap("QMenu", kThemeTextColorPopupLabelActive, kThemeTextColorPopupLabelInactive),
637  PaletteMap("QTextEdit", 0, 0),
638  PaletteMap("QTextControl", 0, 0),
639  PaletteMap("QLineEdit", 0, 0),
640  PaletteMap(0, 0, 0) };
641  QColor qc;
642  for(int i = 0; mac_widget_colors[i].qt_class; i++) {
643  QPalette pal;
644  if (mac_widget_colors[i].active != 0) {
645  qc = qcolorForThemeTextColor(mac_widget_colors[i].active);
649  qc = qcolorForThemeTextColor(mac_widget_colors[i].inactive);
656  }
657  if (!strcmp(mac_widget_colors[i].qt_class, "QMenu")) {
658  qc = qcolorForThemeTextColor(kThemeTextColorMenuItemActive);
660  qc = qcolorForThemeTextColor(kThemeTextColorMenuItemSelected);
662  qc = qcolorForThemeTextColor(kThemeTextColorMenuItemDisabled);
664  } else if (!strcmp(mac_widget_colors[i].qt_class, "QAbstractButton")
665  || !strcmp(mac_widget_colors[i].qt_class, "QHeaderView")
666  || !strcmp(mac_widget_colors[i].qt_class, "Q3Header")) { //special
673  } else if (!strcmp(mac_widget_colors[i].qt_class, "QAbstractItemView")) {
676  qc = qcolorForThemeTextColor(kThemeTextColorMenuItemSelected);
678 #if 1
683 #endif
684  } else if (!strcmp(mac_widget_colors[i].qt_class, "QTextEdit")
685  || !strcmp(mac_widget_colors[i].qt_class, "QTextControl")) {
690  } else if (!strcmp(mac_widget_colors[i].qt_class, "QLineEdit")) {
693  }
694 
695  bool set_palette = true;
697  if (!phash->isEmpty()) {
699  = phash->constFind(mac_widget_colors[i].qt_class);
700  if (it != phash->constEnd())
701  set_palette = (pal != *it);
702  }
703  if (set_palette) {
704  QApplication::setPalette(pal, mac_widget_colors[i].qt_class);
705 #ifdef DEBUG_PLATFORM_SETTINGS
706  qt_mac_debug_palette(pal, QApplication::palette(), QLatin1String("Palette for ") + QString::fromLatin1(mac_widget_colors[i].qt_class));
707 #endif
708  }
709  }
710  }
711 }
712 
714 {
715  ReleaseEvent(event);
716  event = 0;
717 }
718 #ifndef QT_MAC_USE_COCOA
720 {
721  if (event) {
722  QWidget *widget = 0;
723  if (GetEventParameter(event, kEventParamQWidget, typeQWidget, 0, sizeof(widget), 0, &widget) == noErr
724  && w == widget) {
725  if (IsEventInQueue(GetMainEventQueue(), event))
726  RemoveEventFromQueue(GetMainEventQueue(), event);
727  qt_mac_event_release(event);
728  }
729  }
730 }
731 
733 {
734  if (event) {
735  if (IsEventInQueue(GetMainEventQueue(), event))
736  RemoveEventFromQueue(GetMainEventQueue(), event);
737  qt_mac_event_release(event);
738  return true;
739  }
740  return false;
741 }
742 #endif
743 
744 /* sheets */
745 #ifndef QT_MAC_USE_COCOA
747 #endif
749 {
751 #ifdef QT_MAC_USE_COCOA
752  w->repaint();
753  [NSApp beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w->parentWidget())
754  modalDelegate:nil didEndSelector:nil contextInfo:0];
755 #else
756  qt_mac_event_remove(request_showsheet_pending);
757  CreateEvent(0, kEventClassQt, kEventQtRequestShowSheet, GetCurrentEventTime(),
758  kEventAttributeUserEvent, &request_showsheet_pending);
759  SetEventParameter(request_showsheet_pending, kEventParamQWidget, typeQWidget, sizeof(w), &w);
760  PostEventToQueue(GetMainEventQueue(), request_showsheet_pending, kEventPriorityStandard);
761 #endif
762 }
763 
765 {
766  qt_widget_private(widget)->needWindowChange = true;
767  QEvent *glWindowChangeEvent = new QEvent(QEvent::MacGLWindowChange);
768  QApplication::postEvent(widget, glWindowChangeEvent);
769 }
770 
771 /*
772  Posts updates to all child and grandchild OpenGL widgets for the given widget.
773 */
775 {
776  // Update all OpenGL child widgets for the given widget.
777  QList<QWidgetPrivate::GlWidgetInfo> &glWidgets = qt_widget_private(widget)->glWidgets;
780 
781  for (;it != end; ++it) {
782  qt_post_window_change_event(it->widget);
783  }
784 }
785 
786 /*
787  Sends updates to all child and grandchild gl widgets that have updates pending.
788 */
790 {
791  QList<QWidgetPrivate::GlWidgetInfo> &glWidgets = qt_widget_private(widget)->glWidgets;
794 
795  for (;it != end; ++it) {
796  QWidget *glWidget = it->widget;
797  if (qt_widget_private(glWidget)->needWindowChange) {
798  QEvent glChangeEvent(QEvent::MacGLWindowChange);
799  QApplication::sendEvent(glWidget, &glChangeEvent);
800  }
801  }
802 }
803 
804 /*
805  Posts updates to all OpenGL widgets within the window that the given widget intersects.
806 */
808 {
809 #ifndef QT_MAC_USE_COCOA
810  QList<QWidgetPrivate::GlWidgetInfo> &glWidgets = qt_widget_private(widget->window())->glWidgets;
811  if (glWidgets.isEmpty())
812  return;
813 
814  // Exit if the window has not been created yet (mapToGlobal/size will force create it)
815  if (widget->testAttribute(Qt::WA_WState_Created) == false || HIViewGetWindow(qt_mac_nativeview_for(widget)) == 0)
816  return;
817 
818  const QRect globalWidgetRect = QRect(widget->mapToGlobal(QPoint(0, 0)), widget->size());
819 
822 
823  for (;it != end; ++it){
824  QWidget *glWidget = it->widget;
825  const QRect globalGlWidgetRect = QRect(glWidget->mapToGlobal(QPoint(0, 0)), glWidget->size());
826  if (globalWidgetRect.intersects(globalGlWidgetRect)) {
827  qt_post_window_change_event(glWidget);
828  it->lastUpdateWidget = widget;
829  } else if (it->lastUpdateWidget == widget) {
830  // Update the gl wigets that the widget intersected the last time around,
831  // and that we are not intersecting now. This prevents paint errors when the
832  // intersecting widget leaves a gl widget.
833  qt_post_window_change_event(glWidget);
834  it->lastUpdateWidget = 0;
835  }
836  }
837 #else
838  Q_UNUSED(widget);
839 #endif
840 }
841 
842 /*
843  Posts a kEventQtRequestWindowChange event to the main Carbon event queue.
844 */
847 {
848  if(request_window_change_pending)
849  return;
850 
851  CreateEvent(0, kEventClassQt, kEventQtRequestWindowChange, GetCurrentEventTime(),
852  kEventAttributeUserEvent, &request_window_change_pending);
853  PostEventToQueue(GetMainEventQueue(), request_window_change_pending, kEventPriorityHigh);
854 }
855 
856 /* window changing. This is a hack around Apple's missing functionality, pending the toolbox
857  team fix. --Sam */
859 {
860  if (!widget)
861  return;
862 
863  // Post a kEventQtRequestWindowChange event. This event is semi-public,
864  // don't remove this line!
866 
867  // Post update request on gl widgets unconditionally.
868  if (qt_widget_private(widget)->isGLWidget == true) {
870  return;
871  }
872 
875 }
876 
877 /* activation */
878 static struct {
881  EventLoopTimerRef timer;
882  EventLoopTimerUPP timerUPP;
883 } request_activate_pending = { 0, 0, 0, 0 };
885 {
886  if (request_activate_pending.timer) {
887  RemoveEventLoopTimer(request_activate_pending.timer);
888  request_activate_pending.timer = 0;
889  }
890  if (request_activate_pending.event)
892  return true;
893 }
894 
895 void qt_event_activate_timer_callbk(EventLoopTimerRef r, void *)
896 {
897  EventLoopTimerRef otc = request_activate_pending.timer;
899  if (r == otc && !request_activate_pending.widget.isNull()) {
900  const QWidget *tlw = request_activate_pending.widget->window();
901  Qt::WindowType wt = tlw->windowType();
902  if (tlw->isVisible()
903  && ((wt != Qt::Desktop && wt != Qt::Popup && wt != Qt::Tool) || tlw->isModal())) {
904  CreateEvent(0, kEventClassQt, kEventQtRequestActivate, GetCurrentEventTime(),
905  kEventAttributeUserEvent, &request_activate_pending.event);
906  PostEventToQueue(GetMainEventQueue(), request_activate_pending.event, kEventPriorityHigh);
907  }
908  }
909 }
910 
912 {
913  if (w == request_activate_pending.widget)
914  return;
915 
916  /* We put these into a timer because due to order of events being sent we need to be sure this
917  comes from inside of the event loop */
919  if (!request_activate_pending.timerUPP)
920  request_activate_pending.timerUPP = NewEventLoopTimerUPP(qt_event_activate_timer_callbk);
921  request_activate_pending.widget = w;
922  InstallEventLoopTimer(GetMainEventLoop(), 0, 0, request_activate_pending.timerUPP, 0, &request_activate_pending.timer);
923 }
924 
925 
926 /* menubars */
927 #ifndef QT_MAC_USE_COCOA
929 #endif
931 {
932 #ifndef QT_MAC_USE_COCOA
933  if (request_menubarupdate_pending) {
934  if (IsEventInQueue(GetMainEventQueue(), request_menubarupdate_pending))
935  return;
936 #ifdef DEBUG_DROPPED_EVENTS
937  qDebug("%s:%d Whoa, we dropped an event on the floor!", __FILE__, __LINE__);
938 #endif
939  }
940 
941  CreateEvent(0, kEventClassQt, kEventQtRequestMenubarUpdate, GetCurrentEventTime(),
942  kEventAttributeUserEvent, &request_menubarupdate_pending);
943  PostEventToQueue(GetMainEventQueue(), request_menubarupdate_pending, kEventPriorityHigh);
944 #else
945  // Just call this. The request has the benefit that we don't call this multiple times, but
946  // we can optimize this.
948 #endif
949 }
950 
951 #ifndef QT_MAC_USE_COCOA
952 //context menu
954 static void qt_event_request_context(QWidget *w=0, EventRef *where=0)
955 {
956  if (!where)
957  where = &request_context_pending;
958  if (*where)
959  return;
960  CreateEvent(0, kEventClassQt, kEventQtRequestContext, GetCurrentEventTime(),
961  kEventAttributeUserEvent, where);
962  if (w)
963  SetEventParameter(*where, kEventParamQWidget, typeQWidget, sizeof(w), &w);
964  PostEventToQueue(GetMainEventQueue(), *where, kEventPriorityStandard);
965 }
966 #endif
967 
969 {
970  Q_Q(QApplication);
971  if (q->type() != QApplication::Tty)
972  eventDispatcher = new QEventDispatcherMac(q);
973  else
974  eventDispatcher = new QEventDispatcherUNIX(q);
975 }
976 
977 /* clipboard */
979 {
980 #ifndef QT_MAC_USE_COCOA
981  AppleEvent ae;
982  if (AECreateAppleEvent(kEventClassQt, typeAEClipboardChanged, 0, kAutoGenerateReturnID, kAnyTransactionID, &ae) != noErr)
983  qDebug("Can't happen!!");
984  AppleEvent reply;
985  AESend(&ae, &reply, kAENoReply, kAENormalPriority, kAEDefaultTimeout, 0, 0);
986 #endif
987 }
988 
989 /* app menu */
992 {
993  qt_mac_dock_menu = menu;
994 #ifdef QT_MAC_USE_COCOA
995  [NSApp setDockMenu:menu->macMenu()];
996 #else
997  SetApplicationDockTileMenu(menu->macMenu());
998 #endif
999 }
1000 
1001 /* events that hold pointers to widgets, must be cleaned up like this */
1003 {
1004  if (w) {
1005 #ifndef QT_MAC_USE_COCOA
1006  qt_mac_event_release(w, request_showsheet_pending);
1007  qt_mac_event_release(w, request_context_pending);
1008 #endif
1009  if (w == qt_mac_dock_menu) {
1010  qt_mac_dock_menu = 0;
1011 #ifndef QT_MAC_USE_COCOA
1012  SetApplicationDockTileMenu(0);
1013 #else
1014  [NSApp setDockMenu:0];
1015 #endif
1016  }
1017  }
1018 }
1019 
1021  AEEventClass mac_class;
1022  AEEventID mac_id;
1023 } app_apple_events[] = {
1024  { kCoreEventClass, kAEQuitApplication },
1025  { kCoreEventClass, kAEOpenDocuments },
1026  { kInternetEventClass, kAEGetURL },
1027 };
1028 
1029 #ifndef QT_MAC_USE_COCOA
1030 
1031 #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
1032 enum
1033 {
1037 };
1038 #endif
1039 
1040 /* watched events */
1041 static EventTypeSpec app_events[] = {
1047 
1048  { kEventClassWindow, kEventWindowActivated },
1049  { kEventClassWindow, kEventWindowDeactivated },
1050 
1051  { kEventClassMouse, kEventMouseScroll },
1052  { kEventClassMouse, kEventMouseWheelMoved },
1053  { kEventClassMouse, kEventMouseDown },
1054  { kEventClassMouse, kEventMouseUp },
1055  { kEventClassMouse, kEventMouseDragged },
1056  { kEventClassMouse, kEventMouseMoved },
1057 
1058  { kEventClassTablet, kEventTabletProximity },
1059 
1060  { kEventClassApplication, kEventAppActivated },
1061  { kEventClassApplication, kEventAppDeactivated },
1062  { kEventClassApplication, kEventAppAvailableWindowBoundsChanged },
1063 
1064  // { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
1065  { kEventClassKeyboard, kEventRawKeyModifiersChanged },
1066  { kEventClassKeyboard, kEventRawKeyRepeat },
1067  { kEventClassKeyboard, kEventRawKeyUp },
1068  { kEventClassKeyboard, kEventRawKeyDown },
1069 
1070  { kEventClassCommand, kEventCommandProcess },
1071 
1072  { kEventClassAppleEvent, kEventAppleEvent },
1073 
1074  { kAppearanceEventClass, kAEAppearanceChanged }
1075 };
1076 
1078 {
1079  InstallEventHandler(GetApplicationEventTarget(), app_proc_handlerUPP,
1080  GetEventTypeCount(app_events), app_events, (void *)qApp,
1081  &app_proc_handler);
1082 }
1083 #endif // QT_MAC_USE_COCOA
1084 
1086 {
1087  EventTypeSpec tabletProximityEvent = { kEventClassTablet, kEventTabletProximity };
1088  InstallEventHandler(GetEventMonitorTarget(), tablet_proximity_UPP,
1089  1, &tabletProximityEvent, qApp, &tablet_proximity_handler);
1090 }
1091 
1093 {
1094  RemoveEventHandler(tablet_proximity_handler);
1095 }
1096 
1098 {
1099  static QString applName;
1100  if (applName.isEmpty()) {
1102  ProcessSerialNumber psn;
1103  if (applName.isEmpty() && qt_is_gui_used && GetCurrentProcess(&psn) == noErr) {
1104  QCFString cfstr;
1105  CopyProcessName(&psn, &cfstr);
1106  applName = cfstr;
1107  }
1108  }
1109  return applName;
1110 }
1111 
1113 {
1114 #ifndef QT_MAC_USE_COCOA
1115  if (app_proc_handler) {
1116  RemoveEventHandler(app_proc_handler);
1117  app_proc_handler = 0;
1118  }
1119 #endif
1120 }
1121 
1122 void qt_color_profile_changed(CFNotificationCenterRef, void *, CFStringRef, const void *,
1123  CFDictionaryRef)
1124 {
1126 }
1127 /* platform specific implementations */
1129 {
1130  if (qt_is_gui_used) {
1131  CGDisplayRegisterReconfigurationCallback(qt_mac_display_change_callbk, 0);
1132  CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
1133  CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
1135  CFNotificationSuspensionBehaviorDeliverImmediately);
1136  CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
1138  CFNotificationSuspensionBehaviorDeliverImmediately);
1139  CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
1141  CFNotificationSuspensionBehaviorDeliverImmediately);
1142  CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
1144  CFNotificationSuspensionBehaviorDeliverImmediately);
1145  ProcessSerialNumber psn;
1146  if (GetCurrentProcess(&psn) == noErr) {
1147  // Jambi needs to transform itself since most people aren't "used"
1148  // to putting things in bundles, but other people may actually not
1149  // want to tranform the process (running as a helper or something)
1150  // so don't do that for them. This means checking both LSUIElement
1151  // and LSBackgroundOnly. If you set them both... well, you
1152  // shouldn't do that.
1153 
1154  bool forceTransform = true;
1155  CFTypeRef value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(),
1156  CFSTR("LSUIElement"));
1157  if (value) {
1158  CFTypeID valueType = CFGetTypeID(value);
1159  // Officially it's supposed to be a string, a boolean makes sense, so we'll check.
1160  // A number less so, but OK.
1161  if (valueType == CFStringGetTypeID())
1162  forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt());
1163  else if (valueType == CFBooleanGetTypeID())
1164  forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value));
1165  else if (valueType == CFNumberGetTypeID()) {
1166  int valueAsInt;
1167  CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt);
1168  forceTransform = !valueAsInt;
1169  }
1170  }
1171 
1172  if (forceTransform) {
1173  value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(),
1174  CFSTR("LSBackgroundOnly"));
1175  if (value) {
1176  CFTypeID valueType = CFGetTypeID(value);
1177  if (valueType == CFBooleanGetTypeID())
1178  forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value));
1179  else if (valueType == CFStringGetTypeID())
1180  forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt());
1181  else if (valueType == CFNumberGetTypeID()) {
1182  int valueAsInt;
1183  CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt);
1184  forceTransform = !valueAsInt;
1185  }
1186  }
1187  }
1188 
1189 
1190  if (forceTransform) {
1191  TransformProcessType(&psn, kProcessTransformToForegroundApplication);
1192  }
1193  }
1194  }
1195 
1196  char **argv = priv->argv;
1197 
1198  // Get command line params
1199  if (int argc = priv->argc) {
1200  int i, j = 1;
1201  QString passed_psn;
1202  for(i=1; i < argc; i++) {
1203  if (argv[i] && *argv[i] != '-') {
1204  argv[j++] = argv[i];
1205  continue;
1206  }
1207  QByteArray arg(argv[i]);
1208 #if defined(QT_DEBUG)
1209  if (arg == "-nograb")
1210  appNoGrab = !appNoGrab;
1211  else
1212 #endif // QT_DEBUG
1213  if (arg.left(5) == "-psn_") {
1214  passed_psn = QString::fromLatin1(arg.mid(6));
1215  } else {
1216  argv[j++] = argv[i];
1217  }
1218  }
1219  if (j < priv->argc) {
1220  priv->argv[j] = 0;
1221  priv->argc = j;
1222  }
1223 
1224  //special hack to change working directory (for an app bundle) when running from finder
1225  if (!passed_psn.isNull() && QDir::currentPath() == QLatin1String("/")) {
1226  QCFType<CFURLRef> bundleURL(CFBundleCopyBundleURL(CFBundleGetMainBundle()));
1227  QString qbundlePath = QCFString(CFURLCopyFileSystemPath(bundleURL,
1228  kCFURLPOSIXPathStyle));
1229  if (qbundlePath.endsWith(QLatin1String(".app")))
1230  QDir::setCurrent(qbundlePath.section(QLatin1Char('/'), 0, -2));
1231  }
1232  }
1233 
1235 
1236  qApp->setObjectName(priv->appName());
1237  if (qt_is_gui_used) {
1242 #ifndef QT_NO_ACCESSIBILITY
1244 #endif
1245 #ifndef QT_NO_IM
1248 #endif
1251 #ifndef QT_MAC_USE_COCOA
1252  if (!app_proc_handler) {
1255  }
1256 
1257 #endif
1260  for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) {
1261  // Install apple event handler, but avoid overwriting an already
1262  // existing handler (it means a 3rd party application has installed one):
1263  SRefCon refCon = 0;
1264  AEEventHandlerUPP current_handler = NULL;
1265  AEGetEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, &current_handler, &refCon, false);
1266  if (!current_handler)
1267  AEInstallEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id,
1268  app_proc_ae_handlerUPP, SRefCon(qApp), false);
1269  }
1270  }
1271 
1273  QEvent ev(QEvent::Style);
1275  }
1276  }
1279 
1280  // Cocoa application delegate
1281 #ifdef QT_MAC_USE_COCOA
1282  NSApplication *cocoaApp = [QT_MANGLE_NAMESPACE(QNSApplication) sharedApplication];
1283  qt_redirectNSApplicationSendEvent();
1284 
1286  id oldDelegate = [cocoaApp delegate];
1287  QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate];
1288  Q_ASSERT(newDelegate);
1289  [newDelegate setQtPrivate:priv];
1290  // Only do things that make sense to do once, otherwise we crash.
1291  if (oldDelegate != newDelegate && !QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
1292  [newDelegate setReflectionDelegate:oldDelegate];
1293  [cocoaApp setDelegate:newDelegate];
1294 
1295  QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader = [[QT_MANGLE_NAMESPACE(QCocoaMenuLoader) alloc] init];
1296  qt_mac_loadMenuNib(qtMenuLoader);
1297 
1298  [cocoaApp setMenu:[qtMenuLoader menu]];
1299  [newDelegate setMenuLoader:qtMenuLoader];
1300  }
1301 #endif
1302  // Register for Carbon tablet proximity events on the event monitor target.
1303  // This means that we should receive proximity events even when we aren't the active application.
1304  if (!tablet_proximity_handler) {
1307  }
1308  priv->native_modal_dialog_active = false;
1309 
1311 }
1312 
1314 {
1316  for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i)
1317  AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id,
1318  app_proc_ae_handlerUPP, true);
1319  DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP);
1321  }
1322 }
1323 
1324 /*****************************************************************************
1325  qt_cleanup() - cleans up when the application is finished
1326  *****************************************************************************/
1327 
1329 {
1330  CGDisplayRemoveReconfigurationCallback(qt_mac_display_change_callbk, 0);
1331  CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
1332  CFNotificationCenterRemoveObserver(center, qApp, kCMDeviceUnregisteredNotification, 0);
1333  CFNotificationCenterRemoveObserver(center, qApp, kCMDefaultDeviceNotification, 0);
1334  CFNotificationCenterRemoveObserver(center, qApp, kCMDeviceProfilesNotification, 0);
1335  CFNotificationCenterRemoveObserver(center, qApp, kCMDefaultDeviceProfileNotification, 0);
1336 
1337 #ifndef QT_MAC_USE_COCOA
1339  if (app_proc_handlerUPP) {
1340  DisposeEventHandlerUPP(app_proc_handlerUPP);
1341  app_proc_handlerUPP = 0;
1342  }
1343 #endif
1345 
1346 #ifdef QT_MAC_USE_COCOA
1347  qt_resetNSApplicationSendEvent();
1348 #endif
1349 
1352  DisposeEventHandlerUPP(tablet_proximity_UPP);
1353 
1355  if (qt_is_gui_used) {
1356 #ifndef QT_NO_ACCESSIBILITY
1358 #endif
1359 #ifndef QT_NO_IM
1361 #endif
1363  QFont::cleanup();
1365  if (qt_mac_safe_pdev) {
1366  delete qt_mac_safe_pdev;
1367  qt_mac_safe_pdev = 0;
1368  }
1369  extern void qt_mac_unregister_widget(); // qapplication_mac.cpp
1371  }
1372 }
1373 
1374 /*****************************************************************************
1375  Platform specific global and internal functions
1376  *****************************************************************************/
1378 {
1379 }
1380 
1382 {
1383  return false;
1384 }
1385 
1386 /*****************************************************************************
1387  Platform specific QApplication members
1388  *****************************************************************************/
1389 extern QWidget * mac_mouse_grabber;
1390 extern QWidget * mac_keyboard_grabber;
1391 
1392 #ifdef QT3_SUPPORT
1393 void QApplication::setMainWidget(QWidget *mainWidget)
1394 {
1395  QApplicationPrivate::main_widget = mainWidget;
1396  if (QApplicationPrivate::main_widget && windowIcon().isNull()
1398  setWindowIcon(QApplicationPrivate::main_widget->windowIcon());
1399 }
1400 #endif
1401 #ifndef QT_NO_CURSOR
1402 
1403 /*****************************************************************************
1404  QApplication cursor stack
1405  *****************************************************************************/
1406 
1408 {
1409  qApp->d_func()->cursor_list.prepend(cursor);
1410 
1411 #ifdef QT_MAC_USE_COCOA
1413 #else
1414  if (qApp && qApp->activeWindow())
1415  qt_mac_set_cursor(&qApp->d_func()->cursor_list.first());
1416 #endif
1417 }
1418 
1420 {
1421  if (qApp->d_func()->cursor_list.isEmpty())
1422  return;
1423  qApp->d_func()->cursor_list.removeFirst();
1424 
1425 #ifdef QT_MAC_USE_COCOA
1427 #else
1428  if (qApp && qApp->activeWindow()) {
1429  const QCursor def(Qt::ArrowCursor);
1430  qt_mac_set_cursor(qApp->d_func()->cursor_list.isEmpty() ? &def : &qApp->d_func()->cursor_list.first());
1431  }
1432 #endif
1433 }
1434 #endif // QT_NO_CURSOR
1435 
1437 {
1438  return qt_mac_get_modifiers(GetCurrentEventKeyModifiers());
1439 }
1440 
1442 {
1443 #ifndef QT_MAC_USE_COCOA
1444  QWidget *widget;
1445  qt_mac_window_at(p.x(), p.y(), &widget);
1446  return widget;
1447 #else
1448  // Use a cache to avoid iterate through the whole list of windows for all
1449  // calls to to topLevelAt. We e.g. do this for each and every mouse
1450  // move since we need to find the widget under mouse:
1451  if (topLevelAt_cache && topLevelAt_cache->frameGeometry().contains(p))
1452  return topLevelAt_cache;
1453 
1454  // INVARIANT: Cache miss. Go through the list if windows instead:
1456  NSPoint cocoaPoint = flipPoint(p);
1457  NSInteger windowCount;
1458  NSCountWindows(&windowCount);
1459  if (windowCount <= 0)
1460  return 0; // There's no window to find!
1461 
1462  QVarLengthArray<NSInteger> windowList(windowCount);
1463  NSWindowList(windowCount, windowList.data());
1464  int firstQtWindowFound = -1;
1465  for (int i = 0; i < windowCount; ++i) {
1466  NSWindow *window = [NSApp windowWithWindowNumber:windowList[i]];
1467  if (window) {
1468  QWidget *candidateWindow = [window QT_MANGLE_NAMESPACE(qt_qwidget)];
1469  if (candidateWindow && firstQtWindowFound == -1)
1470  firstQtWindowFound = i;
1471 
1472  if (NSPointInRect(cocoaPoint, [window frame])) {
1473  // Check to see if there's a hole in the window where the mask is.
1474  // If there is, we should just continue to see if there is a window below.
1475  if (candidateWindow && !candidateWindow->mask().isEmpty()) {
1476  QPoint localPoint = candidateWindow->mapFromGlobal(p);
1477  if (!candidateWindow->mask().contains(localPoint))
1478  continue;
1479  else
1480  return candidateWindow;
1481  } else {
1482  if (i == firstQtWindowFound) {
1483  // The cache will only work when the window under mouse is
1484  // top most (that is, not partially obscured by other windows.
1485  // And we only set it if no mask is present to optimize for the common case:
1486  topLevelAt_cache = candidateWindow;
1487  }
1488  return candidateWindow;
1489  }
1490  }
1491  }
1492  }
1493 
1494  topLevelAt_cache = 0;
1495  return 0;
1496 #endif
1497 }
1498 
1499 /*****************************************************************************
1500  Main event loop
1501  *****************************************************************************/
1502 
1504 {
1505  return app_do_modal;
1506 }
1507 
1508 #ifdef QT_MAC_USE_COCOA
1509 #endif
1510 
1512 {
1513 #ifdef DEBUG_MODAL_EVENTS
1514  Q_ASSERT(widget);
1515  qDebug("Entering modal state with %s::%s::%p (%d)", widget->metaObject()->className(), widget->objectName().toLocal8Bit().constData(),
1516  widget, qt_modal_stack ? (int)qt_modal_stack->count() : -1);
1517 #endif
1518  if (!qt_modal_stack)
1519  qt_modal_stack = new QWidgetList;
1520 
1521  dispatchEnterLeave(0, qt_last_mouse_receiver);
1522  qt_last_mouse_receiver = 0;
1523 
1524  qt_modal_stack->insert(0, widget);
1525  if (!app_do_modal)
1527  app_do_modal = true;
1528  qt_button_down = 0;
1529 
1530 #ifdef QT_MAC_USE_COCOA
1531  if (!qt_mac_is_macsheet(widget))
1532  QEventDispatcherMacPrivate::beginModalSession(widget);
1533 #endif
1534 }
1535 
1537 {
1538  if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
1539 #ifdef DEBUG_MODAL_EVENTS
1540  qDebug("Leaving modal state with %s::%s::%p (%d)", widget->metaObject()->className(), widget->objectName().toLocal8Bit().constData(),
1541  widget, qt_modal_stack->count());
1542 #endif
1543  if (qt_modal_stack->isEmpty()) {
1544  delete qt_modal_stack;
1545  qt_modal_stack = 0;
1546  QPoint p(QCursor::pos());
1547  app_do_modal = false;
1548  QWidget* w = 0;
1549  if (QWidget *grabber = QWidget::mouseGrabber())
1550  w = grabber;
1551  else
1552  w = QApplication::widgetAt(p.x(), p.y());
1553  dispatchEnterLeave(w, qt_last_mouse_receiver); // send synthetic enter event
1554  qt_last_mouse_receiver = w;
1555  }
1556 #ifdef QT_MAC_USE_COCOA
1557  if (!qt_mac_is_macsheet(widget))
1558  QEventDispatcherMacPrivate::endModalSession(widget);
1559 #endif
1560  }
1561 #ifdef DEBUG_MODAL_EVENTS
1562  else qDebug("Failure to remove %s::%s::%p -- %p", widget->metaObject()->className(), widget->objectName().toLocal8Bit().constData(), widget, qt_modal_stack);
1563 #endif
1564  app_do_modal = (qt_modal_stack != 0);
1565  if (!app_do_modal)
1567 }
1568 
1570 {
1571 #ifndef QT_MAC_USE_COCOA
1572  if(top && qt_mac_is_macsheet(top) && !IsWindowVisible(qt_mac_window_for(top))) {
1573  if(OSWindowRef wp = GetFrontWindowOfClass(kSheetWindowClass, true)) {
1574  if(QWidget *sheet = qt_mac_find_window(wp))
1575  top = sheet;
1576  }
1577  }
1578 #endif
1579  return top;
1580 }
1581 
1582 #ifndef QT_MAC_USE_COCOA
1584 {
1585  QWidget * top = 0;
1586 
1587  if (QApplicationPrivate::tryModalHelper(widget, &top))
1588  return true;
1589 
1590  // INVARIANT: widget is modally shaddowed within its
1591  // window, and should therefore not handle the event.
1592  // However, if the window is not active, the event
1593  // might suggest that we should bring it to front:
1594 
1595  bool block_event = false;
1596 
1597  if (event) {
1598  switch (GetEventClass(event)) {
1599  case kEventClassMouse:
1600  case kEventClassKeyboard:
1601  block_event = true;
1602  break;
1603  }
1604  }
1605 
1607  if ((!activeWidget || QApplicationPrivate::isBlockedByModal(activeWidget)) &&
1609  top->raise();
1610 
1611 #ifdef DEBUG_MODAL_EVENTS
1612  qDebug("%s:%d -- final decision! (%s)", __FILE__, __LINE__, block_event ? "false" : "true");
1613 #endif
1614  return !block_event;
1615 }
1616 #endif
1617 
1619  void *)
1620 {
1621  OSType eventClass = GetEventClass(carbonEvent);
1622  UInt32 eventKind = GetEventKind(carbonEvent);
1623  if (eventClass != kEventClassTablet || eventKind != kEventTabletProximity)
1624  return eventNotHandledErr;
1625 
1626  // Get the current point of the device and its unique ID.
1627  ::TabletProximityRec proxRec;
1628  GetEventParameter(carbonEvent, kEventParamTabletProximityRec, typeTabletProximityRec, 0,
1629  sizeof(proxRec), 0, &proxRec);
1631  return noErr;
1632 }
1633 
1634 OSStatus
1636 {
1637 #ifndef QT_MAC_USE_COCOA
1638  QApplication *app = (QApplication *)data;
1639  QScopedLoopLevelCounter loopLevelCounter(app->d_func()->threadData);
1640  long result;
1641  if (app->filterEvent(&event, &result))
1642  return result;
1643  if(app->macEventFilter(er, event)) //someone else ate it
1644  return noErr;
1646 
1647  /*We assume all events are handled and in
1648  the code below we set it to false when we know we didn't handle it, this
1649  will let rogue events through (shouldn't really happen, but better safe
1650  than sorry) */
1651  bool handled_event=true;
1652  UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
1653  switch(eclass)
1654  {
1655  case kEventClassQt:
1656  if(ekind == kEventQtRequestShowSheet) {
1657  request_showsheet_pending = 0;
1658  QWidget *widget = 0;
1659  GetEventParameter(event, kEventParamQWidget, typeQWidget, 0,
1660  sizeof(widget), 0, &widget);
1661  if(widget) {
1662  if (widget->macEvent(er, event))
1663  return noErr;
1664  WindowPtr window = qt_mac_window_for(widget);
1665  bool just_show = !qt_mac_is_macsheet(widget);
1666  if(!just_show) {
1667  OSStatus err = ShowSheetWindow(window, qt_mac_window_for(widget->parentWidget()));
1668  if(err != noErr)
1669  qWarning("Qt: QWidget: Unable to show as sheet %s::%s [%ld]", widget->metaObject()->className(),
1670  widget->objectName().toLocal8Bit().constData(), long(err));
1671  just_show = true;
1672  }
1673  if(just_show) //at least the window will be visible, but the sheet flag doesn't work sadly (probalby too many sheets)
1674  ShowHide(window, true);
1675  }
1676  } else if(ekind == kEventQtRequestWindowChange) {
1677  qt_mac_event_release(request_window_change_pending);
1678  } else if(ekind == kEventQtRequestMenubarUpdate) {
1679  qt_mac_event_release(request_menubarupdate_pending);
1681  } else if(ekind == kEventQtRequestActivate) {
1683  if(request_activate_pending.widget) {
1684  QWidget *tlw = request_activate_pending.widget->window();
1685  if (tlw->macEvent(er, event))
1686  return noErr;
1687  request_activate_pending.widget = 0;
1688  tlw->activateWindow();
1689  SelectWindow(qt_mac_window_for(tlw));
1690  }
1691  } else if(ekind == kEventQtRequestContext) {
1692  bool send = false;
1693  if ((send = (event == request_context_pending)))
1694  qt_mac_event_release(request_context_pending);
1695  if(send) {
1696  //figure out which widget to send it to
1697  QPoint where = QCursor::pos();
1698  QWidget *widget = 0;
1699  GetEventParameter(event, kEventParamQWidget, typeQWidget, 0,
1700  sizeof(widget), 0, &widget);
1701  if(!widget) {
1702  if(qt_button_down)
1703  widget = qt_button_down;
1704  else
1705  widget = QApplication::widgetAt(where.x(), where.y());
1706  }
1707  if(widget && !isBlockedByModal(widget)) {
1708  if (widget->macEvent(er, event))
1709  return noErr;
1710  QPoint plocal(widget->mapFromGlobal(where));
1711  const Qt::KeyboardModifiers keyboardModifiers = qt_mac_get_modifiers(GetCurrentEventKeyModifiers());
1712  QContextMenuEvent qme(QContextMenuEvent::Mouse, plocal, where, keyboardModifiers);
1713  QApplication::sendEvent(widget, &qme);
1714  if(qme.isAccepted()) { //once this happens the events before are pitched
1715  qt_button_down = 0;
1716  qt_mac_dblclick.last_widget = 0;
1717  }
1718  } else {
1719  handled_event = false;
1720  }
1721  }
1722  } else {
1723  handled_event = false;
1724  }
1725  break;
1726  case kEventClassTablet:
1727  switch (ekind) {
1728  case kEventTabletProximity:
1729  // Get the current point of the device and its unique ID.
1730  ::TabletProximityRec proxRec;
1731  GetEventParameter(event, kEventParamTabletProximityRec, typeTabletProximityRec, 0,
1732  sizeof(proxRec), 0, &proxRec);
1734  }
1735  break;
1736  case kEventClassMouse:
1737  {
1738  static const int kEventParamQAppSeenMouseEvent = 'QASM';
1739  // Check if we've seen the event, if we have we shouldn't process
1740  // it again as it may lead to spurious "double events"
1741  bool seenEvent;
1742  if (GetEventParameter(event, kEventParamQAppSeenMouseEvent,
1743  typeBoolean, 0, sizeof(bool), 0, &seenEvent) == noErr) {
1744  if (seenEvent)
1745  return eventNotHandledErr;
1746  }
1747  seenEvent = true;
1748  SetEventParameter(event, kEventParamQAppSeenMouseEvent, typeBoolean,
1749  sizeof(bool), &seenEvent);
1750 
1751  Point where;
1752  bool inNonClientArea = false;
1753  GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0,
1754  sizeof(where), 0, &where);
1755 #if defined(DEBUG_MOUSE_MAPS)
1756  const char *edesc = 0;
1757  switch(ekind) {
1758  case kEventMouseDown: edesc = "MouseButtonPress"; break;
1759  case kEventMouseUp: edesc = "MouseButtonRelease"; break;
1760  case kEventMouseDragged: case kEventMouseMoved: edesc = "MouseMove"; break;
1761  case kEventMouseScroll: edesc = "MouseWheelScroll"; break;
1762  case kEventMouseWheelMoved: edesc = "MouseWheelMove"; break;
1763  }
1764  if(ekind == kEventMouseDown || ekind == kEventMouseUp)
1765  qDebug("Handling mouse: %s", edesc);
1766 #endif
1767  QEvent::Type etype = QEvent::None;
1768  Qt::KeyboardModifiers modifiers;
1769  {
1770  UInt32 mac_modifiers = 0;
1771  GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
1772  sizeof(mac_modifiers), 0, &mac_modifiers);
1773  modifiers = qt_mac_get_modifiers(mac_modifiers);
1774  }
1775  Qt::MouseButtons buttons;
1776  {
1777  UInt32 mac_buttons = 0;
1778  GetEventParameter(event, kEventParamMouseChord, typeUInt32, 0,
1779  sizeof(mac_buttons), 0, &mac_buttons);
1780  if (ekind != kEventMouseWheelMoved)
1781  buttons = qt_mac_get_buttons(mac_buttons);
1782  else
1783  buttons = QApplication::mouseButtons();
1784  }
1785 
1786  int wheel_deltaX = 0;
1787  int wheel_deltaY = 0;
1788  static EventRef compatibilityEvent = 0;
1789 
1790  if (ekind == kEventMouseScroll) {
1791  // kEventMouseScroll is the new way of dealing with mouse wheel
1792  // events (kEventMouseWheelMoved was the old). kEventMouseScroll results
1793  // in much smoother scrolling when using Mighty Mouse or TrackPad. For
1794  // compatibility with older applications, carbon will also send us
1795  // kEventMouseWheelMoved events if we dont eat this event
1796  // (actually two events; one for horizontal and one for vertical).
1797  // As a results of this, and to make sure we dont't receive duplicate events,
1798  // we try to detect when this happend by checking the 'compatibilityEvent'.
1799  // Since delta is delivered as pixels rather than degrees, we need to
1800  // convert from pixels to degrees in a sensible manner.
1801  // It looks like 1/4 degrees per pixel behaves most native.
1802  // (NB: Qt expects the unit for delta to be 8 per degree):
1803  const int pixelsToDegrees = 2;
1804  SInt32 mdelt = 0;
1805  GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0,
1806  sizeof(mdelt), 0, &mdelt);
1807  wheel_deltaX = mdelt * pixelsToDegrees;
1808  mdelt = 0;
1809  GetEventParameter(event, kEventParamMouseWheelSmoothVerticalDelta, typeSInt32, 0,
1810  sizeof(mdelt), 0, &mdelt);
1811  wheel_deltaY = mdelt * pixelsToDegrees;
1812  GetEventParameter(event, kEventParamEventRef, typeEventRef, 0,
1813  sizeof(compatibilityEvent), 0, &compatibilityEvent);
1814  } else if (ekind == kEventMouseWheelMoved) {
1815  if (event != compatibilityEvent) {
1816  compatibilityEvent = 0;
1817  int mdelt = 0;
1818  GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0,
1819  sizeof(mdelt), 0, &mdelt);
1820  EventMouseWheelAxis axis;
1821  GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, 0,
1822  sizeof(axis), 0, &axis);
1823 
1824  // Remove acceleration, and use either -120 or 120 as delta:
1825  if (axis == kEventMouseWheelAxisX)
1826  wheel_deltaX = qBound(-120, int(mdelt * 10000), 120);
1827  else
1828  wheel_deltaY = qBound(-120, int(mdelt * 10000), 120);
1829  }
1830  }
1831 
1832  Qt::MouseButton button = Qt::NoButton;
1833  if(ekind == kEventMouseDown || ekind == kEventMouseUp) {
1834  EventMouseButton mac_button = 0;
1835  GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0,
1836  sizeof(mac_button), 0, &mac_button);
1837  button = qt_mac_get_button(mac_button);
1838  }
1839 
1840  switch(ekind) {
1841  case kEventMouseDown:
1842  etype = QEvent::MouseButtonPress;
1843  break;
1844  case kEventMouseUp:
1846  break;
1847  case kEventMouseDragged:
1848  case kEventMouseMoved:
1849  etype = QEvent::MouseMove;
1850  break;
1851  }
1852 
1853  const bool inPopupMode = app->d_func()->inPopupMode();
1854 
1855  // A click outside a popup closes the popup. Make sure
1856  // that no events are generated for the release part of that click.
1857  // (The press goes to the popup and closes it.)
1858  if (etype == QEvent::MouseButtonPress) {
1860  } else if (qt_mac_previous_press_in_popup_mode && !inPopupMode && etype == QEvent::MouseButtonRelease) {
1862  handled_event = true;
1863 #if defined(DEBUG_MOUSE_MAPS)
1864  qDebug("Bail out early due to qt_mac_previous_press_in_popup_mode");
1865 #endif
1866  break; // break from case kEventClassMouse
1867  }
1868 
1869  //figure out which widget to send it to
1870  if(inPopupMode) {
1871  QWidget *popup = qApp->activePopupWidget();
1872  if (qt_button_down && qt_button_down->window() == popup) {
1873  widget = qt_button_down;
1874  } else {
1875  QPoint pos = popup->mapFromGlobal(QPoint(where.h, where.v));
1876  widget = popup->childAt(pos);
1877  }
1878  if(!widget)
1879  widget = popup;
1880  } else {
1881  if(mac_mouse_grabber) {
1882  widget = mac_mouse_grabber;
1883  } else if (qt_button_down) {
1884  widget = qt_button_down;
1885  } else {
1886  {
1887  WindowPtr window = 0;
1888  if(GetEventParameter(event, kEventParamWindowRef, typeWindowRef, 0,
1889  sizeof(window), 0, &window) != noErr)
1890  FindWindowOfClass(&where, kAllWindowClasses, &window, 0);
1891  if(window) {
1892  HIViewRef hiview;
1893  if(HIViewGetViewForMouseEvent(HIViewGetRoot(window), event, &hiview) == noErr) {
1894  widget = QWidget::find((WId)hiview);
1895  if (widget) {
1896  // Make sure we didn't pass over a widget with a "fake hole" in it.
1897  QWidget *otherWidget = QApplication::widgetAt(where.h, where.v);
1898  if (otherWidget && otherWidget->testAttribute(Qt::WA_MouseNoMask))
1899  widget = otherWidget;
1900  }
1901  }
1902  }
1903  }
1904  if(!widget) //fallback
1905  widget = QApplication::widgetAt(where.h, where.v);
1906  if(ekind == kEventMouseUp && widget) {
1907  short part = qt_mac_window_at(where.h, where.v);
1908  if(part == inDrag) {
1909  UInt32 count = 0;
1910  GetEventParameter(event, kEventParamClickCount, typeUInt32, NULL,
1911  sizeof(count), NULL, &count);
1912  if(count == 2 && qt_mac_collapse_on_dblclick) {
1913  if (widget->macEvent(er, event))
1914  return noErr;
1915  widget->setWindowState(widget->windowState() | Qt::WindowMinimized);
1916  //we send a hide to be like X11/Windows
1917  QEvent e(QEvent::Hide);
1919  break;
1920  }
1921  }
1922  }
1923  }
1924  }
1925  if (widget && widget->macEvent(er, event))
1926  return noErr;
1927  WindowPartCode wpc = qt_mac_window_at(where.h, where.v, 0);
1928  if (wpc == inProxyIcon && modifiers == Qt::ControlModifier && buttons != Qt::NoButton) {
1929  QIconDragEvent e;
1931  if (e.isAccepted()) {
1932  return noErr; // IconDrag ate it.
1933  }
1934  }
1935  if (inPopupMode == false
1936  && (qt_button_down == 0 || qt_button_down_in_content == false)
1937  && (wpc != inContent && wpc != inStructure)) {
1938  inNonClientArea = true;
1939  switch (etype) {
1940  case QEvent::MouseButtonPress: {
1941  UInt32 count = 0;
1942  GetEventParameter(event, kEventParamClickCount, typeUInt32, 0,
1943  sizeof(count), 0, &count);
1944  if(count % 2 || count == 0) {
1946  } else {
1948  }} break;
1951  break;
1952  case QEvent::MouseMove:
1953  if (widget == 0 || widget->hasMouseTracking())
1955  break;
1956  default:
1957  break;
1958  }
1959  }
1960 
1961  if(qt_mac_find_window((FrontWindow()))) { //set the cursor up
1962  QCursor cursor(Qt::ArrowCursor);
1963  QWidget *cursor_widget = widget;
1964  if(cursor_widget && cursor_widget == qt_button_down && ekind == kEventMouseUp)
1965  cursor_widget = QApplication::widgetAt(where.h, where.v);
1966  if(cursor_widget) { //only over the app, do we set a cursor..
1967  if(!qApp->d_func()->cursor_list.isEmpty()) {
1968  cursor = qApp->d_func()->cursor_list.first();
1969  } else {
1970  for(; cursor_widget; cursor_widget = cursor_widget->parentWidget()) {
1971  QWExtra *extra = cursor_widget->d_func()->extraData();
1972  if(extra && extra->curs && cursor_widget->isEnabled()) {
1973  cursor = *extra->curs;
1974  break;
1975  }
1976  }
1977  }
1978  }
1979  qt_mac_set_cursor(&cursor);
1980  }
1981 
1982  //This mouse button state stuff looks like this on purpose
1983  //although it looks hacky it is VERY intentional..
1984  if(widget && app_do_modal && !qt_try_modal(widget, event)) {
1985  if(ekind == kEventMouseDown && qt_mac_is_macsheet(QApplication::activeModalWidget()))
1986  QApplication::activeModalWidget()->parentWidget()->activateWindow(); //sheets have a parent
1987  handled_event = false;
1988 #if defined(DEBUG_MOUSE_MAPS)
1989  qDebug("Bail out early due to qt_try_modal");
1990 #endif
1991  break;
1992  }
1993 
1994  UInt32 tabletEventType = 0;
1995  GetEventParameter(event, kEventParamTabletEventType, typeUInt32, 0,
1996  sizeof(tabletEventType), 0, &tabletEventType);
1997  if (tabletEventType == kEventTabletPoint) {
1998  TabletPointRec tabletPointRec;
1999  GetEventParameter(event, kEventParamTabletPointRec, typeTabletPointRec, 0,
2000  sizeof(tabletPointRec), 0, &tabletPointRec);
2001  QEvent::Type t = QEvent::TabletMove; //default
2002  int new_tablet_button_state = tabletPointRec.buttons ? 1 : 0;
2003  if (new_tablet_button_state != tablet_button_state)
2004  if (new_tablet_button_state)
2005  t = QEvent::TabletPress;
2006  else
2008  tablet_button_state = new_tablet_button_state;
2009 
2010  QMacTabletHash *tabletHash = qt_mac_tablet_hash();
2011  if (!tabletHash->contains(tabletPointRec.deviceID) && t != QEvent::TabletRelease) {
2012  // Never discard TabletRelease events as they may be delivered *after* TabletLeaveProximity events
2013  qWarning("handleTabletEvent: This tablet device is unknown"
2014  " (received no proximity event for it). Discarding event.");
2015  return false;
2016  }
2017  QTabletDeviceData &deviceData = tabletHash->operator[](tabletPointRec.deviceID);
2018  if (t == QEvent::TabletPress) {
2019  deviceData.widgetToGetPress = widget;
2020  } else if (t == QEvent::TabletRelease && deviceData.widgetToGetPress) {
2021  widget = deviceData.widgetToGetPress;
2022  deviceData.widgetToGetPress = 0;
2023  }
2024 
2025  if (widget) {
2026  int tiltX = ((int)tabletPointRec.tiltX)/(32767/64); // 32K -> 60
2027  int tiltY = ((int)tabletPointRec.tiltY)/(-32767/64); // 32K -> 60
2028  HIPoint hiPoint;
2029  GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, 0, sizeof(HIPoint), 0, &hiPoint);
2030  QPointF hiRes(hiPoint.x, hiPoint.y);
2031  QPoint global(where.h, where.v);
2032 
2033 
2034 
2035  QPoint local(widget->mapFromGlobal(global));
2036  int z = 0;
2037  qreal rotation = 0.0;
2038  qreal tp = 0.0;
2039  // Again from the Wacom.h header
2040 
2041  if (deviceData.capabilityMask & 0x0200) // Z-axis
2042  z = tabletPointRec.absZ;
2043 
2044  if (deviceData.capabilityMask & 0x0800) // Tangential pressure
2045  tp = tabletPointRec.tangentialPressure / 32767.0;
2046 
2047  if (deviceData.capabilityMask & 0x2000) // Rotation
2048  rotation = qreal(tabletPointRec.rotation) / 64.0;
2049 
2050  QTabletEvent e(t, local, global, hiRes, deviceData.tabletDeviceType,
2051  deviceData.tabletPointerType,
2052  qreal(tabletPointRec.pressure / qreal(0xffff)), tiltX, tiltY,
2053  tp, rotation, z, modifiers, deviceData.tabletUniqueID);
2055  if (e.isAccepted()) {
2056  if (t == QEvent::TabletPress) {
2057  qt_button_down = widget;
2058  } else if (t == QEvent::TabletRelease) {
2059  qt_button_down = 0;
2060  }
2061 #if defined(DEBUG_MOUSE_MAPS)
2062  qDebug("Bail out early due to tablet acceptance");
2063 #endif
2064  break;
2065  }
2066  }
2067  }
2068 
2069  if(ekind == kEventMouseDown) {
2071  const short windowPart = qt_mac_window_at(where.h, where.v, 0);
2072  // Menubar almost always wins.
2073  if (!inPopupMode && windowPart == inMenuBar) {
2074  MenuSelect(where); //allow menu tracking
2075  return noErr;
2076  }
2077 
2078  if (widget && !(GetCurrentKeyModifiers() & cmdKey)) {
2079  extern bool qt_isGenuineQWidget(const QWidget *); // qwidget_mac.cpp
2080  QWidget *window = widget->window();
2081  bool genuineQtWidget = qt_isGenuineQWidget(widget); // the widget, not the window.
2082  window->raise();
2083 
2084  bool needActivate = (window->windowType() != Qt::Desktop)
2085  && (window->windowType() != Qt::Popup)
2086  && !qt_mac_is_macsheet(window);
2087  if (needActivate && (!window->isModal() && qobject_cast<QDockWidget *>(window)))
2088  needActivate = false;
2089 
2090  if (genuineQtWidget && needActivate)
2091  needActivate = !window->isActiveWindow()
2092  || !IsWindowActive(qt_mac_window_for(window));
2093 
2094  if (needActivate) {
2095  window->activateWindow();
2096  if (!qt_mac_can_clickThrough(widget)) {
2098  handled_event = false;
2099 #if defined(DEBUG_MOUSE_MAPS)
2100  qDebug("Bail out early due to qt_mac_canClickThrough %s::%s", widget->metaObject()->className(),
2101  widget->objectName().toLocal8Bit().constData());
2102 #endif
2103  break;
2104  }
2105  }
2106  }
2107 
2108  if(qt_mac_dblclick.last_widget &&
2109  qt_mac_dblclick.last_x != -1 && qt_mac_dblclick.last_y != -1 &&
2110  QRect(qt_mac_dblclick.last_x-2, qt_mac_dblclick.last_y-2, 4, 4).contains(QPoint(where.h, where.v))) {
2111  if(qt_mac_dblclick.use_qt_time_limit) {
2112  EventTime now = GetEventTime(event);
2113  if(qt_mac_dblclick.last_time != -2 && qt_mac_dblclick.last_widget == widget &&
2114  now - qt_mac_dblclick.last_time <= ((double)QApplicationPrivate::mouse_double_click_time)/1000 &&
2115  qt_mac_dblclick.last_button == button)
2117  } else {
2118  UInt32 count = 0;
2119  GetEventParameter(event, kEventParamClickCount, typeUInt32, 0,
2120  sizeof(count), 0, &count);
2121  if(!(count % 2) && qt_mac_dblclick.last_modifiers == modifiers &&
2122  qt_mac_dblclick.last_widget == widget && qt_mac_dblclick.last_button == button)
2124  }
2125  if(etype == QEvent::MouseButtonDblClick)
2126  qt_mac_dblclick.last_widget = 0;
2127  }
2128  if(etype != QEvent::MouseButtonDblClick) {
2129  qt_mac_dblclick.last_x = where.h;
2130  qt_mac_dblclick.last_y = where.v;
2131  } else {
2132  qt_mac_dblclick.last_x = qt_mac_dblclick.last_y = -1;
2133  }
2134  } else if(qt_mac_no_click_through_mode) {
2135  if(ekind == kEventMouseUp)
2137  handled_event = false;
2138 #if defined(DEBUG_MOUSE_MAPS)
2139  qDebug("Bail out early due to qt_mac_no_click_through_mode");
2140 #endif
2141  break;
2142  }
2143 
2144  QPointer<QWidget> leaveAfterRelease = 0;
2145  switch(ekind) {
2146  case kEventMouseUp:
2147  if (!buttons) {
2148  if (!inPopupMode && !QWidget::mouseGrabber())
2149  leaveAfterRelease = qt_button_down;
2150  qt_button_down = 0;
2151  }
2152  break;
2153  case kEventMouseDown: {
2154  if (!qt_button_down)
2155  qt_button_down = widget;
2156  WindowPartCode wpc = qt_mac_window_at(where.h, where.v, 0);
2157  qt_button_down_in_content = (wpc == inContent || wpc == inStructure);
2158  break; }
2159  }
2160 
2161  // Check if we should send enter/leave events:
2162  switch(ekind) {
2163  case kEventMouseDragged:
2164  case kEventMouseMoved:
2165  case kEventMouseUp:
2166  case kEventMouseDown: {
2167  // If we are in popup mode, widget will point to the current popup no matter
2168  // where the mouse cursor is. In that case find out if the mouse cursor is
2169  // really over the popup in order to send correct enter / leave envents.
2170  QWidget * const enterLeaveWidget = (inPopupMode || ekind == kEventMouseUp) ?
2171  QApplication::widgetAt(where.h, where.v) : static_cast<QWidget*>(widget);
2172 
2173  if ((QWidget *) qt_last_mouse_receiver != enterLeaveWidget || inNonClientArea) {
2174 #ifdef DEBUG_MOUSE_MAPS
2175  qDebug("Entering: %p - %s (%s), Leaving %s (%s)", (QWidget*)enterLeaveWidget,
2176  enterLeaveWidget ? enterLeaveWidget->metaObject()->className() : "none",
2177  enterLeaveWidget ? enterLeaveWidget->objectName().toLocal8Bit().constData() : "",
2178  qt_last_mouse_receiver ? qt_last_mouse_receiver->metaObject()->className() : "none",
2179  qt_last_mouse_receiver ? qt_last_mouse_receiver->objectName().toLocal8Bit().constData() : "");
2180 #endif
2181 
2182  QWidget * const mouseGrabber = QWidget::mouseGrabber();
2183 
2184  if (inPopupMode) {
2185  QWidget *enter = enterLeaveWidget;
2187  if (mouseGrabber) {
2188  QWidget * const popupWidget = qApp->activePopupWidget();
2189  if (leave == popupWidget)
2190  enter = mouseGrabber;
2191  if (enter == popupWidget)
2192  leave = mouseGrabber;
2193  if ((enter == mouseGrabber && leave == popupWidget)
2194  || (leave == mouseGrabber && enter == popupWidget)) {
2196  qt_last_mouse_receiver = enter;
2197  }
2198  } else {
2200  qt_last_mouse_receiver = enter;
2201  }
2202  } else if ((!qt_button_down || !qt_last_mouse_receiver) && !mouseGrabber && !leaveAfterRelease) {
2203  QApplicationPrivate::dispatchEnterLeave(enterLeaveWidget, qt_last_mouse_receiver);
2204  qt_last_mouse_receiver = enterLeaveWidget;
2205  }
2206  }
2207  break; }
2208  }
2209 
2210  if(widget) {
2211  QPoint p(where.h, where.v);
2212  QPoint plocal(widget->mapFromGlobal(p));
2213  if(etype == QEvent::MouseButtonPress) {
2214  qt_mac_dblclick.last_widget = widget;
2215  qt_mac_dblclick.last_modifiers = modifiers;
2216  qt_mac_dblclick.last_button = button;
2217  qt_mac_dblclick.last_time = GetEventTime(event);
2218  }
2219 
2220  if (wheel_deltaX || wheel_deltaY) {
2221 #ifndef QT_NO_WHEELEVENT
2222  if (wheel_deltaX) {
2223  QWheelEvent qwe(plocal, p, wheel_deltaX, buttons, modifiers, Qt::Horizontal);
2224  QApplication::sendSpontaneousEvent(widget, &qwe);
2226  QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(p), p,
2227  wheel_deltaX, buttons, modifiers, Qt::Horizontal);
2229  if (!qwe2.isAccepted())
2230  handled_event = false;
2231  }
2232  }
2233  if (wheel_deltaY) {
2234  QWheelEvent qwe(plocal, p, wheel_deltaY, buttons, modifiers, Qt::Vertical);
2235  QApplication::sendSpontaneousEvent(widget, &qwe);
2237  QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(p), p,
2238  wheel_deltaY, buttons, modifiers, Qt::Vertical);
2240  if (!qwe2.isAccepted())
2241  handled_event = false;
2242  }
2243  }
2244 #endif // QT_NO_WHEELEVENT
2245  } else {
2246 #ifdef QMAC_SPEAK_TO_ME
2247  const int speak_keys = Qt::AltModifier | Qt::ShiftModifier;
2248  if(etype == QMouseEvent::MouseButtonDblClick && ((modifiers & speak_keys) == speak_keys)) {
2249  QVariant v = widget->property("displayText");
2250  if(!v.isValid()) v = widget->property("text");
2251  if(!v.isValid()) v = widget->property("windowTitle");
2252  if(v.isValid()) {
2253  QString s = v.toString();
2254  s.replace(QRegExp(QString::fromLatin1("(\\&|\\<[^\\>]*\\>)")), QLatin1String(""));
2255  SpeechChannel ch;
2256  NewSpeechChannel(0, &ch);
2257  SpeakText(ch, s.toLatin1().constData(), s.length());
2258  DisposeSpeechChannel(ch);
2259  }
2260  }
2261 #endif
2262  Qt::MouseButton buttonToSend = button;
2263  static bool lastButtonTranslated = false;
2264  if(ekind == kEventMouseDown &&
2265  button == Qt::LeftButton && (modifiers & Qt::MetaModifier)) {
2266  buttonToSend = Qt::RightButton;
2267  lastButtonTranslated = true;
2268  } else if(ekind == kEventMouseUp && lastButtonTranslated) {
2269  buttonToSend = Qt::RightButton;
2270  lastButtonTranslated = false;
2271  }
2272  QMouseEvent qme(etype, plocal, p, buttonToSend, buttons, modifiers);
2273  QApplication::sendSpontaneousEvent(widget, &qme);
2274  if(!qme.isAccepted() || inNonClientArea)
2275  handled_event = false;
2276  }
2277 
2278  if (leaveAfterRelease) {
2279  QWidget *enter = QApplication::widgetAt(where.h, where.v);
2280  QApplicationPrivate::dispatchEnterLeave(enter, leaveAfterRelease);
2281  qt_last_mouse_receiver = enter;
2282  leaveAfterRelease = 0;
2283  }
2284 
2285  if(ekind == kEventMouseDown &&
2286  ((button == Qt::RightButton) ||
2287  (button == Qt::LeftButton && (modifiers & Qt::MetaModifier))))
2289 
2290 #ifdef DEBUG_MOUSE_MAPS
2291  const char *event_desc = edesc;
2292  if(etype == QEvent::MouseButtonDblClick)
2293  event_desc = "Double Click";
2294  else if(etype == QEvent::NonClientAreaMouseButtonPress)
2295  event_desc = "NonClientMousePress";
2296  else if(etype == QEvent::NonClientAreaMouseButtonRelease)
2297  event_desc = "NonClientMouseRelease";
2298  else if(etype == QEvent::NonClientAreaMouseMove)
2299  event_desc = "NonClientMouseMove";
2301  event_desc = "NonClientMouseDblClick";
2302  qDebug("%d %d (%d %d) - Would send (%s) event to %p %s %s (%d 0x%08x 0x%08x %d)", p.x(), p.y(),
2303  plocal.x(), plocal.y(), event_desc, (QWidget*)widget,
2304  widget ? widget->objectName().toLocal8Bit().constData() : "*Unknown*",
2305  widget ? widget->metaObject()->className() : "*Unknown*",
2306  button, (int)buttons, (int)modifiers, wheel_deltaX);
2307 #endif
2308  } else {
2309  handled_event = false;
2310  }
2311  break;
2312  }
2313  case kEventClassTextInput:
2314  case kEventClassKeyboard: {
2315  EventRef key_event = event;
2316  if(eclass == kEventClassTextInput) {
2317  Q_ASSERT(ekind == kEventTextInputUnicodeForKeyEvent);
2318  OSStatus err = GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0,
2319  sizeof(key_event), 0, &key_event);
2320  Q_ASSERT(err == noErr);
2321  Q_UNUSED(err);
2322  }
2323  const UInt32 key_ekind = GetEventKind(key_event);
2324  Q_ASSERT(GetEventClass(key_event) == kEventClassKeyboard);
2325 
2326  if(key_ekind == kEventRawKeyDown)
2327  qt_keymapper_private()->updateKeyMap(er, key_event, data);
2328  if(mac_keyboard_grabber)
2329  widget = mac_keyboard_grabber;
2330  else if (app->activePopupWidget())
2331  widget = (app->activePopupWidget()->focusWidget() ?
2332  app->activePopupWidget()->focusWidget() : app->activePopupWidget());
2333  else if(QApplication::focusWidget())
2334  widget = QApplication::focusWidget();
2335  else
2336  widget = app->activeWindow();
2337 
2338  if (widget) {
2339  if (widget->macEvent(er, event))
2340  return noErr;
2341  } else {
2342  // Darn, I need to update tho modifier state, even though
2343  // Qt itself isn't getting them, otherwise the keyboard state get inconsistent.
2344  if (key_ekind == kEventRawKeyModifiersChanged) {
2345  UInt32 modifiers = 0;
2346  GetEventParameter(key_event, kEventParamKeyModifiers, typeUInt32, 0,
2347  sizeof(modifiers), 0, &modifiers);
2348  extern void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object); // qkeymapper_mac.cpp
2349  // Just send it to the qApp for the time being.
2350  qt_mac_send_modifiers_changed(modifiers, qApp);
2351  }
2352  handled_event = false;
2353  break;
2354  }
2355 
2356  if(app_do_modal && !qt_try_modal(widget, key_event))
2357  break;
2358  if (eclass == kEventClassTextInput) {
2359  handled_event = false;
2360  } else {
2361  handled_event = qt_keymapper_private()->translateKeyEvent(widget, er, key_event, data,
2362  widget == mac_keyboard_grabber);
2363  }
2364  break; }
2365  case kEventClassWindow: {
2366  WindowRef wid = 0;
2367  GetEventParameter(event, kEventParamDirectObject, typeWindowRef, 0,
2368  sizeof(WindowRef), 0, &wid);
2369  widget = qt_mac_find_window(wid);
2370  if (widget && widget->macEvent(er, event))
2371  return noErr;
2372  if(ekind == kEventWindowActivated) {
2374  QEvent ev(QEvent::Style);
2376  }
2377 
2378  if(widget && app_do_modal && !qt_try_modal(widget, event))
2379  break;
2380 
2381  if(widget && widget->window()->isVisible()) {
2382  QWidget *tlw = widget->window();
2383  if(tlw->isWindow() && !(tlw->windowType() == Qt::Popup)
2384  && !qt_mac_is_macdrawer(tlw)
2385  && (!tlw->parentWidget() || tlw->isModal()
2386  || !(tlw->windowType() == Qt::Tool))) {
2387  bool just_send_event = false;
2388  {
2389  WindowActivationScope scope;
2390  if(GetWindowActivationScope((WindowRef)wid, &scope) == noErr &&
2391  scope == kWindowActivationScopeIndependent) {
2392  if(GetFrontWindowOfClass(kAllWindowClasses, true) != wid)
2393  just_send_event = true;
2394  }
2395  }
2396  if(just_send_event) {
2399  } else {
2400  app->setActiveWindow(tlw);
2401  }
2402  }
2404  }
2405  } else if(ekind == kEventWindowDeactivated) {
2406  if(widget && QApplicationPrivate::active_window == widget)
2407  app->setActiveWindow(0);
2408  } else {
2409  handled_event = false;
2410  }
2411  break; }
2412  case kEventClassApplication:
2413  if(ekind == kEventAppActivated) {
2416  if(qt_clipboard) { //manufacture an event so the clipboard can see if it has changed
2419  }
2420  if(app) {
2423  }
2424  if(!app->activeWindow()) {
2425  WindowPtr wp = ActiveNonFloatingWindow();
2426  if(QWidget *tmp_w = qt_mac_find_window(wp))
2427  app->setActiveWindow(tmp_w);
2428  }
2430  } else if(ekind == kEventAppDeactivated) {
2431  //qt_mac_no_click_through_mode = false;
2432  while(app->d_func()->inPopupMode())
2433  app->activePopupWidget()->close();
2434  if(app) {
2437  }
2438  app->setActiveWindow(0);
2439  } else if(ekind == kEventAppAvailableWindowBoundsChanged) {
2441  } else {
2442  handled_event = false;
2443  }
2444  break;
2445  case kAppearanceEventClass:
2446  if(ekind == kAEAppearanceChanged) {
2450  QEvent ev(QEvent::Style);
2452  }
2453  } else {
2454  handled_event = false;
2455  }
2456  break;
2457  case kEventClassAppleEvent:
2458  if(ekind == kEventAppleEvent) {
2459  EventRecord erec;
2460  if(!ConvertEventRefToEventRecord(event, &erec))
2461  qDebug("Qt: internal: WH0A, unexpected condition reached. %s:%d", __FILE__, __LINE__);
2462  else if(AEProcessAppleEvent(&erec) != noErr)
2463  handled_event = false;
2464  } else {
2465  handled_event = false;
2466  }
2467  break;
2468  case kEventClassCommand:
2469  if(ekind == kEventCommandProcess) {
2470  HICommand cmd;
2471  GetEventParameter(event, kEventParamDirectObject, typeHICommand,
2472  0, sizeof(cmd), 0, &cmd);
2473  handled_event = false;
2474  if(!cmd.menu.menuRef && GetApplicationDockTileMenu()) {
2475  EventRef copy = CopyEvent(event);
2476  HICommand copy_cmd;
2477  GetEventParameter(event, kEventParamDirectObject, typeHICommand,
2478  0, sizeof(copy_cmd), 0, &copy_cmd);
2479  copy_cmd.menu.menuRef = GetApplicationDockTileMenu();
2480  SetEventParameter(copy, kEventParamDirectObject, typeHICommand, sizeof(copy_cmd), &copy_cmd);
2481  if(SendEventToMenu(copy, copy_cmd.menu.menuRef) == noErr)
2482  handled_event = true;
2483  }
2484  if(!handled_event) {
2485  if(cmd.commandID == kHICommandQuit) {
2486  // Quitting the application is not Qt's responsibility if
2487  // used in a plugin or just embedded into a native application.
2488  // In that case, let the event pass down to the native apps event handler.
2490  handled_event = true;
2491  HiliteMenu(0);
2492  bool handle_quit = true;
2494  int visible = 0;
2496  for(int i = 0; i < tlws.size(); ++i) {
2497  if(tlws.at(i)->isVisible())
2498  ++visible;
2499  }
2500  handle_quit = (visible <= 1);
2501  }
2502  if(handle_quit) {
2503  QCloseEvent ev;
2505  if(ev.isAccepted())
2506  app->quit();
2507  } else {
2509  }
2510  }
2511  } else if(cmd.commandID == kHICommandSelectWindow) {
2512  if((GetCurrentKeyModifiers() & cmdKey))
2513  handled_event = true;
2514  } else if(cmd.commandID == kHICommandAbout) {
2516  HiliteMenu(0);
2517  handled_event = true;
2518  }
2519  }
2520  }
2521  break;
2522  }
2523 
2524 #ifdef DEBUG_EVENTS
2525  qDebug("%shandled event %c%c%c%c %d", handled_event ? "(*) " : "",
2526  char(eclass >> 24), char((eclass >> 16) & 255), char((eclass >> 8) & 255),
2527  char(eclass & 255), (int)ekind);
2528 #endif
2529  if(!handled_event) //let the event go through
2530  return eventNotHandledErr;
2531  return noErr; //we eat the event
2532 #else
2533  Q_UNUSED(er);
2534  Q_UNUSED(event);
2535  Q_UNUSED(data);
2536  return eventNotHandledErr;
2537 #endif
2538 }
2539 
2540 #ifdef QT_MAC_USE_COCOA
2541 void QApplicationPrivate::qt_initAfterNSAppStarted()
2542 {
2543  setupAppleEvents();
2545 }
2546 
2547 void QApplicationPrivate::setupAppleEvents()
2548 {
2549  // This function is called from the event dispatcher when NSApplication has
2550  // finished initialization, which appears to be just after [NSApplication run] has
2551  // started to execute. By setting up our apple events handlers this late, we override
2552  // the ones set up by NSApplication.
2553 
2554  // If Qt is used as a plugin, we let the 3rd party application handle events
2555  // like quit and open file events. Otherwise, if we install our own handlers, we
2556  // easily end up breaking functionallity the 3rd party application depend on:
2558  return;
2559 
2560  QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate];
2561  NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager];
2562  [eventManager setEventHandler:newDelegate andSelector:@selector(appleEventQuit:withReplyEvent:)
2563  forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
2564  [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:)
2565  forEventClass:kInternetEventClass andEventID:kAEGetURL];
2566 }
2567 #endif
2568 
2569 // In Carbon this is your one stop for apple events.
2570 // In Cocoa, it ISN'T. This is the catch-all Apple Event handler that exists
2571 // for the time between instantiating the NSApplication, but before the
2572 // NSApplication has installed it's OWN Apple Event handler. When Cocoa has
2573 // that set up, we remove this. So, if you are debugging problems, you likely
2574 // want to check out QCocoaApplicationDelegate instead.
2576 {
2577  QApplication *app = (QApplication *)handlerRefcon;
2578  bool handled_event=false;
2579  OSType aeID=typeWildCard, aeClass=typeWildCard;
2580  AEGetAttributePtr(ae, keyEventClassAttr, typeType, 0, &aeClass, sizeof(aeClass), 0);
2581  AEGetAttributePtr(ae, keyEventIDAttr, typeType, 0, &aeID, sizeof(aeID), 0);
2582  if(aeClass == kCoreEventClass) {
2583  switch(aeID) {
2584  case kAEQuitApplication: {
2585  extern bool qt_mac_quit_menu_item_enabled; // qmenu_mac.cpp
2586  if (qt_mac_quit_menu_item_enabled) {
2587  QCloseEvent ev;
2589  if(ev.isAccepted()) {
2590  handled_event = true;
2591  app->quit();
2592  }
2593  } else {
2594  QApplication::beep(); // Sorry, you can't quit right now.
2595  }
2596  break; }
2597  case kAEOpenDocuments: {
2598  AEDescList docs;
2599  if(AEGetParamDesc(ae, keyDirectObject, typeAEList, &docs) == noErr) {
2600  long cnt = 0;
2601  AECountItems(&docs, &cnt);
2602  UInt8 *str_buffer = NULL;
2603  for(int i = 0; i < cnt; i++) {
2604  FSRef ref;
2605  if(AEGetNthPtr(&docs, i+1, typeFSRef, 0, 0, &ref, sizeof(ref), 0) != noErr)
2606  continue;
2607  if(!str_buffer)
2608  str_buffer = (UInt8 *)malloc(1024);
2609  FSRefMakePath(&ref, str_buffer, 1024);
2610  QFileOpenEvent ev(QString::fromUtf8((const char *)str_buffer));
2612  }
2613  if(str_buffer)
2614  free(str_buffer);
2615  }
2616  break; }
2617  default:
2618  break;
2619  }
2620  } else if (aeClass == kInternetEventClass) {
2621  switch (aeID) {
2622  case kAEGetURL: {
2623  char urlData[1024];
2624  Size actualSize;
2625  if (AEGetParamPtr(ae, keyDirectObject, typeChar, 0, urlData,
2626  sizeof(urlData) - 1, &actualSize) == noErr) {
2627  urlData[actualSize] = 0;
2628  QFileOpenEvent ev(QUrl(QString::fromUtf8(urlData)));
2630  }
2631  break;
2632  }
2633  default:
2634  break;
2635  }
2636  }
2637 #ifdef DEBUG_EVENTS
2638  qDebug("Qt: internal: %shandled Apple event! %c%c%c%c %c%c%c%c", handled_event ? "(*)" : "",
2639  char(aeID >> 24), char((aeID >> 16) & 255), char((aeID >> 8) & 255),char(aeID & 255),
2640  char(aeClass >> 24), char((aeClass >> 16) & 255), char((aeClass >> 8) & 255),char(aeClass & 255));
2641 #else
2642  if(!handled_event) //let the event go through
2643  return eventNotHandledErr;
2644  return noErr; //we eat the event
2645 #endif
2646 }
2647 
2671 {
2672  return false;
2673 }
2674 
2679 {
2680  if (!QApplicationPrivate::popupWidgets) // create list
2682  QApplicationPrivate::popupWidgets->append(popup); // add to end of list
2683 
2684  // popups are not focus-handled by the window system (the first
2685  // popup grabbed the keyboard), so we have to do that manually: A
2686  // new popup gets the focus
2687  if (popup->focusWidget()) {
2689  } else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup
2691  }
2692 }
2693 
2698 {
2699  Q_Q(QApplication);
2701  return;
2702 
2704  if (popup == qt_button_down)
2705  qt_button_down = 0;
2706  if (QApplicationPrivate::popupWidgets->isEmpty()) { // this was the last popup
2709 
2710  // Special case for Tool windows: since they are activated and deactived together
2711  // with a normal window they never become the QApplicationPrivate::active_window.
2712  QWidget *appFocusWidget = QApplication::focusWidget();
2713  if (appFocusWidget && appFocusWidget->window()->windowType() == Qt::Tool) {
2714  appFocusWidget->setFocus(Qt::PopupFocusReason);
2716  if (QWidget *fw = QApplicationPrivate::active_window->focusWidget()) {
2717  if (fw != QApplication::focusWidget()) {
2718  fw->setFocus(Qt::PopupFocusReason);
2719  } else {
2721  q->sendEvent(fw, &e);
2722  }
2723  }
2724  }
2725  } else {
2726  // popups are not focus-handled by the window system (the
2727  // first popup grabbed the keyboard), so we have to do that
2728  // manually: A popup was closed, so the previous popup gets
2729  // the focus.
2731  if (QWidget *fw = aw->focusWidget())
2732  fw->setFocus(Qt::PopupFocusReason);
2733  }
2734 }
2735 
2737 {
2738  qt_mac_beep();
2739 }
2740 
2741 void QApplication::alert(QWidget *widget, int duration)
2742 {
2743  if (!QApplicationPrivate::checkInstance("alert"))
2744  return;
2745 
2746  QWidgetList windowsToMark;
2747  if (!widget)
2748  windowsToMark += topLevelWidgets();
2749  else
2750  windowsToMark.append(widget->window());
2751 
2752  bool needNotification = false;
2753  for (int i = 0; i < windowsToMark.size(); ++i) {
2754  QWidget *window = windowsToMark.at(i);
2755  if (!window->isActiveWindow() && window->isVisible()) {
2756  needNotification = true; // yeah, we may set it multiple times, but that's OK.
2757  if (duration != 0) {
2758  QTimer *timer = new QTimer(qApp);
2759  timer->setSingleShot(true);
2760  connect(timer, SIGNAL(timeout()), qApp, SLOT(_q_alertTimeOut()));
2761  if (QTimer *oldTimer = qApp->d_func()->alertTimerHash.value(widget)) {
2762  qApp->d_func()->alertTimerHash.remove(widget);
2763  delete oldTimer;
2764  }
2765  qApp->d_func()->alertTimerHash.insert(widget, timer);
2766  timer->start(duration);
2767  }
2768  }
2769  }
2770  if (needNotification)
2772 }
2773 
2775 {
2776  if (QTimer *timer = qobject_cast<QTimer *>(q_func()->sender())) {
2777  QHash<QWidget *, QTimer *>::iterator it = alertTimerHash.begin();
2778  while (it != alertTimerHash.end()) {
2779  if (it.value() == timer) {
2780  alertTimerHash.erase(it);
2781  timer->deleteLater();
2782  break;
2783  }
2784  ++it;
2785  }
2786  if (alertTimerHash.isEmpty()) {
2788  }
2789  }
2790 }
2791 
2793 {
2795 }
2796 
2798 {
2800 }
2801 
2803 {
2804  qt_mac_dblclick.use_qt_time_limit = true;
2806 }
2807 
2809 {
2810  if (!qt_mac_dblclick.use_qt_time_limit) { //get it from the system
2811  QSettings appleSettings(QLatin1String("apple.com"));
2812  /* First worked as of 10.3.3 */
2813  double dci = appleSettings.value(QLatin1String("com/apple/mouse/doubleClickThreshold"), 0.5).toDouble();
2814  return int(dci * 1000);
2815  }
2817 }
2818 
2820 {
2822 }
2823 
2825 {
2826  // FIXME: get from the system
2828 }
2829 
2830 #ifndef QT_NO_WHEELEVENT
2832 {
2834 }
2835 
2837 {
2839 }
2840 #endif
2841 
2843 {
2844  switch (effect) {
2845  case Qt::UI_FadeMenu:
2847  break;
2848  case Qt::UI_AnimateMenu:
2850  break;
2851  case Qt::UI_FadeTooltip:
2853  break;
2854  case Qt::UI_AnimateTooltip:
2856  break;
2857  case Qt::UI_AnimateCombo:
2859  break;
2860  case Qt::UI_AnimateToolBox:
2862  break;
2863  case Qt::UI_General:
2865  break;
2866  default:
2868  break;
2869  }
2870 
2871  if (enable)
2873 }
2874 
2876 {
2878  return false;
2879 
2880  switch(effect) {
2881  case Qt::UI_AnimateMenu:
2883  case Qt::UI_FadeMenu:
2885  case Qt::UI_AnimateCombo:
2887  case Qt::UI_AnimateTooltip:
2889  case Qt::UI_FadeTooltip:
2891  case Qt::UI_AnimateToolBox:
2893  default:
2894  break;
2895  }
2897 }
2898 
2903 {
2904  QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
2905  settings.beginGroup(QLatin1String("Qt"));
2906 
2907  /*
2908  Qt settings. This is how they are written into the datastream.
2909  Palette/ * - QPalette
2910  font - QFont
2911  libraryPath - QStringList
2912  style - QString
2913  doubleClickInterval - int
2914  cursorFlashTime - int
2915  wheelScrollLines - int
2916  colorSpec - QString
2917  defaultCodec - QString
2918  globalStrut/width - int
2919  globalStrut/height - int
2920  GUIEffects - QStringList
2921  Font Substitutions/ * - QStringList
2922  Font Substitutions/... - QStringList
2923  */
2924 
2925  // read library (ie. plugin) path list
2926  QString libpathkey =
2927  QString::fromLatin1("%1.%2/libraryPath")
2928  .arg(QT_VERSION >> 16)
2929  .arg((QT_VERSION & 0xff00) >> 8);
2930  QStringList pathlist = settings.value(libpathkey).toString().split(QLatin1Char(':'));
2931  if (!pathlist.isEmpty()) {
2932  QStringList::ConstIterator it = pathlist.begin();
2933  while(it != pathlist.end())
2935  }
2936 
2937  QString defaultcodec = settings.value(QLatin1String("defaultCodec"), QVariant(QLatin1String("none"))).toString();
2938  if (defaultcodec != QLatin1String("none")) {
2940  if (codec)
2942  }
2943 
2944  if (qt_is_gui_used) {
2945  QString str;
2946  QStringList strlist;
2947  int num;
2948 
2949  // read new palette
2950  int i;
2952  strlist = settings.value(QLatin1String("Palette/active")).toStringList();
2953  if (strlist.count() == QPalette::NColorRoles) {
2954  for (i = 0; i < QPalette::NColorRoles; i++)
2956  QColor(strlist[i]));
2957  }
2958  strlist = settings.value(QLatin1String("Palette/inactive")).toStringList();
2959  if (strlist.count() == QPalette::NColorRoles) {
2960  for (i = 0; i < QPalette::NColorRoles; i++)
2962  QColor(strlist[i]));
2963  }
2964  strlist = settings.value(QLatin1String("Palette/disabled")).toStringList();
2965  if (strlist.count() == QPalette::NColorRoles) {
2966  for (i = 0; i < QPalette::NColorRoles; i++)
2968  QColor(strlist[i]));
2969  }
2970 
2971  if (pal != QApplication::palette())
2973 
2974  // read new font
2975  QFont font(QApplication::font());
2976  str = settings.value(QLatin1String("font")).toString();
2977  if (!str.isEmpty()) {
2978  font.fromString(str);
2979  if (font != QApplication::font())
2980  QApplication::setFont(font);
2981  }
2982 
2983  // read new QStyle
2984  QString stylename = settings.value(QLatin1String("style")).toString();
2985  if (! stylename.isNull() && ! stylename.isEmpty()) {
2986  QStyle *style = QStyleFactory::create(stylename);
2987  if (style)
2988  QApplication::setStyle(style);
2989  else
2990  stylename = QLatin1String("default");
2991  } else {
2992  stylename = QLatin1String("default");
2993  }
2994 
2995  num = settings.value(QLatin1String("doubleClickInterval"),
2998 
2999  num = settings.value(QLatin1String("cursorFlashTime"),
3002 
3003 #ifndef QT_NO_WHEELEVENT
3004  num = settings.value(QLatin1String("wheelScrollLines"),
3007 #endif
3008 
3009  QString colorspec = settings.value(QLatin1String("colorSpec"),
3010  QVariant(QLatin1String("default"))).toString();
3011  if (colorspec == QLatin1String("normal"))
3013  else if (colorspec == QLatin1String("custom"))
3015  else if (colorspec == QLatin1String("many"))
3017  else if (colorspec != QLatin1String("default"))
3018  colorspec = QLatin1String("default");
3019 
3020  int w = settings.value(QLatin1String("globalStrut/width")).toInt();
3021  int h = settings.value(QLatin1String("globalStrut/height")).toInt();
3022  QSize strut(w, h);
3023  if (strut.isValid())
3025 
3026  QStringList effects = settings.value(QLatin1String("GUIEffects")).toStringList();
3027  if (!effects.isEmpty()) {
3028  if (effects.contains(QLatin1String("none")))
3030  if (effects.contains(QLatin1String("general")))
3032  if (effects.contains(QLatin1String("animatemenu")))
3034  if (effects.contains(QLatin1String("fademenu")))
3036  if (effects.contains(QLatin1String("animatecombo")))
3038  if (effects.contains(QLatin1String("animatetooltip")))
3040  if (effects.contains(QLatin1String("fadetooltip")))
3042  if (effects.contains(QLatin1String("animatetoolbox")))
3044  } else {
3046  }
3047 
3048  settings.beginGroup(QLatin1String("Font Substitutions"));
3049  QStringList fontsubs = settings.childKeys();
3050  if (!fontsubs.isEmpty()) {
3051  QStringList::Iterator it = fontsubs.begin();
3052  for (; it != fontsubs.end(); ++it) {
3053  QString fam = QString::fromLatin1((*it).toLatin1().constData());
3054  QStringList subs = settings.value(fam).toStringList();
3055  QFont::insertSubstitutions(fam, subs);
3056  }
3057  }
3058  settings.endGroup();
3059  }
3060 
3061  settings.endGroup();
3062  return true;
3063 }
3064 
3065 // DRSWAT
3066 
3068 {
3069 #ifndef QT_MAC_USE_COCOA
3070  return true;
3071 #else
3072  Q_Q(QApplication);
3073 #ifdef QT_MAC_USE_COCOA
3074  [[NSApp mainMenu] cancelTracking];
3075 #else
3076  HiliteMenu(0);
3077 #endif
3078 
3079  bool handle_quit = true;
3080  if (QApplicationPrivate::modalState() && [[[[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]
3081  menuLoader] quitMenuItem] isEnabled]) {
3082  int visible = 0;
3084  for(int i = 0; i < tlws.size(); ++i) {
3085  if (tlws.at(i)->isVisible())
3086  ++visible;
3087  }
3088  handle_quit = (visible <= 1);
3089  }
3090  if (handle_quit) {
3091  QCloseEvent ev;
3093  if (ev.isAccepted()) {
3094  return true;
3095  }
3096  }
3097  return false;
3098 #endif
3099 }
3100 
3102 {
3103 #if QT_MAC_USE_COCOA
3104  if (!widget)
3105  return;
3106 
3107  if (activated) {
3109  QEvent ev(QEvent::Style);
3111  }
3112  qApp->setActiveWindow(widget);
3113  } else { // deactivated
3114  if (QApplicationPrivate::active_window == widget)
3115  qApp->setActiveWindow(0);
3116  }
3117 
3120 #else
3121  Q_UNUSED(widget);
3122  Q_UNUSED(activated);
3123 #endif
3124 }
3125 
3126 
3127 void onApplicationChangedActivation( bool activated )
3128 {
3129 #if QT_MAC_USE_COCOA
3130  QApplication *app = qApp;
3131 
3132 //NSLog(@"App Changed Activation\n");
3133 
3134  if ( activated ) {
3137 
3138  if (qt_clipboard) { //manufacture an event so the clipboard can see if it has changed
3141  }
3142 
3143  if (app) {
3145  qt_sendSpontaneousEvent(app, &ev);
3146  }
3147 
3148  if (!app->activeWindow()) {
3149  OSWindowRef wp = [NSApp keyWindow];
3150  if (QWidget *tmp_w = qt_mac_find_window(wp))
3151  app->setActiveWindow(tmp_w);
3152  }
3155  } else { // de-activated
3156  QApplicationPrivate *priv = [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] qAppPrivate];
3157  if (priv->inPopupMode())
3158  app->activePopupWidget()->close();
3159  if (app) {
3161  qt_sendSpontaneousEvent(app, &ev);
3162  }
3163  app->setActiveWindow(0);
3164  }
3165 #else
3166  Q_UNUSED(activated);
3167 #endif
3168 }
3169 
3171 { }
3173 { }
3174 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool isModal() const
Definition: qwidget.h:951
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
static int keyboardInputInterval()
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
static void aboutQt(QWidget *parent, const QString &title=QString())
Displays a simple message box about Qt, with the given title and centered over parent (if parent is n...
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
static QWidget * main_widget
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
bool qt_event_remove_activate()
virtual bool macEvent(EventHandlerCallRef, EventRef)
This special event handler can be reimplemented in a subclass to receive native Macintosh events...
Definition: qwidget.cpp:9918
QPointer< QWidget > qt_last_mouse_receiver
const struct __CFString * CFStringRef
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static QColormap instance(int screen=-1)
static QWidgetList topLevelWidgets()
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
unsigned long WId
Definition: qwindowdefs.h:119
bool inPopupMode() const
static void qt_init_tablet_proximity_handler()
static bool checkInstance(const char *method)
static void setPalette(const QPalette &, const char *className=0)
Changes the default application palette to palette.
static void beep()
Sounds the bell, using the default volume and sound.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
Definition: qsettings.cpp:3460
double qreal
Definition: qglobal.h:1193
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
void qt_event_request_activate(QWidget *w)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QPointer< QWidget > widget
Q_GUI_EXPORT void qt_mac_set_press_and_hold_context(bool b)
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static void setStyle(QStyle *)
Sets the application&#39;s GUI style to style.
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
Qt::MouseButton qt_mac_get_button(EventMouseButton button)
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
static EventHandlerRef app_proc_handler
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
static bool fade_tooltip
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
#define it(className, varName)
void qt_mac_send_notification()
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool fromString(const QString &)
Sets this font to match the description descrip.
Definition: qfont.cpp:2367
static short qt_mac_window_at(int x, int y, QWidget **w=0)
QList< QWidget * > QWidgetList
Definition: qwindowdefs.h:89
void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec)
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
struct OpaqueWindowPtr * WindowRef
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
bool qt_scrollbar_jump_to_pos
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
Definition: qsettings.cpp:3089
EventLoopTimerUPP timerUPP
bool isVisible() const
Definition: qwidget.h:1005
static void initializeWidgetPaletteHash()
#define kCMDefaultDeviceNotification
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
Q_GUI_EXPORT bool qt_applefontsmoothing_enabled
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition: qimage.cpp:2032
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void qt_mac_unregister_widget()
#define kCMDeviceProfilesNotification
static void initialize()
This is an internal function.
Definition: qmime_mac.cpp:1162
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
#define SLOT(a)
Definition: qobjectdefs.h:226
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QCursor * curs
Definition: qwidget_p.h:254
void qt_mac_set_cursor(const QCursor *)
Definition: qcursor_mac.mm:108
static Qt::MouseButtons buttons
static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *)
OSMenuRef macMenu(OSMenuRef merge=0)
Definition: qmenu_mac.mm:1610
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QString fileName() const
Returns the name of the file, excluding the path.
Definition: qfileinfo.cpp:726
static void addLibraryPath(const QString &)
Prepends path to the beginning of the library path list, ensuring that it is searched for libraries f...
static QStyle * create(const QString &)
void beginGroup(const QString &prefix)
Appends prefix to the current group.
Definition: qsettings.cpp:3073
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
QRect frameGeometry
geometry of the widget relative to its parent including any window frame
Definition: qwidget.h:159
static CFStringRef toCFStringRef(const QString &str)
Definition: qcore_mac.cpp:69
static int wheel_scroll_lines
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
int last_modifiers
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
bool qt_isGenuineQWidget(const QWidget *window)
Definition: qwidget_mac.mm:473
void qt_mac_beep()
Definition: qsound_mac.mm:53
bool mkdir(const QString &dirName) const
Creates a sub-directory called dirName.
Definition: qdir.cpp:1424
void qt_init(QApplicationPrivate *priv, int)
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
struct CGImage * CGImageRef
QString absoluteFilePath() const
Returns an absolute path including the file name.
Definition: qfileinfo.cpp:534
static QWidget * active_window
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
static void cleanup()
Internal function that cleans up the font system.
Definition: qfont_mac.cpp:93
void * qt_mac_create_nsimage(const QPixmap &pm)
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
static NMRec qt_mac_notification
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QPalette palette()
Returns the application palette.
static QStyle * style()
Returns the application&#39;s style object.
EventLoopTimerRef timer
void qt_mac_update_cursor()
Definition: qcursor_mac.mm:201
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
void closePopup(QWidget *popup)
bool qt_wstate_iconified(WId)
#define qt_mac_debug_palette(x, y, z)
static int cursorFlashTime()
QString appName() const
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
QPointF flipPoint(const NSPoint &p)
static QString macMenuBarName()
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
static EventHandlerUPP tablet_proximity_UPP
bool qt_mac_quit_menu_item_enabled
Definition: qmenu_mac.mm:75
T * qobject_cast(QObject *object)
Definition: qobject.h:375
static struct @193 request_activate_pending
static QString currentPath()
Returns the absolute path of the application&#39;s current directory.
Definition: qdir.cpp:1875
QClipboard * qt_clipboard
static bool animate_ui
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
int last_button
void updateKeyMap(const MSG &msg)
WindowType
Definition: qnamespace.h:270
static EventRef request_showsheet_pending
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *)
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
void qt_event_activate_timer_callbk(EventLoopTimerRef r, void *)
static int wheelScrollLines()
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
static QDesktopWidgetImplementation * instance()
static QFont * sys_font
QStringList keys
static void cleanup()
QPointer< QWidget > widgetToGetPress
iterator Iterator
Qt-style synonym for QList::iterator.
Definition: qlist.h:278
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
bool qt_mac_can_clickThrough(const QWidget *)
Definition: qwidget_mac.mm:280
static QWidget * focus_widget
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
#define Q_Q(Class)
Definition: qglobal.h:2483
static QFont font()
Returns the default application font.
ColorGroup
Definition: qpalette.h:92
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
static bool appNoGrab
static void initialize()
static int keyboard_input_time
Q_CORE_EXPORT void qDebug(const char *,...)
static void quit()
Tells the application to exit with return code 0 (success).
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
static bool qt_mac_collapse_on_dblclick
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static void qt_mac_update_intersected_gl_widgets(QWidget *widget)
static void qt_event_request_context(QWidget *w=0, EventRef *where=0)
NSWindow * window
static QWidget * activeModalWidget()
Returns the active modal widget.
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static void qt_mac_event_release(EventRef &event)
static void setSystemFont(const QFont &font)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool qt_mac_is_macdrawer(const QWidget *)
Definition: qwidget_mac.mm:306
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
bool isAccepted() const
Definition: qcoreevent.h:307
static bool isEmpty(const char *str)
static struct @192 qt_mac_dblclick
WindowRef OSWindowRef
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QWidget * mac_mouse_grabber
Definition: qwidget_mac.mm:156
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void qt_release_app_proc_handler()
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
static void initialize()
Internal function that initializes the font system.
Definition: qfont_mac.cpp:131
#define qApp
static bool init
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
static bool qt_mac_previous_press_in_popup_mode
void qt_init_app_proc_handler()
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
static QWidgetList * popupWidgets
static void insertSubstitutions(const QString &, const QStringList &)
Inserts the list of families substituteNames into the substitution list for familyName.
Definition: qfont.cpp:2175
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
struct OpaqueControlRef * HIViewRef
static EventRef request_context_pending
void onApplicationWindowChangedActivation(QWidget *widget, bool activated)
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static bool qt_mac_no_click_through_mode
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
static void clear()
Removes all pixmaps from the cache.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)
static int mouse_double_click_time
#define kCMDefaultDeviceProfileNotification
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
QPointer< QWidget > last_widget
struct AEDesc AEDescList
Q_CORE_EXPORT void qWarning(const char *,...)
QFont qfontForThemeFont(ThemeFontID themeID)
Definition: qt_mac.cpp:56
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
Definition: qregion.cpp:4104
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
static void setKeyboardInputInterval(int)
int qt_antialiasing_threshold
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
FontHash * qt_app_fonts_hash()
static QTextCodec * codec(MYSQL *mysql)
Definition: qsql_mysql.cpp:220
static int tablet_button_state
static bool animate_combo
static void alert(QWidget *widget, int duration=0)
void qt_mac_set_app_icon(const QPixmap &pixmap)
static QStyle * app_style
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
static QPalette * sys_pal
QPointer< QWidget > topLevelAt_cache
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
static QDir temp()
Returns the system&#39;s temporary directory.
Definition: qdir.h:216
AERecord AppleEvent
UIEffect
Definition: qnamespace.h:1252
void qt_updated_rootinfo()
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object. ...
Definition: qsettings.cpp:3264
void qt_mac_send_posted_gl_updates(QWidget *widget)
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
void qt_mac_update_os_settings()
signed long OSStatus
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
static bool qt_button_down_in_content
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
QPaintDevice * qt_mac_safe_pdev
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
static EventRef request_menubarupdate_pending
struct OpaqueEventRef * EventRef
bool isEnabled() const
Definition: qwidget.h:948
const void * CFTypeRef
The QTabletEvent class contains parameters that describe a Tablet event.
Definition: qevent.h:179
static bool qt_mac_apply_settings()
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
static EventHandlerRef tablet_proximity_handler
static bool startingUp()
Returns true if an application object has not been created yet; otherwise returns false...
static void enterModal_sys(QWidget *)
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
QWidgetList * qt_modal_stack
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
static EventHandlerUPP app_proc_handlerUPP
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
void repaint()
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the ...
Definition: qwidget.cpp:10761
bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static bool animate_tooltip
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
bool bold() const
Returns true if weight() is a value greater than QFont::Normal ; otherwise returns false...
Definition: qfont.h:348
static void setColorSpec(int)
Sets the color specification for the application to spec.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
#define kThemeBrushAlternatePrimaryHighlightColor
uint qstrlen(const char *str)
Definition: qbytearray.h:79
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static Qt::KeyboardModifiers queryKeyboardModifiers()
Queries and returns the state of the modifier keys on the keyboard.
static void setCursorFlashTime(int)
bool qt_nograb()
static bool isEffectEnabled(Qt::UIEffect)
Returns true if effect is enabled; otherwise returns false.
static QWidget * activePopupWidget()
Returns the active popup widget.
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
static bool isBlockedByModal(QWidget *widget)
Returns true if widget is blocked by a modal window.
static QWidget * tryModalHelper_sys(QWidget *top)
static QInputContext * inputContext
QWidget * qt_mac_find_window(OSWindowRef)
Definition: qwidget_mac.mm:391
#define kCMDeviceUnregisteredNotification
QWidget * qt_button_down
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QMacTabletHash * qt_mac_tablet_hash()
bool hasMouseTracking() const
Definition: qwidget.h:993
void onApplicationChangedActivation(bool activated)
static QList< QMacWindowChangeEvent * > * change_events
Definition: qt_mac_p.h:157
static EventTypeSpec app_events[]
#define QT_MANGLE_NAMESPACE(name)
Definition: qglobal.h:106
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
QColor qcolorForThemeTextColor(ThemeTextColor themeColor)
Definition: qt_mac.cpp:128
void qt_mac_cancel_notification()
Q_GUI_EXPORT void qt_mac_set_dock_menu(QMenu *menu)
bool qt_tab_all_widgets
static bool animate_toolbox
int last_x
static void initialize()
bool qt_mac_app_fullscreen
struct CGPoint NSPoint
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
virtual bool macEventFilter(EventHandlerCallRef, EventRef)
static void setWheelScrollLines(int)
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
Qt::MouseButtons qt_mac_get_buttons(int buttons)
const UInt32 kEventClassQt
Definition: qt_mac_p.h:92
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
static const QMetaObjectPrivate * priv(const uint *data)
QString objectName() const
QString canonicalPath() const
Returns the canonical path, i.e.
Definition: qdir.cpp:642
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QColor qcolorForTheme(ThemeBrush brush)
Definition: qt_mac.cpp:110
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
static bool native_modal_dialog_active
QFactoryLoader * l
static bool macUpdateMenuBar()
Definition: qmenu_mac.mm:2055
OSViewRef qt_mac_nativeview_for(const QWidget *)
Definition: qwidget_mac.mm:419
static void qt_release_tablet_proximity_handler()
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
QWidget * mac_keyboard_grabber
Definition: qwidget_mac.mm:157
bool qt_mac_is_macsheet(const QWidget *)
Definition: qwidget_mac.mm:295
struct OpaqueMenuRef * MenuRef
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
static void setSystemPalette(const QPalette &pal)
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
bool copy(const QString &newName)
Copies the file currently specified by fileName() to a file called newName.
Definition: qfile.cpp:926
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60
Qt::KeyboardModifiers qt_mac_get_modifiers(int keys)
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
void qt_release_apple_event_handler()
void qt_event_request_showsheet(QWidget *w)
static void setOverrideCursor(const QCursor &)
Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is fal...
static EventRef request_window_change_pending
void qt_mac_display_change_callbk(CGDirectDisplayID, CGDisplayChangeSummaryFlags flags, void *)
static void cleanup()
Definition: qcursor.cpp:402
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
bool italic() const
Returns true if the style() of the font is not QFont::StyleNormal.
Definition: qfont.h:355
static void initialize()
Definition: qcursor.cpp:417
int pointSize() const
Returns the point size of the font.
Definition: qfont.cpp:981
struct QMacAppleEventTypeSpec app_apple_events[]
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
struct OpaqueEventHandlerCallRef * EventHandlerCallRef
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
bool qt_is_gui_used
static void setDoubleClickInterval(int)
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429
void qt_mac_send_modifiers_changed(quint32, QObject *)
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
static void qt_post_window_change_event(QWidget *widget)
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
bool use_qt_time_limit
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
static void restoreOverrideCursor()
Undoes the last setOverrideCursor().
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
static void qt_mac_read_fontsmoothing_settings()
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
static bool app_do_modal
int last_y
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
static QWidget * activeWidget
void qt_color_profile_changed(CFNotificationCenterRef, void *, CFStringRef, const void *, CFDictionaryRef)
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
bool filterEvent(void *message, long *result)
Sends message through the event filter that was set by setEventFilter().
void qt_event_send_clipboard_changed()
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
static void leaveModal_sys(QWidget *)
static void setFont(const QFont &, const char *className=0)
Changes the default application font to font.
static const KeyPair *const end
PaletteHash * qt_app_palettes_hash()
The QIconDragEvent class indicates that a main icon drag has begun.
Definition: qevent.h:372
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
static AEEventHandlerUPP app_proc_ae_handlerUPP
static int doubleClickInterval()
void qt_mac_command_set_enabled(MenuRef, UInt32, bool)
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
#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
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364
static QMenu * qt_mac_dock_menu
static bool qt_try_modal(QWidget *widget, EventRef event)
Q_GUI_EXPORT bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret)
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
static void setGlobalStrut(const QSize &)
static void setCodecForTr(QTextCodec *c)
Definition: qtextcodec.h:156
static void setEffectEnabled(Qt::UIEffect, bool enable=true)
Enables the UI effect effect if enable is true, otherwise the effect will not be used.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
static void cleanup()
bool end()
Ends painting.
Definition: qpainter.cpp:1929
void openPopup(QWidget *popup)
static bool setCurrent(const QString &path)
Sets the application&#39;s current working directory to path.
Definition: qdir.cpp:1851
static bool qt_mac_event_remove(EventRef &event)
static bool animate_menu
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
void qt_event_request_menubarupdate()
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
static void qt_mac_update_child_gl_widgets(QWidget *widget)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static int cursor_flash_time
The QFileOpenEvent class provides an event that will be sent when there is a request to open a file o...
Definition: qevent.h:644
void qt_cleanup()
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
Q_GUI_EXPORT void qt_event_request_window_change()
#define QT_VERSION
This macro expands a numeric value of the form 0xMMNNPP (MM = major, NN = minor, PP = patch) that spe...
Definition: qglobal.h:51
MouseButton
Definition: qnamespace.h:150
EventTime last_time
static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long)
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61