summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-08-09 12:38:07 +0200
committerSergio Ahumada <sergio.ahumada@digia.com>2013-08-09 12:38:19 +0200
commit6a56fd306937552dbeb53b30149288dc83d2c90b (patch)
tree2ac21aa1a1862df01cdf5724514c268b6093717b /src/plugins/platforms
parentc98943b4cd1c2c2007a9be19a0cfbe8739ab8ccb (diff)
parent88083a81590c6ac9b9fad88725386e4629fc3d08 (diff)
Merge branch 'release' into stable
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm5
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h1
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.h1
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp69
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h4
7 files changed, 63 insertions, 27 deletions
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index 2dedf99582..ee8d7ea157 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -187,10 +187,8 @@ void QMacPrintEnginePrivate::setPaperName(const QString &name)
if (PMSessionGetCurrentPrinter(session(), &printer) == noErr) {
CFArrayRef array;
- if (PMPrinterGetPaperList(printer, &array) != noErr) {
- PMRelease(printer);
+ if (PMPrinterGetPaperList(printer, &array) != noErr)
return;
- }
int count = CFArrayGetCount(array);
for (int i = 0; i < count; ++i) {
PMPaper paper = static_cast<PMPaper>(const_cast<void *>(CFArrayGetValueAtIndex(array, i)));
@@ -208,7 +206,6 @@ void QMacPrintEnginePrivate::setPaperName(const QString &name)
}
}
}
- PMRelease(printer);
}
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 42b0ee9bfe..37a51e1fec 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -582,6 +582,11 @@ QWindow *QWindowsContext::windowUnderMouse() const
return d->m_mouseHandler.windowUnderMouse();
}
+void QWindowsContext::clearWindowUnderMouse()
+{
+ d->m_mouseHandler.clearWindowUnderMouse();
+}
+
/*!
\brief Find a child window at a screen point.
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index d60b632beb..6b80075379 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -166,6 +166,7 @@ public:
unsigned cwex_flags) const;
QWindow *windowUnderMouse() const;
+ void clearWindowUnderMouse();
inline bool windowsProc(HWND hwnd, UINT message,
QtWindows::WindowsEventType et,
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h
index caf30e6b1a..7a7b92ca7e 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.h
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.h
@@ -72,6 +72,7 @@ public:
static Qt::MouseButtons queryMouseButtons();
QWindow *windowUnderMouse() const { return m_windowUnderMouse.data(); }
+ void clearWindowUnderMouse() { m_windowUnderMouse = 0; }
private:
inline bool translateMouseWheelEvent(QWindow *window, HWND hwnd,
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index dcab51ce3e..e7e964a128 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -871,6 +871,9 @@ void QWindowsWindow::destroyWindow()
qDebug() << __FUNCTION__ << this << window() << m_data.hwnd;
if (m_data.hwnd) { // Stop event dispatching before Window is destroyed.
setFlag(WithinDestroy);
+ QWindowsContext *context = QWindowsContext::instance();
+ if (context->windowUnderMouse() == window())
+ context->clearWindowUnderMouse();
if (hasMouseCapture())
setMouseGrabEnabled(false);
unregisterDropSite();
@@ -893,7 +896,7 @@ void QWindowsWindow::destroyWindow()
#endif // !Q_OS_WINCE
if (m_data.hwnd != GetDesktopWindow())
DestroyWindow(m_data.hwnd);
- QWindowsContext::instance()->removeWindow(m_data.hwnd);
+ context->removeWindow(m_data.hwnd);
m_data.hwnd = 0;
}
}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index 14893d9acc..d1729ed168 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -575,7 +575,7 @@ static const Qt::KeyboardModifiers ModsTbl[] = {
Qt::AltModifier | Qt::ShiftModifier, // 5
Qt::AltModifier | Qt::ControlModifier, // 6
Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier, // 7
- Qt::NoModifier // Fall-back to raw Key_*
+ Qt::NoModifier // Fall-back to raw Key_*, for non-latin1 kb layouts
};
Qt::KeyboardModifiers QXcbKeyboard::translateModifiers(int s) const
@@ -594,8 +594,9 @@ Qt::KeyboardModifiers QXcbKeyboard::translateModifiers(int s) const
return ret;
}
-void QXcbKeyboard::readXKBConfig(struct xkb_rule_names *xkb_names)
+void QXcbKeyboard::readXKBConfig()
{
+ clearXKBConfig();
xcb_generic_error_t *error;
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *config_reply;
@@ -626,15 +627,30 @@ void QXcbKeyboard::readXKBConfig(struct xkb_rule_names *xkb_names)
length -= len + 1;
} while (p < end || i < 5);
- xkb_names->rules = qstrdup(names[0]);
- xkb_names->model = qstrdup(names[1]);
- xkb_names->layout = qstrdup(names[2]);
- xkb_names->variant = qstrdup(names[3]);
- xkb_names->options = qstrdup(names[4]);
+ xkb_names.rules = qstrdup(names[0]);
+ xkb_names.model = qstrdup(names[1]);
+ xkb_names.layout = qstrdup(names[2]);
+ xkb_names.variant = qstrdup(names[3]);
+ xkb_names.options = qstrdup(names[4]);
free(config_reply);
}
+void QXcbKeyboard::clearXKBConfig()
+{
+ if (xkb_names.rules)
+ delete[] xkb_names.rules;
+ if (xkb_names.model)
+ delete[] xkb_names.model;
+ if (xkb_names.layout)
+ delete[] xkb_names.layout;
+ if (xkb_names.variant)
+ delete[] xkb_names.variant;
+ if (xkb_names.options)
+ delete[] xkb_names.options;
+ memset(&xkb_names, 0, sizeof(xkb_names));
+}
+
void QXcbKeyboard::updateKeymap()
{
m_config = true;
@@ -646,22 +662,13 @@ void QXcbKeyboard::updateKeymap()
return;
}
}
-
- struct xkb_rule_names xkb_names = {0, 0, 0, 0, 0};
-
- readXKBConfig(&xkb_names);
+ readXKBConfig();
// Compile a keymap from RMLVO (rules, models, layouts, variants and options) names
if (xkb_keymap)
xkb_keymap_unref(xkb_keymap);
xkb_keymap = xkb_keymap_new_from_names(xkb_context, &xkb_names, (xkb_keymap_compile_flags)0);
- delete[] xkb_names.rules;
- delete[] xkb_names.model;
- delete[] xkb_names.layout;
- delete[] xkb_names.variant;
- delete[] xkb_names.options;
-
if (!xkb_keymap) {
qWarning("Qt: Failed to compile a keymap");
m_config = false;
@@ -835,7 +842,7 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(xkb_keymap, "Control");
xkb_mod_mask_t depressed;
-
+ struct xkb_keymap *fallback_keymap = 0;
int qtKey = 0;
//obtain a list of possible shortcuts for the given key event
for (uint i = 1; i < sizeof(ModsTbl) / sizeof(*ModsTbl) ; ++i) {
@@ -851,8 +858,23 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
depressed |= (1 << controlMod);
// update a keyboard state from a set of explicit masks
- xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods,
- baseLayout, latchedLayout, lockedLayout);
+ if (i == 8) {
+ // Add a fall back key for layouts with non Latin-1 characters
+ if (baseQtKey > 255) {
+ struct xkb_rule_names names = { xkb_names.rules, xkb_names.model, "us", 0, 0 };
+ fallback_keymap = xkb_keymap_new_from_names(xkb_context, &names, (xkb_keymap_compile_flags)0);
+ if (!fallback_keymap)
+ continue;
+ xkb_state_unref(kb_state);
+ kb_state = xkb_state_new(fallback_keymap);
+ if (!kb_state)
+ continue;
+ } else
+ continue;
+ } else {
+ xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods,
+ baseLayout, latchedLayout, lockedLayout);
+ }
sym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode());
if (sym == XKB_KEY_NoSymbol)
@@ -867,8 +889,11 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
result += (qtKey + mods);
}
}
+ if (kb_state)
+ xkb_state_unref(kb_state);
+ if (fallback_keymap)
+ xkb_keymap_unref(fallback_keymap);
- xkb_state_unref(kb_state);
return result;
}
@@ -938,6 +963,7 @@ QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
, core_device_id(0)
#endif
{
+ memset(&xkb_names, 0, sizeof(xkb_names));
updateKeymap();
#ifndef QT_NO_XKB
if (connection->hasXKB()) {
@@ -979,6 +1005,7 @@ QXcbKeyboard::~QXcbKeyboard()
#ifdef QT_NO_XKB
xcb_key_symbols_free(m_key_symbols);
#endif
+ clearXKBConfig();
}
#ifndef QT_NO_XKB
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index 770a7eabea..0256602782 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -91,7 +91,8 @@ protected:
int keysymToQtKey(xcb_keysym_t keysym) const;
int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, QString text) const;
- void readXKBConfig(struct xkb_rule_names *names);
+ void readXKBConfig();
+ void clearXKBConfig();
#ifdef QT_NO_XKB
void updateModifiers();
@@ -107,6 +108,7 @@ private:
struct xkb_context *xkb_context;
struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state;
+ struct xkb_rule_names xkb_names;
struct _mod_masks {
uint alt;