1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:expandtab:shiftwidth=4:tabstop=4:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "nsAppShell.h"
9 #include <qapplication.h>
14 #include <qabstracteventdispatcher.h>
18 #include "nsQAppInstance.h"
26 PRLogModuleInfo
*gWidgetLog
= nullptr;
27 PRLogModuleInfo
*gWidgetFocusLog
= nullptr;
28 PRLogModuleInfo
*gWidgetIMLog
= nullptr;
29 PRLogModuleInfo
*gWidgetDrawLog
= nullptr;
32 static int sPokeEvent
;
34 nsAppShell::~nsAppShell()
36 nsQAppInstance::Release();
44 gWidgetLog
= PR_NewLogModule("Widget");
46 gWidgetFocusLog
= PR_NewLogModule("WidgetFocus");
48 gWidgetIMLog
= PR_NewLogModule("WidgetIM");
50 gWidgetDrawLog
= PR_NewLogModule("WidgetDraw");
52 #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
53 sPokeEvent
= QEvent::registerEventType();
55 sPokeEvent
= QEvent::User
+5000;
58 nsQAppInstance::AddRef();
60 return nsBaseAppShell::Init();
64 nsAppShell::ScheduleNativeEventCallback()
66 QCoreApplication::postEvent(this,
67 new QEvent((QEvent::Type
) sPokeEvent
));
72 nsAppShell::ProcessNextNativeEvent(bool mayWait
)
74 QEventLoop::ProcessEventsFlags flags
= QEventLoop::AllEvents
;
77 flags
|= QEventLoop::WaitForMoreEvents
;
79 QAbstractEventDispatcher
*dispatcher
= QAbstractEventDispatcher::instance(QThread::currentThread());
83 return dispatcher
->processEvents(flags
) ? true : false;
87 nsAppShell::event (QEvent
*e
)
89 if (e
->type() == sPokeEvent
) {
90 NativeEventCallback();