Haiku: Initial version of QPA plugin for Haiku
Change-Id: Ib4d1d75a11602af8423970e12c7cc594576e1c4d Reviewed-by: Augustin Cavalier <waddlesplash@gmail.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
This commit is contained in:
parent
64d7bb9f55
commit
fa93d0ceec
3
src/plugins/platforms/haiku/haiku.json
Normal file
3
src/plugins/platforms/haiku/haiku.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"Keys": [ "haiku" ]
|
||||||
|
}
|
42
src/plugins/platforms/haiku/haiku.pro
Normal file
42
src/plugins/platforms/haiku/haiku.pro
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
TARGET = qhaiku
|
||||||
|
PLUGIN_TYPE = platforms
|
||||||
|
PLUGIN_CLASS_NAME = QHaikuIntegrationPlugin
|
||||||
|
load(qt_plugin)
|
||||||
|
|
||||||
|
QT += platformsupport-private core-private gui-private
|
||||||
|
|
||||||
|
SOURCES = \
|
||||||
|
main.cpp \
|
||||||
|
qhaikuapplication.cpp \
|
||||||
|
qhaikubuffer.cpp \
|
||||||
|
qhaikuclipboard.cpp \
|
||||||
|
qhaikucursor.cpp \
|
||||||
|
qhaikuintegration.cpp \
|
||||||
|
qhaikukeymapper.cpp \
|
||||||
|
qhaikurasterbackingstore.cpp \
|
||||||
|
qhaikurasterwindow.cpp \
|
||||||
|
qhaikuscreen.cpp \
|
||||||
|
qhaikuservices.cpp \
|
||||||
|
qhaikuutils.cpp \
|
||||||
|
qhaikuwindow.cpp
|
||||||
|
|
||||||
|
HEADERS = \
|
||||||
|
main.h \
|
||||||
|
qhaikuapplication.h \
|
||||||
|
qhaikubuffer.h \
|
||||||
|
qhaikuclipboard.h \
|
||||||
|
qhaikucursor.h \
|
||||||
|
qhaikuintegration.h \
|
||||||
|
qhaikukeymapper.h \
|
||||||
|
qhaikurasterbackingstore.h \
|
||||||
|
qhaikurasterwindow.h \
|
||||||
|
qhaikuscreen.h \
|
||||||
|
qhaikuservices.h \
|
||||||
|
qhaikuutils.h \
|
||||||
|
qhaikuwindow.h
|
||||||
|
|
||||||
|
LIBS += -lbe
|
||||||
|
|
||||||
|
OTHER_FILES += haiku.json
|
||||||
|
|
||||||
|
include (../../../platformsupport/fontdatabases/fontdatabases.pri)
|
47
src/plugins/platforms/haiku/main.cpp
Normal file
47
src/plugins/platforms/haiku/main.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "qhaikuintegration.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
QPlatformIntegration *QHaikuIntegrationPlugin::create(const QString& system, const QStringList& paramList)
|
||||||
|
{
|
||||||
|
if (!system.compare(QLatin1String("haiku"), Qt::CaseInsensitive))
|
||||||
|
return new QHaikuIntegration(paramList);
|
||||||
|
|
||||||
|
return Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
47
src/plugins/platforms/haiku/main.h
Normal file
47
src/plugins/platforms/haiku/main.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <qpa/qplatformintegrationplugin.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QHaikuIntegrationPlugin : public QPlatformIntegrationPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "haiku.json")
|
||||||
|
|
||||||
|
public:
|
||||||
|
QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
71
src/plugins/platforms/haiku/qhaikuapplication.cpp
Normal file
71
src/plugins/platforms/haiku/qhaikuapplication.cpp
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikuapplication.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QFileOpenEvent>
|
||||||
|
|
||||||
|
#include <Entry.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
|
QHaikuApplication::QHaikuApplication(const char *signature)
|
||||||
|
: BApplication(signature)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHaikuApplication::QuitRequested()
|
||||||
|
{
|
||||||
|
QEvent quitEvent(QEvent::Quit);
|
||||||
|
QCoreApplication::sendEvent(QCoreApplication::instance(), &quitEvent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuApplication::RefsReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
uint32 type;
|
||||||
|
int32 count;
|
||||||
|
|
||||||
|
const status_t status = message->GetInfo("refs", &type, &count);
|
||||||
|
if (status == B_OK && type == B_REF_TYPE) {
|
||||||
|
entry_ref ref;
|
||||||
|
for (int32 i = 0; i < count; ++i) {
|
||||||
|
if (message->FindRef("refs", i, &ref) == B_OK) {
|
||||||
|
const BPath path(&ref);
|
||||||
|
QCoreApplication::postEvent(QCoreApplication::instance(), new QFileOpenEvent(QFile::decodeName(path.Path())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BApplication::RefsReceived(message);
|
||||||
|
}
|
50
src/plugins/platforms/haiku/qhaikuapplication.h
Normal file
50
src/plugins/platforms/haiku/qhaikuapplication.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUAPPLICATION_H
|
||||||
|
#define QHAIKUAPPLICATION_H
|
||||||
|
|
||||||
|
#include <qglobal.h>
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
|
||||||
|
class QHaikuApplication : public BApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit QHaikuApplication(const char *signature);
|
||||||
|
|
||||||
|
bool QuitRequested() Q_DECL_OVERRIDE;
|
||||||
|
void RefsReceived(BMessage* message) Q_DECL_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
73
src/plugins/platforms/haiku/qhaikubuffer.cpp
Normal file
73
src/plugins/platforms/haiku/qhaikubuffer.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikubuffer.h"
|
||||||
|
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
QHaikuBuffer::QHaikuBuffer()
|
||||||
|
: m_buffer(Q_NULLPTR)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuBuffer::QHaikuBuffer(BBitmap *buffer)
|
||||||
|
: m_buffer(buffer)
|
||||||
|
{
|
||||||
|
// wrap buffer in an image
|
||||||
|
m_image = QImage(static_cast<uchar*>(m_buffer->Bits()), m_buffer->Bounds().right, m_buffer->Bounds().bottom, m_buffer->BytesPerRow(), QImage::Format_RGB32);
|
||||||
|
}
|
||||||
|
|
||||||
|
BBitmap* QHaikuBuffer::nativeBuffer() const
|
||||||
|
{
|
||||||
|
return m_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QImage *QHaikuBuffer::image() const
|
||||||
|
{
|
||||||
|
return (m_buffer != Q_NULLPTR) ? &m_image : Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage *QHaikuBuffer::image()
|
||||||
|
{
|
||||||
|
return (m_buffer != Q_NULLPTR) ? &m_image : Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect QHaikuBuffer::rect() const
|
||||||
|
{
|
||||||
|
return m_image.rect();
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
62
src/plugins/platforms/haiku/qhaikubuffer.h
Normal file
62
src/plugins/platforms/haiku/qhaikubuffer.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUBUFFER_H
|
||||||
|
#define QHAIKUBUFFER_H
|
||||||
|
|
||||||
|
#include <QtGui/QImage>
|
||||||
|
|
||||||
|
class BBitmap;
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QHaikuBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QHaikuBuffer();
|
||||||
|
QHaikuBuffer(BBitmap *buffer);
|
||||||
|
|
||||||
|
BBitmap* nativeBuffer() const;
|
||||||
|
const QImage *image() const;
|
||||||
|
QImage *image();
|
||||||
|
|
||||||
|
QRect rect() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BBitmap *m_buffer;
|
||||||
|
QImage m_image;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
140
src/plugins/platforms/haiku/qhaikuclipboard.cpp
Normal file
140
src/plugins/platforms/haiku/qhaikuclipboard.cpp
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(QT_NO_CLIPBOARD)
|
||||||
|
|
||||||
|
#include "qhaikuclipboard.h"
|
||||||
|
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
#include <Clipboard.h>
|
||||||
|
|
||||||
|
QHaikuClipboard::QHaikuClipboard()
|
||||||
|
{
|
||||||
|
if (be_clipboard)
|
||||||
|
be_clipboard->StartWatching(BMessenger(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuClipboard::~QHaikuClipboard()
|
||||||
|
{
|
||||||
|
if (be_clipboard)
|
||||||
|
be_clipboard->StopWatching(BMessenger(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
QMimeData *QHaikuClipboard::mimeData(QClipboard::Mode mode)
|
||||||
|
{
|
||||||
|
QMimeData *mimeData = new QMimeData();
|
||||||
|
|
||||||
|
if (mode != QClipboard::Clipboard)
|
||||||
|
return mimeData;
|
||||||
|
|
||||||
|
if (!be_clipboard->Lock())
|
||||||
|
return mimeData;
|
||||||
|
|
||||||
|
const BMessage *clipboard = be_clipboard->Data();
|
||||||
|
if (clipboard) {
|
||||||
|
char *name = Q_NULLPTR;
|
||||||
|
uint32 type = 0;
|
||||||
|
int32 count = 0;
|
||||||
|
|
||||||
|
for (int i = 0; clipboard->GetInfo(B_MIME_TYPE, i, &name, &type, &count) == B_OK; i++) {
|
||||||
|
const void *data = Q_NULLPTR;
|
||||||
|
int32 dataLen = 0;
|
||||||
|
|
||||||
|
const status_t status = clipboard->FindData(name, B_MIME_TYPE, &data, &dataLen);
|
||||||
|
if (dataLen && (status == B_OK)) {
|
||||||
|
const QString format = QString::fromLatin1(name);
|
||||||
|
if (format == QStringLiteral("text/plain")) {
|
||||||
|
mimeData->setText(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
|
||||||
|
} else if (format == QStringLiteral("text/html")) {
|
||||||
|
mimeData->setHtml(QString::fromLocal8Bit(reinterpret_cast<const char*>(data), dataLen));
|
||||||
|
} else {
|
||||||
|
mimeData->setData(format, QByteArray(reinterpret_cast<const char*>(data), dataLen));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
be_clipboard->Unlock();
|
||||||
|
|
||||||
|
return mimeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
|
||||||
|
{
|
||||||
|
if (mode != QClipboard::Clipboard)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!be_clipboard->Lock())
|
||||||
|
return;
|
||||||
|
|
||||||
|
be_clipboard->Clear();
|
||||||
|
if (mimeData) {
|
||||||
|
BMessage *clipboard = be_clipboard->Data();
|
||||||
|
if (clipboard) {
|
||||||
|
const QStringList formats = mimeData->formats();
|
||||||
|
Q_FOREACH (const QString &format, formats) {
|
||||||
|
const QByteArray data = mimeData->data(format).data();
|
||||||
|
clipboard->AddData(format.toUtf8(), B_MIME_TYPE, data, data.count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (be_clipboard->Commit() != B_OK)
|
||||||
|
qWarning("Unable to store mime data on clipboard");
|
||||||
|
|
||||||
|
be_clipboard->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHaikuClipboard::supportsMode(QClipboard::Mode mode) const
|
||||||
|
{
|
||||||
|
return (mode == QClipboard::Clipboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHaikuClipboard::ownsMode(QClipboard::Mode mode) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(mode);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuClipboard::MessageReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
if (message->what == B_CLIPBOARD_CHANGED)
|
||||||
|
emitChanged(QClipboard::Clipboard);
|
||||||
|
|
||||||
|
BHandler::MessageReceived(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
64
src/plugins/platforms/haiku/qhaikuclipboard.h
Normal file
64
src/plugins/platforms/haiku/qhaikuclipboard.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUCLIPBOARD_H
|
||||||
|
#define QHAIKUCLIPBOARD_H
|
||||||
|
|
||||||
|
#if !defined(QT_NO_CLIPBOARD)
|
||||||
|
|
||||||
|
#include <qpa/qplatformclipboard.h>
|
||||||
|
|
||||||
|
#include <Handler.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QHaikuClipboard : public QPlatformClipboard, public BHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QHaikuClipboard();
|
||||||
|
~QHaikuClipboard();
|
||||||
|
|
||||||
|
QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) Q_DECL_OVERRIDE;
|
||||||
|
void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard) Q_DECL_OVERRIDE;
|
||||||
|
bool supportsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE;
|
||||||
|
bool ownsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
// override from BHandler to catch change notifications from Haiku clipboard
|
||||||
|
void MessageReceived(BMessage* message) Q_DECL_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
92
src/plugins/platforms/haiku/qhaikucursor.cpp
Normal file
92
src/plugins/platforms/haiku/qhaikucursor.cpp
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikucursor.h"
|
||||||
|
|
||||||
|
#include "qhaikurasterwindow.h"
|
||||||
|
|
||||||
|
#include <Cursor.h>
|
||||||
|
|
||||||
|
QHaikuCursor::QHaikuCursor()
|
||||||
|
{
|
||||||
|
m_cursorIds.insert(Qt::ArrowCursor, B_CURSOR_ID_SYSTEM_DEFAULT);
|
||||||
|
m_cursorIds.insert(Qt::UpArrowCursor, B_CURSOR_ID_RESIZE_NORTH);
|
||||||
|
m_cursorIds.insert(Qt::CrossCursor, B_CURSOR_ID_CROSS_HAIR);
|
||||||
|
m_cursorIds.insert(Qt::WaitCursor, B_CURSOR_ID_PROGRESS);
|
||||||
|
m_cursorIds.insert(Qt::IBeamCursor, B_CURSOR_ID_I_BEAM);
|
||||||
|
m_cursorIds.insert(Qt::SizeVerCursor, B_CURSOR_ID_RESIZE_NORTH_SOUTH);
|
||||||
|
m_cursorIds.insert(Qt::SizeHorCursor, B_CURSOR_ID_RESIZE_EAST_WEST);
|
||||||
|
m_cursorIds.insert(Qt::SizeBDiagCursor, B_CURSOR_ID_RESIZE_NORTH_EAST_SOUTH_WEST);
|
||||||
|
m_cursorIds.insert(Qt::SizeFDiagCursor, B_CURSOR_ID_RESIZE_NORTH_WEST_SOUTH_EAST);
|
||||||
|
m_cursorIds.insert(Qt::SizeAllCursor, B_CURSOR_ID_MOVE);
|
||||||
|
m_cursorIds.insert(Qt::BlankCursor, B_CURSOR_ID_NO_CURSOR);
|
||||||
|
m_cursorIds.insert(Qt::SplitVCursor, B_CURSOR_ID_RESIZE_NORTH_SOUTH);
|
||||||
|
m_cursorIds.insert(Qt::SplitHCursor, B_CURSOR_ID_RESIZE_EAST_WEST);
|
||||||
|
m_cursorIds.insert(Qt::PointingHandCursor, B_CURSOR_ID_FOLLOW_LINK);
|
||||||
|
m_cursorIds.insert(Qt::ForbiddenCursor, B_CURSOR_ID_NOT_ALLOWED);
|
||||||
|
m_cursorIds.insert(Qt::OpenHandCursor, B_CURSOR_ID_GRAB);
|
||||||
|
m_cursorIds.insert(Qt::ClosedHandCursor, B_CURSOR_ID_GRABBING);
|
||||||
|
m_cursorIds.insert(Qt::WhatsThisCursor, B_CURSOR_ID_HELP);
|
||||||
|
m_cursorIds.insert(Qt::BusyCursor, B_CURSOR_ID_PROGRESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef QT_NO_CURSOR
|
||||||
|
void QHaikuCursor::changeCursor(QCursor *windowCursor, QWindow *window)
|
||||||
|
{
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BWindow *haikuWindow = reinterpret_cast<BWindow*>(window->winId());
|
||||||
|
|
||||||
|
// We expect that every BWindow has exactly one BView as child,
|
||||||
|
// so we can use CurrentFocus to retrieve it and call SetViewCursor
|
||||||
|
// to change the cursor for the whole window.
|
||||||
|
if (!windowCursor) {
|
||||||
|
BView *view = haikuWindow->CurrentFocus();
|
||||||
|
if (view) {
|
||||||
|
view->SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const Qt::CursorShape shape = windowCursor->shape();
|
||||||
|
if (!m_cursors.contains(shape))
|
||||||
|
m_cursors.insert(shape, new BCursor(m_cursorIds.value(shape)));
|
||||||
|
|
||||||
|
BView *view = haikuWindow->CurrentFocus();
|
||||||
|
if (view) {
|
||||||
|
view->LockLooper();
|
||||||
|
view->SetViewCursor(m_cursors.value(shape));
|
||||||
|
view->UnlockLooper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
59
src/plugins/platforms/haiku/qhaikucursor.h
Normal file
59
src/plugins/platforms/haiku/qhaikucursor.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUCURSOR_H
|
||||||
|
#define QHAIKUCURSOR_H
|
||||||
|
|
||||||
|
#include <qpa/qplatformcursor.h>
|
||||||
|
|
||||||
|
#include <Cursor.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QHaikuCursor : public QPlatformCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QHaikuCursor();
|
||||||
|
|
||||||
|
#ifndef QT_NO_CURSOR
|
||||||
|
void changeCursor(QCursor *windowCursor, QWindow *window) Q_DECL_OVERRIDE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHash<Qt::CursorShape, BCursorID> m_cursorIds;
|
||||||
|
QHash<Qt::CursorShape, BCursor*> m_cursors;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
133
src/plugins/platforms/haiku/qhaikuintegration.cpp
Normal file
133
src/plugins/platforms/haiku/qhaikuintegration.cpp
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikuintegration.h"
|
||||||
|
|
||||||
|
#include "qhaikuapplication.h"
|
||||||
|
#include "qhaikuclipboard.h"
|
||||||
|
#include "qhaikurasterbackingstore.h"
|
||||||
|
#include "qhaikurasterwindow.h"
|
||||||
|
#include "qhaikuscreen.h"
|
||||||
|
#include "qhaikuservices.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <qpa/qplatformwindow.h>
|
||||||
|
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
static long int startApplicationThread(void *data)
|
||||||
|
{
|
||||||
|
QHaikuApplication *app = static_cast<QHaikuApplication*>(data);
|
||||||
|
app->LockLooper();
|
||||||
|
return app->Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuIntegration::QHaikuIntegration(const QStringList ¶meters)
|
||||||
|
: m_clipboard(new QHaikuClipboard)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parameters);
|
||||||
|
|
||||||
|
const QString signature = QStringLiteral("application/x-vnd.Qt.%1").arg(QFileInfo(QCoreApplication::applicationFilePath()).fileName());
|
||||||
|
|
||||||
|
QHaikuApplication *app = new QHaikuApplication(signature.toLocal8Bit());
|
||||||
|
be_app = app;
|
||||||
|
|
||||||
|
const thread_id applicationThreadId = spawn_thread(startApplicationThread, "app_thread", 1, static_cast<void*>(app));
|
||||||
|
resume_thread(applicationThreadId);
|
||||||
|
app->UnlockLooper();
|
||||||
|
|
||||||
|
m_screen = new QHaikuScreen;
|
||||||
|
|
||||||
|
m_services = new QHaikuServices;
|
||||||
|
|
||||||
|
// notify system about available screen
|
||||||
|
screenAdded(m_screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuIntegration::~QHaikuIntegration()
|
||||||
|
{
|
||||||
|
destroyScreen(m_screen);
|
||||||
|
m_screen = Q_NULLPTR;
|
||||||
|
|
||||||
|
delete m_services;
|
||||||
|
m_services = Q_NULLPTR;
|
||||||
|
|
||||||
|
delete m_clipboard;
|
||||||
|
m_clipboard = Q_NULLPTR;
|
||||||
|
|
||||||
|
be_app->LockLooper();
|
||||||
|
be_app->Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHaikuIntegration::hasCapability(QPlatformIntegration::Capability capability) const
|
||||||
|
{
|
||||||
|
return QPlatformIntegration::hasCapability(capability);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPlatformFontDatabase *QHaikuIntegration::fontDatabase() const
|
||||||
|
{
|
||||||
|
return QPlatformIntegration::fontDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPlatformServices *QHaikuIntegration::services() const
|
||||||
|
{
|
||||||
|
return m_services;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPlatformClipboard *QHaikuIntegration::clipboard() const
|
||||||
|
{
|
||||||
|
return m_clipboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPlatformWindow *QHaikuIntegration::createPlatformWindow(QWindow *window) const
|
||||||
|
{
|
||||||
|
QPlatformWindow *platformWindow = new QHaikuRasterWindow(window);
|
||||||
|
platformWindow->requestActivateWindow();
|
||||||
|
return platformWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPlatformBackingStore *QHaikuIntegration::createPlatformBackingStore(QWindow *window) const
|
||||||
|
{
|
||||||
|
return new QHaikuRasterBackingStore(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
QAbstractEventDispatcher *QHaikuIntegration::createEventDispatcher() const
|
||||||
|
{
|
||||||
|
return createUnixEventDispatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
72
src/plugins/platforms/haiku/qhaikuintegration.h
Normal file
72
src/plugins/platforms/haiku/qhaikuintegration.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUINTEGRATION_H
|
||||||
|
#define QHAIKUINTEGRATION_H
|
||||||
|
|
||||||
|
#include <qpa/qplatformintegration.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QHaikuClipboard;
|
||||||
|
class QHaikuScreen;
|
||||||
|
class QHaikuServices;
|
||||||
|
|
||||||
|
class QHaikuIntegration : public QPlatformIntegration
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit QHaikuIntegration(const QStringList ¶mList);
|
||||||
|
~QHaikuIntegration();
|
||||||
|
|
||||||
|
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
|
||||||
|
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
|
||||||
|
QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
|
||||||
|
QPlatformServices *services() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
#ifndef QT_NO_CLIPBOARD
|
||||||
|
QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHaikuClipboard *m_clipboard;
|
||||||
|
QHaikuScreen *m_screen;
|
||||||
|
QHaikuServices *m_services;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
180
src/plugins/platforms/haiku/qhaikukeymapper.cpp
Normal file
180
src/plugins/platforms/haiku/qhaikukeymapper.cpp
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikukeymapper.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
uint32 Haiku_ScanCodes[] = {
|
||||||
|
Qt::Key_Escape, 0x01,
|
||||||
|
Qt::Key_F1, 0x02,
|
||||||
|
Qt::Key_F2, 0x03,
|
||||||
|
Qt::Key_F3, 0x04,
|
||||||
|
Qt::Key_F4, 0x05,
|
||||||
|
Qt::Key_F5, 0x06,
|
||||||
|
Qt::Key_F6, 0x07,
|
||||||
|
Qt::Key_F7, 0x08,
|
||||||
|
Qt::Key_F8, 0x09,
|
||||||
|
Qt::Key_F9, 0x0A,
|
||||||
|
Qt::Key_F10, 0x0B,
|
||||||
|
Qt::Key_F11, 0x0C,
|
||||||
|
Qt::Key_F12, 0x0D,
|
||||||
|
Qt::Key_Print, 0x0E,
|
||||||
|
Qt::Key_Pause, 0x22,
|
||||||
|
Qt::Key_AsciiTilde, 0x11,
|
||||||
|
Qt::Key_1, 0x12,
|
||||||
|
Qt::Key_2, 0x13,
|
||||||
|
Qt::Key_3, 0x14,
|
||||||
|
Qt::Key_4, 0x15,
|
||||||
|
Qt::Key_5, 0x16,
|
||||||
|
Qt::Key_6, 0x17,
|
||||||
|
Qt::Key_7, 0x18,
|
||||||
|
Qt::Key_8, 0x19,
|
||||||
|
Qt::Key_9, 0x1A,
|
||||||
|
Qt::Key_0, 0x1B,
|
||||||
|
Qt::Key_Minus, 0x1C,
|
||||||
|
Qt::Key_Plus, 0x1D,
|
||||||
|
Qt::Key_Backspace, 0x1E,
|
||||||
|
Qt::Key_Insert, 0x1F,
|
||||||
|
Qt::Key_Home, 0x20,
|
||||||
|
Qt::Key_PageUp, 0x21,
|
||||||
|
Qt::Key_Slash, 0x23,
|
||||||
|
Qt::Key_Asterisk, 0x24,
|
||||||
|
Qt::Key_Minus, 0x25,
|
||||||
|
Qt::Key_Tab, 0x26,
|
||||||
|
Qt::Key_Q, 0x27,
|
||||||
|
Qt::Key_W, 0x28,
|
||||||
|
Qt::Key_E, 0x29,
|
||||||
|
Qt::Key_R, 0x2A,
|
||||||
|
Qt::Key_T, 0x2B,
|
||||||
|
Qt::Key_Y, 0x2C,
|
||||||
|
Qt::Key_U, 0x2D,
|
||||||
|
Qt::Key_I, 0x2E,
|
||||||
|
Qt::Key_O, 0x2F,
|
||||||
|
Qt::Key_P, 0x30,
|
||||||
|
Qt::Key_BracketLeft, 0x31,
|
||||||
|
Qt::Key_BracketRight, 0x32,
|
||||||
|
Qt::Key_Backslash, 0x33,
|
||||||
|
Qt::Key_Delete, 0x34,
|
||||||
|
Qt::Key_End, 0x35,
|
||||||
|
Qt::Key_PageDown, 0x36,
|
||||||
|
Qt::Key_Home, 0x37, // numpad
|
||||||
|
Qt::Key_Up, 0x38, // numpad
|
||||||
|
Qt::Key_PageUp, 0x39, // numpad
|
||||||
|
Qt::Key_Plus, 0x3A, // numpad
|
||||||
|
Qt::Key_A, 0x3C,
|
||||||
|
Qt::Key_S, 0x3D,
|
||||||
|
Qt::Key_D, 0x3E,
|
||||||
|
Qt::Key_F, 0x3F,
|
||||||
|
Qt::Key_G, 0x40,
|
||||||
|
Qt::Key_H, 0x41,
|
||||||
|
Qt::Key_J, 0x42,
|
||||||
|
Qt::Key_K, 0x43,
|
||||||
|
Qt::Key_L, 0x44,
|
||||||
|
Qt::Key_Colon, 0x45,
|
||||||
|
Qt::Key_QuoteDbl, 0x46,
|
||||||
|
Qt::Key_Return, 0x47,
|
||||||
|
Qt::Key_Left, 0x48, // numpad
|
||||||
|
Qt::Key_5, 0x49, // numpad ???
|
||||||
|
Qt::Key_Right, 0x4A, // numpad
|
||||||
|
Qt::Key_Z, 0x4C,
|
||||||
|
Qt::Key_X, 0x4D,
|
||||||
|
Qt::Key_C, 0x4E,
|
||||||
|
Qt::Key_V, 0x4F,
|
||||||
|
Qt::Key_B, 0x50,
|
||||||
|
Qt::Key_N, 0x51,
|
||||||
|
Qt::Key_M, 0x51,
|
||||||
|
Qt::Key_Less, 0x52,
|
||||||
|
Qt::Key_Greater, 0x54,
|
||||||
|
Qt::Key_Question, 0x55,
|
||||||
|
Qt::Key_Up, 0x57, // cursor
|
||||||
|
Qt::Key_End, 0x58, // numpad
|
||||||
|
Qt::Key_Down, 0x59, // numpad
|
||||||
|
Qt::Key_PageDown, 0x5A, // numpad
|
||||||
|
Qt::Key_Enter, 0x5B, // numpad
|
||||||
|
Qt::Key_Space, 0x5E,
|
||||||
|
Qt::Key_Left, 0x61, // cursor
|
||||||
|
Qt::Key_Down, 0x62, // cursor
|
||||||
|
Qt::Key_Right, 0x63, // cursor
|
||||||
|
Qt::Key_Insert, 0x64, // cursor
|
||||||
|
Qt::Key_Delete, 0x65, // numpad
|
||||||
|
0, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32 Haiku_ScanCodes_Numlock[] = {
|
||||||
|
Qt::Key_7, 0x37,
|
||||||
|
Qt::Key_8, 0x38,
|
||||||
|
Qt::Key_9, 0x39,
|
||||||
|
Qt::Key_Plus, 0x3A,
|
||||||
|
Qt::Key_4, 0x48,
|
||||||
|
Qt::Key_5, 0x49,
|
||||||
|
Qt::Key_6, 0x4A,
|
||||||
|
Qt::Key_1, 0x58,
|
||||||
|
Qt::Key_2, 0x59,
|
||||||
|
Qt::Key_3, 0x5A,
|
||||||
|
Qt::Key_Enter, 0x5B,
|
||||||
|
Qt::Key_Comma, 0x65,
|
||||||
|
0, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32 QHaikuKeyMapper::translateKeyCode(uint32 key, bool numlockActive)
|
||||||
|
{
|
||||||
|
uint32 code = 0;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (numlockActive) {
|
||||||
|
while (Haiku_ScanCodes_Numlock[i]) {
|
||||||
|
if (key == Haiku_ScanCodes_Numlock[i + 1]) {
|
||||||
|
code = Haiku_ScanCodes_Numlock[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code > 0)
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (Haiku_ScanCodes[i]) {
|
||||||
|
if (key == Haiku_ScanCodes[i + 1]) {
|
||||||
|
code = Haiku_ScanCodes[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
53
src/plugins/platforms/haiku/qhaikukeymapper.h
Normal file
53
src/plugins/platforms/haiku/qhaikukeymapper.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUKEYMAPPER_H
|
||||||
|
#define QHAIKUKEYMAPPER_H
|
||||||
|
|
||||||
|
#include <qnamespace.h>
|
||||||
|
|
||||||
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QHaikuKeyMapper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QHaikuKeyMapper();
|
||||||
|
|
||||||
|
static uint32 translateKeyCode(uint32 key, bool numlockActive);
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
92
src/plugins/platforms/haiku/qhaikurasterbackingstore.cpp
Normal file
92
src/plugins/platforms/haiku/qhaikurasterbackingstore.cpp
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikurasterbackingstore.h"
|
||||||
|
#include "qhaikurasterwindow.h"
|
||||||
|
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
QHaikuRasterBackingStore::QHaikuRasterBackingStore(QWindow *window)
|
||||||
|
: QPlatformBackingStore(window)
|
||||||
|
, m_bitmap(Q_NULLPTR)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuRasterBackingStore::~QHaikuRasterBackingStore()
|
||||||
|
{
|
||||||
|
delete m_bitmap;
|
||||||
|
m_bitmap = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPaintDevice *QHaikuRasterBackingStore::paintDevice()
|
||||||
|
{
|
||||||
|
if (!m_bufferSize.isEmpty() && m_bitmap)
|
||||||
|
return m_buffer.image();
|
||||||
|
|
||||||
|
return Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuRasterBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset)
|
||||||
|
{
|
||||||
|
Q_UNUSED(region);
|
||||||
|
Q_UNUSED(offset);
|
||||||
|
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QHaikuRasterWindow *targetWindow = static_cast<QHaikuRasterWindow*>(window->handle());
|
||||||
|
|
||||||
|
BView *view = targetWindow->nativeViewHandle();
|
||||||
|
|
||||||
|
view->LockLooper();
|
||||||
|
view->DrawBitmap(m_bitmap);
|
||||||
|
view->UnlockLooper();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuRasterBackingStore::resize(const QSize &size, const QRegion &staticContents)
|
||||||
|
{
|
||||||
|
Q_UNUSED(staticContents);
|
||||||
|
|
||||||
|
if (m_bufferSize == size)
|
||||||
|
return;
|
||||||
|
|
||||||
|
delete m_bitmap;
|
||||||
|
m_bitmap = new BBitmap(BRect(0, 0, size.width(), size.height()), B_RGB32, false, true);
|
||||||
|
m_buffer = QHaikuBuffer(m_bitmap);
|
||||||
|
m_bufferSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
64
src/plugins/platforms/haiku/qhaikurasterbackingstore.h
Normal file
64
src/plugins/platforms/haiku/qhaikurasterbackingstore.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKURASTERWINDOWSURFACE_H
|
||||||
|
#define QHAIKURASTERWINDOWSURFACE_H
|
||||||
|
|
||||||
|
#include <qpa/qplatformbackingstore.h>
|
||||||
|
|
||||||
|
#include "qhaikubuffer.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class BBitmap;
|
||||||
|
class QHaikuRasterWindow;
|
||||||
|
|
||||||
|
class QHaikuRasterBackingStore : public QPlatformBackingStore
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit QHaikuRasterBackingStore(QWindow *window);
|
||||||
|
~QHaikuRasterBackingStore();
|
||||||
|
|
||||||
|
QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
|
||||||
|
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE;
|
||||||
|
void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BBitmap *m_bitmap;
|
||||||
|
QHaikuBuffer m_buffer;
|
||||||
|
QSize m_bufferSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
270
src/plugins/platforms/haiku/qhaikurasterwindow.cpp
Normal file
270
src/plugins/platforms/haiku/qhaikurasterwindow.cpp
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikurasterwindow.h"
|
||||||
|
|
||||||
|
#include "qhaikukeymapper.h"
|
||||||
|
|
||||||
|
#include <View.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include <qpa/qwindowsysteminterface.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QEvent::Type)
|
||||||
|
Q_DECLARE_METATYPE(Qt::MouseButtons)
|
||||||
|
Q_DECLARE_METATYPE(Qt::MouseEventSource)
|
||||||
|
Q_DECLARE_METATYPE(Qt::KeyboardModifiers)
|
||||||
|
Q_DECLARE_METATYPE(Qt::Orientation)
|
||||||
|
|
||||||
|
HaikuViewProxy::HaikuViewProxy(BWindow *window, QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, BView(BRect(0, 0, window->Bounds().right, window->Bounds().bottom), 0, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuViewProxy::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case B_MOUSE_WHEEL_CHANGED:
|
||||||
|
{
|
||||||
|
float deltaX = 0;
|
||||||
|
if (message->FindFloat("be:wheel_delta_x", &deltaX) != B_OK)
|
||||||
|
deltaX = 0;
|
||||||
|
|
||||||
|
float deltaY = 0;
|
||||||
|
if (message->FindFloat("be:wheel_delta_y", &deltaY) != B_OK)
|
||||||
|
deltaY = 0;
|
||||||
|
|
||||||
|
if (deltaX != 0 || deltaY != 0) {
|
||||||
|
BPoint localPos;
|
||||||
|
uint32 keyState = 0;
|
||||||
|
GetMouse(&localPos, &keyState);
|
||||||
|
const Qt::KeyboardModifiers keyboardModifiers = keyStateToModifiers(modifiers());
|
||||||
|
|
||||||
|
const BPoint globalPos = ConvertToScreen(localPos);
|
||||||
|
const QPoint globalPosition = QPoint(globalPos.x, globalPos.y);
|
||||||
|
const QPoint localPosition = QPoint(localPos.x, localPos.y);
|
||||||
|
|
||||||
|
if (deltaX != 0)
|
||||||
|
Q_EMIT wheelEvent(localPosition, globalPosition, (deltaX * -120), Qt::Horizontal, keyboardModifiers);
|
||||||
|
|
||||||
|
if (deltaY != 0)
|
||||||
|
Q_EMIT wheelEvent(localPosition, globalPosition, (deltaY * -120), Qt::Vertical, keyboardModifiers);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
BView::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuViewProxy::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
BView::Draw(updateRect);
|
||||||
|
|
||||||
|
Q_EMIT drawRequest(QRect(updateRect.left, updateRect.top, updateRect.Width(), updateRect.Height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuViewProxy::MouseDown(BPoint localPos)
|
||||||
|
{
|
||||||
|
BPoint dummyPos;
|
||||||
|
uint32 keyState = 0;
|
||||||
|
GetMouse(&dummyPos, &keyState);
|
||||||
|
|
||||||
|
const Qt::MouseButtons mouseButtons = keyStateToMouseButtons(keyState);
|
||||||
|
const Qt::KeyboardModifiers keyboardModifiers = keyStateToModifiers(modifiers());
|
||||||
|
const Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
|
||||||
|
|
||||||
|
const BPoint globalPos = ConvertToScreen(localPos);
|
||||||
|
const QPoint globalPosition = QPoint(globalPos.x, globalPos.y);
|
||||||
|
const QPoint localPosition = QPoint(localPos.x, localPos.y);
|
||||||
|
|
||||||
|
Q_EMIT mouseEvent(localPosition, globalPosition, mouseButtons, keyboardModifiers, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuViewProxy::MouseUp(BPoint localPos)
|
||||||
|
{
|
||||||
|
BPoint dummyPos;
|
||||||
|
uint32 keyState = 0;
|
||||||
|
GetMouse(&dummyPos, &keyState);
|
||||||
|
|
||||||
|
const Qt::MouseButtons mouseButtons = keyStateToMouseButtons(keyState);
|
||||||
|
const Qt::KeyboardModifiers keyboardModifiers = keyStateToModifiers(modifiers());
|
||||||
|
const Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
|
||||||
|
|
||||||
|
const BPoint globalPos = ConvertToScreen(localPos);
|
||||||
|
const QPoint globalPosition = QPoint(globalPos.x, globalPos.y);
|
||||||
|
const QPoint localPosition = QPoint(localPos.x, localPos.y);
|
||||||
|
|
||||||
|
Q_EMIT mouseEvent(localPosition, globalPosition, mouseButtons, keyboardModifiers, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuViewProxy::MouseMoved(BPoint pos, uint32 code, const BMessage *dragMessage)
|
||||||
|
{
|
||||||
|
switch (code) {
|
||||||
|
case B_INSIDE_VIEW:
|
||||||
|
{
|
||||||
|
BPoint dummyPos;
|
||||||
|
uint32 keyState = 0;
|
||||||
|
GetMouse(&dummyPos, &keyState);
|
||||||
|
|
||||||
|
const Qt::MouseButtons mouseButtons = keyStateToMouseButtons(keyState);
|
||||||
|
const Qt::KeyboardModifiers keyboardModifiers = keyStateToModifiers(modifiers());
|
||||||
|
const Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
|
||||||
|
|
||||||
|
const BPoint globalPos = ConvertToScreen(pos);
|
||||||
|
const QPoint globalPosition = QPoint(globalPos.x, globalPos.y);
|
||||||
|
const QPoint localPosition = QPoint(pos.x, pos.y);
|
||||||
|
|
||||||
|
Q_EMIT mouseEvent(localPosition, globalPosition, mouseButtons, keyboardModifiers, source);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case B_ENTERED_VIEW:
|
||||||
|
Q_EMIT enteredView();
|
||||||
|
break;
|
||||||
|
case B_EXITED_VIEW:
|
||||||
|
Q_EMIT exitedView();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BView::MouseMoved(pos, code, dragMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuViewProxy::KeyDown(const char*, int32)
|
||||||
|
{
|
||||||
|
handleKeyEvent(QEvent::KeyPress, Window()->CurrentMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuViewProxy::KeyUp(const char*, int32)
|
||||||
|
{
|
||||||
|
handleKeyEvent(QEvent::KeyRelease, Window()->CurrentMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::MouseButtons HaikuViewProxy::keyStateToMouseButtons(uint32 keyState) const
|
||||||
|
{
|
||||||
|
Qt::MouseButtons mouseButtons(Qt::NoButton);
|
||||||
|
if (keyState & B_PRIMARY_MOUSE_BUTTON)
|
||||||
|
mouseButtons |= Qt::LeftButton;
|
||||||
|
if (keyState & B_SECONDARY_MOUSE_BUTTON)
|
||||||
|
mouseButtons |= Qt::RightButton;
|
||||||
|
if (keyState & B_TERTIARY_MOUSE_BUTTON)
|
||||||
|
mouseButtons |= Qt::MiddleButton;
|
||||||
|
|
||||||
|
return mouseButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::KeyboardModifiers HaikuViewProxy::keyStateToModifiers(uint32 keyState) const
|
||||||
|
{
|
||||||
|
Qt::KeyboardModifiers modifiers(Qt::NoModifier);
|
||||||
|
|
||||||
|
if (keyState & B_SHIFT_KEY)
|
||||||
|
modifiers |= Qt::ShiftModifier;
|
||||||
|
if (keyState & B_CONTROL_KEY)
|
||||||
|
modifiers |= Qt::AltModifier;
|
||||||
|
if (keyState & B_COMMAND_KEY)
|
||||||
|
modifiers |= Qt::ControlModifier;
|
||||||
|
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuViewProxy::handleKeyEvent(QEvent::Type type, BMessage *message)
|
||||||
|
{
|
||||||
|
int32 key = 0;
|
||||||
|
uint32 code = 0;
|
||||||
|
const char *bytes = Q_NULLPTR;
|
||||||
|
QString text;
|
||||||
|
|
||||||
|
if (message) {
|
||||||
|
if (message->FindString("bytes", &bytes) == B_OK) {
|
||||||
|
text = QString::fromLocal8Bit(bytes, strlen(bytes));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message->FindInt32("key", &key) == B_OK) {
|
||||||
|
code = QHaikuKeyMapper::translateKeyCode(key, (modifiers() & B_NUM_LOCK));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Qt::KeyboardModifiers keyboardModifiers = keyStateToModifiers(modifiers());
|
||||||
|
|
||||||
|
Q_EMIT keyEvent(type, code, keyboardModifiers, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QHaikuRasterWindow::QHaikuRasterWindow(QWindow *window)
|
||||||
|
: QHaikuWindow(window)
|
||||||
|
{
|
||||||
|
qRegisterMetaType<QEvent::Type>();
|
||||||
|
qRegisterMetaType<Qt::MouseButtons>();
|
||||||
|
qRegisterMetaType<Qt::MouseEventSource>();
|
||||||
|
qRegisterMetaType<Qt::KeyboardModifiers>();
|
||||||
|
qRegisterMetaType<Qt::Orientation>();
|
||||||
|
|
||||||
|
HaikuViewProxy *haikuView = new HaikuViewProxy(m_window);
|
||||||
|
connect(haikuView, SIGNAL(mouseEvent(QPoint,QPoint,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::MouseEventSource)),
|
||||||
|
this, SLOT(haikuMouseEvent(QPoint,QPoint,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::MouseEventSource)));
|
||||||
|
connect(haikuView, SIGNAL(wheelEvent(QPoint,QPoint,int,Qt::Orientation,Qt::KeyboardModifiers)),
|
||||||
|
this, SLOT(haikuWheelEvent(QPoint,QPoint,int,Qt::Orientation,Qt::KeyboardModifiers)));
|
||||||
|
connect(haikuView, SIGNAL(keyEvent(QEvent::Type,int,Qt::KeyboardModifiers,QString)),
|
||||||
|
this, SLOT(haikuKeyEvent(QEvent::Type,int,Qt::KeyboardModifiers,QString)));
|
||||||
|
connect(haikuView, SIGNAL(enteredView()), this, SLOT(haikuEnteredView()));
|
||||||
|
connect(haikuView, SIGNAL(exitedView()), this, SLOT(haikuExitedView()));
|
||||||
|
connect(haikuView, SIGNAL(drawRequest(QRect)), this, SLOT(haikuDrawRequest(QRect)));
|
||||||
|
|
||||||
|
m_view = haikuView;
|
||||||
|
|
||||||
|
m_window->LockLooper();
|
||||||
|
m_window->AddChild(m_view);
|
||||||
|
m_view->MakeFocus();
|
||||||
|
m_window->UnlockLooper();
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuRasterWindow::~QHaikuRasterWindow()
|
||||||
|
{
|
||||||
|
m_window->LockLooper();
|
||||||
|
m_view->RemoveSelf();
|
||||||
|
m_window->UnlockLooper();
|
||||||
|
|
||||||
|
delete m_view;
|
||||||
|
m_view = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
BView* QHaikuRasterWindow::nativeViewHandle() const
|
||||||
|
{
|
||||||
|
return m_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
88
src/plugins/platforms/haiku/qhaikurasterwindow.h
Normal file
88
src/plugins/platforms/haiku/qhaikurasterwindow.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKURASTERWINDOW_H
|
||||||
|
#define QHAIKURASTERWINDOW_H
|
||||||
|
|
||||||
|
#include "qhaikuwindow.h"
|
||||||
|
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class HaikuViewProxy : public QObject, public BView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit HaikuViewProxy(BWindow *window, QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
void MessageReceived(BMessage *message) Q_DECL_OVERRIDE;
|
||||||
|
void Draw(BRect updateRect) Q_DECL_OVERRIDE;
|
||||||
|
void MouseDown(BPoint pos) Q_DECL_OVERRIDE;
|
||||||
|
void MouseUp(BPoint pos) Q_DECL_OVERRIDE;
|
||||||
|
void MouseMoved(BPoint pos, uint32 code, const BMessage *dragMessage) Q_DECL_OVERRIDE;
|
||||||
|
void KeyDown(const char *bytes, int32 numBytes) Q_DECL_OVERRIDE;
|
||||||
|
void KeyUp(const char *bytes, int32 numBytes) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void mouseEvent(const QPoint &localPosition, const QPoint &globalPosition, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
|
||||||
|
void wheelEvent(const QPoint &localPosition, const QPoint &globalPosition, int delta, Qt::Orientation orientation, Qt::KeyboardModifiers modifiers);
|
||||||
|
void keyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text);
|
||||||
|
void enteredView();
|
||||||
|
void exitedView();
|
||||||
|
void drawRequest(const QRect &rect);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Qt::MouseButtons keyStateToMouseButtons(uint32 keyState) const;
|
||||||
|
Qt::KeyboardModifiers keyStateToModifiers(uint32 keyState) const;
|
||||||
|
void handleKeyEvent(QEvent::Type type, BMessage *message);
|
||||||
|
};
|
||||||
|
|
||||||
|
class QHaikuRasterWindow : public QHaikuWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit QHaikuRasterWindow(QWindow *window);
|
||||||
|
~QHaikuRasterWindow();
|
||||||
|
|
||||||
|
BView* nativeViewHandle() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
HaikuViewProxy *m_view;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
137
src/plugins/platforms/haiku/qhaikuscreen.cpp
Normal file
137
src/plugins/platforms/haiku/qhaikuscreen.cpp
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikuscreen.h"
|
||||||
|
|
||||||
|
#include "qhaikucursor.h"
|
||||||
|
#include "qhaikuutils.h"
|
||||||
|
|
||||||
|
#include <qpa/qwindowsysteminterface.h>
|
||||||
|
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
QHaikuScreen::QHaikuScreen()
|
||||||
|
: m_screen(new BScreen(B_MAIN_SCREEN_ID))
|
||||||
|
, m_cursor(new QHaikuCursor)
|
||||||
|
{
|
||||||
|
Q_ASSERT(m_screen->IsValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuScreen::~QHaikuScreen()
|
||||||
|
{
|
||||||
|
delete m_cursor;
|
||||||
|
m_cursor = Q_NULLPTR;
|
||||||
|
|
||||||
|
delete m_screen;
|
||||||
|
m_screen = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap QHaikuScreen::grabWindow(WId winId, int x, int y, int width, int height) const
|
||||||
|
{
|
||||||
|
if (width == 0 || height == 0)
|
||||||
|
return QPixmap();
|
||||||
|
|
||||||
|
BScreen screen(Q_NULLPTR);
|
||||||
|
BBitmap *bitmap = Q_NULLPTR;
|
||||||
|
screen.GetBitmap(&bitmap);
|
||||||
|
|
||||||
|
const BRect frame = (winId ? ((BWindow*)winId)->Frame() : screen.Frame());
|
||||||
|
|
||||||
|
const int absoluteX = frame.left + x;
|
||||||
|
const int absoluteY = frame.top + y;
|
||||||
|
|
||||||
|
if (width < 0)
|
||||||
|
width = frame.Width() - x;
|
||||||
|
if (height < 0)
|
||||||
|
height = frame.Height() - y;
|
||||||
|
|
||||||
|
const QImage::Format format = QHaikuUtils::colorSpaceToImageFormat(bitmap->ColorSpace());
|
||||||
|
|
||||||
|
// get image of complete screen
|
||||||
|
QImage image((uchar*)bitmap->Bits(), screen.Frame().Width() + 1, screen.Frame().Height() + 1, bitmap->BytesPerRow(), format);
|
||||||
|
|
||||||
|
// extract the area of the requested window
|
||||||
|
QRect grabRect(absoluteX, absoluteY, width, height);
|
||||||
|
image = image.copy(grabRect);
|
||||||
|
|
||||||
|
delete bitmap;
|
||||||
|
|
||||||
|
return QPixmap::fromImage(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect QHaikuScreen::geometry() const
|
||||||
|
{
|
||||||
|
const BRect frame = m_screen->Frame();
|
||||||
|
return QRect(frame.left, frame.top, frame.right - frame.left, frame.bottom - frame.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
int QHaikuScreen::depth() const
|
||||||
|
{
|
||||||
|
switch (format()) {
|
||||||
|
case QImage::Format_Invalid:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case QImage::Format_MonoLSB:
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case QImage::Format_Indexed8:
|
||||||
|
return 8;
|
||||||
|
break;
|
||||||
|
case QImage::Format_RGB16:
|
||||||
|
case QImage::Format_RGB555:
|
||||||
|
return 16;
|
||||||
|
break;
|
||||||
|
case QImage::Format_RGB888:
|
||||||
|
return 24;
|
||||||
|
break;
|
||||||
|
case QImage::Format_RGB32:
|
||||||
|
case QImage::Format_ARGB32:
|
||||||
|
default:
|
||||||
|
return 32;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage::Format QHaikuScreen::format() const
|
||||||
|
{
|
||||||
|
return QHaikuUtils::colorSpaceToImageFormat(m_screen->ColorSpace());
|
||||||
|
}
|
||||||
|
|
||||||
|
QPlatformCursor *QHaikuScreen::cursor() const
|
||||||
|
{
|
||||||
|
return m_cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
66
src/plugins/platforms/haiku/qhaikuscreen.h
Normal file
66
src/plugins/platforms/haiku/qhaikuscreen.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUSCREEN_H
|
||||||
|
#define QHAIKUSCREEN_H
|
||||||
|
|
||||||
|
#include <qpa/qplatformscreen.h>
|
||||||
|
|
||||||
|
class BScreen;
|
||||||
|
class QHaikuCursor;
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QHaikuScreen : public QPlatformScreen
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QHaikuScreen();
|
||||||
|
~QHaikuScreen();
|
||||||
|
|
||||||
|
QPixmap grabWindow(WId window, int x, int y, int width, int height) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
QRect geometry() const Q_DECL_OVERRIDE;
|
||||||
|
int depth() const Q_DECL_OVERRIDE;
|
||||||
|
QImage::Format format() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BScreen *m_screen;
|
||||||
|
|
||||||
|
QHaikuCursor *m_cursor;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
82
src/plugins/platforms/haiku/qhaikuservices.cpp
Normal file
82
src/plugins/platforms/haiku/qhaikuservices.cpp
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikuservices.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QMimeDatabase>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include <Roster.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
bool QHaikuServices::openUrl(const QUrl &url)
|
||||||
|
{
|
||||||
|
const QMimeDatabase mimeDatabase;
|
||||||
|
|
||||||
|
const QMimeType mimeType = mimeDatabase.mimeTypeForUrl(url);
|
||||||
|
if (!mimeType.isValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const QByteArray mimeTypeName = mimeType.name().toLatin1();
|
||||||
|
QByteArray urlData = url.toString().toLocal8Bit();
|
||||||
|
char *rawUrlData = urlData.data();
|
||||||
|
|
||||||
|
if (be_roster->Launch(mimeTypeName.constData(), 1, &rawUrlData) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHaikuServices::openDocument(const QUrl &url)
|
||||||
|
{
|
||||||
|
const QByteArray localPath = QFile::encodeName(url.toLocalFile());
|
||||||
|
|
||||||
|
entry_ref ref;
|
||||||
|
if (get_ref_for_path(localPath.constData(), &ref) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (be_roster->Launch(&ref) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray QHaikuServices::desktopEnvironment() const
|
||||||
|
{
|
||||||
|
return QByteArray("Haiku");
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
52
src/plugins/platforms/haiku/qhaikuservices.h
Normal file
52
src/plugins/platforms/haiku/qhaikuservices.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUSERVICES_H
|
||||||
|
#define QHAIKUSERVICES_H
|
||||||
|
|
||||||
|
#include <qpa/qplatformservices.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QHaikuServices : public QPlatformServices
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool openUrl(const QUrl &url) Q_DECL_OVERRIDE;
|
||||||
|
bool openDocument(const QUrl &url) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
QByteArray desktopEnvironment() const Q_DECL_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
110
src/plugins/platforms/haiku/qhaikuutils.cpp
Normal file
110
src/plugins/platforms/haiku/qhaikuutils.cpp
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikuutils.h"
|
||||||
|
|
||||||
|
color_space QHaikuUtils::imageFormatToColorSpace(QImage::Format format)
|
||||||
|
{
|
||||||
|
color_space colorSpace = B_NO_COLOR_SPACE;
|
||||||
|
switch (format) {
|
||||||
|
case QImage::Format_Invalid:
|
||||||
|
colorSpace = B_NO_COLOR_SPACE;
|
||||||
|
break;
|
||||||
|
case QImage::Format_MonoLSB:
|
||||||
|
colorSpace = B_GRAY1;
|
||||||
|
break;
|
||||||
|
case QImage::Format_Indexed8:
|
||||||
|
colorSpace = B_CMAP8;
|
||||||
|
break;
|
||||||
|
case QImage::Format_RGB32:
|
||||||
|
colorSpace = B_RGB32;
|
||||||
|
break;
|
||||||
|
case QImage::Format_ARGB32:
|
||||||
|
colorSpace = B_RGBA32;
|
||||||
|
break;
|
||||||
|
case QImage::Format_RGB16:
|
||||||
|
colorSpace = B_RGB16;
|
||||||
|
break;
|
||||||
|
case QImage::Format_RGB555:
|
||||||
|
colorSpace = B_RGB15;
|
||||||
|
break;
|
||||||
|
case QImage::Format_RGB888:
|
||||||
|
colorSpace = B_RGB24;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qWarning("Cannot convert image format %d to color space", format);
|
||||||
|
Q_ASSERT(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return colorSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage::Format QHaikuUtils::colorSpaceToImageFormat(color_space colorSpace)
|
||||||
|
{
|
||||||
|
QImage::Format format = QImage::Format_Invalid;
|
||||||
|
switch (colorSpace) {
|
||||||
|
case B_NO_COLOR_SPACE:
|
||||||
|
format = QImage::Format_Invalid;
|
||||||
|
break;
|
||||||
|
case B_GRAY1:
|
||||||
|
format = QImage::Format_MonoLSB;
|
||||||
|
break;
|
||||||
|
case B_CMAP8:
|
||||||
|
format = QImage::Format_Indexed8;
|
||||||
|
break;
|
||||||
|
case B_RGB32:
|
||||||
|
format = QImage::Format_RGB32;
|
||||||
|
break;
|
||||||
|
case B_RGBA32:
|
||||||
|
format = QImage::Format_ARGB32;
|
||||||
|
break;
|
||||||
|
case B_RGB16:
|
||||||
|
format = QImage::Format_RGB16;
|
||||||
|
break;
|
||||||
|
case B_RGB15:
|
||||||
|
format = QImage::Format_RGB555;
|
||||||
|
break;
|
||||||
|
case B_RGB24:
|
||||||
|
format = QImage::Format_RGB888;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qWarning("Cannot convert color space %d to image format", colorSpace);
|
||||||
|
Q_ASSERT(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
51
src/plugins/platforms/haiku/qhaikuutils.h
Normal file
51
src/plugins/platforms/haiku/qhaikuutils.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUUTILS_H
|
||||||
|
#define QHAIKUUTILS_H
|
||||||
|
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace QHaikuUtils
|
||||||
|
{
|
||||||
|
color_space imageFormatToColorSpace(QImage::Format format);
|
||||||
|
QImage::Format colorSpaceToImageFormat(color_space colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
388
src/plugins/platforms/haiku/qhaikuwindow.cpp
Normal file
388
src/plugins/platforms/haiku/qhaikuwindow.cpp
Normal file
@ -0,0 +1,388 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qhaikuwindow.h"
|
||||||
|
|
||||||
|
#include "private/qguiapplication_p.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QWindow>
|
||||||
|
#include <qpa/qwindowsysteminterface.h>
|
||||||
|
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
enum {
|
||||||
|
DefaultWindowWidth = 160,
|
||||||
|
DefaultWindowHeight = 160
|
||||||
|
};
|
||||||
|
|
||||||
|
HaikuWindowProxy::HaikuWindowProxy(QWindow *window, const QRect &rect, QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, BWindow(BRect(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1),
|
||||||
|
window->title().toUtf8(), B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 0)
|
||||||
|
, m_qtCalledZoom(false)
|
||||||
|
, m_zoomInProgress(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuWindowProxy::FrameMoved(BPoint pos)
|
||||||
|
{
|
||||||
|
Q_EMIT moved(QPoint(pos.x, pos.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuWindowProxy::FrameResized(float width, float height)
|
||||||
|
{
|
||||||
|
Q_EMIT resized(QSize(static_cast<int>(width), static_cast<int>(height)), m_zoomInProgress);
|
||||||
|
|
||||||
|
m_zoomInProgress = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuWindowProxy::WindowActivated(bool activated)
|
||||||
|
{
|
||||||
|
Q_EMIT windowActivated(activated);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuWindowProxy::Minimize(bool minimize)
|
||||||
|
{
|
||||||
|
BWindow::Minimize(minimize);
|
||||||
|
|
||||||
|
Q_EMIT minimized(minimize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuWindowProxy::Zoom(BPoint pos, float width, float height)
|
||||||
|
{
|
||||||
|
m_zoomInProgress = true;
|
||||||
|
BWindow::Zoom(pos, width, height);
|
||||||
|
|
||||||
|
// Only notify about Zoom invocations from the Haiku windowing system
|
||||||
|
if (!m_qtCalledZoom)
|
||||||
|
Q_EMIT zoomed();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HaikuWindowProxy::QuitRequested()
|
||||||
|
{
|
||||||
|
Q_EMIT quitRequested();
|
||||||
|
|
||||||
|
// Return false to prevent Haiku windowing system to clean up
|
||||||
|
// the BWindow and BView instances. We will do that ourself when
|
||||||
|
// Qt invokes the dtor of QHaikuWindow
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HaikuWindowProxy::zoomByQt()
|
||||||
|
{
|
||||||
|
m_qtCalledZoom = true;
|
||||||
|
BWindow::Zoom();
|
||||||
|
m_qtCalledZoom = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuWindow::QHaikuWindow(QWindow *window)
|
||||||
|
: QPlatformWindow(window)
|
||||||
|
, m_window(Q_NULLPTR)
|
||||||
|
, m_windowState(Qt::WindowNoState)
|
||||||
|
{
|
||||||
|
const QRect rect = initialGeometry(window, window->geometry(), DefaultWindowWidth, DefaultWindowHeight);
|
||||||
|
|
||||||
|
HaikuWindowProxy *haikuWindow = new HaikuWindowProxy(window, rect, Q_NULLPTR);
|
||||||
|
connect(haikuWindow, SIGNAL(moved(QPoint)), SLOT(haikuWindowMoved(QPoint)));
|
||||||
|
connect(haikuWindow, SIGNAL(resized(QSize,bool)), SLOT(haikuWindowResized(QSize,bool)));
|
||||||
|
connect(haikuWindow, SIGNAL(windowActivated(bool)), SLOT(haikuWindowActivated(bool)));
|
||||||
|
connect(haikuWindow, SIGNAL(minimized(bool)), SLOT(haikuWindowMinimized(bool)));
|
||||||
|
connect(haikuWindow, SIGNAL(zoomed()), SLOT(haikuWindowZoomed()));
|
||||||
|
connect(haikuWindow, SIGNAL(quitRequested()), SLOT(haikuWindowQuitRequested()), Qt::BlockingQueuedConnection);
|
||||||
|
|
||||||
|
m_window = haikuWindow;
|
||||||
|
|
||||||
|
if (!m_window)
|
||||||
|
qFatal("QHaikuWindow: failed to create window");
|
||||||
|
|
||||||
|
setWindowFlags(window->flags());
|
||||||
|
}
|
||||||
|
|
||||||
|
QHaikuWindow::~QHaikuWindow()
|
||||||
|
{
|
||||||
|
m_window->LockLooper();
|
||||||
|
m_window->Quit();
|
||||||
|
|
||||||
|
m_window = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::setGeometry(const QRect &rect)
|
||||||
|
{
|
||||||
|
QPlatformWindow::setGeometry(rect);
|
||||||
|
|
||||||
|
m_window->MoveTo(rect.x(), rect.y());
|
||||||
|
m_window->ResizeTo(rect.width(), rect.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
QMargins QHaikuWindow::frameMargins() const
|
||||||
|
{
|
||||||
|
const BRect decoratorFrame = m_window->DecoratorFrame();
|
||||||
|
const BRect frame = m_window->Frame();
|
||||||
|
|
||||||
|
return QMargins(frame.left - decoratorFrame.left,
|
||||||
|
frame.top - decoratorFrame.top,
|
||||||
|
decoratorFrame.right - frame.right,
|
||||||
|
decoratorFrame.bottom - frame.bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::setVisible(bool visible)
|
||||||
|
{
|
||||||
|
if (visible) {
|
||||||
|
m_window->Show();
|
||||||
|
} else {
|
||||||
|
m_window->Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
window()->requestActivate();
|
||||||
|
|
||||||
|
QWindowSystemInterface::handleExposeEvent(window(), window()->geometry());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHaikuWindow::isExposed() const
|
||||||
|
{
|
||||||
|
return !m_window->IsHidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHaikuWindow::isActive() const
|
||||||
|
{
|
||||||
|
return m_window->IsActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
WId QHaikuWindow::winId() const
|
||||||
|
{
|
||||||
|
return (WId)static_cast<BWindow*>(m_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
BWindow* QHaikuWindow::nativeHandle() const
|
||||||
|
{
|
||||||
|
return m_window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::requestActivateWindow()
|
||||||
|
{
|
||||||
|
m_window->Activate(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::setWindowState(Qt::WindowState state)
|
||||||
|
{
|
||||||
|
if (m_windowState == state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const Qt::WindowState oldState = m_windowState;
|
||||||
|
|
||||||
|
m_windowState = state;
|
||||||
|
|
||||||
|
if (m_windowState == Qt::WindowMaximized) {
|
||||||
|
m_window->zoomByQt();
|
||||||
|
} else if (m_windowState == Qt::WindowMinimized) {
|
||||||
|
m_window->Minimize(true);
|
||||||
|
} else if (m_windowState == Qt::WindowNoState) {
|
||||||
|
if (oldState == Qt::WindowMaximized)
|
||||||
|
m_window->zoomByQt(); // undo zoom
|
||||||
|
|
||||||
|
if (oldState == Qt::WindowMinimized)
|
||||||
|
m_window->Minimize(false); // undo minimize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::setWindowFlags(Qt::WindowFlags flags)
|
||||||
|
{
|
||||||
|
const Qt::WindowType type = static_cast<Qt::WindowType>(static_cast<int>(flags & Qt::WindowType_Mask));
|
||||||
|
|
||||||
|
const bool isPopup = (type == Qt::Popup);
|
||||||
|
const bool isSplashScreen = (type == Qt::SplashScreen);
|
||||||
|
const bool isDialog = ((type == Qt::Dialog) || (type == Qt::Sheet) || (type == Qt::MSWindowsFixedSizeDialogHint));
|
||||||
|
const bool isTool = ((type == Qt::Tool) || (type == Qt::Drawer));
|
||||||
|
const bool isToolTip = (type == Qt::ToolTip);
|
||||||
|
|
||||||
|
window_look wlook = B_TITLED_WINDOW_LOOK;
|
||||||
|
window_feel wfeel = B_NORMAL_WINDOW_FEEL;
|
||||||
|
uint32 wflag = (B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE);
|
||||||
|
|
||||||
|
if (isTool) {
|
||||||
|
wlook = B_FLOATING_WINDOW_LOOK;
|
||||||
|
wflag |= B_WILL_ACCEPT_FIRST_CLICK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSplashScreen) {
|
||||||
|
wlook = B_NO_BORDER_WINDOW_LOOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPopup) {
|
||||||
|
wlook = B_NO_BORDER_WINDOW_LOOK;
|
||||||
|
wflag |= (B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FRONT | B_AVOID_FOCUS);
|
||||||
|
flags |= Qt::WindowStaysOnTopHint;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDialog) {
|
||||||
|
if (window()->modality() == Qt::WindowModal)
|
||||||
|
wfeel = B_MODAL_SUBSET_WINDOW_FEEL;
|
||||||
|
else if (window()->modality() == Qt::ApplicationModal)
|
||||||
|
wfeel = B_MODAL_APP_WINDOW_FEEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isToolTip) {
|
||||||
|
wlook = B_NO_BORDER_WINDOW_LOOK;
|
||||||
|
wflag |= (B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FOCUS);
|
||||||
|
flags |= Qt::WindowStaysOnTopHint;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & Qt::FramelessWindowHint)
|
||||||
|
wlook = B_NO_BORDER_WINDOW_LOOK;
|
||||||
|
|
||||||
|
if (flags & Qt::MSWindowsFixedSizeDialogHint)
|
||||||
|
wflag |= (B_NOT_RESIZABLE | B_NOT_ZOOMABLE);
|
||||||
|
|
||||||
|
if (flags & Qt::CustomizeWindowHint) {
|
||||||
|
if (!(flags & Qt::WindowMinimizeButtonHint))
|
||||||
|
wflag |= B_NOT_MINIMIZABLE;
|
||||||
|
if (!(flags & Qt::WindowMaximizeButtonHint))
|
||||||
|
wflag |= B_NOT_ZOOMABLE;
|
||||||
|
if (!(flags & Qt::WindowCloseButtonHint))
|
||||||
|
wflag |= B_NOT_CLOSABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & Qt::WindowStaysOnTopHint)
|
||||||
|
wfeel = B_FLOATING_ALL_WINDOW_FEEL;
|
||||||
|
|
||||||
|
m_window->SetLook(wlook);
|
||||||
|
m_window->SetFeel(wfeel);
|
||||||
|
m_window->SetFlags(wflag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::setWindowTitle(const QString &title)
|
||||||
|
{
|
||||||
|
m_window->SetTitle(title.toLocal8Bit().constData());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::propagateSizeHints()
|
||||||
|
{
|
||||||
|
m_window->SetSizeLimits(window()->minimumSize().width(),
|
||||||
|
window()->maximumSize().width(),
|
||||||
|
window()->minimumSize().height(),
|
||||||
|
window()->maximumSize().height());
|
||||||
|
|
||||||
|
m_window->SetZoomLimits(window()->maximumSize().width(),
|
||||||
|
window()->maximumSize().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuWindowMoved(const QPoint &pos)
|
||||||
|
{
|
||||||
|
const QRect newGeometry(pos, geometry().size());
|
||||||
|
|
||||||
|
QPlatformWindow::setGeometry(newGeometry);
|
||||||
|
QWindowSystemInterface::setSynchronousWindowsSystemEvents(true);
|
||||||
|
QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
|
||||||
|
QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
|
||||||
|
QWindowSystemInterface::setSynchronousWindowsSystemEvents(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuWindowResized(const QSize &size, bool zoomInProgress)
|
||||||
|
{
|
||||||
|
const QRect newGeometry(geometry().topLeft(), size);
|
||||||
|
|
||||||
|
QPlatformWindow::setGeometry(newGeometry);
|
||||||
|
QWindowSystemInterface::setSynchronousWindowsSystemEvents(true);
|
||||||
|
QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
|
||||||
|
QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
|
||||||
|
QWindowSystemInterface::setSynchronousWindowsSystemEvents(false);
|
||||||
|
|
||||||
|
if ((m_windowState == Qt::WindowMaximized) && !zoomInProgress) {
|
||||||
|
// the user has resized the window while maximized -> reset maximized flag
|
||||||
|
m_windowState = Qt::WindowNoState;
|
||||||
|
|
||||||
|
QWindowSystemInterface::handleWindowStateChanged(window(), m_windowState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuWindowActivated(bool activated)
|
||||||
|
{
|
||||||
|
QWindowSystemInterface::handleWindowActivated(activated ? window() : Q_NULLPTR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuWindowMinimized(bool minimize)
|
||||||
|
{
|
||||||
|
m_windowState = (minimize ? Qt::WindowMinimized : Qt::WindowNoState);
|
||||||
|
|
||||||
|
QWindowSystemInterface::handleWindowStateChanged(window(), m_windowState);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuWindowZoomed()
|
||||||
|
{
|
||||||
|
m_windowState = (m_windowState == Qt::WindowMaximized ? Qt::WindowNoState : Qt::WindowMaximized);
|
||||||
|
|
||||||
|
QWindowSystemInterface::handleWindowStateChanged(window(), m_windowState);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuWindowQuitRequested()
|
||||||
|
{
|
||||||
|
QWindowSystemInterface::handleCloseEvent(window());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuMouseEvent(const QPoint &localPosition, const QPoint &globalPosition, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
|
||||||
|
{
|
||||||
|
QWindowSystemInterface::handleMouseEvent(window(), localPosition, globalPosition,
|
||||||
|
buttons, modifiers, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuWheelEvent(const QPoint &localPosition, const QPoint &globalPosition, int delta, Qt::Orientation orientation, Qt::KeyboardModifiers modifiers)
|
||||||
|
{
|
||||||
|
QWindowSystemInterface::handleWheelEvent(window(), localPosition, globalPosition, delta, orientation, modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text)
|
||||||
|
{
|
||||||
|
QWindowSystemInterface::handleKeyEvent(window(), type, key, modifiers, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuEnteredView()
|
||||||
|
{
|
||||||
|
QWindowSystemInterface::handleEnterEvent(window());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuExitedView()
|
||||||
|
{
|
||||||
|
QWindowSystemInterface::handleLeaveEvent(window());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHaikuWindow::haikuDrawRequest(const QRect &rect)
|
||||||
|
{
|
||||||
|
QWindowSystemInterface::handleExposeEvent(window(), QRegion(rect));
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
122
src/plugins/platforms/haiku/qhaikuwindow.h
Normal file
122
src/plugins/platforms/haiku/qhaikuwindow.h
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QHAIKUWINDOW_H
|
||||||
|
#define QHAIKUWINDOW_H
|
||||||
|
|
||||||
|
#include <qpa/qplatformwindow.h>
|
||||||
|
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class HaikuWindowProxy : public QObject, public BWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit HaikuWindowProxy(QWindow *window, const QRect &rect, QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
void FrameMoved(BPoint pos) Q_DECL_OVERRIDE;
|
||||||
|
void FrameResized(float width, float height) Q_DECL_OVERRIDE;
|
||||||
|
void WindowActivated(bool activated) Q_DECL_OVERRIDE;
|
||||||
|
void Minimize(bool minimize) Q_DECL_OVERRIDE;
|
||||||
|
void Zoom(BPoint pos, float width, float height) Q_DECL_OVERRIDE;
|
||||||
|
bool QuitRequested() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void zoomByQt();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void moved(const QPoint &pos);
|
||||||
|
void resized(const QSize &size, bool zoomInProgress);
|
||||||
|
void windowActivated(bool activated);
|
||||||
|
void minimized(bool minimize);
|
||||||
|
void zoomed();
|
||||||
|
void quitRequested();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_qtCalledZoom;
|
||||||
|
bool m_zoomInProgress;
|
||||||
|
};
|
||||||
|
|
||||||
|
class QHaikuWindow : public QObject, public QPlatformWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit QHaikuWindow(QWindow *window);
|
||||||
|
virtual ~QHaikuWindow();
|
||||||
|
|
||||||
|
void setGeometry(const QRect &rect) Q_DECL_OVERRIDE;
|
||||||
|
QMargins frameMargins() const Q_DECL_OVERRIDE;
|
||||||
|
void setVisible(bool visible) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
bool isExposed() const Q_DECL_OVERRIDE;
|
||||||
|
bool isActive() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
WId winId() const Q_DECL_OVERRIDE;
|
||||||
|
BWindow* nativeHandle() const;
|
||||||
|
|
||||||
|
void requestActivateWindow() Q_DECL_OVERRIDE;
|
||||||
|
void setWindowState(Qt::WindowState state) Q_DECL_OVERRIDE;
|
||||||
|
void setWindowFlags(Qt::WindowFlags flags) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void setWindowTitle(const QString &title) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void propagateSizeHints() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
HaikuWindowProxy *m_window;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void haikuWindowMoved(const QPoint &pos);
|
||||||
|
void haikuWindowResized(const QSize &size, bool zoomInProgress);
|
||||||
|
void haikuWindowActivated(bool activated);
|
||||||
|
void haikuWindowMinimized(bool minimize);
|
||||||
|
void haikuWindowZoomed();
|
||||||
|
void haikuWindowQuitRequested();
|
||||||
|
|
||||||
|
void haikuMouseEvent(const QPoint &localPosition, const QPoint &globalPosition, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
|
||||||
|
void haikuWheelEvent(const QPoint &localPosition, const QPoint &globalPosition, int delta, Qt::Orientation orientation, Qt::KeyboardModifiers modifiers);
|
||||||
|
void haikuKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text);
|
||||||
|
void haikuEnteredView();
|
||||||
|
void haikuExitedView();
|
||||||
|
void haikuDrawRequest(const QRect &rect);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Qt::WindowState m_windowState;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
@ -36,3 +36,7 @@ contains(QT_CONFIG, directfb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contains(QT_CONFIG, linuxfb): SUBDIRS += linuxfb
|
contains(QT_CONFIG, linuxfb): SUBDIRS += linuxfb
|
||||||
|
|
||||||
|
haiku {
|
||||||
|
SUBDIRS += haiku
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user