Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhaikuintegration.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
10#include "qhaikuscreen.h"
11#include "qhaikuservices.h"
12
13#include <QCoreApplication>
14#include <QFileInfo>
15#include <qpa/qplatformwindow.h>
16#include <qpa/qwindowsysteminterface.h>
17#include <QtGui/private/qgenericunixeventdispatcher_p.h>
18
19#include <Application.h>
20
22
23using namespace Qt::StringLiterals;
24
25static long int startApplicationThread(void *data)
26{
27 QHaikuApplication *app = static_cast<QHaikuApplication*>(data);
28 app->LockLooper();
29 return app->Run();
30}
31
32QHaikuIntegration::QHaikuIntegration(const QStringList &parameters)
33 : m_clipboard(new QHaikuClipboard)
34{
35 Q_UNUSED(parameters);
36
37 const QString signature = "application/x-vnd.Qt.%1"_L1.arg(QFileInfo(QCoreApplication::applicationFilePath()).fileName());
38
39 QHaikuApplication *app = new QHaikuApplication(signature.toLocal8Bit());
40 be_app = app;
41
42 const thread_id applicationThreadId = spawn_thread(startApplicationThread, "app_thread", 1, static_cast<void*>(app));
43 resume_thread(applicationThreadId);
44 app->UnlockLooper();
45
46 m_screen = new QHaikuScreen;
47
48 // notify system about available screen
49 QWindowSystemInterface::handleScreenAdded(m_screen);
50}
51
53{
54 QWindowSystemInterface::handleScreenRemoved(m_screen);
55 m_screen = nullptr;
56
57 delete m_services;
58 m_services = nullptr;
59
60 delete m_clipboard;
61 m_clipboard = nullptr;
62
63 be_app->LockLooper();
64 be_app->Quit();
65}
66
67bool QHaikuIntegration::hasCapability(QPlatformIntegration::Capability capability) const
68{
69 return QPlatformIntegration::hasCapability(capability);
70}
71
73{
74 return QPlatformIntegration::fontDatabase();
75}
76
78{
79 if (!m_services)
80 m_services = new QHaikuServices;
81
82 return m_services;
83}
84
86{
87 return m_clipboard;
88}
89
91{
92 QPlatformWindow *platformWindow = new QHaikuRasterWindow(window);
93 platformWindow->requestActivateWindow();
94 return platformWindow;
95}
96
98{
99 return new QHaikuRasterBackingStore(window);
100}
101
103{
104 return createUnixEventDispatcher();
105}
106
107QT_END_NAMESPACE
bool hasCapability(QPlatformIntegration::Capability cap) const override
QHaikuIntegration(const QStringList &paramList)
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
QPlatformBackingStore * createPlatformBackingStore(QWindow *window) const override
Factory function for QPlatformBackingStore.
QPlatformClipboard * clipboard() const override
Accessor for the platform integration's clipboard.
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
QPlatformServices * services() const override
static long int startApplicationThread(void *data)