summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri2
-rw-r--r--src/gui/kernel/qaction.cpp6
-rw-r--r--src/gui/kernel/qapplication.cpp47
-rw-r--r--src/gui/kernel/qapplication.h4
-rw-r--r--src/gui/kernel/qapplication_mac.mm41
-rw-r--r--src/gui/kernel/qapplication_p.h4
-rw-r--r--src/gui/kernel/qapplication_qws.cpp15
-rw-r--r--src/gui/kernel/qapplication_win.cpp180
-rw-r--r--src/gui/kernel/qapplication_x11.cpp26
-rw-r--r--src/gui/kernel/qclipboard.cpp24
-rw-r--r--src/gui/kernel/qclipboard_x11.cpp2
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm14
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qcursor_win.cpp8
-rw-r--r--src/gui/kernel/qdesktopwidget_win.cpp12
-rw-r--r--src/gui/kernel/qdnd_p.h2
-rw-r--r--src/gui/kernel/qdnd_x11.cpp24
-rw-r--r--src/gui/kernel/qevent.cpp17
-rw-r--r--src/gui/kernel/qevent_p.h4
-rw-r--r--src/gui/kernel/qformlayout.cpp6
-rw-r--r--src/gui/kernel/qkeymapper.cpp2
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp32
-rw-r--r--src/gui/kernel/qkeysequence.cpp114
-rw-r--r--src/gui/kernel/qkeysequence.h4
-rw-r--r--src/gui/kernel/qlayout.cpp4
-rw-r--r--src/gui/kernel/qlayoutengine.cpp2
-rw-r--r--src/gui/kernel/qlayoutitem.cpp6
-rw-r--r--src/gui/kernel/qmime_mac.cpp123
-rw-r--r--src/gui/kernel/qmime_win.cpp10
-rw-r--r--src/gui/kernel/qpalette.cpp4
-rw-r--r--src/gui/kernel/qshortcutmap.cpp10
-rw-r--r--src/gui/kernel/qsizepolicy.h2
-rw-r--r--src/gui/kernel/qsound_qws.cpp2
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm79
-rw-r--r--src/gui/kernel/qt_mac_p.h15
-rw-r--r--src/gui/kernel/qt_x11_p.h4
-rw-r--r--src/gui/kernel/qwidget.cpp282
-rw-r--r--src/gui/kernel/qwidget.h5
-rw-r--r--src/gui/kernel/qwidget_mac.mm67
-rw-r--r--src/gui/kernel/qwidget_p.h531
-rw-r--r--src/gui/kernel/qwidget_qws.cpp17
-rw-r--r--src/gui/kernel/qwidget_win.cpp100
-rw-r--r--src/gui/kernel/qwidget_wince.cpp21
-rw-r--r--src/gui/kernel/qwidget_x11.cpp129
-rw-r--r--src/gui/kernel/qwindowdefs_win.h2
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp19
46 files changed, 1084 insertions, 941 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index cb2b014..a1b982a 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -193,7 +193,7 @@ embedded {
MENU_NIB.path = Resources
MENU_NIB.version = Versions
QMAKE_BUNDLE_DATA += MENU_NIB
- RESOURCES += mac/maccursors.qrc
+ RESOURCES += mac/macresources.qrc
LIBS += -framework AppKit
}
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index abb17d7..051b6a6 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -76,7 +76,7 @@ static QString qt_strippedText(QString s)
s.remove(i-1,1);
}
return s.trimmed();
-};
+}
QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
@@ -1151,6 +1151,8 @@ void QAction::activate(ActionEvent event)
// the checked action of an exclusive group cannot be unchecked
if (d->checked && (d->group && d->group->isExclusive()
&& d->group->checkedAction() == this)) {
+ if (guard)
+ emit triggered(true);
QMetaObject::removeGuard(&guard);
return;
}
@@ -1368,7 +1370,7 @@ QAction::MenuRole QAction::menuRole() const
void QAction::setIconVisibleInMenu(bool visible)
{
Q_D(QAction);
- if (visible != (bool)d->iconVisibleInMenu) {
+ if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) {
int oldValue = d->iconVisibleInMenu;
d->iconVisibleInMenu = visible;
// Only send data changed if we really need to.
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 4cf0ad7..4923d23 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -89,7 +89,7 @@
#include "qapplication.h"
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#include "qdatetime.h"
#include "qguifunctions_wince.h"
extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp
@@ -101,15 +101,12 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
static void initResources()
{
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
Q_INIT_RESOURCE(qstyle_wince);
#else
Q_INIT_RESOURCE(qstyle);
#endif
-#if !defined(QT_NO_DIRECT3D) && defined(Q_WS_WIN)
- Q_INIT_RESOURCE(qpaintengine_d3d);
-#endif
Q_INIT_RESOURCE(qmessagebox);
#if !defined(QT_NO_PRINTDIALOG)
Q_INIT_RESOURCE(qprintdialog);
@@ -130,7 +127,7 @@ QInputContext *QApplicationPrivate::inputContext;
bool QApplicationPrivate::quitOnLastWindowClosed = true;
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
int QApplicationPrivate::autoMaximizeThreshold = -1;
bool QApplicationPrivate::autoSipEnabled = false;
#endif
@@ -408,7 +405,7 @@ QPalette *QApplicationPrivate::set_pal = 0; // default palette set by pro
QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system
QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization
-Q_GLOBAL_STATIC(QMutex, applicationFontMutex);
+Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
QFont *QApplicationPrivate::app_font = 0; // default application font
QFont *QApplicationPrivate::sys_font = 0; // default system font
QFont *QApplicationPrivate::set_font = 0; // default font set by programmer
@@ -442,7 +439,7 @@ bool QApplicationPrivate::fade_tooltip = false;
bool QApplicationPrivate::animate_toolbox = false;
bool QApplicationPrivate::widgetCount = false;
QString* QApplicationPrivate::styleOverride = 0;
-#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
bool QApplicationPrivate::inSizeMove = false;
#endif
#ifdef QT_KEYPAD_NAVIGATION
@@ -620,13 +617,6 @@ void QApplicationPrivate::process_cmdline()
and QPixmaps. Available options are \c{raster} and \c{opengl}.
\endlist
- The Windows version of Qt supports an additional command line option, if
- Direct3D support has been compiled into Qt:
- \list
- \o -direct3d will make the Direct3D paint engine the default widget
- paint engine in Qt. \bold {This functionality is experimental.}
- \endlist
-
The X11 version of Qt supports some traditional X11 command line options:
\list
\o -display \e display, sets the X display (default is $DISPLAY).
@@ -848,6 +838,11 @@ void QApplicationPrivate::initialize()
// trigger registering of QVariant's GUI types
extern int qRegisterGuiVariant();
qRegisterGuiVariant();
+#ifndef QT_NO_STATEMACHINE
+ // trigger registering of QStateMachine's GUI types
+ extern int qRegisterGuiStateMachine();
+ qRegisterGuiStateMachine();
+#endif
is_app_running = true; // no longer starting up
@@ -866,7 +861,7 @@ void QApplicationPrivate::initialize()
q->setAttribute(Qt::AA_NativeWindows);
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#ifdef QT_AUTO_MAXIMIZE_THRESHOLD
autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD;
#else
@@ -875,7 +870,7 @@ void QApplicationPrivate::initialize()
else
autoMaximizeThreshold = -1;
#endif //QT_AUTO_MAXIMIZE_THRESHOLD
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
// Set up which span functions should be used in raster engine...
qInitDrawhelperAsm();
@@ -1069,6 +1064,11 @@ QApplication::~QApplication()
QApplicationPrivate::fade_tooltip = false;
QApplicationPrivate::widgetCount = false;
+#ifndef QT_NO_STATEMACHINE
+ // trigger unregistering of QStateMachine's GUI types
+ extern int qUnregisterGuiStateMachine();
+ qUnregisterGuiStateMachine();
+#endif
// trigger unregistering of QVariant's GUI types
extern int qUnregisterGuiVariant();
qUnregisterGuiVariant();
@@ -1227,7 +1227,7 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
the WA_InputMethodEnabled attribute set.
*/
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
void QApplication::setAutoMaximizeThreshold(const int threshold)
{
QApplicationPrivate::autoMaximizeThreshold = threshold;
@@ -1302,7 +1302,7 @@ QStyle *QApplication::style()
delete QApplicationPrivate::styleOverride;
QApplicationPrivate::styleOverride = 0;
} else {
-#if defined(Q_WS_WIN) && defined(Q_OS_WINCE)
+#if defined(Q_WS_WIN) && defined(Q_WS_WINCE)
if (qt_wince_is_smartphone() || qt_wince_is_pocket_pc())
style = QLatin1String("WindowsMobile");
else
@@ -2089,8 +2089,9 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
if(focus && QApplicationPrivate::focus_widget == focus) {
if (focus->testAttribute(Qt::WA_InputMethodEnabled)) {
QInputContext *qic = focus->inputContext();
- if (qic && focus_widget->testAttribute(Qt::WA_WState_Created))
- qic->setFocusWidget( focus_widget );
+ if (qic && focus->testAttribute(Qt::WA_WState_Created)
+ && focus->isEnabled())
+ qic->setFocusWidget(focus);
}
QFocusEvent in(QEvent::FocusIn, reason);
QPointer<QWidget> that = focus;
@@ -3496,7 +3497,7 @@ void QApplication::changeOverrideCursor(const QCursor &cursor)
It is necessary to call this function to start event handling. The main
event loop receives events from the window system and dispatches these to
the application widgets.
-
+
Generally, no user interaction can take place before calling exec(). As a
special case, modal widgets like QMessageBox can be used before calling
exec(), because modal widgets call exec() to start a local event loop.
@@ -4034,7 +4035,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
if (receiver->isWidgetType()) {
QWidget *widget = static_cast<QWidget *>(receiver);
-#if !defined(Q_OS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))
+#if !defined(Q_WS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))
// toggle HasMouse widget state on enter and leave
if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) &&
(!qApp->activePopupWidget() || qApp->activePopupWidget() == widget->window()))
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index 1d6941d..2baf6dc 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -102,7 +102,7 @@ class Q_GUI_EXPORT QApplication : public QCoreApplication
#ifndef QT_NO_STYLE_STYLESHEET
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
#endif
@@ -281,7 +281,7 @@ public Q_SLOTS:
#ifndef QT_NO_STYLE_STYLESHEET
void setStyleSheet(const QString& sheet);
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
void setAutoMaximizeThreshold(const int threshold);
int autoMaximizeThreshold() const;
void setAutoSipEnabled(const bool enabled);
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index 69302ec..6a592e4 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -154,6 +154,10 @@
#define kThemeBrushAlternatePrimaryHighlightColor -5
#endif
+#define kCMDeviceUnregisteredNotification CFSTR("CMDeviceUnregisteredNotification")
+#define kCMDefaultDeviceNotification CFSTR("CMDefaultDeviceNotification")
+#define kCMDeviceProfilesNotification CFSTR("CMDeviceProfilesNotification")
+#define kCMDefaultDeviceProfileNotification CFSTR("CMDefaultDeviceProfileNotification")
QT_BEGIN_NAMESPACE
@@ -1040,11 +1044,29 @@ void qt_release_app_proc_handler()
#endif
}
+void qt_color_profile_changed(CFNotificationCenterRef, void *, CFStringRef, const void *,
+ CFDictionaryRef)
+{
+ QCoreGraphicsPaintEngine::cleanUpMacColorSpaces();
+}
/* platform specific implementations */
void qt_init(QApplicationPrivate *priv, int)
{
if (qt_is_gui_used) {
CGDisplayRegisterReconfigurationCallback(qt_mac_display_change_callbk, 0);
+ CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
+ CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
+ kCMDeviceUnregisteredNotification, 0,
+ CFNotificationSuspensionBehaviorDeliverImmediately);
+ CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
+ kCMDefaultDeviceNotification, 0,
+ CFNotificationSuspensionBehaviorDeliverImmediately);
+ CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
+ kCMDeviceProfilesNotification, 0,
+ CFNotificationSuspensionBehaviorDeliverImmediately);
+ CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
+ kCMDefaultDeviceProfileNotification, 0,
+ CFNotificationSuspensionBehaviorDeliverImmediately);
ProcessSerialNumber psn;
if (GetCurrentProcess(&psn) == noErr) {
// Jambi needs to transform itself since most people aren't "used"
@@ -1196,10 +1218,6 @@ void qt_init(QApplicationPrivate *priv, int)
[qtMenuLoader release];
}
#endif
- if (QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
- extern void qt_mac_set_native_menubar(bool);
- qt_mac_set_native_menubar(false);
- }
// Register for Carbon tablet proximity events on the event monitor target.
// This means that we should receive proximity events even when we aren't the active application.
if (!tablet_proximity_handler) {
@@ -1228,6 +1246,12 @@ void qt_release_apple_event_handler()
void qt_cleanup()
{
CGDisplayRemoveReconfigurationCallback(qt_mac_display_change_callbk, 0);
+ CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
+ CFNotificationCenterRemoveObserver(center, qApp, kCMDeviceUnregisteredNotification, 0);
+ CFNotificationCenterRemoveObserver(center, qApp, kCMDefaultDeviceNotification, 0);
+ CFNotificationCenterRemoveObserver(center, qApp, kCMDeviceProfilesNotification, 0);
+ CFNotificationCenterRemoveObserver(center, qApp, kCMDefaultDeviceProfileNotification, 0);
+
#ifndef QT_MAC_USE_COCOA
qt_release_app_proc_handler();
if (app_proc_handlerUPP) {
@@ -1642,15 +1666,6 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
bool inNonClientArea = false;
GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0,
sizeof(where), 0, &where);
- if(ekind == kEventMouseMoved && qt_mac_app_fullscreen &&
- QApplication::desktop()->screenNumber(QPoint(where.h, where.v)) ==
- QApplication::desktop()->primaryScreen()) {
- if(where.v <= 0)
- ShowMenuBar();
- else if(qt_mac_window_at(where.h, where.v, 0) != inMenuBar)
- HideMenuBar();
- }
-
#if defined(DEBUG_MOUSE_MAPS)
const char *edesc = 0;
switch(ekind) {
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 7487f0a..7e97418 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -219,7 +219,7 @@ public:
#endif
static bool quitOnLastWindowClosed;
static void emitLastWindowClosed();
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
static int autoMaximizeThreshold;
static bool autoSipEnabled;
#endif
@@ -358,7 +358,7 @@ public:
#ifdef Q_WS_MAC
static bool native_modal_dialog_active;
#endif
-#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
static bool inSizeMove;
#endif
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index 018440f..ea52e11 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -194,15 +194,15 @@ QString qws_dataDir()
static QString result;
if (!result.isEmpty())
return result;
- QByteArray dataDir = QString(QLatin1String("/tmp/qtembedded-%1")).arg(qws_display_id).toLocal8Bit();
- if (mkdir(dataDir, 0700)) {
+ QByteArray dataDir = QString::fromLatin1("/tmp/qtembedded-%1").arg(qws_display_id).toLocal8Bit();
+ if (QT_MKDIR(dataDir, 0700)) {
if (errno != EEXIST) {
qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData());
}
}
- struct stat buf;
- if (lstat(dataDir, &buf))
+ QT_STATBUF buf;
+ if (QT_LSTAT(dataDir, &buf))
qFatal("stat failed for Qt for Embedded Linux data directory: %s", dataDir.constData());
if (!S_ISDIR(buf.st_mode))
@@ -215,7 +215,7 @@ QString qws_dataDir()
if ((buf.st_mode & 0677) != 0600)
qFatal("Qt for Embedded Linux data directory has incorrect permissions: %s", dataDir.constData());
#endif
- dataDir += "/";
+ dataDir += '/';
result = QString::fromLocal8Bit(dataDir);
return result;
@@ -224,7 +224,7 @@ QString qws_dataDir()
// Get the filename of the pipe Qt for Embedded Linux uses for server/client comms
Q_GUI_EXPORT QString qws_qtePipeFilename()
{
- return (qws_dataDir() + QString(QLatin1String(QTE_PIPE)).arg(qws_display_id));
+ return (qws_dataDir() + QString::fromLatin1(QTE_PIPE).arg(qws_display_id));
}
static void setMaxWindowRect(const QRect &rect)
@@ -2280,7 +2280,8 @@ void qt_init(QApplicationPrivate *priv, int type)
qt_appType = QApplication::Type(type);
qws_single_process = true;
QWSServer::startup(flags);
- setenv("QWS_DISPLAY", qws_display_spec.constData(), 0);
+ if (!display) // if not already set
+ qputenv("QWS_DISPLAY", qws_display_spec);
}
if(qt_is_gui_used) {
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 239ee14..b21eb36 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#include "qguifunctions_wince.h"
#include "qmenubar.h"
extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp
@@ -48,7 +48,7 @@ extern bool qt_wince_is_smartphone(); //defined in qguifunctions_wince.c
extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.cpp
#endif
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
#include <windowsm.h>
#include <tpcshell.h>
#endif
@@ -106,7 +106,7 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
#include <winuser.h>
#if !defined(WINABLEAPI)
-# if defined(Q_OS_WINCE)
+# if defined(Q_WS_WINCE)
# include <bldver.h>
# endif
# include <winable.h>
@@ -155,7 +155,7 @@ static PtrFlashWindowEx pFlashWindowEx = 0;
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#ifndef SHRG_RETURNCMD
struct SHRGINFO {
DWORD cbSize;
@@ -266,7 +266,7 @@ Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
#define MK_XBUTTON2 0x0040
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam))
#endif
@@ -376,11 +376,6 @@ QRgb qt_colorref2qrgb(COLORREF col)
Internal variables and functions
*****************************************************************************/
-extern Q_CORE_EXPORT char theAppName[];
-extern Q_CORE_EXPORT char appFileName[];
-extern Q_CORE_EXPORT HINSTANCE appInst; // handle to app instance
-extern Q_CORE_EXPORT HINSTANCE appPrevInst; // handle to prev app instance
-extern Q_CORE_EXPORT int appCmdShow; // main window show command
static HWND curWin = 0; // current window
static HDC displayDC = 0; // display device context
@@ -497,7 +492,7 @@ static void qt_set_windows_color_resources()
pal.setColor(QPalette::HighlightedText,
QColor(qt_colorref2qrgb(GetSysColor(COLOR_HIGHLIGHTTEXT))));
-#if defined(Q_OS_WINCE)
+#if defined(Q_WS_WINCE)
// ### hardcoded until I find out how to get it from the system settings.
pal.setColor(QPalette::LinkVisited, pal.highlight().color().dark(150));
pal.setColor(QPalette::Link, pal.highlight().color().light(130));
@@ -573,7 +568,7 @@ static void qt_set_windows_color_resources()
static void qt_set_windows_font_resources()
{
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
QFont menuFont;
QFont messageFont;
QFont statusFont;
@@ -625,11 +620,18 @@ static void qt_set_windows_font_resources()
smallerFont.setPointSize(systemFont.pointSize()-1);
QApplication::setFont(smallerFont, "QTabBar");
}
-#endif// Q_OS_WINCE
+#endif// Q_WS_WINCE
}
static void qt_win_read_cleartype_settings()
{
+#ifdef Q_OS_WINCE
+ UINT result;
+ BOOL ok;
+ ok = SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &result, 0);
+ if (ok)
+ qt_cleartype_enabled = result;
+#else
QT_WA({
UINT result;
BOOL ok;
@@ -643,6 +645,7 @@ static void qt_win_read_cleartype_settings()
if (ok)
qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
});
+#endif
}
@@ -745,9 +748,6 @@ void qt_init(QApplicationPrivate *priv, int)
appNoGrab = !appNoGrab;
else
#endif // QT_DEBUG
- if (qstrcmp(argv[i], "-direct3d") == 0)
- QApplication::setAttribute(Qt::AA_MSWindowsUseDirect3DByDefault);
- else
argv[j++] = argv[i];
}
if(j < priv->argc) {
@@ -755,21 +755,12 @@ void qt_init(QApplicationPrivate *priv, int)
priv->argc = j;
}
- // Get the application name/instance if qWinMain() was not invoked
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// No message boxes but important ones
SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
#endif
- if (appInst == 0) {
- QT_WA({
- appInst = GetModuleHandle(0);
- }, {
- appInst = GetModuleHandleA(0);
- });
- }
-
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// Initialize OLE/COM
// S_OK means success and S_FALSE means that it has already
// been initialized
@@ -781,7 +772,7 @@ void qt_init(QApplicationPrivate *priv, int)
#endif
// Misc. initialization
-#if defined(QT_DEBUG) && !defined(Q_OS_WINCE)
+#if defined(QT_DEBUG) && !defined(Q_WS_WINCE)
GdiSetBatchLimit(1);
#endif
@@ -793,9 +784,9 @@ void qt_init(QApplicationPrivate *priv, int)
#ifndef QT_NO_CURSOR
QCursorData::initialize();
#endif
- qApp->setObjectName(QLatin1String(theAppName));
+ qApp->setObjectName(priv->appName());
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
// default font
HFONT hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
QFont f(QLatin1String("MS Sans Serif"),8);
@@ -815,7 +806,7 @@ void qt_init(QApplicationPrivate *priv, int)
&& f.family() == QLatin1String("MS Shell Dlg"))
f.setFamily(QLatin1String("MS Shell Dlg 2"));
QApplicationPrivate::setSystemFont(f);
-#else //Q_OS_WINCE
+#else //Q_WS_WINCE
LOGFONT lf;
HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT);
int result = 0;
@@ -823,7 +814,7 @@ void qt_init(QApplicationPrivate *priv, int)
QFont font = qt_LOGFONTtoQFont(lf, true);
if (result)
QApplicationPrivate::setSystemFont(font);
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
// QFont::locale_init(); ### Uncomment when it does something on Windows
@@ -880,7 +871,7 @@ void qt_cleanup()
delete QApplicationPrivate::inputContext;
QApplicationPrivate::inputContext = 0;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// Deinitialize OLE/COM
OleUninitialize();
#endif
@@ -891,12 +882,6 @@ void qt_cleanup()
Platform specific global and internal functions
*****************************************************************************/
-Q_GUI_EXPORT int qWinAppCmdShow() // get main window show command
-{
- return appCmdShow;
-}
-
-
Q_GUI_EXPORT HDC qt_win_display_dc() // get display DC
{
Q_ASSERT(qApp && qApp->thread() == QThread::currentThread());
@@ -928,7 +913,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (flags & Qt::MSWindowsOwnDC) {
cname = QLatin1String("QWidgetOwnDC");
style = CS_DBLCLKS;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
style |= CS_OWNDC;
#endif
icon = true;
@@ -943,14 +928,14 @@ const QString qt_reg_winclass(QWidget *w) // register window class
} else {
cname = QLatin1String("QTool");
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
style |= CS_SAVEBITS;
#endif
icon = false;
} else if (type == Qt::Popup) {
cname = QLatin1String("QPopup");
style = CS_DBLCLKS;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
style |= CS_SAVEBITS;
#endif
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
@@ -963,7 +948,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
icon = true;
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// force CS_OWNDC when the GL graphics system is
// used as the default renderer
if (qt_win_owndc_required)
@@ -978,8 +963,8 @@ const QString qt_reg_winclass(QWidget *w) // register window class
wchar_t uniqueAppID[256];
GetModuleFileNameW(0, uniqueAppID, 255);
cname = QString::number(RegisterWindowMessageW(
- (const wchar_t *) QString::fromUtf16((const ushort *)uniqueAppID).toLower().replace(QString(QString::fromLatin1("\\")),
- QString(QString::fromLatin1("_"))).utf16()));
+ (const wchar_t *) QString::fromUtf16((const ushort *)uniqueAppID).toLower().replace(QLatin1Char('\\'),
+ QLatin1Char('_')).utf16()));
#endif
// since multiple Qt versions can be used in one process
@@ -992,11 +977,11 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (classExists == -1) {
QT_WA({
WNDCLASS wcinfo;
- classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (TCHAR*)cname.utf16(), &wcinfo);
+ classExists = GetClassInfo(qWinAppInst(), (TCHAR*)cname.utf16(), &wcinfo);
classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
}, {
WNDCLASSA wcinfo;
- classExists = GetClassInfoA((HINSTANCE)qWinAppInst(), cname.toLatin1(), &wcinfo);
+ classExists = GetClassInfoA(qWinAppInst(), cname.toLatin1(), &wcinfo);
classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
});
}
@@ -1008,7 +993,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
return cname;
ATOM atom;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
HBRUSH bgBrush = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
QT_WA({
WNDCLASS wc;
@@ -1016,9 +1001,9 @@ const QString qt_reg_winclass(QWidget *w) // register window class
wc.lpfnWndProc = (WNDPROC)QtWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
+ wc.hInstance = qWinAppInst();
if (icon) {
- wc.hIcon = LoadIcon(appInst, L"IDI_ICON1");
+ wc.hIcon = LoadIcon(qWinAppInst(), L"IDI_ICON1");
if (!wc.hIcon)
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
} else {
@@ -1035,9 +1020,9 @@ const QString qt_reg_winclass(QWidget *w) // register window class
wc.lpfnWndProc = (WNDPROC)QtWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
+ wc.hInstance = qWinAppInst();
if (icon) {
- wc.hIcon = LoadIconA(appInst, (char*)"IDI_ICON1");
+ wc.hIcon = LoadIconA(qWinAppInst(), (char*)"IDI_ICON1");
if (!wc.hIcon)
wc.hIcon = LoadIconA(0, (char*)IDI_APPLICATION);
} else {
@@ -1056,9 +1041,9 @@ const QString qt_reg_winclass(QWidget *w) // register window class
wc.lpfnWndProc = (WNDPROC)QtWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
+ wc.hInstance = qWinAppInst();
if (icon) {
- wc.hIcon = LoadIcon(appInst, L"IDI_ICON1");
+ wc.hIcon = LoadIcon(qWinAppInst(), L"IDI_ICON1");
// if (!wc.hIcon)
// wc.hIcon = LoadIcon(0, IDI_APPLICATION);
} else {
@@ -1092,9 +1077,9 @@ static void unregWinClasses()
QHash<QString, int>::ConstIterator it = hash->constBegin();
while (it != hash->constEnd()) {
QT_WA({
- UnregisterClass((TCHAR*)it.key().utf16(), (HINSTANCE)qWinAppInst());
+ UnregisterClass((TCHAR*)it.key().utf16(), qWinAppInst());
} , {
- UnregisterClassA(it.key().toLatin1(), (HINSTANCE)qWinAppInst());
+ UnregisterClassA(it.key().toLatin1(), qWinAppInst());
});
++it;
}
@@ -1129,7 +1114,7 @@ void qWinRequestConfig(WId id, int req, int x, int y, int w, int h)
configRequests->append(r); // store request in queue
}
-Q_GUI_EXPORT void qWinProcessConfigRequests() // perform requests in queue
+static void qWinProcessConfigRequests() // perform requests in queue
{
if (!configRequests)
return;
@@ -1381,7 +1366,7 @@ void QApplication::winFocus(QWidget *widget, bool gotFocus)
&& (QApplicationPrivate::active_window->windowType() == Qt::Dialog)) {
// raise the entire application, not just the dialog
QWidget* mw = QApplicationPrivate::active_window;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
while(mw->parentWidget() && (mw->windowType() == Qt::Dialog))
mw = mw->parentWidget()->window();
if (mw->testAttribute(Qt::WA_WState_Created) && mw != QApplicationPrivate::active_window)
@@ -1431,8 +1416,9 @@ static bool qt_is_translatable_mouse_event(UINT message)
return (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST ||
message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK)
&& message != WM_MOUSEWHEEL
+ && message != WM_MOUSEHWHEEL
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
|| message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK
#endif
;
@@ -1472,7 +1458,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
msg.pt.y = GET_Y_LPARAM(lParam);
// If it's a non-client-area message the coords are screen coords, otherwise they are
// client coords.
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
if (message < WM_NCMOUSEMOVE || message > WM_NCMBUTTONDBLCLK)
#endif
ClientToScreen(msg.hwnd, &msg.pt);
@@ -1502,7 +1488,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
if (imeParentWnd && QApplication::activePopupWidget()
&& (message == WM_MBUTTONDOWN || message == WM_XBUTTONDOWN
|| message == WM_LBUTTONDOWN || message == WM_RBUTTONDOWN
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
|| message == WM_NCMBUTTONDOWN || message == WM_NCLBUTTONDOWN
|| message == WM_NCRBUTTONDOWN)) {
#else
@@ -1512,7 +1498,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
switch (message) {
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_QUERYENDSESSION: {
if (sm_smActive) // bogus message from windows
RETURN(true);
@@ -1563,7 +1549,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#endif
case WM_SETTINGCHANGE:
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
// CE SIP hide/show
if (wParam == SPI_SETSIPINFO) {
QResizeEvent re(QSize(0, 0), QSize(0, 0)); // Calculated by QDesktopWidget
@@ -1665,7 +1651,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
if (!qt_tabletChokeMouse) {
result = widget->translateMouseEvent(msg); // mouse event
-#if defined(Q_OS_WINCE) && !defined(QT_NO_CONTEXTMENU)
+#if defined(Q_WS_WINCE) && !defined(QT_NO_CONTEXTMENU)
if (message == WM_LBUTTONDOWN && widget != qApp->activePopupWidget()) {
QWidget* alienWidget = widget;
if ((alienWidget != qApp->activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) {
@@ -1781,6 +1767,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
result = widget->translateWheelEvent(msg);
break;
@@ -1911,7 +1898,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_NCHITTEST:
if (widget->isWindow()) {
QPoint pos = widget->mapFromGlobal(QPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
@@ -1930,7 +1917,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#endif
case WM_SYSCOMMAND: {
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
bool window_state_change = false;
Qt::WindowStates oldstate = Qt::WindowStates(widget->dataPtr()->window_state);
// MSDN:In WM_SYSCOMMAND messages, the four low-order bits of the wParam parameter are
@@ -1958,7 +1945,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
QHideEvent e;
qt_sendSpontaneousEvent(widget, &e);
widget->hideChildren(true);
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
const QString title = widget->windowIconText();
if (!title.isEmpty())
widget->setWindowTitle_helper(title);
@@ -1981,7 +1968,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
widget->showChildren(true);
QShowEvent e;
qt_sendSpontaneousEvent(widget, &e);
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
const QString title = widget->windowTitle();
if (!title.isEmpty())
widget->setWindowTitle_helper(title);
@@ -2031,7 +2018,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
result = widget->translatePaintEvent(msg);
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_ENTERSIZEMOVE:
autoCaptureWnd = hwnd;
QApplicationPrivate::inSizeMove = true;
@@ -2086,9 +2073,13 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// WM_ACTIVATEAPP handles the "true" false case, as this is only when the application
// loses focus. Doing it here would result in the widget getting focus to not know
// where it got it from; it would simply get a 0 value as the old focus widget.
+#ifndef Q_WS_WINCE_WM
if (!(widget->windowState() & Qt::WindowMinimized)) {
// Ignore the activate message send by WindowsXP to a minimized window
-#ifdef Q_OS_WINCE_WM
+#else
+ {
+ if (widget->windowState() & Qt::WindowMinimized)
+ widget->dataPtr()->window_state &= ~Qt::WindowMinimized;
if (widget->windowState() & Qt::WindowFullScreen)
qt_wince_hide_taskbar(widget->winId());
#endif
@@ -2115,7 +2106,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_MOUSEACTIVATE:
if (widget->window()->windowType() == Qt::Tool) {
QWidget *w = widget;
@@ -2204,7 +2195,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
result = false;
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_WINDOWPOSCHANGING:
{
result = false;
@@ -2320,7 +2311,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_CHANGECBCHAIN:
case WM_DRAWCLIPBOARD:
#endif
@@ -2427,7 +2418,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#endif // QT_NO_TABLETEVENT
}
break;
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
case WM_SETFOCUS: {
HIMC hC;
hC = ImmGetContext(hwnd);
@@ -2473,7 +2464,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
widget->update();
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_INPUTLANGCHANGE: {
char info[7];
if (!GetLocaleInfoA(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) {
@@ -2671,19 +2662,20 @@ bool qt_try_modal(QWidget *widget, MSG *msg, int& ret)
int type = msg->message;
bool block_event = false;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
if (type != WM_NCHITTEST)
#endif
if ((type >= WM_MOUSEFIRST && type <= WM_MOUSELAST) ||
type == WM_MOUSEWHEEL || type == (int)WM95_MOUSEWHEEL ||
+ type == WM_MOUSEHWHEEL ||
type == WM_MOUSELEAVE ||
(type >= WM_KEYFIRST && type <= WM_KEYLAST)
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
|| type == WM_NCMOUSEMOVE
#endif
) {
if (type == WM_MOUSEMOVE
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
|| type == WM_NCMOUSEMOVE
#endif
) {
@@ -2701,7 +2693,7 @@ bool qt_try_modal(QWidget *widget, MSG *msg, int& ret)
} else if (type == WM_CLOSE) {
block_event = true;
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){
if (!top->isActiveWindow()) {
top->activateWindow();
@@ -2859,7 +2851,7 @@ static const ushort mouseTbl[] = {
WM_XBUTTONUP, QEvent::MouseButtonRelease, Qt::XButton1,
WM_XBUTTONDBLCLK, QEvent::MouseButtonDblClick, Qt::XButton1,
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
WM_NCMOUSEMOVE, QEvent::NonClientAreaMouseMove, 0,
WM_NCLBUTTONDOWN, QEvent::NonClientAreaMouseButtonPress, Qt::LeftButton,
WM_NCLBUTTONUP, QEvent::NonClientAreaMouseButtonRelease, Qt::LeftButton,
@@ -3176,10 +3168,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
if (popupButtonFocus) {
target = popupButtonFocus;
} else if (popupChild) {
- // forward mouse events to the popup child. mouse move events
- // are only forwarded to popup children that enable mouse tracking.
- if (type != QEvent::MouseMove || popupChild->hasMouseTracking())
- target = popupChild;
+ target = popupChild;
}
pos = target->mapFromGlobal(globalPos);
@@ -3290,12 +3279,12 @@ bool QETWidget::translateWheelEvent(const MSG &msg)
state = translateButtonState(GET_KEYSTATE_WPARAM(msg.wParam), 0, 0);
int delta;
- if (msg.message == WM_MOUSEWHEEL)
+ if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL)
delta = (short) HIWORD (msg.wParam);
else
delta = (int) msg.wParam;
- Qt::Orientation orient = (state&Qt::AltModifier
+ Qt::Orientation orient = (msg.message == WM_MOUSEHWHEEL || state&Qt::AltModifier
#if 0
// disabled for now - Trenton's one-wheel mouse makes trouble...
// "delta" for usual wheels is +-120. +-240 seems to indicate
@@ -3309,6 +3298,13 @@ bool QETWidget::translateWheelEvent(const MSG &msg)
#endif
) ? Qt::Horizontal : Qt::Vertical;
+ // according to the MSDN documentation on WM_MOUSEHWHEEL:
+ // a positive value indicates that the wheel was rotated to the right;
+ // a negative value indicates that the wheel was rotated to the left.
+ // Qt defines this value as the exact opposite, so we have to flip the value!
+ if (msg.message == WM_MOUSEHWHEEL)
+ delta = -delta;
+
QPoint globalPos;
globalPos.rx() = (short)LOWORD (msg.lParam);
@@ -3661,7 +3657,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
WORD b = HIWORD(msg.lParam);
QSize oldSize = size();
QSize newSize(a, b);
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
if (isFullScreen() && (oldSize.width() == newSize.height()) && (oldSize.height() == newSize.width()))
qt_wince_hide_taskbar(internalWinId());
#endif
@@ -3673,7 +3669,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
// Capture SIZE_MINIMIZED without preceding WM_SYSCOMMAND
// (like Windows+M)
if (msg.wParam == SIZE_MINIMIZED && !isMinimized()) {
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
const QString title = windowIconText();
if (!title.isEmpty())
d_func()->setWindowTitle_helper(title);
@@ -3685,7 +3681,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
hideChildren(true);
}
} else if (msg.wParam != SIZE_MINIMIZED && isMinimized()) {
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
const QString title = windowTitle();
if (!title.isEmpty())
d_func()->setWindowTitle_helper(title);
@@ -3731,7 +3727,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
QPoint oldPos = geometry().topLeft();
QPoint newCPos(a, b);
// Ignore silly Windows move event to wild pos after iconify.
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
if (!IsIconic(internalWinId()) && newCPos != oldPos) {
#endif
cr.moveTopLeft(newCPos);
@@ -3743,7 +3739,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
QMoveEvent * e = new QMoveEvent(newCPos, oldPos);
QApplication::postEvent(this, e);
}
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
}
#endif
}
@@ -3785,7 +3781,7 @@ int QApplication::cursorFlashTime()
void QApplication::setDoubleClickInterval(int ms)
{
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
SetDoubleClickTime(ms);
#endif
QApplicationPrivate::mouse_double_click_time = ms;
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 12155f0..1473421 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -294,6 +294,10 @@ static const char * x11_atomnames = {
// XEMBED
"_XEMBED\0"
"_XEMBED_INFO\0"
+
+ "Wacom Stylus\0"
+ "Wacom Cursor\0"
+ "Wacom Eraser\0"
};
Q_GUI_EXPORT QX11Data *qt_x11Data = 0;
@@ -1579,6 +1583,7 @@ static PtrWacomConfigOpenDevice ptrWacomConfigOpenDevice = 0;
static PtrWacomConfigGetRawParam ptrWacomConfigGetRawParam = 0;
static PtrWacomConfigCloseDevice ptrWacomConfigCloseDevice = 0;
static PtrWacomConfigTerm ptrWacomConfigTerm = 0;
+Q_GLOBAL_STATIC(QByteArray, wacomDeviceName)
#endif
#endif
@@ -2356,13 +2361,6 @@ void qt_init(QApplicationPrivate *priv, int,
XAxisInfoPtr a;
XDevice *dev = 0;
-#if !defined(Q_OS_IRIX)
- // XFree86 divides a stylus and eraser into 2 devices, so we must do for both...
- const QString XFREENAMESTYLUS = QLatin1String("stylus");
- const QString XFREENAMEPEN = QLatin1String("pen");
- const QString XFREENAMEERASER = QLatin1String("eraser");
-#endif
-
if (X11->ptrXListInputDevices) {
devices = X11->ptrXListInputDevices(X11->display, &ndev);
if (!devices)
@@ -2377,18 +2375,19 @@ void qt_init(QApplicationPrivate *priv, int,
gotStylus = false;
gotEraser = false;
- QString devName = QString::fromLocal8Bit(devs->name).toLower();
#if defined(Q_OS_IRIX)
+ QString devName = QString::fromLocal8Bit(devs->name).toLower();
if (devName == QLatin1String(WACOM_NAME)) {
deviceType = QTabletEvent::Stylus;
gotStylus = true;
}
#else
- if (devName.startsWith(XFREENAMEPEN)
- || devName.startsWith(XFREENAMESTYLUS)) {
+ if (devs->type == ATOM(XWacomStylus)) {
deviceType = QTabletEvent::Stylus;
+ if (wacomDeviceName()->isEmpty())
+ wacomDeviceName()->append(devs->name);
gotStylus = true;
- } else if (devName.startsWith(XFREENAMEERASER)) {
+ } else if (devs->type == ATOM(XWacomEraser)) {
deviceType = QTabletEvent::XFreeEraser;
gotEraser = true;
}
@@ -2979,7 +2978,7 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
void QApplication::syncX()
{
if (X11->display)
- XSync(X11->display, False); // don't discard events
+ XSync(X11->display, False); // don't discard events
}
@@ -4484,8 +4483,7 @@ void fetchWacomToolId(int &deviceType, qint64 &serialId)
WACOMCONFIG *config = ptrWacomConfigInit(X11->display, 0);
if (config == 0)
return;
- const char *name = "stylus"; // TODO get this from the X config instead (users may have called it differently)
- WACOMDEVICE *device = ptrWacomConfigOpenDevice (config, name);
+ WACOMDEVICE *device = ptrWacomConfigOpenDevice (config, wacomDeviceName()->constData());
if (device == 0)
return;
unsigned keys[1];
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index bab3449..96e9580 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -50,6 +50,7 @@
#include "qvariant.h"
#include "qbuffer.h"
#include "qimage.h"
+#include "qtextcodec.h"
QT_BEGIN_NAMESPACE
@@ -276,11 +277,12 @@ QClipboard::~QClipboard()
*/
QString QClipboard::text(QString &subtype, Mode mode) const
{
- const QMimeData *data = mimeData(mode);
+ const QMimeData *const data = mimeData(mode);
if (!data)
return QString();
+
+ const QStringList formats = data->formats();
if (subtype.isEmpty()) {
- QStringList formats = data->formats();
if (formats.contains(QLatin1String("text/plain")))
subtype = QLatin1String("plain");
else {
@@ -289,13 +291,21 @@ QString QClipboard::text(QString &subtype, Mode mode) const
subtype = formats.at(i).mid(5);
break;
}
+ if (subtype.isEmpty())
+ return QString();
}
- }
- if (subtype.isEmpty())
+ } else if (!formats.contains(QLatin1String("text/") + subtype)) {
return QString();
- if (subtype == QLatin1String("plain"))
- return data->text();
- return QString::fromUtf8(data->data(QLatin1String("text/") + subtype));
+ }
+
+ const QByteArray rawData = data->data(QLatin1String("text/") + subtype);
+
+ QTextCodec* codec = QTextCodec::codecForMib(106); // utf-8 is default
+ if (subtype == QLatin1String("html"))
+ codec = QTextCodec::codecForHtml(rawData, codec);
+ else
+ codec = QTextCodec::codecForUtfText(rawData, codec);
+ return codec->toUnicode(rawData);
}
/*!
diff --git a/src/gui/kernel/qclipboard_x11.cpp b/src/gui/kernel/qclipboard_x11.cpp
index 089cc43..d7eb111 100644
--- a/src/gui/kernel/qclipboard_x11.cpp
+++ b/src/gui/kernel/qclipboard_x11.cpp
@@ -786,7 +786,7 @@ static Atom send_selection(QClipboardData *d, Atom target, Window window, Atom p
QByteArray data;
QByteArray fmt = X11->xdndAtomToString(target);
- if (fmt.isEmpty() || !QInternalMimeData::hasFormatHelper(QString::fromAscii(fmt), d->source())) { // Not a MIME type we have
+ if (fmt.isEmpty()) { // Not a MIME type we have
DEBUG("QClipboard: send_selection(): converting to type '%s' is not supported", fmt.data());
return XNone;
}
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index f1a7f39..838f751 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -196,6 +196,7 @@ extern "C" {
if (self) {
[self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
}
+ composingText = new QString();
composing = false;
sendKeyEvents = true;
currentCustomTypes = 0;
@@ -419,6 +420,7 @@ extern "C" {
- (void)dealloc
{
+ delete composingText;
[[NSNotificationCenter defaultCenter] removeObserver:self];
delete currentCustomTypes;
[self unregisterDraggedTypes];
@@ -1009,7 +1011,7 @@ extern "C" {
- (void) insertText:(id)aString
{
- if (composing) {
+ if ([aString length]) {
// Send the commit string to the widget.
QString commitText;
if ([aString isKindOfClass:[NSAttributedString class]]) {
@@ -1023,6 +1025,7 @@ extern "C" {
e.setCommitString(commitText);
qt_sendSpontaneousEvent(qwidget, &e);
}
+ composingText->clear();
}
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
@@ -1076,12 +1079,21 @@ extern "C" {
attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
0, composingLength, format);
}
+ *composingText = qtText;
QInputMethodEvent e(qtText, attrs);
qt_sendSpontaneousEvent(qwidget, &e);
+ if (!composingLength)
+ composing = false;
}
- (void) unmarkText
{
+ if (composing) {
+ QInputMethodEvent e;
+ e.setCommitString(*composingText);
+ qt_sendSpontaneousEvent(qwidget, &e);
+ }
+ composingText->clear();
composing = false;
}
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 527b1a6..be4501f3 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -84,6 +84,7 @@ Q_GUI_EXPORT
bool composing;
int composingLength;
bool sendKeyEvents;
+ QString *composingText;
QStringList *currentCustomTypes;
}
- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp
index 85d5a11..a475882 100644
--- a/src/gui/kernel/qcursor_win.cpp
+++ b/src/gui/kernel/qcursor_win.cpp
@@ -66,7 +66,7 @@ QCursorData::~QCursorData()
{
delete bm;
delete bmm;
-#if !defined(Q_OS_WINCE) || defined(GWES_ICONCURS)
+#if !defined(Q_WS_WINCE) || defined(GWES_ICONCURS)
if (hcurs)
DestroyCursor(hcurs);
#endif
@@ -129,7 +129,7 @@ extern HBITMAP qt_createIconMask(const QBitmap &bitmap);
static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy)
{
HCURSOR cur = 0;
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
QBitmap mask = pixmap.mask();
if (mask.isNull()) {
mask = QBitmap(pixmap.size());
@@ -407,7 +407,7 @@ void QCursorData::update()
}
int n = qMax(1, bbits.width() / 8);
int h = bbits.height();
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
uchar* xBits = new uchar[h * n];
uchar* xMask = new uchar[h * n];
int x = 0;
@@ -430,7 +430,7 @@ void QCursorData::update()
xBits, xMask);
delete [] xBits;
delete [] xMask;
-#elif defined(GWES_ICONCURS) // Q_OS_WINCE
+#elif defined(GWES_ICONCURS) // Q_WS_WINCE
// Windows CE only supports fixed cursor size.
int sysW = GetSystemMetrics(SM_CXCURSOR);
int sysH = GetSystemMetrics(SM_CYCURSOR);
diff --git a/src/gui/kernel/qdesktopwidget_win.cpp b/src/gui/kernel/qdesktopwidget_win.cpp
index 725e985..b9e2e1e 100644
--- a/src/gui/kernel/qdesktopwidget_win.cpp
+++ b/src/gui/kernel/qdesktopwidget_win.cpp
@@ -45,7 +45,7 @@
#include "qlibrary.h"
#include <qvector.h>
#include <limits.h>
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#include <sipapi.h>
#endif
#include "qwidget_p.h"
@@ -92,7 +92,7 @@ QVector<QRect> *QDesktopWidgetPrivate::rects = 0;
QVector<QRect> *QDesktopWidgetPrivate::workrects = 0;
static int screen_number = 0;
int QDesktopWidgetPrivate::refcount = 0;
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
// Use SIP information, if available
// SipGetInfo is not supported by SSDK (no definition!).
static inline void qt_get_sip_info(QRect &rect)
@@ -208,7 +208,7 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that)
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
QRect qr = QRect(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1));
-#if defined(Q_OS_WINCE_WM)
+#if defined(Q_WS_WINCE_WM)
qt_get_sip_info(qr);
#endif
@@ -222,7 +222,7 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that)
enumDisplayMonitors(0, 0, enumCallback, 0);
enumDisplayMonitors = 0;
getMonitorInfo = 0;
-#endif // Q_OS_WINCE
+#endif // Q_WS_WINCE
}
QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
@@ -303,7 +303,7 @@ QWidget *QDesktopWidget::screen(int /* screen */)
const QRect QDesktopWidget::availableGeometry(int screen) const
{
Q_D(const QDesktopWidget);
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
for(int i=0; i < d->workrects->size(); ++i)
qt_get_sip_info((*d->workrects)[i]);
#endif
@@ -385,7 +385,7 @@ void QDesktopWidget::resizeEvent(QResizeEvent *)
QDesktopWidgetPrivate::cleanup();
QDesktopWidgetPrivate::init(this);
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
for(int i=0; i < d->workrects->size(); ++i)
qt_get_sip_info((*d->workrects)[i]);
#endif
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index 7a0cb7a..9871658 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_p.h
@@ -202,7 +202,7 @@ public:
#endif
};
-class Q_GUI_EXPORT QDragManager: public QObject {
+class QDragManager: public QObject {
Q_OBJECT
QDragManager();
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
index 4c9c73c..9b2305d 100644
--- a/src/gui/kernel/qdnd_x11.cpp
+++ b/src/gui/kernel/qdnd_x11.cpp
@@ -542,6 +542,8 @@ bool QX11Data::xdndMimeDataForAtom(Atom a, QMimeData *mimeData, QByteArray *data
dm->xdndMimeTransferedPixmapIndex =
(dm->xdndMimeTransferedPixmapIndex + 1) % 2;
}
+ } else {
+ DEBUG("QClipboard: xdndMimeDataForAtom(): converting to type '%s' is not supported", qPrintable(atomName));
}
}
return data;
@@ -622,28 +624,12 @@ QVariant QX11Data::xdndMimeConvertToFormat(Atom a, const QByteArray &data, const
if (format == QLatin1String("image/ppm")) {
if (a == XA_PIXMAP && data.size() == sizeof(Pixmap)) {
Pixmap xpm = *((Pixmap*)data.data());
- Display *dpy = display;
- Window r;
- int x,y;
- uint w,h,bw,d;
if (!xpm)
return QByteArray();
- XGetGeometry(dpy,xpm, &r,&x,&y,&w,&h,&bw,&d);
+ QPixmap qpm = QPixmap::fromX11Pixmap(xpm);
QImageWriter imageWriter;
- GC gc = XCreateGC(dpy, xpm, 0, 0);
- QImage imageToWrite;
- if (d == 1) {
- QBitmap qbm(w,h);
- XCopyArea(dpy,xpm,qbm.handle(),gc,0,0,w,h,0,0);
- imageWriter.setFormat("PBMRAW");
- imageToWrite = qbm.toImage();
- } else {
- QPixmap qpm(w,h);
- XCopyArea(dpy,xpm,qpm.handle(),gc,0,0,w,h,0,0);
- imageWriter.setFormat("PPMRAW");
- imageToWrite = qpm.toImage();
- }
- XFreeGC(dpy,gc);
+ imageWriter.setFormat("PPMRAW");
+ QImage imageToWrite = qpm.toImage();
QBuffer buf;
buf.open(QIODevice::WriteOnly);
imageWriter.setDevice(&buf);
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 2aed287..a59e870 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -861,6 +861,17 @@ bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
uint platform = QApplicationPrivate::currentPlatform();
+#ifdef Q_WS_MAC
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ uint oldSearchKey = searchkey;
+ searchkey &= ~(Qt::ControlModifier | Qt::MetaModifier);
+ if (oldSearchKey & Qt::ControlModifier)
+ searchkey |= Qt::MetaModifier;
+ if (oldSearchKey & Qt::MetaModifier)
+ searchkey |= Qt::ControlModifier;
+ }
+#endif
+
uint N = QKeySequencePrivate::numberOfKeyBindings;
int first = 0;
int last = N - 1;
@@ -3070,7 +3081,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e) {
<< ", " << me->button()
<< ", " << hex << (int)me->buttons()
<< ", " << hex << (int)me->modifiers()
- << ")";
+ << ')';
}
return dbg.space();
@@ -3091,7 +3102,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e) {
#ifndef QT_NO_WHEELEVENT
case QEvent::Wheel:
dbg.nospace() << "QWheelEvent(" << static_cast<const QWheelEvent *>(e)->delta()
- << ")";
+ << ')';
return dbg.space();
#endif
case QEvent::KeyPress:
@@ -3117,7 +3128,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e) {
<< ", \"" << ke->text()
<< "\", " << ke->isAutoRepeat()
<< ", " << ke->count()
- << ")";
+ << ')';
}
return dbg.space();
case QEvent::FocusIn:
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index cc94aad..8e762d6 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
//
// ### Qt 5: remove
-class Q_GUI_EXPORT QKeyEventEx : public QKeyEvent
+class QKeyEventEx : public QKeyEvent
{
public:
QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
@@ -76,7 +76,7 @@ protected:
};
// ### Qt 5: remove
-class Q_GUI_EXPORT QMouseEventEx : public QMouseEvent
+class QMouseEventEx : public QMouseEvent
{
public:
QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
diff --git a/src/gui/kernel/qformlayout.cpp b/src/gui/kernel/qformlayout.cpp
index e2d6108..a665c89 100644
--- a/src/gui/kernel/qformlayout.cpp
+++ b/src/gui/kernel/qformlayout.cpp
@@ -689,12 +689,16 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width)
// are split.
maxLabelWidth = 0;
if (!wrapAllRows) {
+ int maxFieldMinWidth = 0; //the maximum minimum size of the field
for (int i = 0; i < rr; ++i) {
const QFormLayoutItem *label = m_matrix(i, 0);
const QFormLayoutItem *field = m_matrix(i, 1);
- if (label && (label->sizeHint.width() + (field ? field->minSize.width() : 0) <= width))
+ if (label && field && label->sideBySide)
maxLabelWidth = qMax(maxLabelWidth, label->sizeHint.width());
+ if (field)
+ maxFieldMinWidth = qMax(maxFieldMinWidth, field->minSize.width() + field->sbsHSpace);
}
+ maxLabelWidth = qMin(maxLabelWidth, width - maxFieldMinWidth);
} else {
maxLabelWidth = width;
}
diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp
index 535d009..503a33b 100644
--- a/src/gui/kernel/qkeymapper.cpp
+++ b/src/gui/kernel/qkeymapper.cpp
@@ -116,6 +116,4 @@ QKeyMapperPrivate *qt_keymapper_private()
return QKeyMapper::instance()->d_func();
}
-Q_GUI_EXPORT QList<int> qt_keymapper_possibleKeys(QKeyEvent *e) { return QKeyMapper::instance()->possibleKeys(e); }
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 1a0fb08..01b2c13 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -48,6 +48,7 @@
#include <qinputcontext.h>
#include <private/qkeymapper_p.h>
#include <private/qapplication_p.h>
+#include <private/qmacinputcontext_p.h>
QT_BEGIN_NAMESPACE
@@ -160,6 +161,14 @@ Qt::KeyboardModifiers qt_mac_get_modifiers(int keys)
ret |= Qt::KeyboardModifier(qt_mac_modifier_symbols[i].qt_code);
}
}
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ Qt::KeyboardModifiers oldModifiers = ret;
+ ret &= ~(Qt::MetaModifier | Qt::ControlModifier);
+ if (oldModifiers & Qt::ControlModifier)
+ ret |= Qt::MetaModifier;
+ if (oldModifiers & Qt::MetaModifier)
+ ret |= Qt::ControlModifier;
+ }
return ret;
}
static int qt_mac_get_mac_modifiers(Qt::KeyboardModifiers keys)
@@ -176,6 +185,15 @@ static int qt_mac_get_mac_modifiers(Qt::KeyboardModifiers keys)
ret |= qt_mac_modifier_symbols[i].mac_code;
}
}
+
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ int oldModifiers = ret;
+ ret &= ~(controlKeyBit | cmdKeyBit);
+ if (oldModifiers & controlKeyBit)
+ ret |= cmdKeyBit;
+ if (oldModifiers & cmdKeyBit)
+ ret |= controlKeyBit;
+ }
return ret;
}
void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object)
@@ -480,7 +498,8 @@ static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent,
#ifdef QT_MAC_USE_COCOA
if (outHandled) {
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, keyEvent);
+ if (er)
+ CallNextEventHandler(er, keyEvent);
*outHandled = qt_mac_eat_unicode_key;
}
#endif
@@ -692,8 +711,14 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
return true;
}
- if (qApp->inputContext() && qApp->inputContext()->isComposing())
+ if (qApp->inputContext() && qApp->inputContext()->isComposing()) {
+ if (ekind == kEventRawKeyDown) {
+ QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
+ if (context)
+ context->setLastKeydownEvent(event);
+ }
return false;
+ }
//get modifiers
Qt::KeyboardModifiers modifiers;
int qtKey;
@@ -721,7 +746,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
//is it of use to text services? If so we won't bother
//with a QKeyEvent.
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, event);
+ if (er)
+ CallNextEventHandler(er, event);
extern bool qt_mac_menubar_is_open();
if (qt_mac_eat_unicode_key || qt_mac_menubar_is_open()) {
return true;
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 3bcf9e3..ee45969 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -105,20 +105,39 @@ static bool operator<(int key, const MacSpecialKey &entry)
static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries;
-static QChar macSymbolForQtKey(int key)
+QChar qt_macSymbolForQtKey(int key)
{
const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key);
if (i == MacSpecialKeyEntriesEnd)
return QChar();
- return QChar(i->macSymbol);
+ ushort macSymbol = i->macSymbol;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
+ && (macSymbol == kControlUnicode || macSymbol == kCommandUnicode)) {
+ if (macSymbol == kControlUnicode)
+ macSymbol = kCommandUnicode;
+ else
+ macSymbol = kControlUnicode;
+ }
+
+ return QChar(macSymbol);
}
static int qtkeyForMacSymbol(const QChar ch)
{
+ const ushort unicode = ch.unicode();
for (int i = 0; i < NumEntries; ++i) {
const MacSpecialKey &entry = entries[i];
- if (entry.macSymbol == ch.unicode())
- return entry.key;
+ if (entry.macSymbol == unicode) {
+ int key = entry.key;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
+ && (unicode == kControlUnicode || unicode == kCommandUnicode)) {
+ if (unicode == kControlUnicode)
+ key = Qt::Key_Control;
+ else
+ key = Qt::Key_Meta;
+ }
+ return key;
+ }
}
return -1;
}
@@ -126,7 +145,7 @@ static int qtkeyForMacSymbol(const QChar ch)
#else
static bool qt_sequence_no_mnemonics = false;
#endif
-void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemonics = !b; }
+void Q_AUTOTEST_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemonics = !b; }
/*!
\class QKeySequence
@@ -213,12 +232,14 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\row \i Open \i Ctrl+O \i Ctrl+O \i Ctrl+O \i Ctrl+O
\row \i Close \i Ctrl+F4, Ctrl+W \i Ctrl+W, Ctrl+F4 \i Ctrl+W \i Ctrl+W
\row \i Save \i Ctrl+S \i Ctrl+S \i Ctrl+S \i Ctrl+S
+ \row \i Quit \i \i Ctrl+Q \i Qtrl+Q \i Qtrl+Q
\row \i SaveAs \i \i Ctrl+Shift+S \i \i Ctrl+Shift+S
\row \i New \i Ctrl+N \i Ctrl+N \i Ctrl+N \i Ctrl+N
\row \i Delete \i Del \i Del, Meta+D \i Del, Ctrl+D \i Del, Ctrl+D
\row \i Cut \i Ctrl+X, Shift+Del \i Ctrl+X \i Ctrl+X, F20, Shift+Del \i Ctrl+X, F20, Shift+Del
\row \i Copy \i Ctrl+C, Ctrl+Ins \i Ctrl+C \i Ctrl+C, F16, Ctrl+Ins \i Ctrl+C, F16, Ctrl+Ins
\row \i Paste \i Ctrl+V, Shift+Ins \i Ctrl+V \i Ctrl+V, F18, Shift+Ins \i Ctrl+V, F18, Shift+Ins
+ \row \i Preferences \i \i Ctrl+, \i \i
\row \i Undo \i Ctrl+Z, Alt+Backspace \i Ctrl+Z \i Ctrl+Z, F14 \i Ctrl+Z, F14
\row \i Redo \i Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \i Ctrl+Shift+Z, Ctrl+Y \i Ctrl+Shift+Z \i Ctrl+Shift+Z
\row \i Back \i Alt+Left, Backspace \i Ctrl+[ \i Alt+Left \i Alt+Left
@@ -521,6 +542,7 @@ const QKeyBinding QKeySequencePrivate::keyBindings[] = {
{QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, QApplicationPrivate::KB_Win},
{QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, QApplicationPrivate::KB_All},
{QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, QApplicationPrivate::KB_KDE},
+ {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, QApplicationPrivate::KB_Mac},
{QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, QApplicationPrivate::KB_All},
{QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, QApplicationPrivate::KB_KDE},
{QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, QApplicationPrivate::KB_Mac},
@@ -538,6 +560,7 @@ const QKeyBinding QKeySequencePrivate::keyBindings[] = {
{QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, QApplicationPrivate::KB_All},
{QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, QApplicationPrivate::KB_All},
{QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, QApplicationPrivate::KB_All},
+ {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_KDE | QApplicationPrivate::KB_Mac},
{QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
{QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, QApplicationPrivate::KB_KDE},
{QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, QApplicationPrivate::KB_All},
@@ -669,12 +692,14 @@ const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate
\value NextChild Navigate to next tab or child window.
\value Open Open document.
\value Paste Paste.
+ \value Preferences Open the preferences dialog.
\value PreviousChild Navigate to previous tab or child window.
\value Print Print document.
+ \value Quit Quit the application.
\value Redo Redo.
\value Refresh Refresh or reload current document.
\value Replace Find and replace.
- \value SaveAs Save document after prompting the user for a file name.
+ \value SaveAs Save document after prompting the user for a file name.
\value Save Save document.
\value SelectAll Select all text.
\value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on OS X.
@@ -780,6 +805,21 @@ QKeySequence::QKeySequence(const QKeySequence& keysequence)
d->ref.ref();
}
+#ifdef Q_WS_MAC
+static inline int maybeSwapShortcut(int shortcut)
+{
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ uint oldshortcut = shortcut;
+ shortcut &= ~(Qt::CTRL | Qt::META);
+ if (oldshortcut & Qt::CTRL)
+ shortcut |= Qt::META;
+ if (oldshortcut & Qt::META)
+ shortcut |= Qt::CTRL;
+ }
+ return shortcut;
+}
+#endif
+
/*!
\since 4.2
@@ -796,10 +836,16 @@ QList<QKeySequence> QKeySequence::keyBindings(StandardKey key)
for (uint i = 0; i < QKeySequencePrivate::numberOfKeyBindings ; ++i) {
QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i];
if (keyBinding.standardKey == key && (keyBinding.platform & platform)) {
- if (keyBinding.priority > 0)
- list.prepend(QKeySequence(QKeySequencePrivate::keyBindings[i].shortcut));
- else
- list.append(QKeySequence(QKeySequencePrivate::keyBindings[i].shortcut));
+ uint shortcut =
+#ifdef Q_WS_MAC
+ maybeSwapShortcut(QKeySequencePrivate::keyBindings[i].shortcut);
+#else
+ QKeySequencePrivate::keyBindings[i].shortcut;
+#endif
+ if (keyBinding.priority > 0)
+ list.prepend(QKeySequence(shortcut));
+ else
+ list.append(QKeySequence(shortcut));
}
}
return list;
@@ -967,9 +1013,16 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
gmodifs = globalModifs();
if (gmodifs->isEmpty()) {
#ifdef Q_WS_MAC
- *gmodifs << QModifKeyName(Qt::CTRL, QChar(kCommandUnicode));
+ const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
+ if (dontSwap)
+ *gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode));
+ else
+ *gmodifs << QModifKeyName(Qt::CTRL, QChar(kCommandUnicode));
*gmodifs << QModifKeyName(Qt::ALT, QChar(kOptionUnicode));
- *gmodifs << QModifKeyName(Qt::META, QChar(kControlUnicode));
+ if (dontSwap)
+ *gmodifs << QModifKeyName(Qt::CTRL, QChar(kControlUnicode));
+ else
+ *gmodifs << QModifKeyName(Qt::META, QChar(kControlUnicode));
*gmodifs << QModifKeyName(Qt::SHIFT, QChar(kShiftUnicode));
#endif
*gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
@@ -1067,8 +1120,6 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
if (found)
break;
}
-#ifdef Q_WS_MAC
-#endif
}
return ret;
}
@@ -1097,15 +1148,30 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
QString s;
#if defined(Q_WS_MAC)
if (nativeText) {
- // On MAC the order is Meta, Alt, Shift, Control.
- if ((key & Qt::META) == Qt::META)
- s += macSymbolForQtKey(Qt::Key_Meta);
- if ((key & Qt::ALT) == Qt::ALT)
- s += macSymbolForQtKey(Qt::Key_Alt);
- if ((key & Qt::SHIFT) == Qt::SHIFT)
- s += macSymbolForQtKey(Qt::Key_Shift);
- if ((key & Qt::CTRL) == Qt::CTRL)
- s += macSymbolForQtKey(Qt::Key_Control);
+ // On Mac OS X the order (by default) is Meta, Alt, Shift, Control.
+ // If the AA_MacDontSwapCtrlAndMeta is enabled, then the order
+ // is Ctrl, Alt, Shift, Meta. The macSymbolForQtKey does this swap
+ // for us, which means that we have to adjust our order here.
+ // The upshot is a lot more infrastructure to keep the number of
+ // if tests down and the code relatively clean.
+ static const int ModifierOrder[] = { Qt::META, Qt::ALT, Qt::SHIFT, Qt::CTRL, 0 };
+ static const int QtKeyOrder[] = { Qt::Key_Meta, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Control, 0 };
+ static const int DontSwapModifierOrder[] = { Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::META, 0 };
+ static const int DontSwapQtKeyOrder[] = { Qt::Key_Control, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Meta, 0 };
+ const int *modifierOrder;
+ const int *qtkeyOrder;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ modifierOrder = DontSwapModifierOrder;
+ qtkeyOrder = DontSwapQtKeyOrder;
+ } else {
+ modifierOrder = ModifierOrder;
+ qtkeyOrder = QtKeyOrder;
+ }
+
+ for (int i = 0; modifierOrder[i] != 0; ++i) {
+ if (key & modifierOrder[i])
+ s += qt_macSymbolForQtKey(qtkeyOrder[i]);
+ }
} else
#endif
{
@@ -1138,7 +1204,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
int i=0;
#if defined(Q_WS_MAC)
if (nativeText) {
- QChar ch = macSymbolForQtKey(key);
+ QChar ch = qt_macSymbolForQtKey(key);
if (!ch.isNull())
p = ch;
else
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index 1c4776f..f78e34a 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -136,7 +136,9 @@ public:
DeleteEndOfLine,
InsertParagraphSeparator,
InsertLineSeparator,
- SaveAs
+ SaveAs,
+ Preferences,
+ Quit
};
QKeySequence();
diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp
index 4463aab..0a233d5 100644
--- a/src/gui/kernel/qlayout.cpp
+++ b/src/gui/kernel/qlayout.cpp
@@ -1583,8 +1583,6 @@ QDataStream &operator>>(QDataStream &stream, QSizePolicy &policy)
{
return stream >> policy.data;
}
-
-#endif
-
+#endif // QT_NO_DATASTREAM
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qlayoutengine.cpp b/src/gui/kernel/qlayoutengine.cpp
index fbaa388..3673f08 100644
--- a/src/gui/kernel/qlayoutengine.cpp
+++ b/src/gui/kernel/qlayoutengine.cpp
@@ -329,7 +329,7 @@ void qGeomCalc(QVector<QLayoutStruct> &chain, int start, int count,
qDebug() << "qGeomCalc" << "start" << start << "count" << count << "pos" << pos
<< "space" << space << "spacer" << spacer;
for (i = start; i < start + count; ++i) {
- qDebug() << i << ":" << chain[i].minimumSize << chain[i].smartSizeHint()
+ qDebug() << i << ':' << chain[i].minimumSize << chain[i].smartSizeHint()
<< chain[i].maximumSize << "stretch" << chain[i].stretch
<< "empty" << chain[i].empty << "expansive" << chain[i].expansive
<< "spacing" << chain[i].spacing;
diff --git a/src/gui/kernel/qlayoutitem.cpp b/src/gui/kernel/qlayoutitem.cpp
index 0fd73b8..c70ab2d 100644
--- a/src/gui/kernel/qlayoutitem.cpp
+++ b/src/gui/kernel/qlayoutitem.cpp
@@ -54,7 +54,8 @@ QT_BEGIN_NAMESPACE
inline static QRect fromLayoutItemRect(QWidgetPrivate *priv, const QRect &rect)
{
- return priv->fromOrToLayoutItemRect(rect, -1);
+ return rect.adjusted(priv->leftLayoutItemMargin, priv->topLayoutItemMargin,
+ -priv->rightLayoutItemMargin, -priv->bottomLayoutItemMargin);
}
inline static QSize fromLayoutItemSize(QWidgetPrivate *priv, const QSize &size)
@@ -64,7 +65,8 @@ inline static QSize fromLayoutItemSize(QWidgetPrivate *priv, const QSize &size)
inline static QRect toLayoutItemRect(QWidgetPrivate *priv, const QRect &rect)
{
- return priv->fromOrToLayoutItemRect(rect, +1);
+ return rect.adjusted(-priv->leftLayoutItemMargin, -priv->topLayoutItemMargin,
+ priv->rightLayoutItemMargin, priv->bottomLayoutItemMargin);
}
inline static QSize toLayoutItemSize(QWidgetPrivate *priv, const QSize &size)
diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp
index cf1d747..9cb8b61 100644
--- a/src/gui/kernel/qmime_mac.cpp
+++ b/src/gui/kernel/qmime_mac.cpp
@@ -127,32 +127,44 @@ CFStringRef qt_mac_mime_typeUTI = CFSTR("com.pasteboard.trolltech.marker");
/*!
\class QMacPasteboardMime
- \brief The QMacPasteboardMime class maps open-standard MIME to Mac flavors.
+ \brief The QMacPasteboardMime class converts between a MIME type and a
+ \l{http://developer.apple.com/macosx/uniformtypeidentifiers.html}{Uniform
+ Type Identifier (UTI)} format.
\since 4.2
\ingroup io
\ingroup draganddrop
\ingroup misc
- Qt's drag and drop support and clipboard facilities use the MIME
- standard. On X11, this maps trivially to the Xdnd protocol, but on
- Mac although some applications use MIME types to describe clipboard
- formats, others use arbitrary non-standardized naming conventions,
- or unnamed built-in Mac formats.
+ Qt's drag and drop and clipboard facilities use the MIME
+ standard. On X11, this maps trivially to the Xdnd protocol. On
+ Mac, although some applications use MIME to describe clipboard
+ contents, it is more common to use Apple's UTI format.
- By instantiating subclasses of QMacPasteboardMime that provide conversions
- between Mac flavors and MIME formats, you can convert proprietary
- clipboard formats to MIME formats.
+ QMacPasteboardMime's role is to bridge the gap between MIME and UTI;
+ By subclasses this class, one can extend Qt's drag and drop
+ and clipboard handling to convert to and from unsupported, or proprietary, UTI formats.
- Qt has predefined support for the following Mac flavors:
+ A subclass of QMacPasteboardMime will automatically be registered, and active, upon instantiation.
+
+ Qt has predefined support for the following UTIs:
\list
- \i kScrapFlavorTypeUnicode - converted to "text/plain;charset=ISO-10646-UCS-2"
- \i kScrapFlavorTypeText - converted to "text/plain;charset=system" or "text/plain"
- \i kScrapFlavorTypePicture - converted to "application/x-qt-image"
- \i typeFileURL - converted to "text/uri-list"
+ \i public.utf8-plain-text - converts to "text/plain"
+ \i public.utf16-plain-text - converts to "text/plain"
+ \i public.html - converts to "text/html"
+ \i public.url - converts to "text/uri-list"
+ \i public.file-url - converts to "text/uri-list"
+ \i public.tiff - converts to "application/x-qt-image"
+ \i com.apple.traditional-mac-plain-text - converts to "text/plain"
+ \i com.apple.pict - converts to "application/x-qt-image"
\endlist
- You can check if a MIME type is convertible using canConvert() and
- can perform conversions with convertToMime() and convertFromMime().
+ When working with MIME data, Qt will interate through all instances of QMacPasteboardMime to
+ find an instance that can convert to, or from, a specific MIME type. It will do this by calling
+ canConvert() on each instance, starting with (and choosing) the last created instance first.
+ The actual conversions will be done by using convertToMime() and convertFromMime().
+
+ \note The API uses the term "flavor" in some cases. This is for backwards
+ compatibility reasons, and should now be understood as UTIs.
*/
/*! \enum QMacPasteboardMime::QMacPasteboardMimeType
@@ -206,7 +218,7 @@ QString QMacPasteboardMimeAny::flavorFor(const QString &mime)
if(mime == QLatin1String("application/x-qt-mime-type-name"))
return QString();
QString ret = QLatin1String("com.trolltech.anymime.") + mime;
- return ret.replace(QLatin1String("/"), QLatin1String("--"));
+ return ret.replace(QLatin1Char('/'), QLatin1String("--"));
}
QString QMacPasteboardMimeAny::mimeFor(QString flav)
@@ -382,7 +394,7 @@ QString QMacPasteboardMimeUnicodeText::flavorFor(const QString &mime)
int i = mime.indexOf(QLatin1String("charset="));
if (i >= 0) {
QString cs(mime.mid(i+8).toLower());
- i = cs.indexOf(QLatin1String(";"));
+ i = cs.indexOf(QLatin1Char(';'));
if (i>=0)
cs = cs.left(i);
if (cs == QLatin1String("system"))
@@ -841,6 +853,80 @@ QList<QByteArray> QMacPasteboardMimeFileUri::convertFromMime(const QString &mime
return ret;
}
+class QMacPasteboardMimeUrl : public QMacPasteboardMime {
+public:
+ QMacPasteboardMimeUrl() : QMacPasteboardMime(MIME_ALL) { }
+ QString convertorName();
+
+ QString flavorFor(const QString &mime);
+ QString mimeFor(QString flav);
+ bool canConvert(const QString &mime, QString flav);
+ QVariant convertToMime(const QString &mime, QList<QByteArray> data, QString flav);
+ QList<QByteArray> convertFromMime(const QString &mime, QVariant data, QString flav);
+};
+
+QString QMacPasteboardMimeUrl::convertorName()
+{
+ return QLatin1String("URL");
+}
+
+QString QMacPasteboardMimeUrl::flavorFor(const QString &mime)
+{
+ if(mime.startsWith(QLatin1String("text/uri-list")))
+ return QLatin1String("public.url");
+ return QString();
+}
+
+QString QMacPasteboardMimeUrl::mimeFor(QString flav)
+{
+ if(flav == QLatin1String("public.url"))
+ return QLatin1String("text/uri-list");
+ return QString();
+}
+
+bool QMacPasteboardMimeUrl::canConvert(const QString &mime, QString flav)
+{
+ return flav == QLatin1String("public.url")
+ && mime == QLatin1String("text/uri-list");
+}
+
+QVariant QMacPasteboardMimeUrl::convertToMime(const QString &mime, QList<QByteArray> data, QString flav)
+{
+ if(!canConvert(mime, flav))
+ return QVariant();
+
+ QList<QVariant> ret;
+ for (int i=0; i<data.size(); ++i) {
+ QUrl url = QUrl::fromEncoded(data.at(i));
+ if (url.host().toLower() == QLatin1String("localhost"))
+ url.setHost(QString());
+ url.setPath(url.path().normalized(QString::NormalizationForm_C));
+ ret.append(url);
+ }
+ return QVariant(ret);
+}
+
+QList<QByteArray> QMacPasteboardMimeUrl::convertFromMime(const QString &mime, QVariant data, QString flav)
+{
+ QList<QByteArray> ret;
+ if (!canConvert(mime, flav))
+ return ret;
+
+ QList<QVariant> urls = data.toList();
+ for(int i=0; i<urls.size(); ++i) {
+ QUrl url = urls.at(i).toUrl();
+ if (url.scheme().isEmpty())
+ url.setScheme(QLatin1String("file"));
+ if (url.scheme().toLower() == QLatin1String("file")) {
+ if (url.host().isEmpty())
+ url.setHost(QLatin1String("localhost"));
+ url.setPath(url.path().normalized(QString::NormalizationForm_D));
+ }
+ ret.append(url.toEncoded());
+ }
+ return ret;
+}
+
#ifdef QT3_SUPPORT
class QMacPasteboardMimeQt3Any : public QMacPasteboardMime {
private:
@@ -1043,6 +1129,7 @@ void QMacPasteboardMime::initialize()
new QMacPasteboardMimePlainText;
new QMacPasteboardMimeHTMLText;
new QMacPasteboardMimeFileUri;
+ new QMacPasteboardMimeUrl;
new QMacPasteboardMimeTypeName;
//make sure our "non-standard" types are always last! --Sam
new QMacPasteboardMimeAny;
diff --git a/src/gui/kernel/qmime_win.cpp b/src/gui/kernel/qmime_win.cpp
index cd0aae6..ad2dec1 100644
--- a/src/gui/kernel/qmime_win.cpp
+++ b/src/gui/kernel/qmime_win.cpp
@@ -852,7 +852,7 @@ QVariant QWindowsMimeHtml::convertToMime(const QString &mime, IDataObject *pData
if (end > start && start > 0) {
html = "<!--StartFragment-->" + html.mid(start, end - start);
html += "<!--EndFragment-->";
- html.replace("\r", "");
+ html.replace('\r', "");
result = QString::fromUtf8(html);
}
}
@@ -1262,16 +1262,16 @@ QVector<FORMATETC> QLastResortMimes::formatsForMime(const QString &mimeType, con
}
return formatetcs;
}
-static const char *x_qt_windows_mime = "application/x-qt-windows-mime;value=\"";
+static const char x_qt_windows_mime[] = "application/x-qt-windows-mime;value=\"";
-bool isCustomMimeType(const QString &mimeType)
+static bool isCustomMimeType(const QString &mimeType)
{
return mimeType.startsWith(QLatin1String(x_qt_windows_mime), Qt::CaseInsensitive);
}
-QString customMimeType(const QString &mimeType)
+static QString customMimeType(const QString &mimeType)
{
- int len = QString(QLatin1String(x_qt_windows_mime)).length();
+ int len = sizeof(x_qt_windows_mime) - 1;
int n = mimeType.lastIndexOf(QLatin1Char('\"'))-len;
return mimeType.mid(len, n);
}
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 6541510..18a2142 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -125,7 +125,7 @@ QDataStream &operator>>(QDataStream &s, QColorGroup &g)
{
return qt_stream_in_qcolorgroup(s, g);
}
-#endif
+#endif // QT_NO_DATASTREAM
/*!
Constructs a palette with the specified \a active, \a disabled and
@@ -158,7 +158,7 @@ void QPalette::setColorGroup(ColorGroup cg, const QColorGroup &g)
g.brush(LinkVisited), g.brush(ToolTipBase), g.brush(ToolTipText));
}
-#endif
+#endif // QT3_SUPPORT
/*!
\fn const QColor &QPalette::color(ColorRole role) const
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index 86894b4..3c2fcdd 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -61,8 +61,6 @@
QT_BEGIN_NAMESPACE
-extern bool qt_mac_no_native_menubar; // qmenu_mac.cpp
-
// To enable verbose output uncomment below
//#define DEBUG_QSHORTCUTMAP
@@ -111,7 +109,7 @@ QDebug &operator<<(QDebug &dbg, const QShortcutEntry *se) {
dbg.nospace()
<< "QShortcutEntry(" << se->keyseq
<< "), id(" << se->id << "), enabled(" << se->enabled << "), autorepeat(" << se->autorepeat
- << "), owner(" << se->owner << ")";
+ << "), owner(" << se->owner << ')';
return dbg.space();
}
#endif // QT_NO_DEBUGSTREAM
@@ -660,7 +658,7 @@ bool QShortcutMap::correctWidgetContext(Qt::ShortcutContext context, QWidget *w,
{
bool visible = w->isVisible();
#ifdef Q_WS_MAC
- if (!qt_mac_no_native_menubar && qobject_cast<QMenuBar *>(w))
+ if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
visible = true;
#endif
@@ -723,7 +721,7 @@ bool QShortcutMap::correctGraphicsWidgetContext(Qt::ShortcutContext context, QGr
{
bool visible = w->isVisible();
#ifdef Q_WS_MAC
- if (!qt_mac_no_native_menubar && qobject_cast<QMenuBar *>(w))
+ if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
visible = true;
#endif
@@ -878,7 +876,7 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e)
qDebug().nospace()
<< "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\""
<< (QString)next->keyseq << "\", " << next->id << ", "
- << (bool)(enabledShortcuts>1) << ") to object(" << next->owner << ")";
+ << (bool)(enabledShortcuts>1) << ") to object(" << next->owner << ')';
#endif
QShortcutEvent se(next->keyseq, next->id, enabledShortcuts>1);
QApplication::sendEvent(const_cast<QObject *>(next->owner), &se);
diff --git a/src/gui/kernel/qsizepolicy.h b/src/gui/kernel/qsizepolicy.h
index 652fda1..32b3b4f 100644
--- a/src/gui/kernel/qsizepolicy.h
+++ b/src/gui/kernel/qsizepolicy.h
@@ -203,9 +203,11 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes)
+#ifndef QT_NO_DATASTREAM
// implemented in qlayout.cpp
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &);
+#endif
inline void QSizePolicy::transpose() {
Policy hData = horizontalPolicy();
diff --git a/src/gui/kernel/qsound_qws.cpp b/src/gui/kernel/qsound_qws.cpp
index e83935f..661544f 100644
--- a/src/gui/kernel/qsound_qws.cpp
+++ b/src/gui/kernel/qsound_qws.cpp
@@ -279,7 +279,7 @@ QAuBucketQWS::QAuBucketQWS( QAuServerQWS *server, QSound *sound, QObject* parent
sound->setObjectName( m_id.toString() );
- m_channel = new QCopChannel(QString( QLatin1String("QPE/QSound/") ).append( m_id ), this );
+ m_channel = new QCopChannel(QLatin1String("QPE/QSound/") + m_id ), this );
connect( m_channel, SIGNAL(received(QString,QByteArray)),
this, SLOT(processMessage(QString,QByteArray)) );
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 9165836..554e9d5 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -88,6 +88,52 @@
QT_BEGIN_NAMESPACE
+Q_GLOBAL_STATIC(QMacWindowFader, macwindowFader);
+
+QMacWindowFader::QMacWindowFader()
+ : m_duration(0.250)
+{
+}
+
+QMacWindowFader *QMacWindowFader::currentFader()
+{
+ return macwindowFader();
+}
+
+void QMacWindowFader::registerWindowToFade(QWidget *window)
+{
+ m_windowsToFade.append(window);
+}
+
+void QMacWindowFader::performFade()
+{
+ const QWidgetList myWidgetsToFade = m_windowsToFade;
+ const int widgetCount = myWidgetsToFade.count();
+#if QT_MAC_USE_COCOA
+ QMacCocoaAutoReleasePool pool;
+ [NSAnimationContext beginGrouping];
+ [[NSAnimationContext currentContext] setDuration:NSTimeInterval(m_duration)];
+#endif
+
+ for (int i = 0; i < widgetCount; ++i) {
+ QWidget *widget = m_windowsToFade.at(i);
+ OSWindowRef window = qt_mac_window_for(widget);
+#if QT_MAC_USE_COCOA
+ [[window animator] setAlphaValue:0.0];
+ QTimer::singleShot(qRound(m_duration * 1000), widget, SLOT(hide()));
+#else
+ TransitionWindowOptions options = {0, m_duration, 0, 0};
+ TransitionWindowWithOptions(window, kWindowFadeTransitionEffect, kWindowHideTransitionAction,
+ 0, 1, &options);
+#endif
+ }
+#if QT_MAC_USE_COCOA
+ [NSAnimationContext endGrouping];
+#endif
+ m_duration = 0.250;
+ m_windowsToFade.clear();
+}
+
extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp;
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
extern QWidget * mac_mouse_grabber;
@@ -95,29 +141,26 @@ extern QWidget * mac_mouse_grabber;
void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
{
OSWindowRef wnd = static_cast<OSWindowRef>(window);
- if( wnd ) {
+ if (wnd) {
+ QWidget *widget;
#if QT_MAC_USE_COCOA
- QMacCocoaAutoReleasePool pool;
- [NSAnimationContext beginGrouping];
- [[wnd animator] setAlphaValue:0.0];
- if (durationSeconds > 0) {
- [[NSAnimationContext currentContext] setDuration:NSTimeInterval(durationSeconds)];
- } else {
- durationSeconds = [[NSAnimationContext currentContext] duration];
- }
- [NSAnimationContext endGrouping];
- QTimer::singleShot(qRound(durationSeconds * 1000), [wnd QT_MANGLE_NAMESPACE(qt_qwidget)], SLOT(hide()));
+ widget = [wnd QT_MANGLE_NAMESPACE(qt_qwidget)];
#else
- if (durationSeconds <= 0)
- durationSeconds = 0.15;
- TransitionWindowOptions options = {0, durationSeconds, 0, 0};
- TransitionWindowWithOptions(wnd, kWindowFadeTransitionEffect, kWindowHideTransitionAction, 0, 1, &options);
+ const UInt32 kWidgetCreatorQt = kEventClassQt;
+ enum {
+ kWidgetPropertyQWidget = 'QWId' //QWidget *
+ };
+ if (GetWindowProperty(static_cast<WindowRef>(window), kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(widget), 0, &widget) != noErr)
+ widget = 0;
#endif
- }
+ if (widget) {
+ QMacWindowFader::currentFader()->setFadeDuration(durationSeconds);
+ QMacWindowFader::currentFader()->registerWindowToFade(widget);
+ QMacWindowFader::currentFader()->performFade();
+ }
+ }
}
-
-
bool macWindowIsTextured( void * /*OSWindowRef*/ window )
{
OSWindowRef wnd = static_cast<OSWindowRef>(window);
diff --git a/src/gui/kernel/qt_mac_p.h b/src/gui/kernel/qt_mac_p.h
index ca995dc..3b0f546 100644
--- a/src/gui/kernel/qt_mac_p.h
+++ b/src/gui/kernel/qt_mac_p.h
@@ -120,6 +120,21 @@ public:
}
};
+// Class for chaining to gether a bunch of fades. It pretty much is only used for qmenu fading.
+class QMacWindowFader
+{
+ QWidgetList m_windowsToFade;
+ float m_duration;
+ Q_DISABLE_COPY(QMacWindowFader)
+public:
+ QMacWindowFader(); // PLEASE DON'T CALL THIS.
+ static QMacWindowFader *currentFader();
+ void registerWindowToFade(QWidget *window);
+ void setFadeDuration(float durationInSecs) { m_duration = durationInSecs; }
+ float fadeDuration() const { return m_duration; }
+ void performFade();
+};
+
class Q_GUI_EXPORT QMacCocoaAutoReleasePool
{
private:
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 563b7e9..b9ace9d 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -652,6 +652,10 @@ struct QX11Data
_XEMBED,
_XEMBED_INFO,
+ XWacomStylus,
+ XWacomCursor,
+ XWacomEraser,
+
NPredefinedAtoms,
_QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index baf3278..6026821 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -167,39 +167,48 @@ static inline bool bypassGraphicsProxyWidget(QWidget *p)
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
-QWidgetPrivate::QWidgetPrivate(int version) :
- QObjectPrivate(version), extra(0), focus_child(0)
- ,layout(0), widgetItem(0)
- ,leftmargin(0), topmargin(0), rightmargin(0), bottommargin(0)
- ,leftLayoutItemMargin(0), topLayoutItemMargin(0), rightLayoutItemMargin(0)
- ,bottomLayoutItemMargin(0)
- ,fg_role(QPalette::NoRole)
- ,bg_role(QPalette::NoRole)
- ,hd(0)
- ,dirty(0)
- ,needsFlush(0)
- ,dirtyOpaqueChildren(1)
- ,isOpaque(0)
- ,inDirtyList(0)
- ,isScrolled(0)
- ,isMoved(0)
- ,usesDoubleBufferedGLContext(0)
-#ifdef Q_WS_WIN
- ,noPaintOnScreen(0)
-#endif
- ,inheritedFontResolveMask(0)
- ,inheritedPaletteResolveMask(0)
+QWidgetPrivate::QWidgetPrivate(int version)
+ : QObjectPrivate(version)
+ , extra(0)
+ , focus_next(0)
+ , focus_prev(0)
+ , focus_child(0)
+ , layout(0)
+ , needsFlush(0)
+ , redirectDev(0)
+ , widgetItem(0)
+ , extraPaintEngine(0)
+ , polished(0)
+ , inheritedFontResolveMask(0)
+ , inheritedPaletteResolveMask(0)
+ , leftmargin(0)
+ , topmargin(0)
+ , rightmargin(0)
+ , bottommargin(0)
+ , leftLayoutItemMargin(0)
+ , topLayoutItemMargin(0)
+ , rightLayoutItemMargin(0)
+ , bottomLayoutItemMargin(0)
+ , hd(0)
+ , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred)
+ , fg_role(QPalette::NoRole)
+ , bg_role(QPalette::NoRole)
+ , dirtyOpaqueChildren(1)
+ , isOpaque(0)
+ , inDirtyList(0)
+ , isScrolled(0)
+ , isMoved(0)
+ , usesDoubleBufferedGLContext(0)
#if defined(Q_WS_X11)
- ,picture(0)
-#endif
-#ifdef Q_WS_MAC
- ,needWindowChange(0)
- ,isGLWidget(0)
+ , picture(0)
+#elif defined(Q_WS_WIN)
+ , noPaintOnScreen(0)
+#elif defined(Q_WS_MAC)
+ , needWindowChange(0)
+ , isGLWidget(0)
+ , window_event(0)
+ , qd_hd(0)
#endif
- ,polished(0)
-
- , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred)
- , redirectDev(0)
{
if (!qApp) {
qFatal("QWidget: Must construct a QApplication before a QPaintDevice");
@@ -1027,7 +1036,7 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
if (customize)
; // don't modify window flags if the user explicitely set them.
else if (type == Qt::Dialog || type == Qt::Sheet)
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint;
#else
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
@@ -1094,7 +1103,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
if (f & Qt::MSWindowsOwnDC)
q->setAttribute(Qt::WA_NativeWindow);
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
data.window_state_internal = 0;
#endif
@@ -1345,7 +1354,7 @@ QWidget::~QWidget()
d->setDirtyOpaqueRegion();
if (isWindow() && isVisible() && internalWinId())
- hide();
+ d->close_helper(QWidgetPrivate::CloseNoEvent);
#if defined(Q_WS_WIN) || defined(Q_WS_X11)
else if (!internalWinId() && isVisible())
qApp->d_func()->sendSyntheticEnterLeave(this);
@@ -1412,36 +1421,26 @@ void QWidgetPrivate::createTLExtra()
createExtra();
if (!extra->topextra) {
QTLWExtra* x = extra->topextra = new QTLWExtra;
+ x->icon = 0;
+ x->iconPixmap = 0;
+ x->backingStore = 0;
x->windowSurface = 0;
+ x->sharedPainter = 0;
+ x->incw = x->inch = 0;
+ x->basew = x->baseh = 0;
+ x->frameStrut.setCoords(0, 0, 0, 0);
+ x->normalGeometry = QRect(0,0,-1,-1);
+ x->savedFlags = 0;
x->opacity = 255;
x->posFromMove = false;
x->sizeAdjusted = false;
x->inTopLevelResize = false;
x->inRepaint = false;
- x->backingStore = 0;
- x->icon = 0;
- x->iconPixmap = 0;
- x->frameStrut.setCoords(0, 0, 0, 0);
- x->incw = x->inch = 0;
- x->basew = x->baseh = 0;
- x->normalGeometry = QRect(0,0,-1,-1);
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
x->embedded = 0;
-#endif
-#if defined(Q_WS_X11)
- x->parentWinId = 0;
- x->spont_unmapped = 0;
- x->dnd = 0;
-#endif
- x->savedFlags = 0;
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
- x->qwsManager = 0;
-#endif
- x->sharedPainter = 0;
createTLSysExtra();
#ifdef QWIDGET_EXTRA_DEBUG
- static int count = 0;
- qDebug() << "tlextra" << ++count;
+ static int count = 0;
+ qDebug() << "tlextra" << ++count;
#endif
}
}
@@ -1455,27 +1454,28 @@ void QWidgetPrivate::createExtra()
{
if (!extra) { // if not exists
extra = new QWExtra;
- extra->minw = extra->minh = 0;
- extra->maxw = extra->maxh = QWIDGETSIZE_MAX;
+ extra->glContext = 0;
+ extra->topextra = 0;
+ extra->proxyWidget = 0;
+#ifndef QT_NO_CURSOR
+ extra->curs = 0;
+#endif
+ extra->minw = 0;
+ extra->minh = 0;
+ extra->maxw = QWIDGETSIZE_MAX;
+ extra->maxh = QWIDGETSIZE_MAX;
+ extra->customDpiX = 0;
+ extra->customDpiY = 0;
extra->explicitMinSize = 0;
extra->explicitMaxSize = 0;
extra->autoFillBackground = 0;
extra->nativeChildrenForced = 0;
extra->inRenderWithPainter = 0;
extra->hasMask = 0;
-#ifndef QT_NO_CURSOR
- extra->curs = 0;
-#endif
- extra->style = 0;
- extra->topextra = 0;
- extra->proxyWidget = 0;
- extra->glContext = 0;
- extra->customDpiX = 0;
- extra->customDpiY = 0;
createSysExtra();
#ifdef QWIDGET_EXTRA_DEBUG
- static int count = 0;
- qDebug() << "extra" << ++count;
+ static int count = 0;
+ qDebug() << "extra" << ++count;
#endif
}
}
@@ -1516,45 +1516,6 @@ void QWidgetPrivate::deleteExtra()
}
/*
- Returns true if the background is inherited; otherwise returns
- false.
-
- Mainly used in the paintOnScreen case.
-*/
-
-bool QWidgetPrivate::isBackgroundInherited() const
-{
- Q_Q(const QWidget);
-
- // windows do not inherit their background
- if (q->isWindow() || q->windowType() == Qt::SubWindow)
- return false;
-
- if (q->testAttribute(Qt::WA_NoSystemBackground) || q->testAttribute(Qt::WA_OpaquePaintEvent))
- return false;
-
- const QPalette &pal = q->palette();
- QPalette::ColorRole bg = q->backgroundRole();
- QBrush brush = pal.brush(bg);
-
- // non opaque brushes leaves us no choice, we must inherit
- if (!q->autoFillBackground() || !brush.isOpaque())
- return true;
-
- if (brush.style() == Qt::SolidPattern) {
- // the background is just a solid color. If there is no
- // propagated contents, then we claim as performance
- // optimization that it was not inheritet. This is the normal
- // case in standard Windows or Motif style.
- const QWidget *w = q->parentWidget();
- if (!w->d_func()->isBackgroundInherited())
- return false;
- }
-
- return true;
-}
-
-/*
Returns true if there are widgets above this which overlap with
\a rect, which is in parent's coordinate system (same as crect).
*/
@@ -1900,24 +1861,6 @@ void QWidgetPrivate::clipToEffectiveMask(QRegion &region) const
}
}
-bool QWidgetPrivate::hasBackground() const
-{
- Q_Q(const QWidget);
- if (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_PaintOnScreen))
- return true;
- if (q->testAttribute(Qt::WA_PaintOnScreen))
- return true;
- if (!q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
- const QPalette &pal = q->palette();
- QPalette::ColorRole bg = q->backgroundRole();
- QBrush bgBrush = pal.brush(bg);
- return (bgBrush.style() != Qt::NoBrush &&
- ((q->isWindow() || q->windowType() == Qt::SubWindow)
- || (QPalette::ColorRole(bg_role) != QPalette::NoRole || (pal.resolve() & (1<<bg)))));
- }
- return false;
-}
-
bool QWidgetPrivate::paintOnScreen() const
{
#if defined(Q_WS_QWS)
@@ -2969,10 +2912,15 @@ void QWidgetPrivate::setEnabled_helper(bool enable)
#if defined(Q_WS_MAC)
setEnabled_helper_sys(enable);
#endif
-#if defined (Q_WS_WIN)
- if (q->hasFocus())
- QInputContextPrivate::updateImeStatus(q, true);
-#endif
+ if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
+ QInputContext *qic = inputContext();
+ if (enable) {
+ qic->setFocusWidget(q);
+ } else {
+ qic->reset();
+ qic->setFocusWidget(0);
+ }
+ }
QEvent e(QEvent::EnabledChange);
QApplication::sendEvent(q, &e);
#ifdef QT3_SUPPORT
@@ -4209,7 +4157,7 @@ const QPalette &QWidget::palette() const
if (!isEnabled()) {
data->pal.setCurrentColorGroup(QPalette::Disabled);
} else if ((!isVisible() || isActiveWindow())
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_WS_WINCE)
&& !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this))
#endif
) {
@@ -4797,7 +4745,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
}
const qreal opacity = painter->opacity();
- if (qFuzzyCompare(opacity + 1, qreal(1.0)))
+ if (qFuzzyIsNull(opacity))
return; // Fully transparent.
Q_D(QWidget);
@@ -5288,7 +5236,7 @@ static QString constructWindowTitleFromFilePath(const QString &filePath)
#ifndef Q_WS_MAC
QString appName = QApplication::applicationName();
if (!appName.isEmpty())
- windowTitle += QLatin1String(" ") + QChar(0x2014) + QLatin1String(" ") + appName;
+ windowTitle += QLatin1Char(' ') + QChar(0x2014) + QLatin1Char(' ') + appName;
#endif
return windowTitle;
}
@@ -5352,7 +5300,7 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg
&& widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
cap.replace(lastIndex, 3, QWidget::tr("*"));
else
- cap.replace(lastIndex, 3, QLatin1String(""));
+ cap.remove(lastIndex, 3);
}
index = cap.indexOf(placeHolder, index);
@@ -5908,6 +5856,8 @@ QWidget *QWidget::focusWidget() const
/*!
Returns the next widget in this widget's focus chain.
+
+ \sa previousInFocusChain
*/
QWidget *QWidget::nextInFocusChain() const
{
@@ -5915,6 +5865,18 @@ QWidget *QWidget::nextInFocusChain() const
}
/*!
+ Returns the previous widget in this widget's focus chain.
+
+ \sa nextInFocusChain
+
+ \since 4.6
+*/
+QWidget *QWidget::previousInFocusChain() const
+{
+ return const_cast<QWidget *>(d_func()->focus_prev);
+}
+
+/*!
\property QWidget::isActiveWindow
\brief whether this widget's window is the active window
@@ -6152,14 +6114,6 @@ int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r)
return dx + dy;
}
-QRect QWidgetPrivate::fromOrToLayoutItemRect(const QRect &rect, int sign) const
-{
- QRect r = rect;
- r.adjust(-sign * leftLayoutItemMargin, -sign * topLayoutItemMargin,
- +sign * rightLayoutItemMargin, +sign * bottomLayoutItemMargin);
- return r;
-}
-
/*!
\property QWidget::frameSize
\brief the size of the widget including any window frame
@@ -7333,7 +7287,7 @@ QSize QWidgetPrivate::adjustedSize() const
#else // all others
QRect screen = QApplication::desktop()->screenGeometry(q->pos());
#endif
-#if defined (Q_OS_WINCE)
+#if defined (Q_WS_WINCE)
s.setWidth(qMin(s.width(), screen.width()));
s.setHeight(qMin(s.height(), screen.height()));
#else
@@ -7641,16 +7595,10 @@ bool QWidget::event(QEvent *event)
}
break;
case QEvent::FocusIn:
-#if defined(Q_WS_WIN)
- QInputContextPrivate::updateImeStatus(this, true);
-#endif
focusInEvent((QFocusEvent*)event);
break;
case QEvent::FocusOut:
-#if defined(Q_WS_WIN)
- QInputContextPrivate::updateImeStatus(this, false);
-#endif
focusOutEvent((QFocusEvent*)event);
break;
@@ -9256,11 +9204,12 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
d->resolveLayoutDirection();
d->resolveLocale();
- // Note: GL widgets under Windows will always need a ParentChange
- // event to handle recreation/rebinding of the GL context, hence
- // the (f & Qt::MSWindowsOwnDC) clause
+ // Note: GL widgets under WGL or EGL will always need a ParentChange
+ // event to handle recreation/rebinding of the GL context, hence the
+ // (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all
+ // platforms).
if (newParent
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN) || defined(QT_OPENGL_ES)
|| (f & Qt::MSWindowsOwnDC)
#endif
) {
@@ -9806,27 +9755,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
QEvent e(QEvent::MouseTrackingChange);
QApplication::sendEvent(this, &e);
break; }
-#if !defined(QT_NO_DIRECT3D) && defined(Q_WS_WIN)
- case Qt::WA_MSWindowsUseDirect3D:
- if (!qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault)) {
- if (on) {
- if (!d->extra)
- d->createExtra();
- d->extra->had_auto_fill_bg = d->extra->autoFillBackground;
- d->extra->had_no_system_bg = testAttribute(Qt::WA_NoSystemBackground);
- d->extra->had_paint_on_screen = testAttribute(Qt::WA_PaintOnScreen);
- // enforce the opaque widget state D3D needs
- d->extra->autoFillBackground = true;
- setAttribute(Qt::WA_PaintOnScreen);
- setAttribute(Qt::WA_NoSystemBackground);
- } else if (d->extra) {
- d->extra->autoFillBackground = d->extra->had_auto_fill_bg;
- setAttribute(Qt::WA_PaintOnScreen, d->extra->had_paint_on_screen);
- setAttribute(Qt::WA_NoSystemBackground, d->extra->had_no_system_bg);
- }
- }
- break;
-#endif
case Qt::WA_NativeWindow: {
QInputContext *ic = 0;
if (on && !internalWinId() && testAttribute(Qt::WA_InputMethodEnabled) && hasFocus()) {
@@ -9838,7 +9766,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
parentWidget()->d_func()->enforceNativeChildren();
if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
d->createWinId();
- if (ic)
+ if (ic && isEnabled())
ic->setFocusWidget(this);
break;
}
@@ -9869,10 +9797,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
#endif
break;
case Qt::WA_InputMethodEnabled: {
-#if defined(Q_WS_WIN) || (defined(Q_WS_QWS) && !defined(QT_NO_QWS_INPUTMETHODS))
- if (hasFocus())
- QInputContextPrivate::updateImeStatus(this, true);
-#endif
QInputContext *ic = d->ic;
if (!ic) {
// implicitly create input context only if we have a focus
@@ -9880,7 +9804,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
ic = d->inputContext();
}
if (ic) {
- if (on && hasFocus() && ic->focusWidget() != this) {
+ if (on && hasFocus() && ic->focusWidget() != this && isEnabled()) {
ic->setFocusWidget(this);
} else if (!on && ic->focusWidget() == this) {
ic->reset();
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index f54ebf9..6703d26 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -130,7 +130,7 @@ public:
int alloc_region_index;
// int alloc_region_revision;
#endif
-#if defined(Q_OS_WINCE)
+#if defined(Q_WS_WINCE)
uint window_state_internal : 4;
#endif
QRect wrect;
@@ -469,7 +469,7 @@ public Q_SLOTS:
virtual void setVisible(bool visible);
inline void setHidden(bool hidden) { setVisible(!hidden); }
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
inline void show() { setVisible(true); }
#else
void show();
@@ -539,6 +539,7 @@ public:
QWidget *focusWidget() const;
QWidget *nextInFocusChain() const;
+ QWidget *previousInFocusChain() const;
// drag and drop
bool acceptDrops() const;
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index b2256cd..f5a8c5f 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -390,21 +390,15 @@ QWidget *qt_mac_find_window(OSWindowRef window)
inline static void qt_mac_set_fullscreen_mode(bool b)
{
- extern bool qt_mac_app_fullscreen; //qapplication_mac.cpp
+ extern bool qt_mac_app_fullscreen; //qapplication_mac.mm
if(qt_mac_app_fullscreen == b)
return;
qt_mac_app_fullscreen = b;
-#if QT_MAC_USE_COCOA
- if(b)
- SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
- else
+ if (b) {
+ SetSystemUIMode(kUIModeAllSuppressed, 0);
+ } else {
SetSystemUIMode(kUIModeNormal, 0);
-#else
- if(b)
- HideMenuBar();
- else
- ShowMenuBar();
-#endif
+ }
}
Q_GUI_EXPORT OSViewRef qt_mac_nativeview_for(const QWidget *w)
@@ -734,6 +728,7 @@ static OSWindowRef qt_mac_create_window(QWidget *, WindowClass wclass, WindowAtt
static EventTypeSpec window_events[] = {
{ kEventClassWindow, kEventWindowClose },
{ kEventClassWindow, kEventWindowExpanded },
+ { kEventClassWindow, kEventWindowHidden },
{ kEventClassWindow, kEventWindowZoomed },
{ kEventClassWindow, kEventWindowCollapsed },
{ kEventClassWindow, kEventWindowToolbarSwitchMode },
@@ -993,6 +988,19 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event,
}
}
}
+ } else if (ekind == kEventWindowHidden) {
+ // Make sure that we also hide any visible sheets on our window.
+ // Cocoa does the right thing for us.
+ const QObjectList children = widget->children();
+ const int childCount = children.count();
+ for (int i = 0; i < childCount; ++i) {
+ QObject *obj = children.at(i);
+ if (obj->isWidgetType()) {
+ QWidget *widget = static_cast<QWidget *>(obj);
+ if (qt_mac_is_macsheet(widget) && widget->isVisible())
+ widget->hide();
+ }
+ }
} else {
handled_event = false;
}
@@ -1595,24 +1603,6 @@ bool QWidgetPrivate::qt_create_root_win()
return true;
}
-bool QWidgetPrivate::qt_recreate_root_win()
-{
- if(!qt_root_win) //sanity check
- return false;
- //store old
- OSWindowRef old_root_win = qt_root_win;
- //recreate
- qt_root_win = 0;
- qt_create_root_win();
- //cleanup old window
-#ifdef QT_MAC_USE_COCOA
- [old_root_win release];
-#else
- CFRelease(old_root_win);
-#endif
- return true;
-}
-
bool QWidgetPrivate::qt_widget_rgn(QWidget *widget, short wcode, RgnHandle rgn, bool force = false)
{
bool ret = false;
@@ -4440,11 +4430,13 @@ void QWidgetPrivate::deleteSysExtra()
void QWidgetPrivate::createTLSysExtra()
{
+ extra->topextra->resizer = 0;
+ extra->topextra->isSetGeometry = 0;
+ extra->topextra->isMove = 0;
+ extra->topextra->wattr = 0;
extra->topextra->wclass = 0;
extra->topextra->group = 0;
extra->topextra->windowIcon = 0;
- extra->topextra->resizer = 0;
- extra->topextra->isSetGeometry = 0;
extra->topextra->savedWindowAttributesFromMaximized = 0;
}
@@ -4519,14 +4511,6 @@ void QWidgetPrivate::setMask_sys(const QRegion &region)
#endif
}
-extern "C" {
- typedef struct CGSConnection *CGSConnectionRef;
- typedef struct CGSWindow *CGSWindowRef;
- extern OSStatus CGSSetWindowAlpha(CGSConnectionRef, CGSWindowRef, float);
- extern CGSWindowRef GetNativeWindowFromWindowRef(WindowRef);
- extern CGSConnectionRef _CGSDefaultConnection();
-}
-
void QWidgetPrivate::setWindowOpacity_sys(qreal level)
{
Q_Q(QWidget);
@@ -4539,12 +4523,11 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
if (!q->testAttribute(Qt::WA_WState_Created))
return;
-#if QT_MAC_USE_COCOA
OSWindowRef oswindow = qt_mac_window_for(q);
+#if QT_MAC_USE_COCOA
[oswindow setAlphaValue:level];
#else
- CGSSetWindowAlpha(_CGSDefaultConnection(),
- GetNativeWindowFromWindowRef(qt_mac_window_for(q)), level);
+ SetWindowAlpha(oswindow, level);
#endif
}
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 2461820..bf4f091 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -99,93 +99,92 @@ class QWidgetItemV2;
class QStyle;
struct QTLWExtra {
+ // *************************** Cross-platform variables *****************************
+
+ // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
+ QIcon *icon; // widget icon
+ QPixmap *iconPixmap;
+ QWidgetBackingStore *backingStore;
+ QWindowSurface *windowSurface;
+ QPainter *sharedPainter;
+
+ // Implicit pointers (shared_null).
QString caption; // widget caption
QString iconText; // widget icon text
QString role; // widget role
QString filePath; // widget file path
- QIcon *icon; // widget icon
- QPixmap *iconPixmap;
+
+ // Other variables.
short incw, inch; // size increments
+ short basew, baseh; // base sizes
// frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
QRect frameStrut;
+ QRect normalGeometry; // used by showMin/maximized/FullScreen
+ Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
+
+ // *************************** Cross-platform bit fields ****************************
uint opacity : 8;
uint posFromMove : 1;
uint sizeAdjusted : 1;
uint inTopLevelResize : 1;
uint inRepaint : 1;
- QWidgetBackingStore *backingStore;
-#if defined(Q_WS_WIN)
- ulong savedFlags; // Save window flags while showing fullscreen
- uint embedded : 1; // window is embedded in another application
-#else
- Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
-#endif
- short basew, baseh; // base sizes
-#if defined(Q_WS_X11)
- WId parentWinId; // parent window Id (valid after reparenting)
- uint embedded : 1; // window is embedded in another Qt application
+ uint embedded : 1;
+
+ // *************************** Platform specific values (bit fields first) **********
+#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
uint spont_unmapped: 1; // window was spontaneously unmapped
uint dnd : 1; // DND properties installed
uint validWMState : 1; // is WM_STATE valid?
uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
+ WId parentWinId; // parent window Id (valid after reparenting)
WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
QPoint fullScreenOffset;
-#endif
-#if defined(Q_WS_MAC)
+#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
+ HICON winIconBig; // internal big Windows icon
+ HICON winIconSmall; // internal small Windows icon
+#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
+ uint resizer : 4;
+ uint isSetGeometry : 1;
+ uint isMove : 1;
quint32 wattr;
quint32 wclass;
WindowGroupRef group;
IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
- uint resizer : 4;
- uint isSetGeometry : 1;
- uint isMove : 1;
- uint embedded : 1;
-#endif
-#if defined(Q_WS_QWS) && !defined (QT_NO_QWS_MANAGER)
+#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
+#ifndef QT_NO_QWS_MANAGER
QWSManager *qwsManager;
#endif
-#if defined(Q_WS_WIN)
- HICON winIconBig; // internal big Windows icon
- HICON winIconSmall; // internal small Windows icon
#endif
- QRect normalGeometry; // used by showMin/maximized/FullScreen
- QWindowSurface *windowSurface;
- QPainter *sharedPainter;
};
struct QWExtra {
- qint32 minw, minh; // minimum size
- qint32 maxw, maxh; // maximum size
- QPointer<QWidget> focus_proxy;
-#ifndef QT_NO_CURSOR
- QCursor *curs;
-#endif
+ // *************************** Cross-platform variables *****************************
+
+ // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
+ void *glContext; // if the widget is hijacked by QGLWindowSurface
QTLWExtra *topextra; // only useful for TLWs
QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
- void *glContext; // if the widget is hijacked by QGLWindowSurface
-#if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
- QOleDropTarget *dropTarget; // drop target
- QList<QPointer<QWidget> > oleDropWidgets;
-#endif
-#if defined(Q_WS_X11)
- WId xDndProxy; // XDND forwarding to embedded windows
+#ifndef QT_NO_CURSOR
+ QCursor *curs;
#endif
+ QPointer<QStyle> style;
+ QPointer<QWidget> focus_proxy;
+
+ // Implicit pointers (shared_empty/shared_null).
QRegion mask; // widget mask
+ QString styleSheet;
+
+ // Other variables.
+ qint32 minw;
+ qint32 minh; // minimum size
+ qint32 maxw;
+ qint32 maxh; // maximum size
+ quint16 customDpiX;
+ quint16 customDpiY;
QSize staticContentsSize;
-//bit flags at the end to improve packing
-#if defined(Q_WS_WIN)
- uint shown_mode : 8; // widget show mode
-#ifndef QT_NO_DIRECT3D
- uint had_paint_on_screen : 1;
- uint had_no_system_bg : 1;
- uint had_auto_fill_bg : 1;
-#endif
-#endif
-#if defined(Q_WS_X11)
- uint compress_events : 1;
-#endif
+ // *************************** Cross-platform bit fields ****************************
uint explicitMinSize : 2;
uint explicitMaxSize : 2;
uint autoFillBackground : 1;
@@ -193,16 +192,22 @@ struct QWExtra {
uint inRenderWithPainter : 1;
uint hasMask : 1;
- QPointer<QStyle> style;
- QString styleSheet;
-
- quint16 customDpiX;
- quint16 customDpiY;
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ // *************************** Platform specific values (bit fields first) **********
+#if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
+#ifndef QT_NO_DRAGANDDROP
+ QOleDropTarget *dropTarget; // drop target
+ QList<QPointer<QWidget> > oleDropWidgets;
+#endif
+#elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
+ uint compress_events : 1;
+ WId xDndProxy; // XDND forwarding to embedded windows
+#elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
+#ifdef QT_MAC_USE_COCOA
// Cocoa Mask stuff
QImage maskBits;
CGImageRef imageMask;
#endif
+#endif
};
class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
@@ -210,6 +215,24 @@ class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QWidget)
public:
+ // *************************** Cross-platform ***************************************
+ enum DrawWidgetFlags {
+ DrawAsRoot = 0x01,
+ DrawPaintOnScreen = 0x02,
+ DrawRecursive = 0x04,
+ DrawInvisible = 0x08,
+ DontSubtractOpaqueChildren = 0x10,
+ DontSetCompositionMode = 0x20,
+ DontDrawOpaqueChildren = 0x40
+ };
+
+ enum CloseMode {
+ CloseNoEvent,
+ CloseWithEvent,
+ CloseWithSpontaneousEvent
+ };
+
+ // Functions.
explicit QWidgetPrivate(int version = QObjectPrivateVersion);
~QWidgetPrivate();
@@ -219,10 +242,6 @@ public:
QPainter *sharedPainter() const;
void setSharedPainter(QPainter *painter);
QWidgetBackingStore *maybeBackingStore() const;
-#ifdef Q_WS_QWS
- void setMaxWindowState_helper();
- void setFullScreenSize_helper();
-#endif
void init(QWidget *desktopWidget, Qt::WindowFlags f);
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
void createRecursively();
@@ -243,24 +262,6 @@ public:
QPalette naturalWidgetPalette(uint inheritedMask) const;
void setMask_sys(const QRegion &);
-#ifdef Q_WS_WIN
- bool shouldShowMaximizeButton();
- void winUpdateIsOpaque();
-#endif
-
-#ifdef Q_WS_MAC
- void macUpdateSizeAttribute();
- void macUpdateHideOnSuspend();
- void macUpdateOpaqueSizeGrip();
- void macUpdateIgnoreMouseEvents();
- void macUpdateMetalAttribute();
- void macUpdateIsOpaque();
- void setEnabled_helper_sys(bool enable);
- bool isRealWindow() const;
- void adjustWithinMaxAndMinSize(int &w, int &h);
- void applyMaxAndMinSizeOnWindow();
-#endif
-
void raise_sys();
void lower_sys();
void stackUnder_sys(QWidget *);
@@ -285,20 +286,9 @@ public:
void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
void inheritStyle();
- bool isBackgroundInherited() const;
-
void setUpdatesEnabled_helper(bool );
void paintBackground(QPainter *, const QRegion &, const QPoint & = QPoint(), int flags = DrawAsRoot) const;
- enum DrawWidgetFlags {
- DrawAsRoot = 0x01,
- DrawPaintOnScreen = 0x02,
- DrawRecursive = 0x04,
- DrawInvisible = 0x08,
- DontSubtractOpaqueChildren = 0x10,
- DontSetCompositionMode = 0x20,
- DontDrawOpaqueChildren = 0x40
- };
bool isAboutToShow() const;
QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
@@ -321,10 +311,6 @@ public:
QWindowSurface *createDefaultWindowSurface();
QWindowSurface *createDefaultWindowSurface_sys();
void repaint_sys(const QRegion &rgn);
-#ifdef Q_WS_MAC
- void update_sys(const QRect &rect);
- void update_sys(const QRegion &rgn);
-#endif
QRect clipRect() const;
QRegion clipRegion() const;
@@ -335,42 +321,20 @@ public:
void updateIsOpaque();
void setOpaque(bool opaque);
void updateIsTranslucent();
- bool hasBackground() const;
bool paintOnScreen() const;
QRegion getOpaqueRegion() const;
const QRegion &getOpaqueChildren() const;
void setDirtyOpaqueRegion();
- QRegion opaqueChildren;
-
- enum CloseMode {
- CloseNoEvent,
- CloseWithEvent,
- CloseWithSpontaneousEvent
- };
bool close_helper(CloseMode mode);
- bool compositeEvent(QEvent *e);
void setWindowIcon_helper();
void setWindowIcon_sys(bool forceReset = false);
void setWindowOpacity_sys(qreal opacity);
-
void adjustQuitOnCloseAttribute();
-#if defined(Q_WS_X11)
- void setWindowRole();
- void sendStartupMessage(const char *message) const;
- void setNetWmWindowTypes();
- void x11UpdateIsOpaque();
-#endif
-
-#if defined (Q_WS_WIN)
- void reparentChildren();
-#endif
-
void scrollChildren(int dx, int dy);
-
void moveRect(const QRect &, int dx, int dy);
void scrollRect(const QRect &, int dx, int dy);
void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
@@ -384,7 +348,6 @@ public:
void reparentFocusWidgets(QWidget *oldtlw);
static int pointToRect(const QPoint &p, const QRect &r);
- QRect fromOrToLayoutItemRect(const QRect &rect, int sign) const;
void setWinId(WId);
void showChildren(bool spontaneous);
@@ -394,9 +357,6 @@ public:
void scroll_sys(int dx, int dy, const QRect &r);
void deactivateWidgetCleanup();
void setGeometry_sys(int, int, int, int, bool);
-#ifdef Q_WS_MAC
- void setGeometry_sys_helper(int, int, int, int, bool);
-#endif
void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
void activateChildLayoutsRecursively();
void show_recursive();
@@ -408,10 +368,6 @@ public:
void setEnabled_helper(bool);
void registerDropSite(bool);
-#if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
- QOleDropTarget *registerOleDnd(QWidget *widget);
- void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
-#endif
static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
void updateFrameStrut();
@@ -421,32 +377,11 @@ public:
void setWindowIconText_helper(const QString &cap);
void setWindowTitle_sys(const QString &cap);
-#ifdef Q_OS_WIN
- void grabMouseWhileInWindow();
-#endif
-
#ifndef QT_NO_CURSOR
void setCursor_sys(const QCursor &cursor);
void unsetCursor_sys();
#endif
-#ifdef Q_WS_MAC
- void setWindowModified_sys(bool b);
- void updateMaximizeButton_sys();
- void setWindowFilePath_sys(const QString &filePath);
- void createWindow_sys();
- void recreateMacWindow();
-#ifndef QT_MAC_USE_COCOA
- void initWindowPtr();
- void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
-#else
- void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
- void syncCocoaMask();
- void finishCocoaMaskSetup();
-#endif
- void determineWindowClass();
- void transferChildren();
-#endif
void setWindowTitle_helper(const QString &cap);
void setWindowFilePath_helper(const QString &filePath);
@@ -462,59 +397,89 @@ public:
QInputContext *inputContext() const;
-#if defined(Q_WS_QWS)
- void moveSurface(QWindowSurface *surface, const QPoint &offset);
+ void setModal_sys();
- QRegion localRequestedRegion() const;
- QRegion localAllocatedRegion() const;
+ inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
+ {
+ Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
+ redirectDev = replacement;
+ redirectOffset = offset;
+ }
- void blitToScreen(const QRegion &globalrgn);
-#ifndef QT_NO_CURSOR
- void updateCursor() const;
-#endif
+ inline QPaintDevice *redirected(QPoint *offset) const
+ {
+ if (offset)
+ *offset = redirectDev ? redirectOffset : QPoint();
+ return redirectDev;
+ }
- QScreen* getScreen() const;
+ inline void restoreRedirected()
+ { redirectDev = 0; }
- friend class QWSManager;
- friend class QWSManagerPrivate;
- friend class QDecoration;
-#endif
+ inline void enforceNativeChildren()
+ {
+ if (!extra)
+ createExtra();
- static int instanceCounter; // Current number of widget instances
- static int maxInstances; // Maximum number of widget instances
+ if (extra->nativeChildrenForced)
+ return;
+ extra->nativeChildrenForced = 1;
-#ifdef QT_KEYPAD_NAVIGATION
- static QPointer<QWidget> editingWidget;
-#endif
+ for (int i = 0; i < children.size(); ++i) {
+ if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
+ child->setAttribute(Qt::WA_NativeWindow);
+ }
+ }
- QWidgetData data;
+ inline bool nativeChildrenForced() const
+ {
+ return extra ? extra->nativeChildrenForced : false;
+ }
+ QSize adjustedSize() const;
+
+#ifndef Q_WS_QWS // Almost cross-platform :-)
+ void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
+
+ inline QPoint mapToWS(const QPoint &p) const
+ { return p - data.wrect.topLeft(); }
+
+ inline QPoint mapFromWS(const QPoint &p) const
+ { return p + data.wrect.topLeft(); }
+
+ inline QRect mapToWS(const QRect &r) const
+ { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
+
+ inline QRect mapFromWS(const QRect &r) const
+ { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
+#endif
+
+ // Variables.
+ // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
QWExtra *extra;
QWidget *focus_next;
QWidget *focus_prev;
QWidget *focus_child;
-#ifndef QT_NO_ACTION
- QList<QAction*> actions;
-#endif
QLayout *layout;
+ QRegion *needsFlush;
+ QPaintDevice *redirectDev;
QWidgetItemV2 *widgetItem;
-#if !defined(QT_NO_IM)
- QPointer<QInputContext> ic;
-#endif
+ QPaintEngine *extraPaintEngine;
+ mutable const QMetaObject *polished;
// All widgets are initially added into the uncreatedWidgets set. Once
// they receive a window id they are removed and added to the mapper
static QWidgetMapper *mapper;
static QWidgetSet *uncreatedWidgets;
+#if !defined(QT_NO_IM)
+ QPointer<QInputContext> ic;
+#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ static QPointer<QWidget> editingWidget;
+#endif
- short leftmargin, topmargin, rightmargin, bottommargin;
-
- signed char leftLayoutItemMargin;
- signed char topLayoutItemMargin;
- signed char rightLayoutItemMargin;
- signed char bottomLayoutItemMargin;
-
- // ### TODO: reorganize private/extra/topextra to save memory
- QPointer<QWidget> compositeChildGrab;
+ // Implicit pointers (shared_null/shared_empty).
+ QRegion opaqueChildren;
+ QRegion dirty;
#ifndef QT_NO_TOOLTIP
QString toolTip;
#endif
@@ -524,14 +489,37 @@ public:
#ifndef QT_NO_WHATSTHIS
QString whatsThis;
#endif
- QString accessibleName, accessibleDescription;
+#ifndef QT_NO_ACCESSIBILITY
+ QString accessibleName;
+ QString accessibleDescription;
+#endif
+
+ // Other variables.
+ uint inheritedFontResolveMask;
+ uint inheritedPaletteResolveMask;
+ short leftmargin;
+ short topmargin;
+ short rightmargin;
+ short bottommargin;
+ signed char leftLayoutItemMargin;
+ signed char topLayoutItemMargin;
+ signed char rightLayoutItemMargin;
+ signed char bottomLayoutItemMargin;
+ static int instanceCounter; // Current number of widget instances
+ static int maxInstances; // Maximum number of widget instances
+ Qt::HANDLE hd;
+ QWidgetData data;
+ QSizePolicy size_policy;
+ QLocale locale;
+ QPoint redirectOffset;
+#ifndef QT_NO_ACTION
+ QList<QAction*> actions;
+#endif
+ // Bit fields.
+ uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
QPalette::ColorRole fg_role : 8;
QPalette::ColorRole bg_role : 8;
- uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
- Qt::HANDLE hd;
- QRegion dirty;
- QRegion *needsFlush;
uint dirtyOpaqueChildren : 1;
uint isOpaque : 1;
uint inDirtyList : 1;
@@ -539,35 +527,33 @@ public:
uint isMoved : 1;
uint usesDoubleBufferedGLContext : 1;
-#ifdef Q_WS_WIN
- uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
-#endif
-
- uint inheritedFontResolveMask;
- uint inheritedPaletteResolveMask;
-#if defined(Q_WS_X11)
+ // *************************** Platform specific ************************************
+#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
QX11Info xinfo;
Qt::HANDLE picture;
+ static QWidget *mouseGrabber;
+ static QWidget *keyboardGrabber;
+
+ void setWindowRole();
+ void sendStartupMessage(const char *message) const;
+ void setNetWmWindowTypes();
+ void x11UpdateIsOpaque();
+ bool isBackgroundInherited() const;
+#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
+ uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
+
+ bool shouldShowMaximizeButton();
+ void winUpdateIsOpaque();
+ void reparentChildren();
+#ifndef QT_NO_DRAGANDDROP
+ QOleDropTarget *registerOleDnd(QWidget *widget);
+ void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
#endif
-#if defined(Q_WS_MAC)
- enum PaintChildrenOPs {
- PC_None = 0x00,
- PC_Now = 0x01,
- PC_NoPaint = 0x04,
- PC_Later = 0x10
- };
- EventHandlerRef window_event;
- bool qt_mac_dnd_event(uint, DragRef);
- void toggleDrawers(bool);
- //mac event functions
- static bool qt_create_root_win();
- static void qt_clean_root_win();
- static bool qt_recreate_root_win();
- static bool qt_mac_update_sizer(QWidget *, int up = 0);
- static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
- static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
- static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
- static bool qt_widget_shape(QWidget *, short, HIMutableShapeRef, bool);
+ void grabMouseWhileInWindow();
+#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
+ // This is new stuff
+ uint needWindowChange : 1;
+ uint isGLWidget : 1;
// Each wiget keeps a list of all its child and grandchild OpenGL widgets.
// This list is used to update the gl context whenever a parent and a granparent
@@ -580,95 +566,70 @@ public:
QWidget * widget;
QWidget * lastUpdateWidget;
};
- QList<GlWidgetInfo> glWidgets;
// dirtyOnWidget contains the areas in the widget that needs to be repained,
// in the same way as dirtyOnScreen does for the window. Areas are added in
// dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
// this information repaint invalid areas when widgets are scrolled.
QRegion dirtyOnWidget;
+ EventHandlerRef window_event;
+ QList<GlWidgetInfo> glWidgets;
//these are here just for code compat (HIViews)
Qt::HANDLE qd_hd;
- // This is new stuff
- uint needWindowChange : 1;
- uint isGLWidget : 1;
-#endif
-
-#if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined(Q_WS_MAC)
-#ifdef Q_WS_MAC
- void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
+ void macUpdateSizeAttribute();
+ void macUpdateHideOnSuspend();
+ void macUpdateOpaqueSizeGrip();
+ void macUpdateIgnoreMouseEvents();
+ void macUpdateMetalAttribute();
+ void macUpdateIsOpaque();
+ void setEnabled_helper_sys(bool enable);
+ bool isRealWindow() const;
+ void adjustWithinMaxAndMinSize(int &w, int &h);
+ void applyMaxAndMinSizeOnWindow();
+ void update_sys(const QRect &rect);
+ void update_sys(const QRegion &rgn);
+ void setGeometry_sys_helper(int, int, int, int, bool);
+ void setWindowModified_sys(bool b);
+ void updateMaximizeButton_sys();
+ void setWindowFilePath_sys(const QString &filePath);
+ void createWindow_sys();
+ void recreateMacWindow();
+#ifndef QT_MAC_USE_COCOA
+ void initWindowPtr();
+ void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
#else
- void setWSGeometry(bool dontShow=false);
+ void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
+ void syncCocoaMask();
+ void finishCocoaMaskSetup();
#endif
+ void determineWindowClass();
+ void transferChildren();
+ bool qt_mac_dnd_event(uint, DragRef);
+ void toggleDrawers(bool);
+ //mac event functions
+ static bool qt_create_root_win();
+ static void qt_clean_root_win();
+ static bool qt_mac_update_sizer(QWidget *, int up = 0);
+ static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
+ static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
+ static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
+#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
+ void setMaxWindowState_helper();
+ void setFullScreenSize_helper();
+ void moveSurface(QWindowSurface *surface, const QPoint &offset);
+ QRegion localRequestedRegion() const;
+ QRegion localAllocatedRegion() const;
- inline QPoint mapToWS(const QPoint &p) const
- { return p - data.wrect.topLeft(); }
-
- inline QPoint mapFromWS(const QPoint &p) const
- { return p + data.wrect.topLeft(); }
-
- inline QRect mapToWS(const QRect &r) const
- { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
-
- inline QRect mapFromWS(const QRect &r) const
- { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
+ friend class QWSManager;
+ friend class QWSManagerPrivate;
+ friend class QDecoration;
+#ifndef QT_NO_CURSOR
+ void updateCursor() const;
#endif
-
- QPaintEngine *extraPaintEngine;
-
- mutable const QMetaObject *polished;
-
- void setModal_sys();
- QSizePolicy size_policy;
- QLocale locale;
-
-#ifdef Q_WS_X11
- static QWidget *mouseGrabber;
- static QWidget *keyboardGrabber;
+ QScreen* getScreen() const;
#endif
- QPaintDevice *redirectDev;
- QPoint redirectOffset;
-
- inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
- {
- Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
- redirectDev = replacement;
- redirectOffset = offset;
- }
-
- inline QPaintDevice *redirected(QPoint *offset) const
- {
- if (offset)
- *offset = redirectDev ? redirectOffset : QPoint();
- return redirectDev;
- }
-
- inline void restoreRedirected()
- { redirectDev = 0; }
-
- inline void enforceNativeChildren()
- {
- if (!extra)
- createExtra();
-
- if (extra->nativeChildrenForced)
- return;
- extra->nativeChildrenForced = 1;
-
- for (int i = 0; i < children.size(); ++i) {
- if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
- child->setAttribute(Qt::WA_NativeWindow);
- }
- }
-
- inline bool nativeChildrenForced() const
- {
- return extra ? extra->nativeChildrenForced : false;
- }
-
- QSize adjustedSize() const;
};
inline QWExtra *QWidgetPrivate::extraData() const
diff --git a/src/gui/kernel/qwidget_qws.cpp b/src/gui/kernel/qwidget_qws.cpp
index 1445f57..94bdb85 100644
--- a/src/gui/kernel/qwidget_qws.cpp
+++ b/src/gui/kernel/qwidget_qws.cpp
@@ -565,20 +565,6 @@ void QWidget::activateWindow()
}
}
-/*
- Should we require that q is a toplevel window ???
-
- Used by QWSManager
- */
-void QWidgetPrivate::blitToScreen(const QRegion &globalrgn)
-{
- Q_Q(QWidget);
- QWidget *win = q->window();
- QBrush bgBrush = win->palette().brush(win->backgroundRole());
- bool opaque = bgBrush.style() == Qt::NoBrush || bgBrush.isOpaque();
- QWidget::qwsDisplay()->repaintRegion(win->data->winid, win->windowFlags(), opaque, globalrgn);
-}
-
void QWidgetPrivate::show_sys()
{
Q_Q(QWidget);
@@ -1037,6 +1023,9 @@ void QWidgetPrivate::deleteSysExtra()
void QWidgetPrivate::createTLSysExtra()
{
+#ifndef QT_NO_QWS_MANAGER
+ extra->topextra->qwsManager = 0;
+#endif
}
void QWidgetPrivate::deleteTLSysExtra()
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index ffbb341..0f341fd 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -56,19 +56,13 @@
#include "private/qbackingstore_p.h"
#include "private/qwindowsurface_raster_p.h"
-#ifndef QT_NO_DIRECT3D
-#include "private/qpaintengine_d3d_p.h"
-#include "private/qwindowsurface_d3d_p.h"
-#endif
-
-
#include <qdebug.h>
#include <private/qapplication_p.h>
#include <private/qwininputcontext_p.h>
#include <private/qpaintengine_raster_p.h>
-#if defined(Q_OS_WINCE)
+#if defined(Q_WS_WINCE)
#include "qguifunctions_wince.h"
QT_USE_NAMESPACE
extern void qt_wince_maximize(QWidget *widget); //defined in qguifunctions_wince.cpp
@@ -257,7 +251,7 @@ extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
QWidget member functions
*****************************************************************************/
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
{
Q_Q(QWidget);
@@ -546,7 +540,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
}
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
@@ -574,7 +568,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if (destroyWindow && !(windowType() == Qt::Desktop) && internalWinId()) {
DestroyWindow(internalWinId());
}
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
if (destroyWindow && (windowType() == Qt::Desktop) && !GetDesktopWindow()) {
DestroyWindow(internalWinId());
}
@@ -681,7 +675,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
}
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
// Show borderless toplevel windows in tasklist & NavBar
if (!parent) {
QString txt = q->windowTitle().isEmpty()?qAppName():q->windowTitle();
@@ -877,12 +871,12 @@ QCursor *qt_grab_cursor()
}
// The procedure does nothing, but is required for mousegrabbing to work
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
LRESULT CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam)
{
return CallNextHookEx(journalRec, nCode, wParam, lParam);
}
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
/* Works only as long as pointer is inside the application's window,
which is good enough for QDockWidget.
@@ -905,7 +899,7 @@ void QWidgetPrivate::grabMouseWhileInWindow()
}
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
void QWidget::grabMouse()
{
if (!qt_nograb()) {
@@ -982,7 +976,7 @@ void QWidget::activateWindow()
SetForegroundWindow(window()->internalWinId());
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
void QWidget::setWindowState(Qt::WindowStates newstate)
{
Q_D(QWidget);
@@ -1031,13 +1025,13 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
if (newstate & Qt::WindowFullScreen) {
if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized))
d->topData()->normalGeometry = geometry();
- d->topData()->savedFlags = GetWindowLongA(internalWinId(), GWL_STYLE);
+ d->topData()->savedFlags = Qt::WindowFlags(GetWindowLongA(internalWinId(), GWL_STYLE));
#ifndef Q_FLATTEN_EXPOSE
UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
#else
UINT style = WS_POPUP;
#endif
- if (d->topData()->savedFlags & WS_SYSMENU)
+ if (ulong(d->topData()->savedFlags) & WS_SYSMENU)
style |= WS_SYSMENU;
if (isVisible())
style |= WS_VISIBLE;
@@ -1084,7 +1078,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
QWindowStateChangeEvent e(oldstate);
QApplication::sendEvent(this, &e);
}
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
/*
@@ -1097,7 +1091,7 @@ void QWidgetPrivate::hide_sys()
Q_Q(QWidget);
deactivateWidgetCleanup();
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
if (!qt_wince_is_mobile() && q->isFullScreen()) {
HWND handle = FindWindow(L"HHTaskBar", L"");
if (handle) {
@@ -1126,7 +1120,7 @@ void QWidgetPrivate::hide_sys()
\internal
Platform-specific part of QWidget::show().
*/
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
void QWidgetPrivate::show_sys()
{
Q_Q(QWidget);
@@ -1194,7 +1188,7 @@ void QWidgetPrivate::show_sys()
invalidateBuffer(q->rect());
}
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
void QWidgetPrivate::setFocus_sys()
{
@@ -1240,7 +1234,7 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w)
(In all comments below: s/X/Windows/g)
*/
-void QWidgetPrivate::setWSGeometry(bool dontShow)
+void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &)
{
Q_Q(QWidget);
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
@@ -1452,7 +1446,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
show_sys();
} else if (!q->testAttribute(Qt::WA_DontShowOnScreen)) {
q->setAttribute(Qt::WA_OutsideWSRange, false);
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// If the window is hidden and in maximized state or minimized, instead of moving the
// window, set the normal position of the window.
WINDOWPLACEMENT wndpl;
@@ -1571,7 +1565,7 @@ bool QWidgetPrivate::shouldShowMaximizeButton()
void QWidgetPrivate::winUpdateIsOpaque()
{
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
Q_Q(QWidget);
if (!q->isWindow() || !q->testAttribute(Qt::WA_TranslucentBackground))
@@ -1592,7 +1586,7 @@ void QWidgetPrivate::winUpdateIsOpaque()
void QWidgetPrivate::setConstraints_sys()
{
-#ifndef Q_OS_WINCE_WM
+#ifndef Q_WS_WINCE_WM
Q_Q(QWidget);
if (q->isWindow() && q->testAttribute(Qt::WA_WState_Created)) {
int style = GetWindowLongA(q->internalWinId(), GWL_STYLE);
@@ -1710,28 +1704,24 @@ int QWidget::metric(PaintDeviceMetric m) const
return val;
}
-#ifndef Q_OS_WINCE
void QWidgetPrivate::createSysExtra()
{
#ifndef QT_NO_DRAGANDDROP
extra->dropTarget = 0;
#endif
-#ifndef QT_NO_DIRECT3D
- extra->had_auto_fill_bg = 0;
- extra->had_paint_on_screen = 0;
- extra->had_no_system_bg = 0;
-#endif
}
+#ifndef Q_WS_WINCE
void QWidgetPrivate::deleteSysExtra()
{
}
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
void QWidgetPrivate::createTLSysExtra()
{
- extra->topextra->winIconSmall = 0;
+ extra->topextra->savedFlags = 0;
extra->topextra->winIconBig = 0;
+ extra->topextra->winIconSmall = 0;
}
void QWidgetPrivate::deleteTLSysExtra()
@@ -1877,7 +1867,7 @@ void QWidgetPrivate::updateFrameStrut()
GetWindowLongA(q->internalWinId(), GWL_EXSTYLE));
uint style = QT_WA_INLINE(GetWindowLongW(q->internalWinId(), GWL_STYLE),
GetWindowLongA(q->internalWinId(), GWL_STYLE));
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
if (AdjustWindowRectEx(&rect, style & ~(WS_OVERLAPPED), FALSE, exstyle)) {
#else
if (AdjustWindowRectEx(&rect, style, FALSE, exstyle)) {
@@ -1887,7 +1877,7 @@ void QWidgetPrivate::updateFrameStrut()
}
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
void QWidgetPrivate::setWindowOpacity_sys(qreal level)
{
Q_Q(QWidget);
@@ -1922,7 +1912,7 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
}
(*ptrSetLayeredWindowAttributes)(q->internalWinId(), 0, (int)(level * 255), Q_LWA_ALPHA);
}
-#endif //Q_OS_WINCE
+#endif //Q_WS_WINCE
// class QGlobalRasterPaintEngine: public QRasterPaintEngine
// {
@@ -1931,22 +1921,6 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
// };
// Q_GLOBAL_STATIC(QGlobalRasterPaintEngine, globalRasterPaintEngine)
-#ifndef QT_NO_DIRECT3D
-static void cleanup_d3d_engine();
-Q_GLOBAL_STATIC_WITH_INITIALIZER(QDirect3DPaintEngine, _qt_d3dEngine,
- {
- qAddPostRoutine(cleanup_d3d_engine);
- })
-static void cleanup_d3d_engine()
-{
- _qt_d3dEngine()->cleanup();
-}
-QDirect3DPaintEngine* qt_d3dEngine()
-{
- return _qt_d3dEngine();
-}
-#endif
-
#ifndef QT_NO_DIRECTDRAW
static uchar *qt_primary_surface_bits;
@@ -2059,19 +2033,6 @@ void qt_win_initialize_directdraw() { }
QPaintEngine *QWidget::paintEngine() const
{
-#ifndef QT_NO_DIRECT3D
- if ((qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault)
- || testAttribute(Qt::WA_MSWindowsUseDirect3D))
- && qt_d3dEngine()->hasDirect3DSupport())
- {
- QDirect3DPaintEngine *engine = qt_d3dEngine();
- if (qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault))
- engine->setFlushOnEnd(false);
- else
- engine->setFlushOnEnd(true);
- return engine;
- }
-#endif
#ifndef QT_NO_DIRECTDRAW
QOnScreenRasterPaintEngine *pe = onScreenPaintEngine();
pe->widget = this;
@@ -2100,13 +2061,6 @@ QPaintEngine *QWidget::paintEngine() const
QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
{
Q_Q(QWidget);
-#ifndef QT_NO_DIRECT3D
- extern QDirect3DPaintEngine *qt_d3dEngine();
- if (qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault) && (q->windowOpacity() == 1.0f)
- && qt_d3dEngine()->hasDirect3DSupport()) {
- return new QD3DWindowSurface(q);
- }
-#endif
return new QRasterWindowSurface(q);
}
@@ -2119,6 +2073,6 @@ void QWidgetPrivate::setModal_sys()
QT_END_NAMESPACE
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
# include "qwidget_wince.cpp"
#endif
diff --git a/src/gui/kernel/qwidget_wince.cpp b/src/gui/kernel/qwidget_wince.cpp
index bb9681e..435fd31 100644
--- a/src/gui/kernel/qwidget_wince.cpp
+++ b/src/gui/kernel/qwidget_wince.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#include "qguifunctions_wince.h"
@@ -211,7 +211,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
style |= WS_SYSMENU;
if (flags & Qt::WindowContextHelpButtonHint)
exsty |= WS_EX_CONTEXTHELP;
-#ifndef Q_OS_WINCE_WM
+#ifndef Q_WS_WINCE_WM
if (flags & Qt::WindowMinimizeButtonHint)
style |= WS_MINIMIZEBOX;
if (shouldShowMaximizeButton())
@@ -414,7 +414,7 @@ void QWidgetPrivate::show_sys() {
int sm = SW_SHOW;
bool fakedMaximize = false;
if (q->isWindow()) {
-#ifndef Q_OS_WINCE_WM
+#ifndef Q_WS_WINCE_WM
if (q->isMinimized()) {
sm = SW_SHOWMINIMIZED;
} else if (q->isMaximized()) {
@@ -450,7 +450,7 @@ void QWidgetPrivate::show_sys() {
if (q->isMaximized() && q->isWindow())
qt_wince_maximize(q);
-#ifndef Q_OS_WINCE_WM
+#ifndef Q_WS_WINCE_WM
if (!qt_wince_is_mobile() && q->isFullScreen()) {
HWND handle = FindWindow(L"HHTaskBar", L"");
if (handle) {
@@ -535,7 +535,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
if (newstate & Qt::WindowFullScreen) {
if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized))
d->topData()->normalGeometry = geometry();
- d->topData()->savedFlags = GetWindowLongA(internalWinId(), GWL_STYLE);
+ d->topData()->savedFlags = (Qt::WindowFlags) GetWindowLongA(internalWinId(), GWL_STYLE);
UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
if (isVisible())
style |= WS_VISIBLE;
@@ -583,7 +583,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
}
if ((newstate & Qt::WindowMaximized) && !(newstate & Qt::WindowFullScreen)) {
QRect r = d->topData()->normalGeometry;
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
if (!inherits("QDialog") && !inherits("QMdiArea") && !isVisible()) {
d->data.crect.setRect(0, 0, -1, -1);
}
@@ -598,13 +598,6 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
QApplication::sendEvent(this, &e);
}
-
-void QWidgetPrivate::createSysExtra() {
-#ifndef QT_NO_DRAGANDDROP
- extra->dropTarget = 0;
-#endif
-}
-
void QWidgetPrivate::deleteSysExtra()
{
Q_Q(QWidget);
@@ -704,4 +697,4 @@ void QWidget::show()
QT_END_NAMESPACE
-#endif Q_OS_WINCE
+#endif // Q_WS_WINCE
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 6250fb77..4e34045 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -893,19 +893,70 @@ void QWidgetPrivate::x11UpdateIsOpaque()
int screen = xinfo.screen();
if (topLevel && X11->use_xrender
&& X11->argbVisuals[screen] && xinfo.depth() != 32) {
- // recreate widget
- QPoint pos = q->pos();
- bool visible = q->isVisible();
- if (visible)
- q->hide();
- q->setParent(q->parentWidget(), q->windowFlags());
- q->move(pos);
- if (visible)
- q->show();
+
+ if (q->inherits("QGLWidget")) {
+ // We send QGLWidgets a ParentChange event which causes them to
+ // recreate their GL context, which in turn causes them to choose
+ // their visual again. Now that WA_TranslucentBackground is set,
+ // QGLContext::chooseVisual will select an ARGB visual.
+ QEvent e(QEvent::ParentChange);
+ QApplication::sendEvent(q, &e);
+ }
+ else {
+ // For regular widgets, reparent them with their parent which
+ // also triggers a recreation of the native window
+ QPoint pos = q->pos();
+ bool visible = q->isVisible();
+ if (visible)
+ q->hide();
+
+ q->setParent(q->parentWidget(), q->windowFlags());
+ q->move(pos);
+ if (visible)
+ q->show();
+ }
}
#endif
}
+/*
+ Returns true if the background is inherited; otherwise returns
+ false.
+
+ Mainly used in the paintOnScreen case.
+*/
+bool QWidgetPrivate::isBackgroundInherited() const
+{
+ Q_Q(const QWidget);
+
+ // windows do not inherit their background
+ if (q->isWindow() || q->windowType() == Qt::SubWindow)
+ return false;
+
+ if (q->testAttribute(Qt::WA_NoSystemBackground) || q->testAttribute(Qt::WA_OpaquePaintEvent))
+ return false;
+
+ const QPalette &pal = q->palette();
+ QPalette::ColorRole bg = q->backgroundRole();
+ QBrush brush = pal.brush(bg);
+
+ // non opaque brushes leaves us no choice, we must inherit
+ if (!q->autoFillBackground() || !brush.isOpaque())
+ return true;
+
+ if (brush.style() == Qt::SolidPattern) {
+ // the background is just a solid color. If there is no
+ // propagated contents, then we claim as performance
+ // optimization that it was not inheritet. This is the normal
+ // case in standard Windows or Motif style.
+ const QWidget *w = q->parentWidget();
+ if (!w->d_func()->isBackgroundInherited())
+ return false;
+ }
+
+ return true;
+}
+
void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
{
Q_D(QWidget);
@@ -1308,17 +1359,10 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
// already been set
return;
- XWMHints *h = 0;
- if (q->internalWinId())
- h = XGetWMHints(X11->display, q->internalWinId());
- XWMHints wm_hints;
- if (!h) {
- memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
- h = &wm_hints;
- }
-
// preparing images to set the _NET_WM_ICON property
QIcon icon = q->windowIcon();
+ QVector<long> icon_data;
+ Qt::HANDLE pixmap_handle = 0;
if (!icon.isNull()) {
QList<QSize> availableSizes = icon.availableSizes();
if(availableSizes.isEmpty()) {
@@ -1328,7 +1372,6 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
availableSizes.push_back(QSize(64,64));
availableSizes.push_back(QSize(128,128));
}
- QVector<long> icon_data;
for(int i = 0; i < availableSizes.size(); ++i) {
QSize size = availableSizes.at(i);
QPixmap pixmap = icon.pixmap(size);
@@ -1350,11 +1393,6 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
}
}
if (!icon_data.isEmpty()) {
- if (q->internalWinId()) {
- XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON), XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *) icon_data.data(),
- icon_data.size());
- }
extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap);
/*
if the app is running on an unknown desktop, or it is not
@@ -1368,22 +1406,44 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
// unknown DE or non-default visual/colormap, use 1bpp bitmap
if (!forceReset || !topData->iconPixmap)
topData->iconPixmap = new QBitmap(qt_toX11Pixmap(icon.pixmap(QSize(64,64))));
- h->icon_pixmap = topData->iconPixmap->handle();
+ pixmap_handle = topData->iconPixmap->handle();
} else {
// default depth, use a normal pixmap (even though this
// violates the ICCCM), since this works on all DEs known to Qt
if (!forceReset || !topData->iconPixmap)
topData->iconPixmap = new QPixmap(qt_toX11Pixmap(icon.pixmap(QSize(64,64))));
- h->icon_pixmap = static_cast<QX11PixmapData*>(topData->iconPixmap->data)->x11ConvertToDefaultDepth();
+ pixmap_handle = static_cast<QX11PixmapData*>(topData->iconPixmap->data)->x11ConvertToDefaultDepth();
}
- h->flags |= IconPixmapHint;
- } else {
- h->flags &= ~(IconPixmapHint | IconMaskHint);
}
}
- if (q->internalWinId())
- XSetWMHints(X11->display, q->internalWinId(), h);
+ if (!q->internalWinId())
+ return;
+
+ if (!icon_data.isEmpty()) {
+ XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON), XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *) icon_data.data(),
+ icon_data.size());
+ } else {
+ XDeleteProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON));
+ }
+
+ XWMHints *h = XGetWMHints(X11->display, q->internalWinId());
+ XWMHints wm_hints;
+ if (!h) {
+ memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
+ h = &wm_hints;
+ }
+
+ if (pixmap_handle) {
+ h->icon_pixmap = pixmap_handle;
+ h->flags |= IconPixmapHint;
+ } else {
+ h->icon_pixmap = 0;
+ h->flags &= ~(IconPixmapHint | IconMaskHint);
+ }
+
+ XSetWMHints(X11->display, q->internalWinId(), h);
if (h != &wm_hints)
XFree((char *)h);
}
@@ -2151,7 +2211,7 @@ static void do_size_hints(QWidget* widget, QWExtra *x)
parentWRect is the geometry of the parent's X rect, measured in
parent's coord sys
*/
-void QWidgetPrivate::setWSGeometry(bool dontShow)
+void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &)
{
Q_Q(QWidget);
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
@@ -2611,8 +2671,8 @@ int QWidget::metric(PaintDeviceMetric m) const
void QWidgetPrivate::createSysExtra()
{
- extra->xDndProxy = 0;
extra->compress_events = true;
+ extra->xDndProxy = 0;
}
void QWidgetPrivate::deleteSysExtra()
@@ -2621,8 +2681,11 @@ void QWidgetPrivate::deleteSysExtra()
void QWidgetPrivate::createTLSysExtra()
{
+ extra->topextra->spont_unmapped = 0;
+ extra->topextra->dnd = 0;
extra->topextra->validWMState = 0;
extra->topextra->waitingForMapNotify = 0;
+ extra->topextra->parentWinId = 0;
extra->topextra->userTimeWindow = 0;
}
diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h
index 3899c23..a24afd4 100644
--- a/src/gui/kernel/qwindowdefs_win.h
+++ b/src/gui/kernel/qwindowdefs_win.h
@@ -122,7 +122,7 @@ QT_BEGIN_NAMESPACE
Q_CORE_EXPORT HINSTANCE qWinAppInst();
Q_CORE_EXPORT HINSTANCE qWinAppPrevInst();
-Q_GUI_EXPORT int qWinAppCmdShow();
+Q_CORE_EXPORT int qWinAppCmdShow();
Q_GUI_EXPORT HDC qt_win_display_dc();
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index 6329135..ae93efe 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -1297,9 +1297,6 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
// focus is set to our focus proxy. We want to intercept all
// keypresses.
if (o == window() && d->client) {
- if (!d->isEmbedded() && d->activeContainer == this)
- d->moveInputToProxy();
-
if (d->clientIsXEmbed) {
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_WINDOW_ACTIVATE);
} else {
@@ -1307,6 +1304,8 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
if (hasFocus())
XSetInputFocus(x11Info().display(), d->client, XRevertToParent, x11Time());
}
+ if (!d->isEmbedded())
+ d->moveInputToProxy();
}
break;
case QEvent::WindowDeactivate:
@@ -1729,10 +1728,10 @@ void QX11EmbedContainerPrivate::acceptClient(WId window)
checkGrab();
if (q->hasFocus()) {
XSetInputFocus(q->x11Info().display(), client, XRevertToParent, x11Time());
- } else {
- if (!isEmbedded())
- moveInputToProxy();
}
+ } else {
+ if (!isEmbedded())
+ moveInputToProxy();
}
emit q->clientIsEmbedded();
@@ -1749,11 +1748,9 @@ void QX11EmbedContainerPrivate::acceptClient(WId window)
void QX11EmbedContainerPrivate::moveInputToProxy()
{
Q_Q(QX11EmbedContainer);
- WId focus;
- int revert_to;
- XGetInputFocus(q->x11Info().display(), &focus, &revert_to);
- if (focus != focusProxy->internalWinId())
- XSetInputFocus(q->x11Info().display(), focusProxy->internalWinId(), XRevertToParent, x11Time());
+ // Following Owen Taylor's advice from the XEmbed specification to
+ // always use CurrentTime when no explicit user action is involved.
+ XSetInputFocus(q->x11Info().display(), focusProxy->internalWinId(), XRevertToParent, CurrentTime);
}
/*! \internal