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 <QGuiApplication>
14 #include <qabstracteventdispatcher.h>
18 #include "nsQAppInstance.h"
25 PRLogModuleInfo
*gWidgetLog
= nullptr;
26 PRLogModuleInfo
*gWidgetFocusLog
= nullptr;
27 PRLogModuleInfo
*gWidgetIMLog
= nullptr;
28 PRLogModuleInfo
*gWidgetDrawLog
= nullptr;
31 static int sPokeEvent
;
33 nsAppShell::~nsAppShell()
35 nsQAppInstance::Release();
43 gWidgetLog
= PR_NewLogModule("Widget");
45 gWidgetFocusLog
= PR_NewLogModule("WidgetFocus");
47 gWidgetIMLog
= PR_NewLogModule("WidgetIM");
49 gWidgetDrawLog
= PR_NewLogModule("WidgetDraw");
51 sPokeEvent
= QEvent::registerEventType();
53 nsQAppInstance::AddRef();
55 return nsBaseAppShell::Init();
59 nsAppShell::ScheduleNativeEventCallback()
61 QCoreApplication::postEvent(this,
62 new QEvent((QEvent::Type
) sPokeEvent
));
67 nsAppShell::ProcessNextNativeEvent(bool mayWait
)
69 QEventLoop::ProcessEventsFlags flags
= QEventLoop::AllEvents
;
72 flags
|= QEventLoop::WaitForMoreEvents
;
74 QAbstractEventDispatcher
*dispatcher
= QAbstractEventDispatcher::instance(QThread::currentThread());
78 return dispatcher
->processEvents(flags
) ? true : false;
82 nsAppShell::event (QEvent
*e
)
84 if (e
->type() == sPokeEvent
) {
85 NativeEventCallback();