Separate application into platform specific files. (#4799)

Signed-off-by: Yaakuro <y1@codeposer.net>
This commit is contained in:
Yaakuro
2021-10-22 20:10:47 +02:00
committed by GitHub
parent b536abbf4e
commit 8e03d6f306
12 changed files with 279 additions and 150 deletions
@@ -0,0 +1,25 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Editor/Core/QtEditorApplication.h>
namespace Editor
{
class EditorQtApplicationMac : public EditorQtApplication
{
Q_OBJECT
public:
EditorQtApplicationMac(int& argc, char** argv)
: EditorQtApplication(argc, argv)
{
}
// QAbstractNativeEventFilter:
bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) override;
};
} // namespace Editor
@@ -0,0 +1,51 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#import <AppKit/NSEvent.h>
#include "EditorDefs.h"
#include "QtEditorApplication.h"
// AzFramework
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
// Qt
#include <QCursor>
namespace Editor
{
EditorQtApplication* EditorQtApplication::newInstance(int& argc, char** argv)
{
QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
return new EditorQtApplicationMac(argc, argv);
}
bool EditorQtApplicationMac::nativeEventFilter(const QByteArray& eventType, void* message, long* result)
{
NSEvent* event = (NSEvent*)message;
if (GetIEditor()->IsInGameMode())
{
AzFramework::RawInputNotificationBusMac::Broadcast(&AzFramework::RawInputNotificationsMac::OnRawInputEvent, event);
return true;
}
if ([event type] == NSEventTypeMouseEntered)
{
// filter out mouse enter events when the widget the mouse entered into
// does not exist anymore. This happened occasionally on startup when hovering
// over the splash screen - LY-84100
if (widgetAt(QCursor::pos()) == nullptr)
{
return true;
}
}
return false;
}
} // end namespace Editor
@@ -7,7 +7,7 @@
#
set(FILES
../../Core/QtEditorApplication_mac.mm
Editor/Core/QtEditorApplication_mac.mm
../../LogFile_mac.mm
../../WindowObserver_mac.h
../../WindowObserver_mac.mm