Bug 690656 - Don't Init XAtom and XEvents listener in non-main thread r=dougt

This commit is contained in:
Oleg Romashin 2011-10-07 16:16:37 +01:00
Родитель e898a9c599
Коммит 5ec1284a87
1 изменённых файлов: 22 добавлений и 16 удалений

Просмотреть файл

@ -131,8 +131,9 @@ using namespace QtMobility;
#include "keysym2ucs.h"
#if MOZ_PLATFORM_MAEMO == 6
#include <X11/Xatom.h>
static Atom sPluginIMEAtom;
static Atom sPluginIMEAtom = nsnull;
#define PLUGIN_VKB_REQUEST_PROP "_NPAPI_PLUGIN_REQUEST_VKB"
#include <QThread>
#endif
#endif //MOZ_X11
@ -258,7 +259,10 @@ nsWindow::nsWindow()
gGlobalsInitialized = PR_TRUE;
#if defined(MOZ_X11) && (MOZ_PLATFORM_MAEMO == 6)
sPluginIMEAtom = XInternAtom(QX11Info::display(), PLUGIN_VKB_REQUEST_PROP, False);
// This cannot be called on non-main thread
if (QThread::currentThread() == qApp->thread()) {
sPluginIMEAtom = XInternAtom(QX11Info::display(), PLUGIN_VKB_REQUEST_PROP, False);
}
#endif
// It's OK if either of these fail, but it may not be one day.
initialize_prefs();
@ -3236,19 +3240,21 @@ nsWindow::SetInputMode(const IMEContext& aContext)
mIMEContext = aContext;
#if defined(MOZ_X11) && (MOZ_PLATFORM_MAEMO == 6)
static QCoreApplication::EventFilter currentEventFilter = NULL;
if (mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN && currentEventFilter != x11EventFilter) {
// Install event filter for listening Plugin IME state changes
previousEventFilter = QCoreApplication::instance()->setEventFilter(x11EventFilter);
currentEventFilter = x11EventFilter;
} else if (mIMEContext.mStatus != nsIWidget::IME_STATUS_PLUGIN && currentEventFilter == x11EventFilter) {
// Remove event filter
QCoreApplication::instance()->setEventFilter(previousEventFilter);
currentEventFilter = previousEventFilter;
previousEventFilter = NULL;
QWidget* view = GetViewWidget();
if (view) {
SetVKBState(view->winId(), VKBUndefined);
if (sPluginIMEAtom) {
static QCoreApplication::EventFilter currentEventFilter = NULL;
if (mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN && currentEventFilter != x11EventFilter) {
// Install event filter for listening Plugin IME state changes
previousEventFilter = QCoreApplication::instance()->setEventFilter(x11EventFilter);
currentEventFilter = x11EventFilter;
} else if (mIMEContext.mStatus != nsIWidget::IME_STATUS_PLUGIN && currentEventFilter == x11EventFilter) {
// Remove event filter
QCoreApplication::instance()->setEventFilter(previousEventFilter);
currentEventFilter = previousEventFilter;
previousEventFilter = NULL;
QWidget* view = GetViewWidget();
if (view) {
SetVKBState(view->winId(), VKBUndefined);
}
}
}
#endif
@ -3291,7 +3297,7 @@ nsWindow::SetSoftwareKeyboardState(bool aOpen)
}
#if defined(MOZ_X11) && (MOZ_PLATFORM_MAEMO == 6)
// doen't open VKB if plugin did set closed state
else {
else if (sPluginIMEAtom) {
QWidget* view = GetViewWidget();
if (view && GetPluginVKBState(view->winId()) == VKBClose) {
return;