summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qapplication.cpp7
-rw-r--r--src/gui/kernel/qapplication_win.cpp4
-rw-r--r--src/gui/kernel/qapplication_x11.cpp9
-rw-r--r--src/gui/kernel/qclipboard_x11.cpp15
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac.mm3
-rw-r--r--src/gui/kernel/qcocoasharedwindowmethods_mac_p.h20
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm63
-rw-r--r--src/gui/kernel/qcursor_x11.cpp68
-rw-r--r--src/gui/kernel/qdnd_win.cpp16
-rw-r--r--src/gui/kernel/qdnd_x11.cpp12
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm8
-rw-r--r--src/gui/kernel/qeventdispatcher_mac_p.h1
-rw-r--r--src/gui/kernel/qgesture_p.h4
-rw-r--r--src/gui/kernel/qkeysequence.cpp35
-rw-r--r--src/gui/kernel/qstandardgestures.cpp7
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm7
-rw-r--r--src/gui/kernel/qt_x11_p.h2
-rw-r--r--src/gui/kernel/qwidget.cpp4
-rw-r--r--src/gui/kernel/qwidget_mac.mm9
-rw-r--r--src/gui/kernel/qwidget_p.h3
-rw-r--r--src/gui/kernel/qwidget_x11.cpp52
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp4
22 files changed, 232 insertions, 121 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 9fe6c87..be2683d 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -2311,12 +2311,15 @@ static bool qt_detectRTLLanguage()
" languages or to 'RTL' in right-to-left languages (such as Hebrew"
" and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
}
-#if defined(QT_MAC_USE_COCOA)
+#if defined(Q_WS_MAC)
static const char *application_menu_strings[] = {
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"),
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"),
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"),
- QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All")
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1")
};
QString qt_mac_applicationmenu_string(int type)
{
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 715b4c4..1d8eb4c 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1578,6 +1578,10 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_XBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
+ case WM_RBUTTONDBLCLK:
+ case WM_MBUTTONDBLCLK:
+ case WM_XBUTTONDBLCLK:
if (qt_win_ignoreNextMouseReleaseEvent)
qt_win_ignoreNextMouseReleaseEvent = false;
break;
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 985f825..78fc704 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -275,6 +275,8 @@ static const char * x11_atomnames = {
"_NET_SYSTEM_TRAY_VISUAL\0"
+ "_NET_ACTIVE_WINDOW\0"
+
// Property formats
"COMPOUND_TEXT\0"
"TEXT\0"
@@ -667,11 +669,6 @@ static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
return 0;
break;
- case BadMatch:
- if (err->request_code == 42 /* X_SetInputFocus */)
- return 0;
- break;
-
default:
#if !defined(QT_NO_XINPUT)
if (err->request_code == X11->xinput_major
@@ -3058,6 +3055,8 @@ int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only)
if ((ulong) event->xclient.data.l[1] > X11->time)
X11->time = event->xclient.data.l[1];
QWidget *amw = activeModalWidget();
+ if (amw && amw->testAttribute(Qt::WA_X11DoNotAcceptFocus))
+ amw = 0;
if (amw && !QApplicationPrivate::tryModalHelper(widget, 0)) {
QWidget *p = amw->parentWidget();
while (p && p != widget)
diff --git a/src/gui/kernel/qclipboard_x11.cpp b/src/gui/kernel/qclipboard_x11.cpp
index 047bd09..3bdc971 100644
--- a/src/gui/kernel/qclipboard_x11.cpp
+++ b/src/gui/kernel/qclipboard_x11.cpp
@@ -65,7 +65,6 @@
#include "qapplication.h"
#include "qdesktopwidget.h"
#include "qbitmap.h"
-#include "qdatetime.h"
#include "qiodevice.h"
#include "qbuffer.h"
#include "qtextcodec.h"
@@ -76,6 +75,7 @@
#include "qt_x11_p.h"
#include "qx11info_x11.h"
#include "qimagewriter.h"
+#include "qelapsedtimer.h"
#include "qvariant.h"
#include "qdnd_p.h"
#include <private/qwidget_p.h>
@@ -516,8 +516,9 @@ static Bool checkForClipboardEvents(Display *, XEvent *e, XPointer)
bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout)
{
- QTime started = QTime::currentTime();
- QTime now = started;
+ QElapsedTimer started;
+ started.start();
+ QElapsedTimer now = started;
if (QAbstractEventDispatcher::instance()->inherits("QtMotif")
|| QApplication::clipboard()->property("useEventLoopWhenWaiting").toBool()) {
@@ -545,9 +546,7 @@ bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int ti
XSync(X11->display, false);
usleep(50000);
- now = QTime::currentTime();
- if (started > now) // crossed midnight
- started = now;
+ now.start();
QEventLoop::ProcessEventsFlags flags(QEventLoop::ExcludeUserInputEvents
| QEventLoop::ExcludeSocketNotifiers
@@ -576,9 +575,7 @@ bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int ti
if (XCheckIfEvent(X11->display, &e, checkForClipboardEvents, 0))
qApp->x11ProcessEvent(&e);
- now = QTime::currentTime();
- if ( started > now ) // crossed midnight
- started = now;
+ now.start();
XFlush(X11->display);
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm
index 35d156a..b58fd7c 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/gui/kernel/qcocoamenuloader_mac.mm
@@ -231,6 +231,9 @@ QT_USE_NAMESPACE
[hideItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(1).arg(qAppName()))];
[hideAllOthersItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(2))];
[showAllItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(3))];
+ [preferencesItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(4))];
+ [quitItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(5).arg(qAppName()))];
+ [aboutItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(6).arg(qAppName()))];
#endif
}
diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
index 9fe5ae0..129e0a5 100644
--- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
@@ -132,26 +132,6 @@ QT_END_NAMESPACE
[super toggleToolbarShown:sender];
}
-/*
- The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
- get hit. We automatically say we can be first responder if we are a window.
- So, the handling should get handled by the view. This is here more as a
- last resort (i.e., this is code that can potentially be removed).
- */
-- (void)keyDown:(NSEvent *)theEvent
-{
- bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
- if (!keyOK)
- [super keyDown:theEvent];
-}
-
-- (void)keyUp:(NSEvent *)theEvent
-{
- bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
- if (!keyOK)
- [super keyUp:theEvent];
-}
-
- (void)flagsChanged:(NSEvent *)theEvent
{
qt_dispatchModifiersChanged(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 4f71681..06eb7ff 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -197,6 +197,7 @@ static int qCocoaViewCount = 0;
if (self) {
[self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
}
+ [self setFocusRingType:NSFocusRingTypeNone];
composingText = new QString();
#ifdef ALIEN_DEBUG
@@ -241,7 +242,8 @@ static int qCocoaViewCount = 0;
QRegion mask = qt_widget_private(cursorWidget)->extra->mask;
NSCursor *nscursor = static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursorWidget->cursor()));
- if (mask.isEmpty()) {
+ // The mask could have the WA_MouseNoMask attribute set and that means that we have to ignore the mask.
+ if (mask.isEmpty() || cursorWidget->testAttribute(Qt::WA_MouseNoMask)) {
[self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor];
} else {
const QVector<QRect> &rects = mask.rects();
@@ -444,7 +446,11 @@ static int qCocoaViewCount = 0;
return YES;
}
-- (BOOL) preservesContentDuringLiveResize;
+// We preserve the content of the view if WA_StaticContents is defined.
+//
+// More info in the Cocoa documentation:
+// http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CocoaViewsGuide/Optimizing/Optimizing.html
+- (BOOL) preservesContentDuringLiveResize
{
return qwidget->testAttribute(Qt::WA_StaticContents);
}
@@ -474,6 +480,18 @@ static int qCocoaViewCount = 0;
}
}
+// We catch the 'setNeedsDisplay:' message in order to avoid a useless full repaint.
+// During the resize, the top of the widget is repainted, probably because of the
+// change of coordinate space (Quartz vs Qt). This is then followed by this message:
+// -[NSView _setNeedsDisplayIfTopLeftChanged]
+// which force a full repaint by sending the message 'setNeedsDisplay:'.
+// That is what we are preventing here.
+- (void)setNeedsDisplay:(BOOL)flag {
+ if (![self inLiveResize] || !(qwidget->testAttribute(Qt::WA_StaticContents))) {
+ [super setNeedsDisplay:flag];
+ }
+}
+
- (void)drawRect:(NSRect)aRect
{
if (!qwidget)
@@ -1029,11 +1047,16 @@ static int qCocoaViewCount = 0;
{
if (!qwidget)
return NO;
+ // disabled widget shouldn't get focus even if it's a window.
+ // hence disabled windows will not get any key or mouse events.
+ if (!qwidget->isEnabled())
+ return NO;
// Before accepting the focus for a window, we check that
// the focusWidget (if any) is not contained in the same window.
- if (qwidget->isWindow() && (!qApp->focusWidget()
- || qApp->focusWidget()->window() != qwidget))
+ if (qwidget->isWindow() && !qt_widget_private(qwidget)->topData()->embedded
+ && (!qApp->focusWidget() || qApp->focusWidget()->window() != qwidget)) {
return YES; // Always do it, so that windows can accept key press events.
+ }
return qwidget->focusPolicy() != Qt::NoFocus;
}
@@ -1044,7 +1067,17 @@ static int qCocoaViewCount = 0;
// Seems like the following test only triggers if this
// view is inside a QMacNativeWidget:
if (qwidget == QApplication::focusWidget())
- QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
+ qwidget->clearFocus();
+ return YES;
+}
+
+- (BOOL)becomeFirstResponder
+{
+ // see the comment in the acceptsFirstResponder - if the window "stole" focus
+ // let it become the responder, but don't tell Qt
+ if (qwidget && qt_widget_private(qwidget->window())->topData()->embedded
+ && !QApplication::focusWidget() && qwidget->focusPolicy() != Qt::NoFocus)
+ qwidget->setFocus(Qt::OtherFocusReason);
return YES;
}
@@ -1118,8 +1151,15 @@ static int qCocoaViewCount = 0;
}
if (sendKeyEvents && !composing) {
bool keyOK = qt_dispatchKeyEvent(theEvent, widgetToGetKey);
- if (!keyOK && !sendToPopup)
- [super keyDown:theEvent];
+ if (!keyOK && !sendToPopup) {
+ // find the first responder that is not created by Qt and forward
+ // the event to it (for example if Qt widget is embedded into native).
+ QWidget *toplevel = qwidget->window();
+ if (toplevel && qt_widget_private(toplevel)->topData()->embedded) {
+ if (NSResponder *w = [qt_mac_nativeview_for(toplevel) superview])
+ [w keyDown:theEvent];
+ }
+ }
}
}
@@ -1128,8 +1168,13 @@ static int qCocoaViewCount = 0;
{
if (sendKeyEvents) {
bool keyOK = qt_dispatchKeyEvent(theEvent, qwidget);
- if (!keyOK)
- [super keyUp:theEvent];
+ if (!keyOK) {
+ QWidget *toplevel = qwidget->window();
+ if (toplevel && qt_widget_private(toplevel)->topData()->embedded) {
+ if (NSResponder *w = [qt_mac_nativeview_for(toplevel) superview])
+ [w keyUp:theEvent];
+ }
+ }
}
}
diff --git a/src/gui/kernel/qcursor_x11.cpp b/src/gui/kernel/qcursor_x11.cpp
index 4e871a6..8e48628 100644
--- a/src/gui/kernel/qcursor_x11.cpp
+++ b/src/gui/kernel/qcursor_x11.cpp
@@ -294,7 +294,7 @@ void QCursorData::update()
return;
#endif // QT_NO_XCURSOR
- static const char cur_blank_bits[] = {
+ static const uchar cur_blank_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@@ -302,44 +302,44 @@ void QCursorData::update()
// Non-standard X11 cursors are created from bitmaps
#ifndef QT_USE_APPROXIMATE_CURSORS
- static const char cur_ver_bits[] = {
+ static const uchar cur_ver_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
- static const char mcur_ver_bits[] = {
+ static const uchar mcur_ver_bits[] = {
0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
- static const char cur_hor_bits[] = {
+ static const uchar cur_hor_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- static const char mcur_hor_bits[] = {
+ static const uchar mcur_hor_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
- static const char cur_bdiag_bits[] = {
+ static const uchar cur_bdiag_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- static const char mcur_bdiag_bits[] = {
+ static const uchar mcur_bdiag_bits[] = {
0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
- static const char cur_fdiag_bits[] = {
+ static const uchar cur_fdiag_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
- static const char mcur_fdiag_bits[] = {
+ static const uchar mcur_fdiag_bits[] = {
0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
- static const char *cursor_bits16[] = {
+ static const uchar *cursor_bits16[] = {
cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits,
cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits,
0, 0, cur_blank_bits, cur_blank_bits };
- static const char vsplit_bits[] = {
+ static const uchar vsplit_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
@@ -351,7 +351,7 @@ void QCursorData::update()
0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- static const char vsplitm_bits[] = {
+ static const uchar vsplitm_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
@@ -363,7 +363,7 @@ void QCursorData::update()
0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- static const char hsplit_bits[] = {
+ static const uchar hsplit_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
@@ -375,7 +375,7 @@ void QCursorData::update()
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- static const char hsplitm_bits[] = {
+ static const uchar hsplitm_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
@@ -387,7 +387,7 @@ void QCursorData::update()
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- static const char whatsthis_bits[] = {
+ static const uchar whatsthis_bits[] = {
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
@@ -399,7 +399,7 @@ void QCursorData::update()
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
- static const char whatsthism_bits[] = {
+ static const uchar whatsthism_bits[] = {
0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
@@ -411,7 +411,7 @@ void QCursorData::update()
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
- static const char busy_bits[] = {
+ static const uchar busy_bits[] = {
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
@@ -423,7 +423,7 @@ void QCursorData::update()
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- static const char busym_bits[] = {
+ static const uchar busym_bits[] = {
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
@@ -436,41 +436,41 @@ void QCursorData::update()
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- static const char * const cursor_bits32[] = {
+ static const uchar * const cursor_bits32[] = {
vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
};
- static const char forbidden_bits[] = {
+ static const uchar forbidden_bits[] = {
0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
- static const char forbiddenm_bits[] = {
+ static const uchar forbiddenm_bits[] = {
0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
- static const char openhand_bits[] = {
+ static const uchar openhand_bits[] = {
0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
- static const char openhandm_bits[] = {
+ static const uchar openhandm_bits[] = {
0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
- static const char closedhand_bits[] = {
+ static const uchar closedhand_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
- static const char closedhandm_bits[] = {
+ static const uchar closedhandm_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
- static const char * const cursor_bits20[] = {
+ static const uchar * const cursor_bits20[] = {
forbidden_bits, forbiddenm_bits
};
@@ -484,8 +484,8 @@ void QCursorData::update()
fg.green = 0;
fg.blue = 0;
int i = (cshape - Qt::SizeVerCursor) * 2;
- pm = XCreateBitmapFromData(dpy, rootwin, cursor_bits16[i], 16, 16);
- pmm = XCreateBitmapFromData(dpy, rootwin, cursor_bits16[i + 1], 16, 16);
+ pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i]), 16, 16);
+ pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i + 1]), 16, 16);
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
} else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor)
|| cshape == Qt::WhatsThisCursor || cshape == Qt::BusyCursor) {
@@ -497,8 +497,8 @@ void QCursorData::update()
fg.green = 0;
fg.blue = 0;
int i = (cshape - Qt::SplitVCursor) * 2;
- pm = XCreateBitmapFromData(dpy, rootwin, cursor_bits32[i], 32, 32);
- pmm = XCreateBitmapFromData(dpy, rootwin, cursor_bits32[i + 1], 32, 32);
+ pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i]), 32, 32);
+ pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i + 1]), 32, 32);
int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor
|| cshape == Qt::BusyCursor) ? 0 : 16;
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, hs, hs);
@@ -511,8 +511,8 @@ void QCursorData::update()
fg.green = 0;
fg.blue = 0;
int i = (cshape - Qt::ForbiddenCursor) * 2;
- pm = XCreateBitmapFromData(dpy, rootwin, cursor_bits20[i], 20, 20);
- pmm = XCreateBitmapFromData(dpy, rootwin, cursor_bits20[i + 1], 20, 20);
+ pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i]), 20, 20);
+ pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i + 1]), 20, 20);
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 10, 10);
} else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
XColor bg, fg;
@@ -523,8 +523,8 @@ void QCursorData::update()
fg.green = 0;
fg.blue = 0;
bool open = cshape == Qt::OpenHandCursor;
- pm = XCreateBitmapFromData(dpy, rootwin, open ? openhand_bits : closedhand_bits, 16, 16);
- pmm = XCreateBitmapFromData(dpy, rootwin, open ? openhandm_bits : closedhandm_bits, 16, 16);
+ pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhand_bits : closedhand_bits), 16, 16);
+ pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhandm_bits : closedhandm_bits), 16, 16);
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
} else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor
|| cshape == Qt::DragLinkCursor) {
diff --git a/src/gui/kernel/qdnd_win.cpp b/src/gui/kernel/qdnd_win.cpp
index 0742a93..a164c2a 100644
--- a/src/gui/kernel/qdnd_win.cpp
+++ b/src/gui/kernel/qdnd_win.cpp
@@ -524,18 +524,14 @@ QOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
if (fEscapePressed) {
return ResultFromScode(DRAGDROP_S_CANCEL);
- } else if (!(grfKeyState & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON))) {
+ } else if ((GetAsyncKeyState(VK_LBUTTON) == 0)
+ && (GetAsyncKeyState(VK_MBUTTON) == 0)
+ && (GetAsyncKeyState(VK_RBUTTON) == 0)) {
+ // grfKeyState is broken on CE & some Windows XP versions,
+ // therefore we need to check the state manually
return ResultFromScode(DRAGDROP_S_DROP);
} else {
-#if defined(Q_OS_WINCE)
- // grfKeyState is broken on CE, therefore need to check
- // the state manually
- if ((GetAsyncKeyState(VK_LBUTTON) == 0) &&
- (GetAsyncKeyState(VK_MBUTTON) == 0) &&
- (GetAsyncKeyState(VK_RBUTTON) == 0)) {
- return ResultFromScode(DRAGDROP_S_DROP);
- }
-#else
+#if !defined(Q_OS_WINCE)
if (currentButtons == Qt::NoButton) {
currentButtons = keystate_to_mousebutton(grfKeyState);
} else {
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
index 9591b9a..0a05d8e 100644
--- a/src/gui/kernel/qdnd_x11.cpp
+++ b/src/gui/kernel/qdnd_x11.cpp
@@ -51,10 +51,10 @@
#include "qbitmap.h"
#include "qdesktopwidget.h"
#include "qevent.h"
-#include "qdatetime.h"
#include "qiodevice.h"
#include "qpointer.h"
#include "qcursor.h"
+#include "qelapsedtimer.h"
#include "qvariant.h"
#include "qvector.h"
#include "qurl.h"
@@ -1911,23 +1911,19 @@ Qt::DropAction QDragManager::drag(QDrag * o)
// then we could still have problems, but this is highly unlikely
QApplication::flush();
- QTime started = QTime::currentTime();
- QTime now = started;
+ QElapsedTimer timer;
+ timer.start();
do {
XEvent event;
if (XCheckTypedEvent(X11->display, ClientMessage, &event))
qApp->x11ProcessEvent(&event);
- now = QTime::currentTime();
- if (started > now) // crossed midnight
- started = now;
-
// sleep 50 ms, so we don't use up CPU cycles all the time.
struct timeval usleep_tv;
usleep_tv.tv_sec = 0;
usleep_tv.tv_usec = 50000;
select(0, 0, 0, 0, &usleep_tv);
- } while (object && started.msecsTo(now) < 1000);
+ } while (object && timer.hasExpired(1000));
}
object = o;
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index afea3ec..62e1e81 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -829,6 +829,8 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession()
ensureNSAppInitialized();
QBoolBlocker block1(blockSendPostedEvents, true);
+ info.nswindow = window;
+ [(NSWindow*) info.nswindow retain];
info.session = [NSApp beginModalSessionForWindow:window];
}
currentModalSessionCached = info.session;
@@ -903,8 +905,10 @@ void QEventDispatcherMacPrivate::cleanupModalSessions()
}
cocoaModalSessionStack.remove(i);
currentModalSessionCached = 0;
- if (info.session)
+ if (info.session) {
[NSApp endModalSession:info.session];
+ [(NSWindow *)info.nswindow release];
+ }
}
updateChildrenWorksWhenModal();
@@ -920,7 +924,7 @@ void QEventDispatcherMacPrivate::beginModalSession(QWidget *widget)
// currentModalSession). A QCocoaModalSessionInfo is considered pending to be stopped if
// the widget pointer is zero, and the session pointer is non-zero (it will be fully
// stopped in cleanupModalSessions()).
- QCocoaModalSessionInfo info = {widget, 0};
+ QCocoaModalSessionInfo info = {widget, 0, 0};
cocoaModalSessionStack.push(info);
updateChildrenWorksWhenModal();
currentModalSessionCached = 0;
diff --git a/src/gui/kernel/qeventdispatcher_mac_p.h b/src/gui/kernel/qeventdispatcher_mac_p.h
index e932532..8ac7c65 100644
--- a/src/gui/kernel/qeventdispatcher_mac_p.h
+++ b/src/gui/kernel/qeventdispatcher_mac_p.h
@@ -100,6 +100,7 @@ typedef struct _NSModalSession *NSModalSession;
typedef struct _QCocoaModalSessionInfo {
QPointer<QWidget> widget;
NSModalSession session;
+ void *nswindow;
} QCocoaModalSessionInfo;
#endif
diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h
index 649a310..bf60f97 100644
--- a/src/gui/kernel/qgesture_p.h
+++ b/src/gui/kernel/qgesture_p.h
@@ -55,8 +55,8 @@
#include "qrect.h"
#include "qpoint.h"
-#include "qdatetime.h"
#include "qgesture.h"
+#include "qelapsedtimer.h"
#include "private/qobject_p.h"
QT_BEGIN_NAMESPACE
@@ -148,7 +148,7 @@ public:
QPoint lastPositions[3];
bool started;
qreal speed;
- QTime time;
+ QElapsedTimer time;
};
class QTapGesturePrivate : public QGesturePrivate
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 7f92a2c..9efcc4e 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -580,6 +580,41 @@ static const struct {
{ Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") },
{ Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") },
+ // --------------------------------------------------------------
+ // Japanese keyboard support
+ { Qt::Key_Kanji, QT_TRANSLATE_NOOP("QShortcut", "Kanji") },
+ { Qt::Key_Muhenkan, QT_TRANSLATE_NOOP("QShortcut", "Muhenkan") },
+ { Qt::Key_Henkan, QT_TRANSLATE_NOOP("QShortcut", "Henkan") },
+ { Qt::Key_Romaji, QT_TRANSLATE_NOOP("QShortcut", "Romaji") },
+ { Qt::Key_Hiragana, QT_TRANSLATE_NOOP("QShortcut", "Hiragana") },
+ { Qt::Key_Katakana, QT_TRANSLATE_NOOP("QShortcut", "Katakana") },
+ { Qt::Key_Hiragana_Katakana,QT_TRANSLATE_NOOP("QShortcut", "Hiragana Katakana") },
+ { Qt::Key_Zenkaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku") },
+ { Qt::Key_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Hankaku") },
+ { Qt::Key_Zenkaku_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku Hankaku") },
+ { Qt::Key_Touroku, QT_TRANSLATE_NOOP("QShortcut", "Touroku") },
+ { Qt::Key_Massyo, QT_TRANSLATE_NOOP("QShortcut", "Massyo") },
+ { Qt::Key_Kana_Lock, QT_TRANSLATE_NOOP("QShortcut", "Kana Lock") },
+ { Qt::Key_Kana_Shift, QT_TRANSLATE_NOOP("QShortcut", "Kana Shift") },
+ { Qt::Key_Eisu_Shift, QT_TRANSLATE_NOOP("QShortcut", "Eisu Shift") },
+ { Qt::Key_Eisu_toggle, QT_TRANSLATE_NOOP("QShortcut", "Eisu toggle") },
+ { Qt::Key_Codeinput, QT_TRANSLATE_NOOP("QShortcut", "Code input") },
+ { Qt::Key_MultipleCandidate,QT_TRANSLATE_NOOP("QShortcut", "Multiple Candidate") },
+ { Qt::Key_PreviousCandidate,QT_TRANSLATE_NOOP("QShortcut", "Previous Candidate") },
+
+ // --------------------------------------------------------------
+ // Korean keyboard support
+ { Qt::Key_Hangul, QT_TRANSLATE_NOOP("QShortcut", "Hangul") },
+ { Qt::Key_Hangul_Start, QT_TRANSLATE_NOOP("QShortcut", "Hangul Start") },
+ { Qt::Key_Hangul_End, QT_TRANSLATE_NOOP("QShortcut", "Hangul End") },
+ { Qt::Key_Hangul_Hanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Hanja") },
+ { Qt::Key_Hangul_Jamo, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jamo") },
+ { Qt::Key_Hangul_Romaja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Romaja") },
+ { Qt::Key_Hangul_Jeonja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jeonja") },
+ { Qt::Key_Hangul_Banja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Banja") },
+ { Qt::Key_Hangul_PreHanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul PreHanja") },
+ { Qt::Key_Hangul_PostHanja,QT_TRANSLATE_NOOP("QShortcut", "Hangul PostHanja") },
+ { Qt::Key_Hangul_Special, QT_TRANSLATE_NOOP("QShortcut", "Hangul Special") },
{ 0, 0 }
};
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 86bf1b2e..a575717 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -301,7 +301,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
switch (event->type()) {
case QEvent::TouchBegin: {
d->speed = 1;
- d->time = QTime::currentTime();
+ d->time.start();
d->started = true;
result = QGestureRecognizer::MayBeGesture;
break;
@@ -338,11 +338,10 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
p3.screenPos().y() - d->lastPositions[2].y()) / 3;
const int distance = xDistance >= yDistance ? xDistance : yDistance;
- int elapsedTime = d->time.msecsTo(QTime::currentTime());
+ int elapsedTime = d->time.restart();
if (!elapsedTime)
elapsedTime = 1;
d->speed = 0.9 * d->speed + distance / elapsedTime;
- d->time = QTime::currentTime();
d->swipeAngle = QLineF(p1.startScreenPos(), p1.screenPos()).angle();
static const int MoveThreshold = 50;
@@ -405,7 +404,7 @@ void QSwipeGestureRecognizer::reset(QGesture *state)
d->lastPositions[0] = d->lastPositions[1] = d->lastPositions[2] = QPoint();
d->started = false;
d->speed = 0;
- d->time = QTime();
+ d->time.invalidate();
QGestureRecognizer::reset(state);
}
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 24fe5f7..b1e4c94 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -652,8 +652,7 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
UInt32 macScanCode = 1;
QKeyEventEx ke(cocoaEvent2QtEvent([event type]), qtKey, keyMods, text, [event isARepeat], qMax(1, keyLength),
macScanCode, [event keyCode], [event modifierFlags]);
- qt_sendSpontaneousEvent(widgetToGetEvent, &ke);
- return ke.isAccepted();
+ return qt_sendSpontaneousEvent(widgetToGetEvent, &ke) && ke.isAccepted();
}
#endif
@@ -703,8 +702,8 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve
if (mustUseCocoaKeyEvent())
return qt_dispatchKeyEventWithCocoa(keyEvent, widgetToGetEvent);
bool isAccepted;
- qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &isAccepted, true);
- return isAccepted;
+ bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &isAccepted, true);
+ return consumed && isAccepted;
#endif
}
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index e1b2625..7383382 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -632,6 +632,8 @@ struct QX11Data
_NET_SYSTEM_TRAY_VISUAL,
+ _NET_ACTIVE_WINDOW,
+
// Property formats
COMPOUND_TEXT,
TEXT,
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index af5fcd1..e88026c 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -10550,6 +10550,10 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
case Qt::WA_X11OpenGLOverlay:
d->updateIsOpaque();
break;
+ case Qt::WA_X11DoNotAcceptFocus:
+ if (testAttribute(Qt::WA_WState_Created))
+ d->updateX11AcceptFocus();
+ break;
#endif
case Qt::WA_DontShowOnScreen: {
if (on && isVisible()) {
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index b3a6aec..3d86936 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3933,7 +3933,7 @@ void QWidgetPrivate::stackUnder_sys(QWidget *w)
widget, either by scrolling its contents or repainting, depending on the WA_StaticContents
flag
*/
-static void qt_mac_update_widget_posisiton(QWidget *q, QRect oldRect, QRect newRect)
+static void qt_mac_update_widget_position(QWidget *q, QRect oldRect, QRect newRect)
{
#ifndef QT_MAC_USE_COCOA
HIRect bounds = CGRectMake(newRect.x(), newRect.y(),
@@ -4067,7 +4067,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
QRect xrect = data.crect;
QRect parentWRect;
- if (q->isWindow() && topData()->embedded) {
+ bool isEmbeddedWindow = (q->isWindow() && topData()->embedded);
+ if (isEmbeddedWindow) {
#ifndef QT_MAC_USE_COCOA
HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q));
#else
@@ -4092,7 +4093,7 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
if (parentWRect.isValid()) {
// parent is clipped, and we have to clip to the same limit as parent
- if (!parentWRect.contains(xrect)) {
+ if (!parentWRect.contains(xrect) && !isEmbeddedWindow) {
xrect &= parentWRect;
wrect = xrect;
//translate from parent's to my Qt coord sys
@@ -4194,7 +4195,7 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
}
}
- qt_mac_update_widget_posisiton(q, oldRect, xrect);
+ qt_mac_update_widget_position(q, oldRect, xrect);
if (jump)
q->update();
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 2cb8586..ef7ac1f 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -680,7 +680,7 @@ public:
QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
// Bit fields.
- uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
+ uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
QPalette::ColorRole fg_role : 8;
QPalette::ColorRole bg_role : 8;
uint dirtyOpaqueChildren : 1;
@@ -703,6 +703,7 @@ public:
void setNetWmWindowTypes();
void x11UpdateIsOpaque();
bool isBackgroundInherited() const;
+ void updateX11AcceptFocus();
#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
uint nativeGesturePanEnabled : 1;
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 9660de5..37ac6bf 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -49,7 +49,7 @@
#include "qbitmap.h"
#include "qlayout.h"
#include "qtextcodec.h"
-#include "qdatetime.h"
+#include "qelapsedtimer.h"
#include "qcursor.h"
#include "qstack.h"
#include "qcolormap.h"
@@ -352,7 +352,7 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
return;
QApplication::flush();
XEvent ev;
- QTime t;
+ QElapsedTimer t;
t.start();
static const int maximumWaitTime = 2000;
if (!w->testAttribute(Qt::WA_WState_Created))
@@ -780,7 +780,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
XWMHints wm_hints; // window manager hints
memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
wm_hints.flags = InputHint | StateHint | WindowGroupHint;
- wm_hints.input = True;
+ wm_hints.input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True;
wm_hints.initial_state = NormalState;
wm_hints.window_group = X11->wm_client_leader;
@@ -1166,7 +1166,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
adjustFlags(data.window_flags, q);
// keep compatibility with previous versions, we need to preserve the created state
// (but we recreate the winId for the widget being reparented, again for compatibility)
- if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created)))
+ if (wasCreated)
createWinId();
if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden)
q->setAttribute(Qt::WA_WState_Hidden);
@@ -1641,7 +1641,29 @@ void QWidget::activateWindow()
if (X11->userTime == 0)
X11->userTime = X11->time;
qt_net_update_user_time(tlw, X11->userTime);
- XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
+
+ if (X11->isSupportedByWM(ATOM(_NET_ACTIVE_WINDOW))
+ && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)) {
+ XEvent e;
+ e.xclient.type = ClientMessage;
+ e.xclient.message_type = ATOM(_NET_ACTIVE_WINDOW);
+ e.xclient.display = X11->display;
+ e.xclient.window = tlw->internalWinId();
+ e.xclient.format = 32;
+ e.xclient.data.l[0] = 1; // 1 == application
+ e.xclient.data.l[1] = X11->userTime;
+ if (QWidget *aw = QApplication::activeWindow())
+ e.xclient.data.l[2] = aw->internalWinId();
+ else
+ e.xclient.data.l[2] = XNone;
+ e.xclient.data.l[3] = 0;
+ e.xclient.data.l[4] = 0;
+ XSendEvent(X11->display, RootWindow(X11->display, tlw->x11Info().screen()),
+ false, SubstructureNotifyMask | SubstructureRedirectMask, &e);
+ } else {
+ if (!qt_widget_private(tlw)->topData()->waitingForMapNotify)
+ XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
+ }
}
}
@@ -3030,4 +3052,24 @@ void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const QX11WindowAttributes &at
xinfo->setX11Data(xd);
}
+void QWidgetPrivate::updateX11AcceptFocus()
+{
+ Q_Q(QWidget);
+ if (!q->isWindow() || !q->internalWinId())
+ return;
+
+ 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;
+ }
+ h->flags |= InputHint;
+ h->input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True;
+
+ XSetWMHints(X11->display, q->internalWinId(), h);
+ if (h != &wm_hints)
+ XFree((char *)h);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index 35850db..b527e72 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -47,7 +47,7 @@
#include <qlayout.h>
#include <qstyle.h>
#include <qstyleoption.h>
-#include <qdatetime.h>
+#include <qelapsedtimer.h>
#include <qpointer.h>
#include <qdebug.h>
#include <qx11info_x11.h>
@@ -1231,7 +1231,7 @@ void QX11EmbedContainer::embedClient(WId id)
For safety, we will not wait more than 500 ms, so that we can
preemptively workaround buggy window managers.
*/
- QTime t;
+ QElapsedTimer t;
t.start();
functorData data;