summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm8
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm5
-rw-r--r--src/plugins/platforms/cocoa/qnsviewaccessibility.mm2
-rw-r--r--src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp5
-rw-r--r--src/plugins/platforms/windows/accessible/comutils.cpp20
-rw-r--r--src/plugins/platforms/windows/accessible/comutils.h3
-rw-r--r--src/plugins/platforms/windows/accessible/iaccessible2.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp22
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp71
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp46
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h11
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp86
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h3
15 files changed, 215 insertions, 89 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index df6b64443d..d5841c1983 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -122,7 +122,7 @@ static QAccessibleInterface *acast(void *ptr)
[attributes addObject : NSAccessibilityValueAttribute];
}
- return attributes;
+ return [attributes autorelease];
}
- (id)accessibilityAttributeValue:(NSString *)attribute {
@@ -139,7 +139,7 @@ static QAccessibleInterface *acast(void *ptr)
[kids addObject:[QCocoaAccessibleElement elementWithInterface:(void*)childInterface parent:self]];
}
- return NSAccessibilityUnignoredChildren(kids);
+ return kids;
} else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
// Just check if the app thinks we're focused.
id focusedElement = [NSApp accessibilityAttributeValue:NSAccessibilityFocusedUIElementAttribute];
@@ -239,6 +239,10 @@ static QAccessibleInterface *acast(void *ptr)
if (!accessibleInterface)
return NSAccessibilityUnignoredAncestor(self);
+
+ if (!acast(accessibleInterface)->isValid())
+ return NSAccessibilityUnignoredAncestor(self);
+
QAccessibleInterface *childInterface = acast(accessibleInterface)->childAt(point.x, qt_mac_flipYCoordinate(point.y));
// No child found, meaning we hit this element.
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index f9122f56d1..5747cc01e9 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -223,7 +223,7 @@ static QString strippedText(QString s)
- (void)showModelessPanel
{
if (mOpenPanel){
- QFileInfo info(*mCurrentSelection);
+ QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir));
NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath());
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
@@ -241,7 +241,7 @@ static QString strippedText(QString s)
- (BOOL)runApplicationModalPanel
{
- QFileInfo info(*mCurrentSelection);
+ QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir));
NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath());
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
@@ -266,7 +266,7 @@ static QString strippedText(QString s)
- (void)showWindowModalSheet:(QWindow *)parent
{
- QFileInfo info(*mCurrentSelection);
+ QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir));
NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath());
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index ffee8528f0..b545844a24 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -49,6 +49,7 @@
#include <QtCore/qfileinfo.h>
#include <QtCore/private/qcore_mac_p.h>
#include <qwindow.h>
+#include <private/qwindow_p.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformscreen.h>
@@ -649,6 +650,10 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
[m_contentView setFrame:frame];
}
+
+ const qreal opacity = qt_window_private(window())->opacity;
+ if (!qFuzzyCompare(opacity, qreal(1.0)))
+ setOpacity(opacity);
}
NSWindow * QCocoaWindow::createNSWindow()
diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
index 6824f19489..da714d3326 100644
--- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
@@ -80,7 +80,7 @@
[kids addObject:[QCocoaAccessibleElement elementWithInterface: m_accessibleRoot->child(i) parent:self ]];
}
- return NSAccessibilityUnignoredChildren(kids);
+ return kids;
} else {
return [super accessibilityAttributeValue:attribute];
}
diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp
index 059dcb574b..3d2f49aa6c 100644
--- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp
+++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardbps.cpp
@@ -86,6 +86,11 @@ bool QQnxVirtualKeyboardBps::handleEvent(bps_event_t *event)
bool QQnxVirtualKeyboardBps::showKeyboard()
{
qVirtualKeyboardDebug() << Q_FUNC_INFO << "current visibility=" << isVisible();
+
+ // They keyboard's mode is global between applications, we have to set it each time
+ if ( !isVisible() )
+ applyKeyboardMode(keyboardMode());
+
virtualkeyboard_show();
return true;
}
diff --git a/src/plugins/platforms/windows/accessible/comutils.cpp b/src/plugins/platforms/windows/accessible/comutils.cpp
index 5e5a1ebd0f..a67e2c4534 100644
--- a/src/plugins/platforms/windows/accessible/comutils.cpp
+++ b/src/plugins/platforms/windows/accessible/comutils.cpp
@@ -88,7 +88,7 @@ inline uint QColorToOLEColor(const QColor &col)
return qRgba(col.blue(), col.green(), col.red(), 0x00);
}
-bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeName, bool out)
+bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeName, bool out)
{
QVariant qvar = var;
// "type" is the expected type, so coerce if necessary
@@ -107,12 +107,12 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
}
if (out && arg.vt == (VT_VARIANT|VT_BYREF) && arg.pvarVal) {
- return QVariantToVARIANT(var, *arg.pvarVal, typeName, false);
+ return QVariant2VARIANT(var, *arg.pvarVal, typeName, false);
}
if (out && proptype == QVariant::UserType && typeName == "QVariant") {
VARIANT *pVariant = new VARIANT;
- QVariantToVARIANT(var, *pVariant, QByteArray(), false);
+ QVariant2VARIANT(var, *pVariant, QByteArray(), false);
arg.vt = VT_VARIANT|VT_BYREF;
arg.pvarVal = pVariant;
return true;
@@ -409,7 +409,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
for (LONG j = 0; j < columnCount; ++j) {
QVariant elem = columns.at(j);
VariantInit(&variant);
- QVariantToVARIANT(elem, variant, elem.typeName());
+ QVariant2VARIANT(elem, variant, elem.typeName());
rgIndices[1] = j;
SafeArrayPutElement(array, rgIndices, pElement);
clearVARIANT(&variant);
@@ -425,7 +425,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
if (listType != QVariant::LastType)
elem.convert(listType);
VariantInit(&variant);
- QVariantToVARIANT(elem, variant, elem.typeName());
+ QVariant2VARIANT(elem, variant, elem.typeName());
SafeArrayPutElement(array, &index, pElement);
clearVARIANT(&variant);
}
@@ -555,7 +555,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
arg.pRecInfo = recordInfo,
arg.pvRecord = record;
if (out) {
- qWarning("QVariantToVARIANT: out-parameter not supported for records");
+ qWarning("QVariant2VARIANT: out-parameter not supported for records");
return false;
}
}
@@ -574,7 +574,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
if (arg.pdispVal)
arg.pdispVal->AddRef();
if (out) {
- qWarning("QVariantToVARIANT: out-parameter not supported for IDispatch");
+ qWarning("QVariant2VARIANT: out-parameter not supported for IDispatch");
return false;
}
} else if (!qstrcmp(qvar.typeName(), "IDispatch**")) {
@@ -588,7 +588,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
if (arg.punkVal)
arg.punkVal->AddRef();
if (out) {
- qWarning("QVariantToVARIANT: out-parameter not supported for IUnknown");
+ qWarning("QVariant2VARIANT: out-parameter not supported for IUnknown");
return false;
}
#ifdef QAX_SERVER
@@ -602,7 +602,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
qAxFactory()->createObjectWrapper(static_cast<QObject*>(user), &arg.pdispVal);
}
if (out) {
- qWarning("QVariantToVARIANT: out-parameter not supported for subtype");
+ qWarning("QVariant2VARIANT: out-parameter not supported for subtype");
return false;
}
#else
@@ -612,7 +612,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type
arg.vt = VT_DISPATCH;
object->queryInterface(IID_IDispatch, (void**)&arg.pdispVal);
if (out) {
- qWarning("QVariantToVARIANT: out-parameter not supported for subtype");
+ qWarning("QVariant2VARIANT: out-parameter not supported for subtype");
return false;
}
#endif
diff --git a/src/plugins/platforms/windows/accessible/comutils.h b/src/plugins/platforms/windows/accessible/comutils.h
index c9ed2b1224..8593f68d76 100644
--- a/src/plugins/platforms/windows/accessible/comutils.h
+++ b/src/plugins/platforms/windows/accessible/comutils.h
@@ -52,7 +52,8 @@ QT_BEGIN_NAMESPACE
class QVariant;
-bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeName, bool out);
+// Originally QVariantToVARIANT copied from ActiveQt - renamed to avoid conflicts in static builds.
+bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeName, bool out);
inline QString BSTRToQString(const BSTR &bstr)
{
diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
index 03bb94db8f..838cd055ab 100644
--- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp
+++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
@@ -1425,7 +1425,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_currentValue(VARIANT *curre
return E_FAIL;
if (QAccessibleValueInterface *valueIface = valueInterface()) {
const QVariant var = valueIface->currentValue();
- if (QVariantToVARIANT(var, *currentValue, QByteArray(), false))
+ if (QVariant2VARIANT(var, *currentValue, QByteArray(), false))
return S_OK;
}
@@ -1456,7 +1456,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_maximumValue(VARIANT *maxim
return E_FAIL;
if (QAccessibleValueInterface *valueIface = valueInterface()) {
const QVariant var = valueIface->maximumValue();
- if (QVariantToVARIANT(var, *maximumValue, QByteArray(), false))
+ if (QVariant2VARIANT(var, *maximumValue, QByteArray(), false))
return S_OK;
}
maximumValue->vt = VT_EMPTY;
@@ -1470,7 +1470,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_minimumValue(VARIANT *minim
return E_FAIL;
if (QAccessibleValueInterface *valueIface = valueInterface()) {
const QVariant var = valueIface->minimumValue();
- if (QVariantToVARIANT(var, *minimumValue, QByteArray(), false))
+ if (QVariant2VARIANT(var, *minimumValue, QByteArray(), false))
return S_OK;
}
minimumValue->vt = VT_EMPTY;
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 1f6253438f..3831c6b10e 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -55,6 +55,7 @@
#include <QtGui/QWindow>
#include <QtGui/QRegion>
#include <private/qwindow_p.h>
+#include <private/qguiapplication_p.h>
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/QDebug>
@@ -321,7 +322,6 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
topLevel = ((creationFlags & ForceChild) || embedded) ? false : w->isTopLevel();
if (topLevel && flags == 1) {
- qWarning("Remove me: fixing toplevel window flags");
flags |= Qt::WindowTitleHint|Qt::WindowSystemMenuHint|Qt::WindowMinimizeButtonHint
|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint;
}
@@ -731,6 +731,9 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) :
if (QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, 0);
setWindowState(aWindow->windowState());
+ const qreal opacity = qt_window_private(aWindow)->opacity;
+ if (!qFuzzyCompare(opacity, qreal(1.0)))
+ setOpacity(opacity);
}
QWindowsWindow::~QWindowsWindow()
@@ -1185,8 +1188,21 @@ void QWindowsWindow::setWindowTitle(const QString &title)
{
if (QWindowsContext::verboseWindows)
qDebug() << __FUNCTION__ << this << window() <<title;
- if (m_data.hwnd)
- SetWindowText(m_data.hwnd, (const wchar_t*)title.utf16());
+ if (m_data.hwnd) {
+
+ QString fullTitle = title;
+ if (QGuiApplicationPrivate::displayName) {
+ // Append display name, if set.
+ if (!fullTitle.isEmpty())
+ fullTitle += QStringLiteral(" - ");
+ fullTitle += *QGuiApplicationPrivate::displayName;
+ } else if (fullTitle.isEmpty()) {
+ // Don't let the window title be completely empty, use the app name as fallback.
+ fullTitle = QCoreApplication::applicationName();
+ }
+
+ SetWindowText(m_data.hwnd, (const wchar_t*)fullTitle.utf16());
+ }
}
void QWindowsWindow::setWindowFlags(Qt::WindowFlags flags)
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 4c4df137a3..1192894693 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -257,6 +257,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char
, has_shape_extension(false)
, has_randr_extension(false)
, has_input_shape(false)
+ , m_buttons(0)
{
#ifdef XCB_USE_XLIB
Display *dpy = XOpenDisplay(m_displayName.constData());
@@ -312,6 +313,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char
initializeAllAtoms();
m_time = XCB_CURRENT_TIME;
+ m_netWmUserTime = XCB_CURRENT_TIME;
initializeXRandr();
updateScreens();
@@ -662,6 +664,73 @@ void QXcbConnection::handleXcbError(xcb_generic_error_t *error)
#endif
}
+static Qt::MouseButtons translateMouseButtons(int s)
+{
+ Qt::MouseButtons ret = 0;
+ if (s & XCB_BUTTON_MASK_1)
+ ret |= Qt::LeftButton;
+ if (s & XCB_BUTTON_MASK_2)
+ ret |= Qt::MidButton;
+ if (s & XCB_BUTTON_MASK_3)
+ ret |= Qt::RightButton;
+ return ret;
+}
+
+static Qt::MouseButton translateMouseButton(xcb_button_t s)
+{
+ switch (s) {
+ case 1: return Qt::LeftButton;
+ case 2: return Qt::MidButton;
+ case 3: return Qt::RightButton;
+ // Button values 4-7 were already handled as Wheel events, and won't occur here.
+ case 8: return Qt::BackButton; // Also known as Qt::ExtraButton1
+ case 9: return Qt::ForwardButton; // Also known as Qt::ExtraButton2
+ case 10: return Qt::ExtraButton3;
+ case 11: return Qt::ExtraButton4;
+ case 12: return Qt::ExtraButton5;
+ case 13: return Qt::ExtraButton6;
+ case 14: return Qt::ExtraButton7;
+ case 15: return Qt::ExtraButton8;
+ case 16: return Qt::ExtraButton9;
+ case 17: return Qt::ExtraButton10;
+ case 18: return Qt::ExtraButton11;
+ case 19: return Qt::ExtraButton12;
+ case 20: return Qt::ExtraButton13;
+ case 21: return Qt::ExtraButton14;
+ case 22: return Qt::ExtraButton15;
+ case 23: return Qt::ExtraButton16;
+ case 24: return Qt::ExtraButton17;
+ case 25: return Qt::ExtraButton18;
+ case 26: return Qt::ExtraButton19;
+ case 27: return Qt::ExtraButton20;
+ case 28: return Qt::ExtraButton21;
+ case 29: return Qt::ExtraButton22;
+ case 30: return Qt::ExtraButton23;
+ case 31: return Qt::ExtraButton24;
+ default: return Qt::NoButton;
+ }
+}
+
+void QXcbConnection::handleButtonPress(xcb_generic_event_t *ev)
+{
+ xcb_button_press_event_t *event = (xcb_button_press_event_t *)ev;
+
+ // the event explicitly contains the state of the three first buttons,
+ // the rest we need to manage ourselves
+ m_buttons = (m_buttons & ~0x7) | translateMouseButtons(event->state);
+ m_buttons |= translateMouseButton(event->detail);
+}
+
+void QXcbConnection::handleButtonRelease(xcb_generic_event_t *ev)
+{
+ xcb_button_release_event_t *event = (xcb_button_release_event_t *)ev;
+
+ // the event explicitly contains the state of the three first buttons,
+ // the rest we need to manage ourselves
+ m_buttons = (m_buttons & ~0x7) | translateMouseButtons(event->state);
+ m_buttons &= ~translateMouseButton(event->detail);
+}
+
void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
{
#ifdef Q_XCB_DEBUG
@@ -686,8 +755,10 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
case XCB_EXPOSE:
HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent);
case XCB_BUTTON_PRESS:
+ handleButtonPress(event);
HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent);
case XCB_BUTTON_RELEASE:
+ handleButtonRelease(event);
HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
case XCB_MOTION_NOTIFY:
HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index c67acb3218..464d918adf 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -370,6 +370,9 @@ public:
inline xcb_timestamp_t time() const { return m_time; }
inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; }
+ inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; }
+ inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; }
+
bool hasGLX() const { return has_glx_extension; }
bool hasXFixes() const { return xfixes_first_event > 0; }
bool hasXShape() const { return has_shape_extension; }
@@ -380,6 +383,8 @@ public:
xcb_timestamp_t getTimestamp();
+ Qt::MouseButtons buttons() const { return m_buttons; }
+
private slots:
void processXcbEvents();
@@ -400,6 +405,8 @@ private:
QXcbScreen* findOrCreateScreen(QList<QXcbScreen *>& newScreens, int screenNumber,
xcb_screen_t* xcbScreen, xcb_randr_get_output_info_reply_t *output = NULL);
void updateScreens();
+ void handleButtonPress(xcb_generic_event_t *event);
+ void handleButtonRelease(xcb_generic_event_t *event);
bool m_xi2Enabled;
int m_xi2Minor;
@@ -448,6 +455,7 @@ private:
xcb_atom_t m_allAtoms[QXcbAtom::NAtoms];
xcb_timestamp_t m_time;
+ xcb_timestamp_t m_netWmUserTime;
QByteArray m_displayName;
@@ -501,6 +509,8 @@ private:
bool has_shape_extension;
bool has_randr_extension;
bool has_input_shape;
+
+ Qt::MouseButtons m_buttons;
};
#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index a44e7fb959..9c360df900 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -71,6 +71,8 @@ public:
insert("screen",QXcbNativeInterface::Screen);
insert("eglcontext",QXcbNativeInterface::EglContext);
insert("glxcontext",QXcbNativeInterface::GLXContext);
+ insert("apptime",QXcbNativeInterface::AppTime);
+ insert("appusertime",QXcbNativeInterface::AppUserTime);
}
};
@@ -109,18 +111,24 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q
const QXcbResourceMap::const_iterator it = qXcbResourceMap()->constFind(resource.toLower());
if (it == qXcbResourceMap()->constEnd() || !screen->handle())
return 0;
+ void *result = 0;
const QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(screen->handle());
switch (it.value()) {
case Display:
#ifdef XCB_USE_XLIB
- return xcbScreen->connection()->xlib_display();
-#else
- break;
+ result = xcbScreen->connection()->xlib_display();
#endif
+ break;
+ case AppTime:
+ result = appTime(xcbScreen);
+ break;
+ case AppUserTime:
+ result = appUserTime(xcbScreen);
+ break;
default:
break;
}
- return 0;
+ return result;
}
void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
@@ -151,6 +159,36 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr
return result;
}
+QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::nativeResourceFunctionForScreen(const QByteArray &resource)
+{
+ const QByteArray lowerCaseResource = resource.toLower();
+ if (lowerCaseResource == "setapptime")
+ return NativeResourceForScreenFunction(setAppTime);
+ else if (lowerCaseResource == "setappusertime")
+ return NativeResourceForScreenFunction(setAppUserTime);
+ return 0;
+}
+
+void *QXcbNativeInterface::appTime(const QXcbScreen *screen)
+{
+ return reinterpret_cast<void *>(quintptr(screen->connection()->time()));
+}
+
+void *QXcbNativeInterface::appUserTime(const QXcbScreen *screen)
+{
+ return reinterpret_cast<void *>(quintptr(screen->connection()->netWmUserTime()));
+}
+
+void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time)
+{
+ static_cast<QXcbScreen *>(screen->handle())->connection()->setTime(time);
+}
+
+void QXcbNativeInterface::setAppUserTime(QScreen* screen, xcb_timestamp_t time)
+{
+ static_cast<QXcbScreen *>(screen->handle())->connection()->setNetWmUserTime(time);
+}
+
QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource)
{
QByteArray lowerCaseResource = resource.toLower();
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index a7e0a207cb..e2e03fce8f 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -43,11 +43,13 @@
#define QXCBNATIVEINTERFACE_H
#include <qpa/qplatformnativeinterface.h>
+#include <xcb/xcb.h>
QT_BEGIN_NAMESPACE
class QWidget;
class QXcbScreen;
+class QXcbConnection;
class QXcbNativeInterface : public QPlatformNativeInterface
{
@@ -59,7 +61,9 @@ public:
Screen,
GraphicsDevice,
EglContext,
- GLXContext
+ GLXContext,
+ AppTime,
+ AppUserTime
};
QXcbNativeInterface();
@@ -69,6 +73,7 @@ public:
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource);
+ NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) Q_DECL_OVERRIDE;
inline const QByteArray &genericEventFilterType() const { return m_genericEventFilterType; }
@@ -77,6 +82,10 @@ public:
void *connectionForWindow(QWindow *window);
void *screenForWindow(QWindow *window);
void *graphicsDeviceForWindow(QWindow *window);
+ void *appTime(const QXcbScreen *screen);
+ void *appUserTime(const QXcbScreen *screen);
+ static void setAppTime(QScreen *screen, xcb_timestamp_t time);
+ static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);
static void *eglContextForContext(QOpenGLContext *context);
static void *glxContextForContext(QOpenGLContext *context);
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 0db4176607..528c4c6580 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -385,6 +385,10 @@ void QXcbWindow::create()
#ifndef QT_NO_DRAGANDDROP
connection()->drag()->dndEnable(this, true);
#endif
+
+ const qreal opacity = qt_window_private(window())->opacity;
+ if (!qFuzzyCompare(opacity, qreal(1.0)))
+ setOpacity(opacity);
}
QXcbWindow::~QXcbWindow()
@@ -1024,6 +1028,7 @@ void QXcbWindow::updateNetWmStateBeforeMap()
void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp)
{
xcb_window_t wid = m_window;
+ connection()->setNetWmUserTime(timestamp);
const bool isSupportedByWM = connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW));
if (m_netWmUserTimeWindow || isSupportedByWM) {
@@ -1112,7 +1117,18 @@ void QXcbWindow::setParent(const QPlatformWindow *parent)
void QXcbWindow::setWindowTitle(const QString &title)
{
- QByteArray ba = title.toUtf8();
+ QString fullTitle = title;
+ if (QGuiApplicationPrivate::displayName) {
+ // Append display name, if set.
+ if (!fullTitle.isEmpty())
+ fullTitle += QString::fromUtf8(" \xe2\x80\x94 "); // unicode character U+2014, EM DASH
+ fullTitle += *QGuiApplicationPrivate::displayName;
+ } else if (fullTitle.isEmpty()) {
+ // Don't let the window title be completely empty, use the app name as fallback.
+ fullTitle = QCoreApplication::applicationName();
+ }
+ const QByteArray ba = fullTitle.toUtf8();
+
Q_XCB_CALL(xcb_change_property(xcb_connection(),
XCB_PROP_MODE_REPLACE,
m_window,
@@ -1460,53 +1476,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
}
}
-static Qt::MouseButtons translateMouseButtons(int s)
-{
- Qt::MouseButtons ret = 0;
- if (s & XCB_BUTTON_MASK_1)
- ret |= Qt::LeftButton;
- if (s & XCB_BUTTON_MASK_2)
- ret |= Qt::MidButton;
- if (s & XCB_BUTTON_MASK_3)
- ret |= Qt::RightButton;
- return ret;
-}
-
-static Qt::MouseButton translateMouseButton(xcb_button_t s)
-{
- switch (s) {
- case 1: return Qt::LeftButton;
- case 2: return Qt::MidButton;
- case 3: return Qt::RightButton;
- // Button values 4-7 were already handled as Wheel events, and won't occur here.
- case 8: return Qt::BackButton; // Also known as Qt::ExtraButton1
- case 9: return Qt::ForwardButton; // Also known as Qt::ExtraButton2
- case 10: return Qt::ExtraButton3;
- case 11: return Qt::ExtraButton4;
- case 12: return Qt::ExtraButton5;
- case 13: return Qt::ExtraButton6;
- case 14: return Qt::ExtraButton7;
- case 15: return Qt::ExtraButton8;
- case 16: return Qt::ExtraButton9;
- case 17: return Qt::ExtraButton10;
- case 18: return Qt::ExtraButton11;
- case 19: return Qt::ExtraButton12;
- case 20: return Qt::ExtraButton13;
- case 21: return Qt::ExtraButton14;
- case 22: return Qt::ExtraButton15;
- case 23: return Qt::ExtraButton16;
- case 24: return Qt::ExtraButton17;
- case 25: return Qt::ExtraButton18;
- case 26: return Qt::ExtraButton19;
- case 27: return Qt::ExtraButton20;
- case 28: return Qt::ExtraButton21;
- case 29: return Qt::ExtraButton22;
- case 30: return Qt::ExtraButton23;
- case 31: return Qt::ExtraButton24;
- default: return Qt::NoButton;
- }
-}
-
void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
{
updateNetWmUserTime(event->time);
@@ -1528,7 +1497,7 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
return;
}
- handleMouseEvent(event->detail, event->state, event->time, local, global, modifiers);
+ handleMouseEvent(event->time, local, global, modifiers);
}
void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *event)
@@ -1537,7 +1506,12 @@ void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *even
QPoint global(event->root_x, event->root_y);
Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
- handleMouseEvent(event->detail, event->state, event->time, local, global, modifiers);
+ if (event->detail >= 4 && event->detail <= 7) {
+ // mouse wheel, handled in handleButtonPressEvent()
+ return;
+ }
+
+ handleMouseEvent(event->time, local, global, modifiers);
}
void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
@@ -1546,19 +1520,13 @@ void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
QPoint global(event->root_x, event->root_y);
Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
- handleMouseEvent(event->detail, event->state, event->time, local, global, modifiers);
+ handleMouseEvent(event->time, local, global, modifiers);
}
-void QXcbWindow::handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers)
+void QXcbWindow::handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers)
{
connection()->setTime(time);
-
- Qt::MouseButtons buttons = translateMouseButtons(state);
- Qt::MouseButton button = translateMouseButton(detail);
-
- buttons ^= button; // X event uses state *before*, Qt uses state *after*
-
- QWindowSystemInterface::handleMouseEvent(window(), time, local, global, buttons, modifiers);
+ QWindowSystemInterface::handleMouseEvent(window(), time, local, global, connection()->buttons(), modifiers);
}
class EnterEventChecker
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 07ac0e0fcb..b2c637281d 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -134,11 +134,10 @@ public:
void handleFocusOutEvent(const xcb_focus_out_event_t *event);
void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event);
- void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers);
+ void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers);
void updateSyncRequestCounter();
void updateNetWmUserTime(xcb_timestamp_t timestamp);
- void netWmUserTime() const;
#if defined(XCB_USE_EGL)
QXcbEGLSurface *eglSurface() const;