platforms related plugins are no longer relevant

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-07-12 21:39:09 +00:00
parent 221925eeb2
commit efbb0e7e82
202 changed files with 4 additions and 30017 deletions

View file

@ -405,14 +405,6 @@ set_package_properties(OpenGL PROPERTIES
TYPE RECOMMENDED TYPE RECOMMENDED
) )
find_package(Wayland)
set_package_properties(Wayland PROPERTIES
PURPOSE "Required for Wayland support"
DESCRIPTION "Wayland is intended as a simpler replacement for X"
URL "http://wayland.freedesktop.org/"
TYPE OPTIONAL
)
find_package(ODBC) find_package(ODBC)
set_package_properties(ODBC PROPERTIES set_package_properties(ODBC PROPERTIES
PURPOSE "Required for ODBC database support" PURPOSE "Required for ODBC database support"

1
TODO
View file

@ -1,4 +1,3 @@
finish plugins porting to cmake
use system harfbuzz and clucene (optionally) and unbundle use system harfbuzz and clucene (optionally) and unbundle
QT_MOC_CPP seems unused but checked for in two headers QT_MOC_CPP seems unused but checked for in two headers
QCache must implement begin() and end() for qDeleteAll() QCache must implement begin() and end() for qDeleteAll()

View file

@ -1,54 +0,0 @@
# - Try to find the Wayland directory library
# Once done this will define
#
# WAYLAND_FOUND - system has Wayland libraries
# WAYLAND_SERVER_FOUND - system has Wayland server libraries
# WAYLAND_CLIENT_FOUND - system has Wayland client libraries
# WAYLAND_SERVER_INCLUDE_DIR - Wayland Server include directory
# WAYLAND_SERVER_LIBRARIES - The libraries needed for Wayland Server
# WAYLAND_CLIENT_INCLUDE_DIR - Wayland Client include directory
# WAYLAND_CLIENT_LIBRARIES - The libraries needed for Wayland Clients
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_WAYLAND_SERVER_PC QUIET wayland-server)
pkg_check_modules(_WAYLAND_CLIENT_PC QUIET wayland-client)
endif (PKG_CONFIG_FOUND)
# Wayland server
FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR wayland-server.h
${_WAYLAND_SERVER_PC_INCLUDE_DIRS}
)
FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server
PATHS
${_WAYLAND_SERVER_PC_LIBDIR}
)
if (WAYLAND_SERVER_INCLUDE_DIR AND WAYLAND_SERVER_LIBRARIES)
set(WAYLAND_SERVER_FOUND TRUE)
endif (WAYLAND_SERVER_INCLUDE_DIR AND WAYLAND_SERVER_LIBRARIES)
# Wayland Client
FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR wayland-client.h
${_WAYLAND_CLIENT_PC_INCLUDE_DIRS}
)
FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client
PATHS
${_WAYLAND_CLIENT_PC_LIBDIR}
)
if (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARIES)
set(WAYLAND_CLIENT_FOUND TRUE)
endif (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARIES)
if (WAYLAND_SERVER_FOUND AND WAYLAND_CLIENT_FOUND)
set(WAYLAND_FOUND TRUE)
endif (WAYLAND_SERVER_FOUND AND WAYLAND_CLIENT_FOUND)
MARK_AS_ADVANCED(WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES)

View file

@ -10,15 +10,15 @@ X-Python-Version: >= 2.7
Build-Depends: debhelper (>= 9~), g++, python-dev (>= 2.7~), libssl-dev, Build-Depends: debhelper (>= 9~), g++, python-dev (>= 2.7~), libssl-dev,
zlib1g-dev, libc6-dev, libpng12-dev, libjpeg62-turbo-dev, libtiff5-dev, zlib1g-dev, libc6-dev, libpng12-dev, libjpeg62-turbo-dev, libtiff5-dev,
libmng-dev, libcups2-dev, libasound2-dev, libfreetype6-dev, libmng-dev, libcups2-dev, libasound2-dev, libfreetype6-dev,
libfontconfig1-dev, libicu-dev, libglib2.0-dev, libdbus-1-dev, libfontconfig1-dev, libicu-dev, libglib2.0-dev, libdbus-1-dev, libgtk2.0-dev,
libgtk2.0-dev, libgl1-mesa-dev, libwayland-dev, unixodbc-dev, libpq-dev, libgl1-mesa-dev, unixodbc-dev, libpq-dev, libmysqld-dev, libsqlite3-dev,
libmysqld-dev, libsqlite3-dev, xorg-dev, cmake, git xorg-dev, cmake, git
Package: katie-git Package: katie-git
Architecture: i386 amd64 Architecture: i386 amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, openssl, zlib1g, libc6, libpng12, Depends: ${shlibs:Depends}, ${misc:Depends}, openssl, zlib1g, libc6, libpng12,
libjpeg62-turbo, libtiffxx5, libmng1, libcups2, libasound2, nas, libfreetype6, libjpeg62-turbo, libtiffxx5, libmng1, libcups2, libasound2, nas, libfreetype6,
libfontconfig1, libicu52, libglib2.0, libdbus-1, libgtk2.0, libgl1-mesa-glx, libfontconfig1, libicu52, libglib2.0, libdbus-1, libgtk2.0, libgl1-mesa-glx,
libwayland-client0, libwayland-server0, libsqlite3 libsqlite3
Recommends: unixodbc, libpq5, libmysqlclient18, xorg Recommends: unixodbc, libpq5, libmysqlclient18, xorg
Description: C++ toolkit derived from the Qt 4.8 framework Description: C++ toolkit derived from the Qt 4.8 framework

View file

@ -32,7 +32,6 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/iconengines ${CMAKE_CURRENT_SOURCE_DIR}/iconengines
${CMAKE_CURRENT_SOURCE_DIR}/inputmethods ${CMAKE_CURRENT_SOURCE_DIR}/inputmethods
${CMAKE_CURRENT_SOURCE_DIR}/accessible ${CMAKE_CURRENT_SOURCE_DIR}/accessible
${CMAKE_CURRENT_SOURCE_DIR}/platforms
${CMAKE_CURRENT_SOURCE_DIR}/qmltooling ${CMAKE_CURRENT_SOURCE_DIR}/qmltooling
${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src
) )
@ -113,17 +112,6 @@ if(NOT ${KATIE_PLATFORM} STREQUAL "mac")
endif() endif()
if(WITH_WALAND AND WAYLAND_FOUND)
include(platforms/wayland/wayland.cmake)
endif()
if(${KATIE_PLATFORM} STREQUAL "qnx")
include(platforms/blackberry/blackberry.cmake)
endif()
#if(WITH_X11 AND X11_FOUND)
# include(platforms/xlib/xlib.cmake)
#endif()
if(WITH_DBUS AND DBUS_FOUND) if(WITH_DBUS AND DBUS_FOUND)
include(script/qtdbus/qtdbus.cmake) include(script/qtdbus/qtdbus.cmake)
endif() endif()

View file

@ -1,86 +0,0 @@
set(BLACKBERRYPLUGIN_DEFINITIONS
${BLACKBERRYPLUGIN_DEFINITIONS}
# Unomment this to enable screen event handling through a dedicated thread.
# -DQQNX_SCREENEVENTTHREAD
-DQBB_SCREENEVENTTHREAD
)
set(BLACKBERRYPLUGIN_INCLUDES
${BLACKBERRYPLUGIN_INCLUDES}
${EGL_INCLUDES}
)
set(BLACKBERRYPLUGIN_HEADERS
${QTRACEPLUGIN_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbbuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbscreeneventthread.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbinputcontext.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbintegration.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbnavigatoreventhandler.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbnavigatoreventnotifier.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbglcontext.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbglwindowsurface.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbscreen.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbwindow.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbrasterwindowsurface.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbvirtualkeyboardpps.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbclipboard.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbblocalethread.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbrootwindow.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbscreeneventhandler.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbabstractvirtualkeyboard.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbnativeinterface.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbbuttoneventnotifier.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbcursor.h
)
set(BLACKBERRYPLUGIN_SOURCES
${BLACKBERRYPLUGIN_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/blackberryplugin.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbbuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbscreeneventthread.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbglcontext.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbglwindowsurface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbinputcontext.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbintegration.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbnavigatoreventhandler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbnavigatoreventnotifier.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbscreen.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbwindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbrasterwindowsurface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbvirtualkeyboardpps.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbclipboard.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbblocalethread.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbrootwindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbscreeneventhandler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbabstractvirtualkeyboard.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbnativeinterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbbuttoneventnotifier.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbcursor.cpp
)
if(${KATIE_PLATFORM} STREQUAL "blackberry")
set(BLACKBERRYPLUGIN_HEADERS
${BLACKBERRYPLUGIN_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbbpseventfilter.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbvirtualkeyboardbps.h
)
set(BLACKBERRYPLUGIN_SOURCES
${BLACKBERRYPLUGIN_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbbpseventfilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/blackberry/qbbvirtualkeyboardbps.cpp
)
endif()
katie_resources(${BLACKBERRYPLUGIN_SOURCES} ${BLACKBERRYPLUGIN_HEADERS})
add_library(blackberryplugin MODULE ${BLACKBERRYPLUGIN_SOURCES} ${BLACKBERRYPLUGIN_HEADERS})
set_target_properties(blackberryplugin PROPERTIES OUTPUT_NAME blackberry)
target_link_libraries(blackberryplugin pps screen clipboard ${EGL_LIBRARIES})
target_compile_definitions(blackberryplugin ${BLACKBERRYPLUGIN_DEFINITIONS})
target_include_directories(blackberryplugin PRIVATE ${BLACKBERRYPLUGIN_INCLUDES})
install(
TARGETS blackberryplugin
DESTINATION ${QT_PLUGINS_PATH}/platforms
)

View file

@ -1,2 +0,0 @@
include (../eglconvenience/eglconvenience.pri)
include (../fontdatabases/genericunix/genericunix.pri)

View file

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtGui/QPlatformIntegrationPlugin>
#include "qbbintegration.h"
QT_BEGIN_NAMESPACE
class QBBIntegrationPlugin : public QPlatformIntegrationPlugin
{
public:
QStringList keys() const;
QPlatformIntegration *create(const QString&, const QStringList&);
};
QStringList QBBIntegrationPlugin::keys() const
{
QStringList list;
list << "blackberry";
return list;
}
QPlatformIntegration *QBBIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
if (system.toLower() == "blackberry")
return new QBBIntegration;
return 0;
}
Q_EXPORT_PLUGIN2(blackberry, QBBIntegrationPlugin)
QT_END_NAMESPACE

View file

@ -1,129 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qbbabstractvirtualkeyboard.h"
#include <QWidget>
QT_BEGIN_NAMESPACE
QBBAbstractVirtualKeyboard::QBBAbstractVirtualKeyboard(QObject *parent)
: QObject(parent)
, mHeight(0)
, mKeyboardMode(Default)
, mVisible(false)
, mLanguageId(QString::fromLatin1("en"))
, mCountryId(QString::fromLatin1("US"))
{
}
void QBBAbstractVirtualKeyboard::setKeyboardMode(KeyboardMode mode)
{
if (mode == mKeyboardMode)
return;
mKeyboardMode = mode;
applyKeyboardMode(mode);
}
void QBBAbstractVirtualKeyboard::setInputHintsFromWidget(QWidget *focusWidget)
{
if (focusWidget) {
const Qt::InputMethodHints hints = focusWidget->inputMethodHints();
if (hints & Qt::ImhEmailCharactersOnly)
setKeyboardMode(QBBAbstractVirtualKeyboard::Email);
else if (hints & Qt::ImhDialableCharactersOnly)
setKeyboardMode(QBBAbstractVirtualKeyboard::Phone);
else if (hints & Qt::ImhUrlCharactersOnly)
setKeyboardMode(QBBAbstractVirtualKeyboard::Web);
else if (hints & Qt::ImhFormattedNumbersOnly || hints & Qt::ImhDigitsOnly)
setKeyboardMode(QBBAbstractVirtualKeyboard::NumPunc);
else
setKeyboardMode(QBBAbstractVirtualKeyboard::Default);
} else {
setKeyboardMode(QBBAbstractVirtualKeyboard::Default);
}
}
void QBBAbstractVirtualKeyboard::setVisible(bool visible)
{
if (visible == mVisible)
return;
const int effectiveHeight = getHeight();
mVisible = visible;
if (effectiveHeight != getHeight())
emit heightChanged(getHeight());
}
void QBBAbstractVirtualKeyboard::setHeight(int height)
{
if (height == mHeight)
return;
const int effectiveHeight = getHeight();
mHeight = height;
if (effectiveHeight != getHeight())
emit heightChanged(getHeight());
}
void QBBAbstractVirtualKeyboard::setLanguage(const QString &language)
{
if (language == mLanguageId)
return;
mLanguageId = language;
}
void QBBAbstractVirtualKeyboard::setCountry(const QString &country)
{
if (country == mCountryId)
return;
mCountryId = country;
}
QT_END_NAMESPACE

View file

@ -1,102 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBABSTRACTVIRTUALKEYBOARD_H
#define QBBABSTRACTVIRTUALKEYBOARD_H
#include <QObject>
QT_BEGIN_NAMESPACE
class QBBAbstractVirtualKeyboard : public QObject
{
Q_OBJECT
public:
// NOTE: Not all the following keyboard modes are currently used.
// Default - Regular Keyboard
// Url/Email - Enhanced keys for each types.
// Web - Regular keyboard with two blank keys, currently unused.
// NumPunc - Numbers & Punctionation, alternate to Symbol
// Symbol - All symbols, alternate to NumPunc, currently unused.
// Phone - Phone enhanced keyboard - currently unused as no alternate keyboard available to access a-zA-Z
// Pin - Keyboard for entering Pins (Hex values) currently unused.
//
// SPECIAL NOTE: Usage of NumPunc may have to be removed, ABC button is non-functional.
//
enum KeyboardMode { Default, Url, Email, Web, NumPunc, Symbol, Phone, Pin };
explicit QBBAbstractVirtualKeyboard(QObject *parent = 0);
virtual bool showKeyboard() = 0;
virtual bool hideKeyboard() = 0;
int getHeight() const { return mVisible ? mHeight : 0; }
void setKeyboardMode(KeyboardMode mode);
void setInputHintsFromWidget(QWidget *focusWidget);
KeyboardMode keyboardMode() const { return mKeyboardMode; }
bool isVisible() const { return mVisible; }
QString languageId() const { return mLanguageId; }
QString countryId() const { return mCountryId; }
Q_SIGNALS:
void heightChanged(int height);
protected:
virtual void applyKeyboardMode(KeyboardMode mode) = 0;
void setVisible(bool visible);
void setHeight(int height);
void setLanguage(const QString &language);
void setCountry(const QString &country);
private:
int mHeight;
KeyboardMode mKeyboardMode;
bool mVisible;
QString mLanguageId;
QString mCountryId;
};
QT_END_NAMESPACE
#endif // QBBABSTRACTVIRTUALKEYBOARD_H

View file

@ -1,282 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBBPSEVENTFILTER_DEBUG
#include "qbbbpseventfilter.h"
#include "qbbnavigatoreventhandler.h"
#include "qbbscreen.h"
#include "qbbscreeneventhandler.h"
#include "qbbvirtualkeyboardbps.h"
#include <QCoreApplication>
#include <QAbstractEventDispatcher>
#include <QDebug>
#include <bps/event.h>
#include <bps/navigator.h>
#include <bps/screen.h>
QT_BEGIN_NAMESPACE
static QBBBpsEventFilter *sInstance;
QBBBpsEventFilter::QBBBpsEventFilter(QBBNavigatorEventHandler *navigatorEventHandler,
QBBScreenEventHandler *screenEventHandler,
QBBVirtualKeyboardBps *virtualKeyboard, QObject *parent)
: QObject(parent)
, mNavigatorEventHandler(navigatorEventHandler)
, mScreenEventHandler(screenEventHandler)
, mVirtualKeyboard(virtualKeyboard)
{
Q_ASSERT(sInstance == 0);
sInstance = this;
}
QBBBpsEventFilter::~QBBBpsEventFilter()
{
Q_ASSERT(sInstance == this);
sInstance = 0;
}
void QBBBpsEventFilter::installOnEventDispatcher(QAbstractEventDispatcher *dispatcher)
{
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO << "dispatcher=" << dispatcher;
#endif
if (navigator_request_events(0) != BPS_SUCCESS)
qWarning("QBB: failed to register for navigator events");
QAbstractEventDispatcher::EventFilter previousEventFilter = dispatcher->setEventFilter(dispatcherEventFilter);
// the QPA plugin in created in the QApplication constructor which indirectly also creates
// the event dispatcher so we are the first event filter.
// assert on that just in case somebody adds another event filter
// in the QBBIntegration constructor instead of adding a new section in here
Q_ASSERT(previousEventFilter == 0);
Q_UNUSED(previousEventFilter);
}
void QBBBpsEventFilter::registerForScreenEvents(QBBScreen *screen)
{
if (!mScreenEventHandler) {
qWarning("QBB: trying to register for screen events, but no handler provided");
return;
}
int attached;
if (screen_get_display_property_iv(screen->nativeDisplay(), SCREEN_PROPERTY_ATTACHED, &attached) != BPS_SUCCESS) {
qWarning() << "QBB: unable to query display attachment";
return;
}
if (!attached) {
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO << "skipping event registration for non-attached screen";
#endif
return;
}
if (screen_request_events(screen->nativeContext()) != BPS_SUCCESS)
qWarning("QBB: failed to register for screen events on screen %p", screen->nativeContext());
}
void QBBBpsEventFilter::unregisterForScreenEvents(QBBScreen *screen)
{
if (!mScreenEventHandler) {
qWarning("QBB: trying to unregister for screen events, but no handler provided");
return;
}
if (screen_stop_events(screen->nativeContext()) != BPS_SUCCESS)
qWarning("QBB: failed to unregister for screen events on screen %p", screen->nativeContext());
}
bool QBBBpsEventFilter::dispatcherEventFilter(void *message)
{
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
if (sInstance == 0)
return false;
bps_event_t *event = static_cast<bps_event_t *>(message);
return sInstance->bpsEventFilter(event);
}
bool QBBBpsEventFilter::bpsEventFilter(bps_event_t *event)
{
const int eventDomain = bps_event_get_domain(event);
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO << "event=" << event << "domain=" << eventDomain;
#endif
if (eventDomain == screen_get_domain()) {
if (!mScreenEventHandler) {
qWarning("QBB: registered for screen events, but no handler provided");
return false;
}
screen_event_t screenEvent = screen_event_get_event(event);
return mScreenEventHandler->handleEvent(screenEvent);
}
if (eventDomain == navigator_get_domain())
return handleNavigatorEvent(event);
if (mVirtualKeyboard->handleEvent(event))
return true;
return false;
}
bool QBBBpsEventFilter::handleNavigatorEvent(bps_event_t *event)
{
switch (bps_event_get_code(event)) {
case NAVIGATOR_ORIENTATION_CHECK: {
const int angle = navigator_event_get_orientation_angle(event);
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << "QBB: Navigator ORIENTATION CHECK event. angle=" << angle;
#endif
const bool result = mNavigatorEventHandler->handleOrientationCheck(angle);
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << "QBB: Navigator ORIENTATION CHECK event. result=" << result;
#endif
// reply to navigator whether orientation is acceptable
navigator_orientation_check_response(event, result);
break;
}
case NAVIGATOR_ORIENTATION: {
const int angle = navigator_event_get_orientation_angle(event);
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << "QBB: Navigator ORIENTATION event. angle=" << angle;
#endif
mNavigatorEventHandler->handleOrientationChange(angle);
navigator_done_orientation(event);
break;
}
case NAVIGATOR_SWIPE_DOWN:
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << "QBB: Navigator SWIPE DOWN event";
#endif
mNavigatorEventHandler->handleSwipeDown();
break;
case NAVIGATOR_EXIT:
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << "QBB: Navigator EXIT event";
#endif
mNavigatorEventHandler->handleExit();
break;
case NAVIGATOR_WINDOW_STATE: {
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO << "WINDOW STATE event";
#endif
const navigator_window_state_t state = navigator_event_get_window_state(event);
const QByteArray id(navigator_event_get_groupid(event));
switch (state) {
case NAVIGATOR_WINDOW_FULLSCREEN:
mNavigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowFullScreen);
break;
case NAVIGATOR_WINDOW_THUMBNAIL:
mNavigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowMinimized);
break;
case NAVIGATOR_WINDOW_INVISIBLE:
mNavigatorEventHandler->handleWindowGroupDeactivated(id);
break;
}
break;
}
case NAVIGATOR_WINDOW_ACTIVE: {
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << "QBB: Navigator WINDOW ACTIVE event";
#endif
const QByteArray id(navigator_event_get_groupid(event));
mNavigatorEventHandler->handleWindowGroupActivated(id);
break;
}
case NAVIGATOR_WINDOW_INACTIVE: {
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << "QBB: Navigator WINDOW INACTIVE event";
#endif
const QByteArray id(navigator_event_get_groupid(event));
mNavigatorEventHandler->handleWindowGroupDeactivated(id);
break;
}
case NAVIGATOR_LOW_MEMORY:
qWarning() << "QApplication based process" << QCoreApplication::applicationPid()
<< "received \"NAVIGATOR_LOW_MEMORY\" event";
return false;
default:
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << "QBB: Unhandled navigator event. code=" << bps_event_get_code(event);
#endif
return false;
}
return true;
}
QT_END_NAMESPACE

View file

@ -1,85 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBBPSEVENTFILTER_H
#define QBBBPSEVENTFILTER_H
#include <QObject>
struct bps_event_t;
QT_BEGIN_NAMESPACE
class QAbstractEventDispatcher;
class QBBNavigatorEventHandler;
class QBBScreen;
class QBBScreenEventHandler;
class QBBVirtualKeyboardBps;
class QBBBpsEventFilter : public QObject
{
Q_OBJECT
public:
QBBBpsEventFilter(QBBNavigatorEventHandler *navigatorEventHandler,
QBBScreenEventHandler *screenEventHandler,
QBBVirtualKeyboardBps *virtualKeyboard, QObject *parent = 0);
~QBBBpsEventFilter();
void installOnEventDispatcher(QAbstractEventDispatcher *dispatcher);
void registerForScreenEvents(QBBScreen *screen);
void unregisterForScreenEvents(QBBScreen *screen);
private:
static bool dispatcherEventFilter(void *message);
bool bpsEventFilter(bps_event_t *event);
bool handleNavigatorEvent(bps_event_t *event);
private:
QBBNavigatorEventHandler *mNavigatorEventHandler;
QBBScreenEventHandler *mScreenEventHandler;
QBBVirtualKeyboardBps *mVirtualKeyboard;
};
QT_END_NAMESPACE
#endif // QBBBPSEVENTFILTER_H

View file

@ -1,168 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBBUFFER_DEBUG
#include "qbbbuffer.h"
#include <QDebug>
#include <errno.h>
#include <sys/mman.h>
QT_BEGIN_NAMESPACE
QBBBuffer::QBBBuffer()
: mBuffer(NULL)
{
#if defined(QBBBUFFER_DEBUG)
qDebug() << "QBBBuffer::QBBBuffer - empty";
#endif
}
QBBBuffer::QBBBuffer(screen_buffer_t buffer)
: mBuffer(buffer)
{
#if defined(QBBBUFFER_DEBUG)
qDebug() << "QBBBuffer::QBBBuffer - normal";
#endif
// get size of buffer
errno = 0;
int size[2];
int result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_BUFFER_SIZE, size);
if (result != 0) {
qFatal("QBB: failed to query buffer size, errno=%d", errno);
}
// get stride of buffer
errno = 0;
int stride;
result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride);
if (result != 0) {
qFatal("QBB: failed to query buffer stride, errno=%d", errno);
}
// get access to buffer's data
errno = 0;
uchar* dataPtr = NULL;
result = screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr);
if (result != 0) {
qFatal("QBB: failed to query buffer pointer, errno=%d", errno);
}
if (dataPtr == NULL) {
qFatal("QBB: buffer pointer is NULL, errno=%d", errno);
}
// get format of buffer
errno = 0;
int screenFormat;
result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_FORMAT, &screenFormat);
if (result != 0) {
qFatal("QBB: failed to query buffer format, errno=%d", errno);
}
// convert screen format to QImage format
QImage::Format imageFormat = QImage::Format_Invalid;
switch (screenFormat) {
case SCREEN_FORMAT_RGBX4444:
imageFormat = QImage::Format_RGB444;
break;
case SCREEN_FORMAT_RGBA4444:
imageFormat = QImage::Format_ARGB4444_Premultiplied;
break;
case SCREEN_FORMAT_RGBX5551:
imageFormat = QImage::Format_RGB555;
break;
case SCREEN_FORMAT_RGB565:
imageFormat = QImage::Format_RGB16;
break;
case SCREEN_FORMAT_RGBX8888:
imageFormat = QImage::Format_RGB32;
break;
case SCREEN_FORMAT_RGBA8888:
imageFormat = QImage::Format_ARGB32_Premultiplied;
break;
default:
qFatal("QBB: unsupported buffer format, format=%d", screenFormat);
}
// wrap buffer in an image
mImage = QImage(dataPtr, size[0], size[1], stride, imageFormat);
}
QBBBuffer::QBBBuffer(const QBBBuffer &other)
: mBuffer(other.mBuffer),
mImage(other.mImage)
{
#if defined(QBBBUFFER_DEBUG)
qDebug() << "QBBBuffer::QBBBuffer - copy";
#endif
}
QBBBuffer::~QBBBuffer()
{
#if defined(QBBBUFFER_DEBUG)
qDebug() << "QBBBuffer::~QBBBuffer";
#endif
}
void QBBBuffer::invalidateInCache()
{
#if defined(QBBBUFFER_DEBUG)
qDebug() << "QBBBuffer::invalidateInCache";
#endif
// verify native buffer exists
if (mBuffer == NULL) {
qFatal("QBB: can't invalidate cache for null buffer");
}
// evict buffer's data from cache
errno = 0;
int result = msync(mImage.bits(), mImage.height() * mImage.bytesPerLine(), MS_INVALIDATE | MS_CACHE_ONLY);
if (result != 0) {
qFatal("QBB: failed to invalidate cache, errno=%d", errno);
}
}
QT_END_NAMESPACE

View file

@ -1,74 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBBUFFER_H
#define QBBBUFFER_H
#include <QImage>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
class QBBBuffer
{
public:
QBBBuffer();
QBBBuffer(screen_buffer_t buffer);
QBBBuffer(const QBBBuffer &other);
virtual ~QBBBuffer();
screen_buffer_t nativeBuffer() const { return mBuffer; }
const QImage *image() const { return (mBuffer != NULL) ? &mImage : NULL; }
QImage *image() { return (mBuffer != NULL) ? &mImage : NULL; }
QRect rect() const { return mImage.rect(); }
void invalidateInCache();
private:
screen_buffer_t mBuffer;
QImage mImage;
};
QT_END_NAMESPACE
#endif // QBBBUFFER_H

View file

@ -1,223 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qbbbuttoneventnotifier.h"
#include <QtGui/QApplication>
#include <qwindowsysteminterface_qpa.h>
#include <QtCore/QDebug>
#include <QtCore/qmetaobject.h>
#include <QtCore/QSocketNotifier>
#include <QtCore/qcore_unix_p.h>
//#define QBBBUTTON_DEBUG
#ifdef QBBBUTTON_DEBUG
#define qButtonDebug qDebug
#else
#define qButtonDebug QT_NO_QDEBUG_MACRO
#endif
QT_BEGIN_NAMESPACE
static const char *ppsPath = "/pps/system/buttons/status";
static const int ppsBufferSize = 256;
QBBButtonEventNotifier::QBBButtonEventNotifier(QObject *parent)
: QObject(parent),
mFd(-1),
mReadNotifier(0)
{
// Set initial state of buttons to ButtonUp and
// fetch the new button ids
int enumeratorIndex = QBBButtonEventNotifier::staticMetaObject.indexOfEnumerator("ButtonId");
QMetaEnum enumerator = QBBButtonEventNotifier::staticMetaObject.enumerator(enumeratorIndex);
for (int buttonId = bid_minus; buttonId < ButtonCount; ++buttonId) {
mButtonKeys.append(enumerator.valueToKey(buttonId));
mState[buttonId] = ButtonUp;
}
}
QBBButtonEventNotifier::~QBBButtonEventNotifier()
{
close();
}
void QBBButtonEventNotifier::start()
{
qButtonDebug() << Q_FUNC_INFO << "starting hardware button event processing";
if (mFd != -1)
return;
// Open the pps interface
errno = 0;
mFd = qt_safe_open(ppsPath, O_RDONLY);
if (mFd == -1) {
qWarning("QQNX: failed to open buttons pps, errno=%d", errno);
return;
}
mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read);
QObject::connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(updateButtonStates()));
qButtonDebug() << Q_FUNC_INFO << "successfully connected to Navigator. fd =" << mFd;
}
void QBBButtonEventNotifier::updateButtonStates()
{
// Allocate buffer for pps data
char buffer[ppsBufferSize];
// Attempt to read pps data
errno = 0;
int bytes = qt_safe_read(mFd, buffer, ppsBufferSize - 1);
qButtonDebug() << "Read" << bytes << "bytes of data";
if (bytes == -1) {
qWarning("QQNX: failed to read hardware buttons pps object, errno=%d", errno);
return;
}
// We seem to get a spurious read notification after the real one. Ignore it
if (bytes == 0)
return;
// Ensure data is null terminated
buffer[bytes] = '\0';
qButtonDebug() << Q_FUNC_INFO << "received PPS message:\n" << buffer;
// Process received message
QByteArray ppsData = QByteArray::fromRawData(buffer, bytes);
QHash<QByteArray, QByteArray> fields;
if (!parsePPS(ppsData, &fields))
return;
// Update our state and inject key events as needed
for (int buttonId = bid_minus; buttonId < ButtonCount; ++buttonId) {
// Extract the new button state
QByteArray key = mButtonKeys.at(buttonId);
ButtonState newState = (fields.value(key) == QByteArray("b_up") ? ButtonUp : ButtonDown);
// If state has changed, update our state and inject a keypress event
if (mState[buttonId] != newState) {
qButtonDebug() << "Hardware button event: button =" << key << "state =" << fields.value(key);
mState[buttonId] = newState;
// Is it a key press or key release event?
QEvent::Type type = (newState == ButtonDown) ? QEvent::KeyPress : QEvent::KeyRelease;
Qt::Key key;
switch (buttonId) {
case bid_minus:
key = Qt::Key_VolumeDown;
break;
case bid_playpause:
key = Qt::Key_Play;
break;
case bid_plus:
key = Qt::Key_VolumeUp;
break;
case bid_power:
key = Qt::Key_PowerDown;
break;
default:
qButtonDebug() << "Unknown hardware button";
continue;
}
// No modifiers
Qt::KeyboardModifiers modifier = Qt::NoModifier;
// Post the event
QWindowSystemInterface::handleKeyEvent(QApplication::activeWindow(), type, key, modifier);
}
}
}
void QBBButtonEventNotifier::close()
{
delete mReadNotifier;
mReadNotifier = 0;
if (mFd != -1) {
qt_safe_close(mFd);
mFd = -1;
}
}
bool QBBButtonEventNotifier::parsePPS(const QByteArray &ppsData, QHash<QByteArray, QByteArray> *messageFields) const
{
// tokenize pps data into lines
QList<QByteArray> lines = ppsData.split('\n');
// validate pps object
if (lines.size() == 0 || !lines.at(0).contains(QByteArray("@status"))) {
qWarning("QQNX: unrecognized pps object, data=%s", ppsData.constData());
return false;
}
// parse pps object attributes and extract values
for (int i = 1; i < lines.size(); i++) {
// tokenize current attribute
const QByteArray &attr = lines.at(i);
qButtonDebug() << Q_FUNC_INFO << "attr=" << attr;
int doubleColon = attr.indexOf(QByteArray("::"));
if (doubleColon == -1) {
// abort - malformed attribute
continue;
}
QByteArray key = attr.left(doubleColon);
QByteArray value = attr.mid(doubleColon + 2);
messageFields->insert(key, value);
}
return true;
}
QT_END_NAMESPACE

View file

@ -1,91 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBBUTTONSEVENTNOTIFIER_H
#define QBBBUTTONSEVENTNOTIFIER_H
#include <QObject>
#include <QHash>
QT_BEGIN_NAMESPACE
class QSocketNotifier;
class QBBButtonEventNotifier : public QObject
{
Q_OBJECT
Q_ENUMS(ButtonId)
public:
enum ButtonId {
bid_minus = 0,
bid_playpause,
bid_plus,
bid_power,
ButtonCount
};
enum ButtonState {
ButtonUp,
ButtonDown
};
explicit QBBButtonEventNotifier(QObject *parent = 0);
~QBBButtonEventNotifier();
public Q_SLOTS:
void start();
private Q_SLOTS:
void updateButtonStates();
private:
void close();
bool parsePPS(const QByteArray &ppsData, QHash<QByteArray, QByteArray> *messageFields) const;
int mFd;
QSocketNotifier *mReadNotifier;
ButtonState mState[ButtonCount];
QList<QByteArray> mButtonKeys;
};
QT_END_NAMESPACE
#endif // QBBBUTTONSEVENTNOTIFIER_H

View file

@ -1,245 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
// #define QBBCLIPBOARD_DEBUG
#ifndef QT_NO_CLIPBOARD
#include "qbbclipboard.h"
#include <QDebug>
#include <QMimeData>
#include <QStringList>
#include <clipboard/clipboard.h>
#include <errno.h>
QT_BEGIN_NAMESPACE
// null terminated array
static const char *typeList[] = {"text/html", "text/plain", "image/png", "image/jpeg", "application/x-color", 0};
static QByteArray readClipboardBuff(const char *type)
{
char *pbuffer;
if (is_clipboard_format_present(type) == 0) {
int size = get_clipboard_data(type, &pbuffer);
if (size != -1 && pbuffer) {
const QByteArray result = QByteArray(pbuffer, size);
free(pbuffer);
return result;
}
}
return QByteArray();
}
class QBBClipboard::MimeData : public QMimeData
{
Q_OBJECT
public:
MimeData(QBBClipboard *clipboard)
: QMimeData(),
m_clipboard(clipboard),
m_userMimeData(0)
{
Q_ASSERT(clipboard);
for (int i = 0; typeList[i] != 0; ++i) {
m_formatsToCheck << QString::fromUtf8(typeList[i]);
}
}
~MimeData()
{
delete m_userMimeData;
}
void addFormatToCheck(const QString &format) {
m_formatsToCheck << format;
#if defined(QBBCLIPBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "formats=" << m_formatsToCheck;
#endif
}
bool hasFormat(const QString &mimetype) const
{
const bool result = is_clipboard_format_present(mimetype.toUtf8().constData()) == 0;
#if defined(QBBCLIPBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "mimetype=" << mimetype << "result=" << result;
#endif
return result;
}
QStringList formats() const
{
QStringList result;
Q_FOREACH (const QString &format, m_formatsToCheck) {
if (is_clipboard_format_present(format.toUtf8().constData()) == 0)
result << format;
}
#if defined(QBBCLIPBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "result=" << result;
#endif
return result;
}
void setUserMimeData(QMimeData *userMimeData)
{
delete m_userMimeData;
m_userMimeData = userMimeData;
// system clipboard API doesn't allow detection of changes by other applications
// simulate an owner change through delayed invocation
// basically transfer ownership of data to the system clipboard once event processing resumes
if (m_userMimeData)
QMetaObject::invokeMethod(this, "releaseOwnership", Qt::QueuedConnection);
}
QMimeData *userMimeData()
{
return m_userMimeData;
}
protected:
QVariant retrieveData(const QString &mimetype, QVariant::Type preferredType) const
{
#if defined(QBBCLIPBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "mimetype=" << mimetype << "preferredType=" << preferredType;
#endif
if (is_clipboard_format_present(mimetype.toUtf8().constData()) != 0)
return QMimeData::retrieveData(mimetype, preferredType);
const QByteArray data = readClipboardBuff(mimetype.toUtf8().constData());
return qVariantFromValue(data);
}
private Q_SLOTS:
void releaseOwnership()
{
if (m_userMimeData) {
#if defined(QBBCLIPBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "user data formats=" << m_userMimeData->formats() << "system formats=" << formats();
#endif
delete m_userMimeData;
m_userMimeData = 0;
m_clipboard->emitChanged(QClipboard::Clipboard);
}
}
private:
QBBClipboard * const m_clipboard;
QSet<QString> m_formatsToCheck;
QMimeData *m_userMimeData;
};
QBBClipboard::QBBClipboard()
: m_mimeData(new MimeData(this))
{
}
QBBClipboard::~QBBClipboard()
{
delete m_mimeData;
}
void QBBClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
{
if (mode != QClipboard::Clipboard)
return;
if (m_mimeData == data)
return;
if (m_mimeData->userMimeData() && m_mimeData->userMimeData() == data)
return;
empty_clipboard();
m_mimeData->clear();
m_mimeData->setUserMimeData(data);
if (data == 0)
return;
const QStringList formats = data->formats();
#if defined(QBBCLIPBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "formats=" << formats;
#endif
Q_FOREACH (const QString &format, formats) {
const QByteArray buf = data->data(format);
if (buf.isEmpty())
continue;
int ret = set_clipboard_data(format.toUtf8().data(), buf.size(), buf.data());
#if defined(QBBCLIPBOARD_DEBUG)
qDebug() << "QBB: set " << format << "to clipboard, size=" << buf.size() << ";ret=" << ret;
#endif
if (ret)
m_mimeData->addFormatToCheck(format);
}
}
QMimeData* QBBClipboard::mimeData(QClipboard::Mode mode)
{
if (mode != QClipboard::Clipboard)
return 0;
if (m_mimeData->userMimeData())
return m_mimeData->userMimeData();
m_mimeData->clear();
return m_mimeData;
}
QT_END_NAMESPACE
#include "qbbclipboard.moc"
#endif //QT_NO_CLIPBOARD

View file

@ -1,66 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBCLIPBOARD_H
#define QBBCLIPBOARD_H
#ifndef QT_NO_CLIPBOARD
#include <QtGui/QPlatformClipboard>
QT_BEGIN_NAMESPACE
class QBBClipboard : public QPlatformClipboard
{
public:
QBBClipboard();
virtual ~QBBClipboard();
virtual QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
private:
class MimeData;
MimeData *m_mimeData;
};
QT_END_NAMESPACE
#endif //QT_NO_CLIPBOARD
#endif //QBBCLIPBOARD_H

View file

@ -1,74 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qbbcursor.h"
#include <QDebug>
QT_BEGIN_NAMESPACE
QBBCursor::QBBCursor(QPlatformScreen *screen) : QPlatformCursor(screen)
{
}
void QBBCursor::changeCursor(QCursor *widgetCursor, QWidget *widget)
{
Q_UNUSED(widgetCursor);
Q_UNUSED(widget);
}
void QBBCursor::setPos(const QPoint &pos)
{
#ifdef QBBCURSOR_DEBUG
qDebug() << "QBBCursor::setPos -" << pos;
#endif
mPos = pos;
}
QPoint QBBCursor::pos() const
{
#ifdef QBBCURSOR_DEBUG
qDebug() << "QBBCursor::pos -" << mPos;
#endif
return mPos;
}
QT_END_NAMESPACE

View file

@ -1,63 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBCURSOR_H
#define QBBCURSOR_H
#include <qplatformcursor_qpa.h>
QT_BEGIN_NAMESPACE
class QBBCursor : public QPlatformCursor
{
public:
QBBCursor(QPlatformScreen *screen);
void changeCursor(QCursor *widgetCursor, QWidget *widget);
void setPos(const QPoint &pos);
QPoint pos() const;
private:
QPoint mPos;
};
#endif // QBBCURSOR_H

View file

@ -1,347 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBGLCONTEXT_DEBUG
#include "qbbglcontext.h"
#include "qbbscreen.h"
#include "qbbwindow.h"
#include "../eglconvenience/qeglconvenience.h"
#include <QtGui/QWidget>
#include <QDebug>
QT_BEGIN_NAMESPACE
EGLDisplay QBBGLContext::sEglDisplay = EGL_NO_DISPLAY;
QBBGLContext::QBBGLContext(QBBWindow* platformWindow)
: QPlatformGLContext(),
mPlatformWindow(platformWindow),
mEglSurface(EGL_NO_SURFACE)
{
#if defined(QBBGLCONTEXT_DEBUG)
qDebug() << "QBBGLContext::QBBGLContext - w=" << mPlatformWindow->widget();
#endif
// verify rendering API is correct
QPlatformWindowFormat format = mPlatformWindow->widget()->platformWindowFormat();
if (format.windowApi() != QPlatformWindowFormat::OpenGL) {
qFatal("QBB: window API is not OpenGL");
}
// set current rendering API
EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
}
// get colour channel sizes from window format
int alphaSize = format.alphaBufferSize();
int redSize = format.redBufferSize();
int greenSize = format.greenBufferSize();
int blueSize = format.blueBufferSize();
// check if all channels are don't care
if (alphaSize == -1 && redSize == -1 && greenSize == -1 && blueSize == -1) {
// set colour channels based on depth of window's screen
int depth = platformWindow->screen()->depth();
if (depth == 32) {
// SCREEN_FORMAT_RGBA8888
alphaSize = 8;
redSize = 8;
greenSize = 8;
blueSize = 8;
} else {
// SCREEN_FORMAT_RGB565
alphaSize = 0;
redSize = 5;
greenSize = 6;
blueSize = 5;
}
} else {
// choose best match based on supported pixel formats
if (alphaSize <= 0 && redSize <= 5 && greenSize <= 6 && blueSize <= 5) {
// SCREEN_FORMAT_RGB565
alphaSize = 0;
redSize = 5;
greenSize = 6;
blueSize = 5;
} else {
// SCREEN_FORMAT_RGBA8888
alphaSize = 8;
redSize = 8;
greenSize = 8;
blueSize = 8;
}
}
// update colour channel sizes in window format
format.setAlphaBufferSize(alphaSize);
format.setRedBufferSize(redSize);
format.setGreenBufferSize(greenSize);
format.setBlueBufferSize(blueSize);
// select EGL config based on requested window format
mEglConfig = q_configFromQPlatformWindowFormat(sEglDisplay, format);
if (mEglConfig == 0) {
qFatal("QBB: failed to find EGL config");
}
mEglContext = eglCreateContext(sEglDisplay, mEglConfig, EGL_NO_CONTEXT, contextAttrs());
if (mEglContext == EGL_NO_CONTEXT) {
qFatal("QBB: failed to create EGL context, err=%d", eglGetError());
}
// query/cache window format of selected EGL config
mWindowFormat = qt_qPlatformWindowFormatFromConfig(sEglDisplay, mEglConfig);
}
QBBGLContext::~QBBGLContext()
{
#if defined(QBBGLCONTEXT_DEBUG)
qDebug() << "QBBGLContext::~QBBGLContext - w=" << mPlatformWindow->widget();
#endif
// cleanup EGL context if it exists
if (mEglContext != EGL_NO_CONTEXT) {
eglDestroyContext(sEglDisplay, mEglContext);
}
// cleanup EGL surface if it exists
destroySurface();
}
void QBBGLContext::initialize()
{
// initialize connection to EGL
sEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (sEglDisplay == EGL_NO_DISPLAY) {
qFatal("QBB: failed to obtain EGL display");
}
EGLBoolean eglResult = eglInitialize(sEglDisplay, NULL, NULL);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to initialize EGL display, err=%d", eglGetError());
}
// choose EGL settings based on OpenGL version
#if defined(QT_OPENGL_ES_2)
EGLint renderableType = EGL_OPENGL_ES2_BIT;
#else
EGLint renderableType = EGL_OPENGL_ES_BIT;
#endif
}
void QBBGLContext::shutdown()
{
// close connection to EGL
eglTerminate(sEglDisplay);
}
void QBBGLContext::makeCurrent()
{
#if defined(QBBGLCONTEXT_DEBUG)
qDebug() << "QBBGLContext::makeCurrent - w=" << mPlatformWindow->widget();
#endif
if (!mPlatformWindow->hasBuffers()) {
// NOTE: create a dummy EGL surface since Qt will call makeCurrent() before
// setting the geometry on the associated window
mSurfaceSize = QSize(1, 1);
mPlatformWindow->setBufferSize(mSurfaceSize);
createSurface();
}
// call the parent method
QPlatformGLContext::makeCurrent();
// set current rendering API
EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
}
// set current EGL context and bind with EGL surface
eglResult = eglMakeCurrent(sEglDisplay, mEglSurface, mEglSurface, mEglContext);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to set current EGL context, err=%d", eglGetError());
}
}
void QBBGLContext::doneCurrent()
{
#if defined(QBBGLCONTEXT_DEBUG)
qDebug() << "QBBGLContext::doneCurrent - w=" << mPlatformWindow->widget();
#endif
// call the parent method
QPlatformGLContext::doneCurrent();
// set current rendering API
EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
}
// clear curent EGL context and unbind EGL surface
eglResult = eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to clear current EGL context, err=%d", eglGetError());
}
}
void QBBGLContext::swapBuffers()
{
#if defined(QBBGLCONTEXT_DEBUG)
qDebug() << "QBBGLContext::swapBuffers - w=" << mPlatformWindow->widget();
#endif
// set current rendering API
EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
}
// post EGL surface to window
eglResult = eglSwapBuffers(sEglDisplay, mEglSurface);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to swap EGL buffers, err=%d", eglGetError());
}
// resize surface if window was resized
QSize s = mPlatformWindow->geometry().size();
if (s != mSurfaceSize) {
resizeSurface(s);
}
}
void* QBBGLContext::getProcAddress(const QString& procName)
{
#if defined(QBBGLCONTEXT_DEBUG)
qDebug() << "QBBGLContext::getProcAddress - w=" << mPlatformWindow->widget();
#endif
// set current rendering API
EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
}
// lookup EGL extension function pointer
return (void *)eglGetProcAddress( procName.toAscii().constData() );
}
void QBBGLContext::resizeSurface(const QSize &size)
{
// need to destroy surface so make sure its not current
bool restoreCurrent = false;
if (isCurrent()) {
doneCurrent();
restoreCurrent = true;
}
// destroy old EGL surface
destroySurface();
// resize window's buffers
mPlatformWindow->setBufferSize(size);
// re-create EGL surface with new size
mSurfaceSize = size;
createSurface();
// make context current again
if (restoreCurrent) {
makeCurrent();
mPlatformWindow->widget()->update();
}
}
EGLint *QBBGLContext::contextAttrs()
{
// choose EGL settings based on OpenGL version
#if defined(QT_OPENGL_ES_2)
static EGLint attrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
return attrs;
#else
return NULL;
#endif
}
bool QBBGLContext::isCurrent() const
{
return (eglGetCurrentContext() == mEglContext);
}
void QBBGLContext::createSurface()
{
#if defined(QBBGLCONTEXT_DEBUG)
qDebug() << "QBBGLContext::createSurface - w=" << mPlatformWindow->widget();
#endif
// create EGL surface
mEglSurface = eglCreateWindowSurface(sEglDisplay, mEglConfig, (EGLNativeWindowType)mPlatformWindow->winId(), NULL);
if (mEglSurface == EGL_NO_SURFACE) {
qFatal("QBB: failed to create EGL surface, err=%d", eglGetError());
}
}
void QBBGLContext::destroySurface()
{
#if defined(QBBGLCONTEXT_DEBUG)
qDebug() << "QBBGLContext::destroySurface - w=" << mPlatformWindow->widget();
#endif
// destroy EGL surface if it exists
if (mEglSurface != EGL_NO_SURFACE) {
EGLBoolean eglResult = eglDestroySurface(sEglDisplay, mEglSurface);
if (eglResult != EGL_TRUE) {
qFatal("QBB: failed to destroy EGL surface, err=%d", eglGetError());
}
}
}
QT_END_NAMESPACE

View file

@ -1,92 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBGLCONTEXT_H
#define QBBGLCONTEXT_H
#include <QtGui/QPlatformGLContext>
#include <QtGui/QPlatformWindowFormat>
#include <QSize>
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
class QBBWindow;
class QBBGLContext : public QPlatformGLContext
{
public:
QBBGLContext(QBBWindow* platformWindow);
virtual ~QBBGLContext();
static void initialize();
static void shutdown();
virtual void makeCurrent();
virtual void doneCurrent();
virtual void swapBuffers();
virtual void* getProcAddress(const QString& procName);
virtual QPlatformWindowFormat platformWindowFormat() const { return mWindowFormat; }
void resizeSurface(const QSize &size);
QSize surfaceSize() const { return mSurfaceSize; }
private:
static EGLDisplay sEglDisplay;
QPlatformWindowFormat mWindowFormat;
EGLConfig mEglConfig;
QBBWindow *mPlatformWindow;
EGLContext mEglContext;
EGLSurface mEglSurface;
QSize mSurfaceSize;
static EGLint *contextAttrs();
bool isCurrent() const;
void createSurface();
void destroySurface();
};
QT_END_NAMESPACE
#endif // QBBGLCONTEXT_H

View file

@ -1,163 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBGLWINDOWSURFACE_DEBUG
#include "qbbglwindowsurface.h"
#include "qbbglcontext.h"
#include "qbbwindow.h"
#include <QtGui/QWidget>
#include <QtOpenGL/qgl_p.h>
#include <QtOpenGL/qgl.h>
#include <QDebug>
#include <errno.h>
QT_BEGIN_NAMESPACE
QBBGLPaintDevice::QBBGLPaintDevice(QBBGLContext* platformGlContext)
: mPlatformGlContext(platformGlContext)
{
// create GL context from platform GL context
mGlContext = QGLContext::fromPlatformGLContext(mPlatformGlContext);
}
QBBGLPaintDevice::~QBBGLPaintDevice()
{
// cleanup GL context
delete mGlContext;
}
QPaintEngine *QBBGLPaintDevice::paintEngine() const
{
// select a paint engine based on configued OpenGL version
return qt_qgl_paint_engine();
}
QSize QBBGLPaintDevice::size() const
{
// get size of EGL surface
return mPlatformGlContext->surfaceSize();
}
QBBGLWindowSurface::QBBGLWindowSurface(QWidget *window)
: QWindowSurface(window)
{
#if defined(QBBGLWINDOWSURFACE_DEBUG)
qDebug() << "QBBGLWindowSurface::QBBGLWindowSurface - w=" << window;
#endif
// extract GL context associated with window
mPlatformGlContext = static_cast<QBBGLContext*>(window->platformWindow()->glContext());
// create an OpenGL paint device
mPaintDevice = new QBBGLPaintDevice(mPlatformGlContext);
}
QBBGLWindowSurface::~QBBGLWindowSurface()
{
#if defined(QBBGLWINDOWSURFACE_DEBUG)
qDebug() << "QBBGLWindowSurface::~QBBGLWindowSurface - w=" << window();
#endif
// cleanup OpenGL paint device
delete mPaintDevice;
}
void QBBGLWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(widget);
Q_UNUSED(region);
Q_UNUSED(offset);
#if defined(QBBGLWINDOWSURFACE_DEBUG)
qDebug() << "QBBGLWindowSurface::flush - w=" << window();
#endif
// update the display with newly rendered content
mPlatformGlContext->swapBuffers();
}
void QBBGLWindowSurface::resize(const QSize &size)
{
#if defined(QBBGLWINDOWSURFACE_DEBUG)
qDebug() << "QBBGLWindowSurface::resize - w=" << window() << ", s=" << size;
#endif
// call parent method
QWindowSurface::resize(size);
// NOTE: defer resizing window buffers until next paint as
// resize() can be called multiple times before a paint occurs
}
void QBBGLWindowSurface::beginPaint(const QRegion &region)
{
Q_UNUSED(region);
#if defined(QBBGLWINDOWSURFACE_DEBUG)
qDebug() << "QBBGLWindowSurface::beginPaint - w=" << window();
#endif
// resize EGL surface if window surface resized
QSize s = size();
if (s != mPlatformGlContext->surfaceSize()) {
mPlatformGlContext->resizeSurface(s);
}
}
void QBBGLWindowSurface::endPaint(const QRegion &region)
{
Q_UNUSED(region);
#if defined(QBBGLWINDOWSURFACE_DEBUG)
qDebug() << "QBBGLWindowSurface::endPaint - w=" << window();
#endif
}
QWindowSurface::WindowSurfaceFeatures QBBGLWindowSurface::features() const
{
// force full frame updates on every paint
return 0;
}
QT_END_NAMESPACE

View file

@ -1,92 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBGLWINDOWSURFACE_H
#define QBBGLWINDOWSURFACE_H
#include <QtGui/qwindowsurface_p.h>
#include <QtOpenGL/qglpaintdevice_p.h>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
class QGLContext;
class QBBGLContext;
class QBBWindow;
class QBBGLPaintDevice : public QGLPaintDevice
{
public:
QBBGLPaintDevice(QBBGLContext* platformGlContext);
virtual ~QBBGLPaintDevice();
virtual QPaintEngine *paintEngine() const;
virtual QSize size() const;
virtual QGLContext *context() const { return mGlContext; }
private:
QBBGLContext* mPlatformGlContext;
QGLContext *mGlContext;
};
class QBBGLWindowSurface : public QWindowSurface
{
public:
QBBGLWindowSurface(QWidget *window);
virtual ~QBBGLWindowSurface();
virtual QPaintDevice *paintDevice() { return mPaintDevice; }
virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
virtual void resize(const QSize &size);
virtual void beginPaint(const QRegion &region);
virtual void endPaint(const QRegion &region);
virtual QWindowSurface::WindowSurfaceFeatures features() const;
private:
QBBGLContext* mPlatformGlContext;
QBBGLPaintDevice* mPaintDevice;
};
QT_END_NAMESPACE
#endif // QBBGLWINDOWSURFACE_H

View file

@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifdef QBB_IMF
#include "qbbinputcontext_imf.cpp"
#else
#include "qbbinputcontext_noimf.cpp"
#endif

View file

@ -1,46 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBB_IMF
#include "qbbinputcontext_noimf.h"
#else
#include "qbbinputcontext_imf.h"
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,122 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBINPUTCONTEXT_H
#define QBBINPUTCONTEXT_H
#include "imf/imf_client.h"
#include "imf/input_control.h"
#include <QtGui/QPlatformIntegration>
#include <qinputcontext.h>
QT_BEGIN_NAMESPACE
class QBBAbstractVirtualKeyboard;
class QBBInputContext : public QInputContext
{
public:
explicit QBBInputContext(QBBAbstractVirtualKeyboard &keyboard, QObject* parent = 0);
~QBBInputContext();
virtual QList<QAction *> actions();
virtual bool filterEvent(const QEvent * event);
virtual QFont font() const;
virtual QString identifierName();
virtual bool isComposing() const;
virtual QString language();
virtual void mouseHandler(int x, QMouseEvent * event);
virtual void reset();
virtual void setFocusWidget(QWidget * widget);
virtual void update();
virtual void widgetDestroyed(QWidget * widget);
bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
protected:
// Filters only for IMF events.
bool eventFilter(QObject *obj, QEvent *event);
private:
// IMF Event dispatchers
bool dispatchFocusEvent(FocusEventId id, int hints = Qt::ImhNone);
bool dispatchRequestSoftwareInputPanel();
bool dispatchCloseSoftwareInputPanel();
int32_t processEvent(event_t* event);
void closeSession();
void openSession();
bool hasSession();
void endComposition();
void setComposingText(QString const& composingText);
bool hasSelectedText();
// IMF Event handlers - these events will come in from QCoreApplication.
int32_t onBeginBatchEdit(input_session_t* ic);
int32_t onClearMetaKeyStates(input_session_t* ic, int32_t states);
int32_t onCommitText(input_session_t* ic, spannable_string_t* text, int32_t new_cursor_position);
int32_t onDeleteSurroundingText(input_session_t* ic, int32_t left_length, int32_t right_length);
int32_t onEndBatchEdit(input_session_t* ic);
int32_t onFinishComposingText(input_session_t* ic);
int32_t onGetCursorCapsMode(input_session_t* ic, int32_t req_modes);
int32_t onGetCursorPosition(input_session_t* ic);
extracted_text_t* onGetExtractedText(input_session_t* ic, extracted_text_request_t* request, int32_t flags);
spannable_string_t* onGetSelectedText(input_session_t* ic, int32_t flags);
spannable_string_t* onGetTextAfterCursor(input_session_t* ic, int32_t n, int32_t flags);
spannable_string_t* onGetTextBeforeCursor(input_session_t* ic, int32_t n, int32_t flags);
int32_t onPerformEditorAction(input_session_t* ic, int32_t editor_action);
int32_t onReportFullscreenMode(input_session_t* ic, int32_t enabled);
int32_t onSendEvent(input_session_t* ic, event_t * event);
int32_t onSendAsyncEvent(input_session_t* ic, event_t * event);
int32_t onSetComposingRegion(input_session_t* ic, int32_t start, int32_t end);
int32_t onSetComposingText(input_session_t* ic, spannable_string_t* text, int32_t new_cursor_position);
int32_t onSetSelection(input_session_t* ic, int32_t start, int32_t end);
int32_t onForceUpdate();
int mLastCaretPos;
bool mIsComposing;
QString mComposingText;
QBBAbstractVirtualKeyboard &mVirtualKeyboard;
};
QT_END_NAMESPACE
#endif // QBBINPUTCONTEXT_H

View file

@ -1,128 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
// #define QBBINPUTCONTEXT_DEBUG
#include <qbbinputcontext.h>
#include <qbbabstractvirtualkeyboard.h>
#include <QDebug>
#include <QAbstractSpinBox>
#include <QAbstractItemView>
QT_BEGIN_NAMESPACE
QBBInputContext::QBBInputContext(QBBAbstractVirtualKeyboard &keyboard, QObject* parent)
: QInputContext(parent),
mVirtualKeyboard(keyboard)
{
}
QBBInputContext::~QBBInputContext()
{
}
QString QBBInputContext::language()
{
// Once we enable full IMF support, we need to hook that up here.
return mVirtualKeyboard.languageId();
}
bool QBBInputContext::hasPhysicalKeyboard()
{
// TODO: This should query the system to check if a USB keyboard is connected.
return false;
}
void QBBInputContext::reset()
{
}
bool QBBInputContext::filterEvent( const QEvent *event )
{
if (hasPhysicalKeyboard())
return false;
if (event->type() == QEvent::CloseSoftwareInputPanel) {
mVirtualKeyboard.hideKeyboard();
#if defined(QBBINPUTCONTEXT_DEBUG)
qDebug() << "QBB: hiding virtual keyboard";
#endif
return false;
}
if (event->type() == QEvent::RequestSoftwareInputPanel) {
mVirtualKeyboard.showKeyboard();
#if defined(QBBINPUTCONTEXT_DEBUG)
qDebug() << "QBB: requesting virtual keyboard";
#endif
return false;
}
return false;
}
bool QBBInputContext::handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
{
return false;
}
void QBBInputContext::setFocusWidget(QWidget *w)
{
#if defined(QBBINPUTCONTEXT_DEBUG)
qDebug() << Q_FUNC_INFO << (w ? "requesting" : "hiding") << "virtual keyboard";
#endif
QInputContext::setFocusWidget(w);
if (w) {
// Special case for item view which should not show the keyboard when focused
if (qobject_cast<QAbstractItemView*>(w))
return;
mVirtualKeyboard.setInputHintsFromWidget(w);
mVirtualKeyboard.showKeyboard();
} else {
mVirtualKeyboard.hideKeyboard();
}
}
QT_END_NAMESPACE

View file

@ -1,75 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBINPUTCONTEXT_H
#define QBBINPUTCONTEXT_H
#include <QtGui/QPlatformIntegration>
#include <qinputcontext.h>
QT_BEGIN_NAMESPACE
class QBBAbstractVirtualKeyboard;
class QBBInputContext : public QInputContext
{
public:
explicit QBBInputContext(QBBAbstractVirtualKeyboard &keyboard, QObject* parent = 0);
~QBBInputContext();
QString identifierName() { return QString("BlackBerry IMF"); }
QString language();
void reset();
bool isComposing() const { return false; }
virtual bool filterEvent( const QEvent *event );
bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
void setFocusWidget(QWidget *w);
private:
bool hasPhysicalKeyboard();
QBBAbstractVirtualKeyboard &mVirtualKeyboard;
};
QT_END_NAMESPACE
#endif // QBBINPUTCONTEXT_H

View file

@ -1,411 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBINTEGRATION_DEBUG
#include "qbbintegration.h"
#include "qbbinputcontext.h"
#include "qbbscreeneventthread.h"
#include "qbbglcontext.h"
#include "qbbglwindowsurface.h"
#include "qbbnavigatoreventhandler.h"
#include "qbbnavigatoreventnotifier.h"
#include "qbbrasterwindowsurface.h"
#include "qbbscreen.h"
#include "qbbscreeneventhandler.h"
#include "qbbwindow.h"
#include "qbbvirtualkeyboardpps.h"
#include "qgenericunixfontdatabase.h"
#include "qbbclipboard.h"
#include "qbbglcontext.h"
#include "qbblocalethread.h"
#include "qbbnativeinterface.h"
#include "qbbbuttoneventnotifier.h"
#if defined(Q_OS_BLACKBERRY)
#include "qbbbpseventfilter.h"
#include "qbbvirtualkeyboardbps.h"
#endif
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/QApplication>
#include <QtGui/qpixmap_raster_p.h>
#include <QtGui/QPlatformWindow>
#include <QtGui/QWindowSystemInterface>
#include <QtOpenGL/qpixmapdata_gl_p.h>
#include <QDebug>
#include <errno.h>
#if defined(Q_OS_BLACKBERRY)
#include <bps/navigator.h>
#endif
QT_BEGIN_NAMESPACE
Q_DECLARE_METATYPE(screen_window_t);
QBBIntegration::QBBIntegration() :
mScreenEventThread(0),
mNavigatorEventHandler(new QBBNavigatorEventHandler()),
mButtonsNotifier(new QBBButtonEventNotifier()),
mFontDb(new QGenericUnixFontDatabase()),
mScreenEventHandler(new QBBScreenEventHandler(this)),
mPaintUsingOpenGL(getenv("QBB_USE_OPENGL") != NULL),
mVirtualKeyboard(0),
mNativeInterface(new QBBNativeInterface(this)),
mBpsEventFilter(0)
{
qRegisterMetaType<screen_window_t>();
if (mPaintUsingOpenGL) {
// Set default window API to OpenGL
QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat();
format.setWindowApi(QPlatformWindowFormat::OpenGL);
QPlatformWindowFormat::setDefaultFormat(format);
}
// initialize global OpenGL resources
QBBGLContext::initialize();
// open connection to QNX composition manager
errno = 0;
int result = screen_create_context(&mContext, SCREEN_APPLICATION_CONTEXT);
if (result != 0) {
qFatal("QBB: failed to connect to composition manager, errno=%d", errno);
}
// Create/start navigator event notifier
// Not on BlackBerry, it has specialised event dispatcher which also handles navigator events
#if !defined(Q_OS_BLACKBERRY)
mNavigatorEventNotifier = new QBBNavigatorEventNotifier(mNavigatorEventHandler);
// delay invocation of start() to the time the event loop is up and running
// needed to have the QThread internals of the main thread properly initialized
QMetaObject::invokeMethod(mNavigatorEventNotifier, "start", Qt::QueuedConnection);
#endif
// Create displays for all possible screens (which may not be attached)
createDisplays();
// create/start event thread
#if defined(QBB_SCREENEVENTTHREAD)
mScreenEventThread = new QBBScreenEventThread(mContext, mScreenEventHandler);
mScreenEventThread->start();
#endif
#ifdef QBBLOCALETHREAD_ENABLED
// Start the locale change monitoring thread.
mLocaleThread = new QBBLocaleThread();
mLocaleThread->start();
#endif
#if defined(Q_OS_BLACKBERRY)
bps_initialize();
QBBVirtualKeyboardBps *virtualKeyboardBps = new QBBVirtualKeyboardBps;
mBpsEventFilter = new QBBBpsEventFilter(mNavigatorEventHandler,
(mScreenEventThread ? 0 : mScreenEventHandler), virtualKeyboardBps);
if (!mScreenEventThread) {
Q_FOREACH (QPlatformScreen *platformScreen, mScreens) {
QBBScreen *screen = static_cast<QBBScreen*>(platformScreen);
mBpsEventFilter->registerForScreenEvents(screen);
}
}
mBpsEventFilter->installOnEventDispatcher(QAbstractEventDispatcher::instance());
mVirtualKeyboard = virtualKeyboardBps;
#else
// create/start the keyboard class.
mVirtualKeyboard = new QBBVirtualKeyboardPps();
// delay invocation of start() to the time the event loop is up and running
// needed to have the QThread internals of the main thread properly initialized
QMetaObject::invokeMethod(mVirtualKeyboard, "start", Qt::QueuedConnection);
#endif
// TODO check if we need to do this for all screens or only the primary one
QObject::connect(mVirtualKeyboard, SIGNAL(heightChanged(int)),
primaryDisplay(), SLOT(keyboardHeightChanged(int)));
// Set up the input context
qApp->setInputContext(new QBBInputContext(*mVirtualKeyboard, qApp));
// delay invocation of start() to the time the event loop is up and running
// needed to have the QThread internals of the main thread properly initialized
QMetaObject::invokeMethod(mButtonsNotifier, "start", Qt::QueuedConnection);
}
QBBIntegration::~QBBIntegration()
{
#if defined(QBBINTEGRATION_DEBUG)
qDebug() << "QBB: platform plugin shutdown begin";
#endif
delete mNativeInterface;
// Destroy the hardware button notifier
delete mButtonsNotifier;
#ifdef QBBLOCALETHREAD_ENABLED
// stop/destroy the locale thread.
delete mLocaleThread;
#endif
#if defined(QBB_SCREENEVENTTHREAD)
// stop/destroy event thread
delete mScreenEventThread;
#elif defined(Q_OS_BLACKBERRY)
Q_FOREACH (QPlatformScreen *platformScreen, mScreens) {
QBBScreen *screen = static_cast<QBBScreen*>(platformScreen);
mBpsEventFilter->unregisterForScreenEvents(screen);
}
#endif
#if defined(Q_OS_BLACKBERRY)
delete mBpsEventFilter;
#else
// stop/destroy navigator event handling classes
delete mNavigatorEventNotifier;
#endif
// destroy the keyboard class.
delete mVirtualKeyboard;
delete mNavigatorEventHandler;
delete mScreenEventHandler;
// destroy all displays
destroyDisplays();
// close connection to QNX composition manager
screen_destroy_context(mContext);
// cleanup global OpenGL resources
QBBGLContext::shutdown();
#if defined(Q_OS_BLACKBERRY)
bps_shutdown();
#endif
#if defined(QBBINTEGRATION_DEBUG)
qDebug() << "QBB: platform plugin shutdown end";
#endif
}
bool QBBIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case ThreadedPixmaps: return true;
#if defined(QT_OPENGL_ES)
case OpenGL: return true;
#endif
default: return QPlatformIntegration::hasCapability(cap);
}
}
QPixmapData *QBBIntegration::createPixmapData(QPixmapData::PixelType type) const
{
if (paintUsingOpenGL())
return new QGLPixmapData(type);
else
return new QRasterPixmapData(type);
}
QPlatformWindow *QBBIntegration::createPlatformWindow(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
return new QBBWindow(widget, mContext, primaryDisplay());
}
QWindowSurface *QBBIntegration::createWindowSurface(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
if (paintUsingOpenGL())
return new QBBGLWindowSurface(widget);
else
return new QBBRasterWindowSurface(widget);
}
QPlatformNativeInterface *QBBIntegration::nativeInterface() const
{
return mNativeInterface;
}
void QBBIntegration::moveToScreen(QWidget *window, int screen)
{
#if defined(QBBINTEGRATION_DEBUG)
qDebug() << "QBBIntegration::moveToScreen - w=" << window << ", s=" << screen;
#endif
// get platform window used by widget
QBBWindow* platformWindow = static_cast<QBBWindow*>(window->platformWindow());
// lookup platform screen by index
QBBScreen* platformScreen = static_cast<QBBScreen*>(mScreens.at(screen));
// move the platform window to the platform screen (this can fail when move to screen
// is called before the window is actually created).
if (platformWindow && platformScreen)
platformWindow->setScreen(platformScreen);
}
QList<QPlatformScreen *> QBBIntegration::screens() const
{
return mScreens;
}
#ifndef QT_NO_CLIPBOARD
QPlatformClipboard *QBBIntegration::clipboard() const
{
static QPlatformClipboard *clipboard = 0;
if (!clipboard) {
clipboard = static_cast<QPlatformClipboard *>(new QBBClipboard);
}
return clipboard;
}
#endif
QBBScreen *QBBIntegration::screenForWindow(screen_window_t window) const
{
screen_display_t display = 0;
if (screen_get_window_property_pv(window, SCREEN_PROPERTY_DISPLAY, (void**)&display) != 0) {
qWarning("QBBIntegration: Failed to get screen for window, errno=%d", errno);
return 0;
}
Q_FOREACH (QPlatformScreen *screen, mScreens) {
QBBScreen * const bbScreen = static_cast<QBBScreen*>(screen);
if (bbScreen->nativeDisplay() == display)
return bbScreen;
}
return 0;
}
QBBScreen *QBBIntegration::primaryDisplay() const
{
return static_cast<QBBScreen*>(mScreens.first());
}
void QBBIntegration::setCursorPos(int x, int y)
{
mScreenEventThread->injectPointerMoveEvent(x, y);
}
void QBBIntegration::createDisplays()
{
// get number of displays
errno = 0;
int displayCount;
int result = screen_get_context_property_iv(mContext, SCREEN_PROPERTY_DISPLAY_COUNT, &displayCount);
if (result != 0)
qFatal("QBBIntegration: failed to query display count, errno=%d", errno);
// get all displays
errno = 0;
screen_display_t *displays = (screen_display_t *)alloca(sizeof(screen_display_t) * displayCount);
result = screen_get_context_property_pv(mContext, SCREEN_PROPERTY_DISPLAYS, (void **)displays);
if (result != 0)
qFatal("QBBIntegration: failed to query displays, errno=%d", errno);
for (int i=0; i<displayCount; i++) {
int isAttached = 0;
result = screen_get_display_property_iv(displays[i], SCREEN_PROPERTY_ATTACHED, &isAttached);
if (result != 0) {
qWarning("QBBIntegration: failed to query display attachment, errno=%d", errno);
isAttached = 1; // assume attached
}
if (!isAttached)
continue;
createDisplay(displays[i], i);
} // of displays iteration
}
void QBBIntegration::createDisplay(screen_display_t display, int screenIndex)
{
QBBScreen *screen = new QBBScreen(mContext, display, screenIndex);
mScreens.append(screen);
screen->adjustOrientation();
QObject::connect(mScreenEventHandler, SIGNAL(newWindowCreated(screen_window_t)),
screen, SLOT(newWindowCreated(screen_window_t)));
QObject::connect(mScreenEventHandler, SIGNAL(windowClosed(screen_window_t)),
screen, SLOT(windowClosed(screen_window_t)));
QObject::connect(mNavigatorEventHandler, SIGNAL(rotationChanged(int)), screen, SLOT(setRotation(int)));
QObject::connect(mNavigatorEventHandler, SIGNAL(windowGroupActivated(QByteArray)), screen, SLOT(activateWindowGroup(QByteArray)));
QObject::connect(mNavigatorEventHandler, SIGNAL(windowGroupDeactivated(QByteArray)), screen, SLOT(deactivateWindowGroup(QByteArray)));
QObject::connect(mNavigatorEventHandler, SIGNAL(windowGroupStateChanged(QByteArray,Qt::WindowState)),
screen, SLOT(windowGroupStateChanged(QByteArray,Qt::WindowState)));
}
void QBBIntegration::removeDisplay(QBBScreen *screen)
{
Q_CHECK_PTR(screen);
Q_ASSERT(mScreens.contains(screen));
mScreens.removeAll(screen);
screen->deleteLater();
}
void QBBIntegration::destroyDisplays()
{
qDeleteAll(mScreens);
mScreens.clear();
}
QBBScreen *QBBIntegration::screenForNative(screen_display_t nativeScreen) const
{
Q_FOREACH (QPlatformScreen *screen, mScreens) {
QBBScreen *bbScreen = static_cast<QBBScreen*>(screen);
if (bbScreen->nativeDisplay() == nativeScreen)
return bbScreen;
}
return 0;
}
QT_END_NAMESPACE

View file

@ -1,115 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBINTEGRATION_H
#define QBBINTEGRATION_H
#include <QtGui/QPlatformIntegration>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
class QBBScreenEventThread;
class QBBNavigatorEventHandler;
class QBBNavigatorEventNotifier;
class QBBLocaleThread;
class QBBAbstractVirtualKeyboard;
class QBBScreen;
class QBBScreenEventHandler;
class QBBNativeInterface;
class QBBBpsEventFilter;
class QBBButtonEventNotifier;
class QBBIntegration : public QPlatformIntegration
{
public:
QBBIntegration();
virtual ~QBBIntegration();
virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
virtual QPlatformNativeInterface *nativeInterface() const;
virtual QList<QPlatformScreen *> screens() const;
virtual void moveToScreen(QWidget *window, int screen);
virtual void setCursorPos(int x, int y);
virtual QPlatformFontDatabase *fontDatabase() const { return mFontDb; }
#ifndef QT_NO_CLIPBOARD
virtual QPlatformClipboard *clipboard() const;
#endif
bool paintUsingOpenGL() const { return mPaintUsingOpenGL; }
QBBScreen *screenForWindow(screen_window_t window) const;
QBBScreen *screenForNative(screen_display_t screen) const;
void createDisplay(screen_display_t display, int screenIndex);
void removeDisplay(QBBScreen *screen);
private:
QBBScreen *primaryDisplay() const;
void createDisplays();
void destroyDisplays();
screen_context_t mContext;
QBBScreenEventThread *mScreenEventThread;
QBBNavigatorEventHandler *mNavigatorEventHandler;
QBBNavigatorEventNotifier *mNavigatorEventNotifier;
QBBButtonEventNotifier *mButtonsNotifier;
QBBLocaleThread *mLocaleThread;
QPlatformFontDatabase *mFontDb;
QList<QPlatformScreen*> mScreens;
QBBScreenEventHandler *mScreenEventHandler;
bool mPaintUsingOpenGL;
QBBAbstractVirtualKeyboard *mVirtualKeyboard;
QBBNativeInterface *mNativeInterface;
QBBBpsEventFilter *mBpsEventFilter;
};
QT_END_NAMESPACE
#endif // QBBINTEGRATION_H

View file

@ -1,268 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBKEYTRANSLATOR_H
#define QBBKEYTRANSLATOR_H
#include <sys/keycodes.h>
#include <QDebug>
QT_BEGIN_NAMESPACE
Qt::Key keyTranslator( int key )
{
switch (key) {
case KEYCODE_PAUSE:
return Qt::Key_Pause;
case KEYCODE_SCROLL_LOCK:
return Qt::Key_ScrollLock;
case KEYCODE_PRINT:
return Qt::Key_Print;
case KEYCODE_SYSREQ:
return Qt::Key_SysReq;
// case KEYCODE_BREAK:
case KEYCODE_ESCAPE:
return Qt::Key_Escape;
case KEYCODE_BACKSPACE:
return Qt::Key_Backspace;
case KEYCODE_TAB:
return Qt::Key_Tab;
case KEYCODE_BACK_TAB:
return Qt::Key_Backtab;
case KEYCODE_RETURN:
return Qt::Key_Return;
case KEYCODE_CAPS_LOCK:
return Qt::Key_CapsLock;
case KEYCODE_LEFT_SHIFT:
case KEYCODE_RIGHT_SHIFT:
return Qt::Key_Shift;
case KEYCODE_LEFT_CTRL:
case KEYCODE_RIGHT_CTRL:
return Qt::Key_Control;
case KEYCODE_LEFT_ALT:
case KEYCODE_RIGHT_ALT:
return Qt::Key_Alt;
case KEYCODE_MENU:
return Qt::Key_Menu;
case KEYCODE_LEFT_HYPER:
return Qt::Key_Hyper_L;
case KEYCODE_RIGHT_HYPER:
return Qt::Key_Hyper_R;
case KEYCODE_INSERT:
return Qt::Key_Insert;
case KEYCODE_HOME:
return Qt::Key_Home;
case KEYCODE_PG_UP:
return Qt::Key_PageUp;
case KEYCODE_DELETE:
return Qt::Key_Delete;
case KEYCODE_END:
return Qt::Key_End;
case KEYCODE_PG_DOWN:
return Qt::Key_PageDown;
case KEYCODE_LEFT:
return Qt::Key_Left;
case KEYCODE_RIGHT:
return Qt::Key_Right;
case KEYCODE_UP:
return Qt::Key_Up;
case KEYCODE_DOWN:
return Qt::Key_Down;
case KEYCODE_NUM_LOCK:
return Qt::Key_NumLock;
case KEYCODE_KP_PLUS:
return Qt::Key_Plus;
case KEYCODE_KP_MINUS:
return Qt::Key_Minus;
case KEYCODE_KP_MULTIPLY:
return Qt::Key_Asterisk;
case KEYCODE_KP_DIVIDE:
return Qt::Key_Slash;
case KEYCODE_KP_ENTER:
return Qt::Key_Enter;
case KEYCODE_KP_HOME:
return Qt::Key_Home;
case KEYCODE_KP_UP:
return Qt::Key_Up;
case KEYCODE_KP_PG_UP:
return Qt::Key_PageUp;
case KEYCODE_KP_LEFT:
return Qt::Key_Left;
// Is this right?
case KEYCODE_KP_FIVE:
return Qt::Key_5;
case KEYCODE_KP_RIGHT:
return Qt::Key_Right;
case KEYCODE_KP_END:
return Qt::Key_End;
case KEYCODE_KP_DOWN:
return Qt::Key_Down;
case KEYCODE_KP_PG_DOWN:
return Qt::Key_PageDown;
case KEYCODE_KP_INSERT:
return Qt::Key_Insert;
case KEYCODE_KP_DELETE:
return Qt::Key_Delete;
case KEYCODE_F1:
return Qt::Key_F1;
case KEYCODE_F2:
return Qt::Key_F2;
case KEYCODE_F3:
return Qt::Key_F3;
case KEYCODE_F4:
return Qt::Key_F4;
case KEYCODE_F5:
return Qt::Key_F5;
case KEYCODE_F6:
return Qt::Key_F6;
case KEYCODE_F7:
return Qt::Key_F7;
case KEYCODE_F8:
return Qt::Key_F8;
case KEYCODE_F9:
return Qt::Key_F9;
case KEYCODE_F10:
return Qt::Key_F10;
case KEYCODE_F11:
return Qt::Key_F11;
case KEYCODE_F12:
return Qt::Key_F12;
// See keycodes.h for more, but these are all the basics. And printables are already included.
default:
#if defined(QBBEVENTTHREAD_DEBUG)
qDebug() << "QBB: unknown key for translation:" << key;
#endif
break;
}
return Qt::Key_Escape;
}
bool isKeypadKey( int key )
{
switch (key)
{
case KEYCODE_KP_PLUS:
case KEYCODE_KP_MINUS:
case KEYCODE_KP_MULTIPLY:
case KEYCODE_KP_DIVIDE:
case KEYCODE_KP_ENTER:
case KEYCODE_KP_HOME:
case KEYCODE_KP_UP:
case KEYCODE_KP_PG_UP:
case KEYCODE_KP_LEFT:
case KEYCODE_KP_FIVE:
case KEYCODE_KP_RIGHT:
case KEYCODE_KP_END:
case KEYCODE_KP_DOWN:
case KEYCODE_KP_PG_DOWN:
case KEYCODE_KP_INSERT:
case KEYCODE_KP_DELETE:
return true;
default:
break;
}
return false;
}
QT_END_NAMESPACE
#endif // QBBKEYTRANSLATOR_H

View file

@ -1,139 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBLOCALETHREAD_DEBUG
#ifdef QBBLOCALETHREAD_ENABLED
#include "qbblocalethread.h"
#include <QtGui/QApplication>
#include <QtGui/QWidget>
#include <QtGui/QWindowSystemInterface>
#include <QByteArray>
#include <QList>
#include <QDebug>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#define NAV_CONTROL_PATH "/pps/services/confstr/_CS_LOCALE"
#define PPS_BUFFER_SIZE 4096
QBBLocaleThread::QBBLocaleThread()
: mFd(-1),
mQuit(false)
{
}
QBBLocaleThread::~QBBLocaleThread()
{
// block until thread terminates
shutdown();
}
void QBBLocaleThread::run()
{
#if defined(QBBLOCALETHREAD_DEBUG)
qDebug() << "QBB: Locale thread started";
#endif
// open connection to Locale
errno = 0;
mFd = open(NAV_CONTROL_PATH, O_RDONLY);
if (mFd == -1) {
qWarning("QBB: failed to open Locale pps, errno=%d", errno);
return;
}
// allocate buffer for pps data
char buffer[PPS_BUFFER_SIZE];
// loop indefinitely
while (!mQuit) {
// attempt to read pps data
errno = 0;
int bytes = read(mFd, buffer, PPS_BUFFER_SIZE - 1);
if (bytes == -1) {
qWarning("QBB: failed to read Locale pps, errno=%d", errno);
return;
}
// check if pps data was received
if (bytes > 0) {
// Notify the world that the locale has changed.
QWindowSystemInterface::handleLocaleChange();
}
// yield
msleep(5);
}
// close connection to Locale
close(mFd);
#if defined(QBBLOCALETHREAD_DEBUG)
qDebug() << "QBB: Locale thread stopped";
#endif
}
void QBBLocaleThread::shutdown()
{
// signal thread to terminate
mQuit = true;
#if defined(QBBLOCALETHREAD_DEBUG)
qDebug() << "QBB: Locale thread shutdown begin";
#endif
// block until thread terminates
wait();
#if defined(QBBLOCALETHREAD_DEBUG)
qDebug() << "QBB: Locale thread shutdown end";
#endif
}
#endif // QBBLOCALETHREAD_ENABLED

View file

@ -1,71 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifdef QBBLOCALETHREAD_ENABLED
#ifndef QBBLOCALETHREAD_H
#define QBBLOCALETHREAD_H
#include <QThread>
QT_BEGIN_NAMESPACE
class QBBLocaleThread : public QThread
{
public:
QBBLocaleThread();
virtual ~QBBLocaleThread();
protected:
virtual void run();
private:
int mFd;
bool mQuit;
void shutdown();
};
QT_END_NAMESPACE
#endif // QBBLOCALETHREAD_H
#endif // QBBLOCALETHREAD_ENABLED

View file

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qbbnativeinterface.h"
#include "qbbintegration.h"
#include "qbbscreen.h"
#include <QtGui/QWidget>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
QBBNativeInterface::QBBNativeInterface(QBBIntegration *integration)
: mIntegration(integration)
{
}
void *QBBNativeInterface::nativeResourceForWidget(const QByteArray &resource, QWidget *widget)
{
if (resource == "windowGroup" && widget) {
const QWidget * const nativeWidget =
widget->parentWidget() ? widget->nativeParentWidget() : widget;
const screen_window_t window = reinterpret_cast<screen_window_t>(nativeWidget->winId());
const QBBScreen * const screen = mIntegration->screenForWindow(window);
if (screen) {
// We can't just call data() instead of constData() here, since that would detach
// and the lifetime of the char * would not be long enough. Therefore the const_cast.
return const_cast<char *>(screen->rootWindow()->groupName().constData());
}
}
return 0;
}
QT_END_NAMESPACE

View file

@ -1,63 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBNATIVEINTERFACE_H
#define QBBNATIVEINTERFACE_H
#include <QtGui/QPlatformNativeInterface>
QT_BEGIN_NAMESPACE
class QBBIntegration;
class QBBNativeInterface : public QPlatformNativeInterface
{
public:
explicit QBBNativeInterface(QBBIntegration *integration);
virtual void *nativeResourceForWidget(const QByteArray &resource, QWidget *widget);
private:
QBBIntegration *mIntegration;
};
QT_END_NAMESPACE
#endif

View file

@ -1,128 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBNAVIGATOREVENTHANDLER_DEBUG
#include "qbbnavigatoreventhandler.h"
#include <QApplication>
#include <QDebug>
#include <QWidget>
#include <QWindowSystemInterface>
QT_BEGIN_NAMESPACE
QBBNavigatorEventHandler::QBBNavigatorEventHandler(QObject *parent)
: QObject(parent)
{
}
bool QBBNavigatorEventHandler::handleOrientationCheck(int angle)
{
#if defined(QBBNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << Q_FUNC_INFO << "angle=" << angle;
#else
Q_UNUSED(angle);
#endif
// reply to navigator that (any) orientation is acceptable
// TODO: check if top window flags prohibit orientation change
return true;
}
void QBBNavigatorEventHandler::handleOrientationChange(int angle)
{
// update screen geometry and reply to navigator that we're ready
#if defined(QBBNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << Q_FUNC_INFO << "angle=" << angle;
#endif
emit rotationChanged(angle);
}
void QBBNavigatorEventHandler::handleSwipeDown()
{
#if defined(QBBNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
QWidget *w = QApplication::activeWindow();
if (w)
QWindowSystemInterface::handlePlatformPanelEvent(w);
}
void QBBNavigatorEventHandler::handleExit()
{
// shutdown everything
#if defined(QBBNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
QApplication::quit();
}
void QBBNavigatorEventHandler::handleWindowGroupActivated(const QByteArray &id)
{
#if defined(QBBNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << Q_FUNC_INFO << id;
#endif
Q_EMIT windowGroupActivated(id);
}
void QBBNavigatorEventHandler::handleWindowGroupDeactivated(const QByteArray &id)
{
#if defined(QBBNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << Q_FUNC_INFO << id;
#endif
Q_EMIT windowGroupDeactivated(id);
}
void QBBNavigatorEventHandler::handleWindowGroupStateChanged(const QByteArray &id, Qt::WindowState state)
{
#if defined(QBBNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << Q_FUNC_INFO << id;
#endif
Q_EMIT windowGroupStateChanged(id, state);
}
QT_END_NAMESPACE

View file

@ -1,72 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBNAVIGATOREVENTHANDLER_H
#define QBBNAVIGATOREVENTHANDLER_H
#include <QObject>
QT_BEGIN_NAMESPACE
class QBBNavigatorEventHandler : public QObject
{
Q_OBJECT
public:
explicit QBBNavigatorEventHandler(QObject *parent = 0);
bool handleOrientationCheck(int angle);
void handleOrientationChange(int angle);
void handleSwipeDown();
void handleExit();
void handleWindowGroupActivated(const QByteArray &id);
void handleWindowGroupDeactivated(const QByteArray &id);
void handleWindowGroupStateChanged(const QByteArray &id, Qt::WindowState state);
Q_SIGNALS:
void rotationChanged(int angle);
void windowGroupActivated(const QByteArray &id);
void windowGroupDeactivated(const QByteArray &id);
void windowGroupStateChanged(const QByteArray &id, Qt::WindowState state);
};
QT_END_NAMESPACE
#endif // QBBNAVIGATOREVENTHANDLER_H

View file

@ -1,234 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBNAVIGATOREVENTNOTIFIER_DEBUG
#include "qbbnavigatoreventnotifier.h"
#include "qbbnavigatoreventhandler.h"
#include <QtCore/qcore_unix_p.h>
#include <QByteArray>
#include <QList>
#include <QDebug>
#include <QSocketNotifier>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#define NAV_CONTROL_PATH "/pps/services/navigator/control"
#define PPS_BUFFER_SIZE 4096
QBBNavigatorEventNotifier::QBBNavigatorEventNotifier(QBBNavigatorEventHandler *eventHandler, QObject *parent)
: QObject(parent),
mEventHandler(eventHandler),
mFd(-1),
mReadNotifier(0)
{
}
QBBNavigatorEventNotifier::~QBBNavigatorEventNotifier()
{
delete mReadNotifier;
if (mFd != -1)
qt_safe_close(mFd);
#if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG)
qDebug() << "QBB: navigator event notifier stopped";
#endif
}
void QBBNavigatorEventNotifier::start()
{
#if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG)
qDebug() << "QBB: navigator event notifier started";
#endif
// open connection to navigator
errno = 0;
mFd = qt_safe_open(NAV_CONTROL_PATH, O_RDWR);
if (mFd == -1) {
qWarning("QBB: failed to open navigator pps, errno=%d", errno);
return;
}
mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read);
connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readData()));
}
void QBBNavigatorEventNotifier::parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id)
{
#if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG)
qDebug() << "PPS: data=" << ppsData;
#endif
// tokenize pps data into lines
QList<QByteArray> lines = ppsData.split('\n');
// validate pps object
if (lines.size() == 0 || lines.at(0) != "@control")
qFatal("QBB: unrecognized pps object, data=%s", ppsData.constData());
// parse pps object attributes and extract values
for (int i = 1; i < lines.size(); i++) {
// tokenize current attribute
const QByteArray &attr = lines.at(i);
#if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG)
qDebug() << "PPS: attr=" << attr;
#endif
int firstColon = attr.indexOf(':');
if (firstColon == -1) {
// abort - malformed attribute
continue;
}
int secondColon = attr.indexOf(':', firstColon + 1);
if (secondColon == -1) {
// abort - malformed attribute
continue;
}
QByteArray key = attr.left(firstColon);
QByteArray value = attr.mid(secondColon + 1);
#if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG)
qDebug() << "PPS: key=" << key;
qDebug() << "PPS: val=" << value;
#endif
// save attribute value
if (key == "msg")
msg = value;
else if (key == "dat")
dat = value;
else if (key == "id")
id = value;
else
qFatal("QBB: unrecognized pps attribute, attr=%s", key.constData());
}
}
void QBBNavigatorEventNotifier::replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat)
{
// construct pps message
QByteArray ppsData = "res::";
ppsData += res;
ppsData += "\nid::";
ppsData += id;
if (!dat.isEmpty()) {
ppsData += "\ndat::";
ppsData += dat;
}
ppsData += "\n";
#if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG)
qDebug() << "PPS reply=" << ppsData;
#endif
// send pps message to navigator
errno = 0;
int bytes = write(mFd, ppsData.constData(), ppsData.size());
if (bytes == -1)
qFatal("QBB: failed to write navigator pps, errno=%d", errno);
}
void QBBNavigatorEventNotifier::handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id)
{
#if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG)
qDebug() << "PPS: msg=" << msg << ", dat=" << dat << ", id=" << id;
#endif
// check message type
if (msg == "orientationCheck") {
const bool result = mEventHandler->handleOrientationCheck(dat.toInt());
replyPPS(msg, id, result ? "true": "false");
} else if (msg == "orientation") {
mEventHandler->handleOrientationChange(dat.toInt());
replyPPS(msg, id, "");
} else if (msg == "SWIPE_DOWN") {
mEventHandler->handleSwipeDown();
} else if (msg == "exit") {
mEventHandler->handleExit();
} else if (msg == "windowActive") {
mEventHandler->handleWindowGroupActivated(dat);
} else if (msg == "windowInactive") {
mEventHandler->handleWindowGroupDeactivated(dat);
}
}
void QBBNavigatorEventNotifier::readData()
{
#if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG)
qDebug() << "QBB: reading navigator data";
#endif
// allocate buffer for pps data
char buffer[PPS_BUFFER_SIZE];
// attempt to read pps data
errno = 0;
int bytes = qt_safe_read(mFd, buffer, PPS_BUFFER_SIZE - 1);
if (bytes == -1)
qFatal("QBB: failed to read navigator pps, errno=%d", errno);
// check if pps data was received
if (bytes > 0) {
// ensure data is null terminated
buffer[bytes] = '\0';
// process received message
QByteArray ppsData(buffer);
QByteArray msg;
QByteArray dat;
QByteArray id;
parsePPS(ppsData, msg, dat, id);
handleMessage(msg, dat, id);
}
}

View file

@ -1,77 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBNAVIGATOREVENTNOTIFIER_H
#define QBBNAVIGATOREVENTNOTIFIER_H
#include <QObject>
QT_BEGIN_NAMESPACE
class QBBNavigatorEventHandler;
class QSocketNotifier;
class QBBNavigatorEventNotifier : public QObject
{
Q_OBJECT
public:
explicit QBBNavigatorEventNotifier(QBBNavigatorEventHandler *eventHandler, QObject *parent = 0);
~QBBNavigatorEventNotifier();
public Q_SLOTS:
void start();
private Q_SLOTS:
void readData();
private:
QBBNavigatorEventHandler *mEventHandler;
int mFd;
QSocketNotifier *mReadNotifier;
void parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id);
void replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat);
void handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id);
};
QT_END_NAMESPACE
#endif // QBBNAVIGATOREVENTNOTIFIER_H

View file

@ -1,191 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
// #define QBBRASTERWINDOWSURFACE_DEBUG
#include "qbbrasterwindowsurface.h"
#include "qbbwindow.h"
#include <QtGui/QWidget>
#include <QDebug>
#include <errno.h>
QT_BEGIN_NAMESPACE
QBBRasterWindowSurface::QBBRasterWindowSurface(QWidget *window)
: QWindowSurface(window),
mUseFrontBuffer(false)
{
#if defined(QBBRASTERWINDOWSURFACE_DEBUG)
qDebug() << "QBBRasterWindowSurface::QBBRasterWindowSurface - w=" << window;
#endif
// save platform window associated with widget
mPlatformWindow = static_cast<QBBWindow*>(window->platformWindow());
}
QBBRasterWindowSurface::~QBBRasterWindowSurface()
{
#if defined(QBBRASTERWINDOWSURFACE_DEBUG)
qDebug() << "QBBRasterWindowSurface::~QBBRasterWindowSurface - w=" << window();
#endif
}
QPaintDevice *QBBRasterWindowSurface::paintDevice()
{
if (mPlatformWindow->hasBuffers())
return (mUseFrontBuffer) ? mPlatformWindow->frontBuffer().image()
: mPlatformWindow->renderBuffer().image();
return 0;
}
void QBBRasterWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(widget);
Q_UNUSED(offset);
#if defined(QBBRASTERWINDOWSURFACE_DEBUG)
qDebug() << "QBBRasterWindowSurface::flush - w=" << window();
#endif
// visit all pending scroll operations
for (int i = mScrollOpList.size() - 1; i >= 0; i--) {
// do the scroll operation
ScrollOp& op = mScrollOpList[i];
QRegion srcArea = op.totalArea.intersected( op.totalArea.translated(-op.dx, -op.dy) );
mPlatformWindow->scroll(srcArea, op.dx, op.dy);
}
// clear all pending scroll operations
mScrollOpList.clear();
// update the display with newly rendered content
mPlatformWindow->post(region);
}
void QBBRasterWindowSurface::resize(const QSize &size)
{
#if defined(QBBRASTERWINDOWSURFACE_DEBUG)
qDebug() << "QBBRasterWindowSurface::resize - w=" << window() << ", s=" << size;
#endif
// call parent method
QWindowSurface::resize(size);
// NOTE: defer resizing window buffers until next paint as
// resize() can be called multiple times before a paint occurs
}
bool QBBRasterWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
#if defined(QBBRASTERWINDOWSURFACE_DEBUG)
qDebug() << "QBBRasterWindowSurface::scroll - w=" << window();
#endif
// calculate entire region affected by scroll operation (src + dst)
QRegion totalArea = area.translated(dx, dy);
totalArea += area;
// visit all pending scroll operations
for (int i = mScrollOpList.size() - 1; i >= 0; i--) {
ScrollOp& op = mScrollOpList[i];
if (op.totalArea == totalArea) {
// same area is being scrolled again - update delta
op.dx += dx;
op.dy += dy;
return true;
} else if (op.totalArea.intersects(totalArea)) {
// current scroll overlaps previous scroll but is
// not equal in area - just paint everything
qWarning("QBB: pending scroll operations overlap but not equal");
return false;
}
}
// create new scroll operation
mScrollOpList.append( ScrollOp(totalArea, dx, dy) );
return true;
}
void QBBRasterWindowSurface::beginPaint(const QRegion &region)
{
Q_UNUSED(region);
#if defined(QBBRASTERWINDOWSURFACE_DEBUG)
qDebug() << "QBBRasterWindowSurface::beginPaint - w=" << window();
#endif
// resize window buffers if surface resized
QSize s = size();
if (s != mPlatformWindow->bufferSize()) {
mPlatformWindow->setBufferSize(s);
}
}
void QBBRasterWindowSurface::endPaint(const QRegion &region)
{
Q_UNUSED(region);
#if defined(QBBRASTERWINDOWSURFACE_DEBUG)
qDebug() << "QBBRasterWindowSurface::endPaint - w=" << window();
#endif
}
QPixmap QBBRasterWindowSurface::grabWidget(const QWidget *widget, const QRect &rectangle) const
{
// mUseFrontBuffer is used as a workaround to tell
// QBBRasterWindowSurface::paintDevice() to return the
// front buffer instead of the renderBuffer. grabWidget()
// is the only use case.
mUseFrontBuffer = true;
QPixmap pixmap = QWindowSurface::grabWidget(widget, rectangle);
mUseFrontBuffer = false;
return pixmap;
}
QT_END_NAMESPACE

View file

@ -1,85 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBRASTERWINDOWSURFACE_H
#define QBBRASTERWINDOWSURFACE_H
#include <QtGui/qwindowsurface_p.h>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
class QBBWindow;
class QBBRasterWindowSurface : public QWindowSurface
{
public:
QBBRasterWindowSurface(QWidget *window);
virtual ~QBBRasterWindowSurface();
virtual QPaintDevice *paintDevice();
virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
virtual void resize(const QSize &size);
virtual bool scroll(const QRegion &area, int dx, int dy);
virtual void beginPaint(const QRegion &region);
virtual void endPaint(const QRegion &region);
virtual QPixmap grabWidget(const QWidget *widget, const QRect &rectangle) const;
private:
class ScrollOp {
public:
ScrollOp(const QRegion& a, int x, int y) : totalArea(a), dx(x), dy(y) {}
QRegion totalArea;
int dx;
int dy;
};
mutable bool mUseFrontBuffer;
QBBWindow *mPlatformWindow;
QList<ScrollOp> mScrollOpList;
};
QT_END_NAMESPACE
#endif // QBBRASTERWINDOWSURFACE_H

View file

@ -1,257 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qbbrootwindow.h"
#include "qbbscreen.h"
#include <QtCore/QUuid>
#if defined(QBBROOTWINDOW_DEBUG)
#include <QtCore/QDebug>
#endif
#include <errno.h>
#include <unistd.h>
static const int MAGIC_ZORDER_FOR_NO_NAV = 10;
QBBRootWindow::QBBRootWindow(QBBScreen *screen)
: m_screen(screen),
m_window(0),
m_windowGroupName()
{
#if defined(QBBROOTWINDOW_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
// Create one top-level QNX window to act as a container for child windows
// since navigator only supports one application window
errno = 0;
int result = screen_create_window(&m_window, m_screen->nativeContext());
int val[2];
if (result != 0) {
qFatal("QBBRootWindow: failed to create window, errno=%d", errno);
}
// Move window to proper display
errno = 0;
screen_display_t display = m_screen->nativeDisplay();
result = screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (void **)&display);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window display, errno=%d", errno);
}
// Make sure window is above navigator but below keyboard if running as root
// since navigator won't automatically set our z-order in this case
if (getuid() == 0) {
errno = 0;
val[0] = MAGIC_ZORDER_FOR_NO_NAV;
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ZORDER, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window z-order, errno=%d", errno);
}
}
// Window won't be visible unless it has some buffers so make one dummy buffer that is 1x1
errno = 0;
val[0] = SCREEN_USAGE_NATIVE;
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_USAGE, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window buffer usage, errno=%d", errno);
}
errno = 0;
val[0] = m_screen->nativeFormat();
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window pixel format, errno=%d", errno);
}
errno = 0;
val[0] = 1;
val[1] = 1;
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window buffer size, errno=%d", errno);
}
errno = 0;
result = screen_create_window_buffers(m_window, 1);
if (result != 0) {
qFatal("QBB: failed to create window buffer, errno=%d", errno);
}
// Window is always the size of the display
errno = 0;
QRect geometry = m_screen->geometry();
val[0] = geometry.width();
val[1] = geometry.height();
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window size, errno=%d", errno);
}
// Fill the window with solid black
errno = 0;
val[0] = 0;
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_COLOR, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window colour, errno=%d", errno);
}
// Make the window opaque
errno = 0;
val[0] = SCREEN_TRANSPARENCY_NONE;
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window transparency, errno=%d", errno);
}
// Set the swap interval to 1
errno = 0;
val[0] = 1;
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window swap interval, errno=%d", errno);
}
// Set viewport size equal to window size but move outside buffer so the fill colour is used exclusively
errno = 0;
val[0] = geometry.width();
val[1] = geometry.height();
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window source size, errno=%d", errno);
}
errno = 0;
val[0] = 1;
val[1] = 0;
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_POSITION, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window source position, errno=%d", errno);
}
createWindowGroup();
post();
}
QBBRootWindow::~QBBRootWindow()
{
// Cleanup top-level QNX window
screen_destroy_window(m_window);
}
void QBBRootWindow::post() const
{
#if defined(QBBROOTWINDOW_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
errno = 0;
screen_buffer_t buffer;
int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&buffer);
if (result != 0) {
qFatal("QBBRootWindow: failed to query window buffer, errno=%d", errno);
}
errno = 0;
int dirtyRect[] = {0, 0, 1, 1};
result = screen_post_window(m_window, buffer, 1, dirtyRect, 0);
if (result != 0) {
qFatal("QBB: failed to post window buffer, errno=%d", errno);
}
}
void QBBRootWindow::flush() const
{
#if defined(QBBROOTWINDOW_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
// Force immediate display update
errno = 0;
int result = screen_flush_context(m_screen->nativeContext(), 0);
if (result != 0) {
qFatal("QBBRootWindow: failed to flush context, errno=%d", errno);
}
}
void QBBRootWindow::setRotation(int rotation)
{
#if defined(QBBROOTWINDOW_DEBUG)
qDebug() << Q_FUNC_INFO << "angle =" << rotation;
#endif
errno = 0;
int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &rotation);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window rotation, errno=%d", errno);
}
}
void QBBRootWindow::resize(const QSize &size)
{
errno = 0;
int val[] = {size.width(), size.height()};
int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window size, errno=%d", errno);
}
errno = 0;
result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val);
if (result != 0) {
qFatal("QBBRootWindow: failed to set window source size, errno=%d", errno);
}
// NOTE: display will update when child windows relayout and repaint
}
void QBBRootWindow::createWindowGroup()
{
// Generate a random window group name
m_windowGroupName = QUuid::createUuid().toString().toAscii();
// Create window group so child windows can be parented by container window
errno = 0;
int result = screen_create_window_group(m_window, m_windowGroupName.constData());
if (result != 0) {
qFatal("QBBRootWindow: failed to create app window group, errno=%d", errno);
}
}

View file

@ -1,81 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBROOTWINDOW_H
#define QBBROOTWINDOW_H
#include <QtCore/QByteArray>
#include <QtCore/QRect>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
class QBBScreen;
class QBBRootWindow
{
public:
QBBRootWindow(QBBScreen *screen);
~QBBRootWindow();
screen_window_t nativeHandle() const { return m_window; }
void post() const;
void flush() const;
void setRotation(int rotation);
void resize(const QSize &size);
QByteArray groupName() const { return m_windowGroupName; }
private:
void createWindowGroup();
QBBScreen *m_screen;
screen_window_t m_window;
QByteArray m_windowGroupName;
};
QT_END_NAMESPACE
#endif // QBBROOTWINDOW_H

View file

@ -1,595 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
// #define QBBSCREEN_DEBUG
#include "qbbscreen.h"
#include "qbbrootwindow.h"
#include "qbbwindow.h"
#include "qbbcursor.h"
#include <QDebug>
#include <QtCore/QThread>
#include <QtGui/QWindowSystemInterface>
#include <errno.h>
#include <unistd.h>
QT_BEGIN_NAMESPACE
#if defined(QBB_PHYSICAL_SCREEN_WIDTH) && QBB_PHYSICAL_SCREEN_WIDTH > 0 \
&& defined(QBB_PHYSICAL_SCREEN_HEIGHT) && QBB_PHYSICAL_SCREEN_HEIGHT > 0
#define QBB_PHYSICAL_SCREEN_SIZE_DEFINED
#elif defined(QBB_PHYSICAL_SCREEN_WIDTH) || defined(QBB_PHYSICAL_SCREEN_HEIGHT)
#error Please define QBB_PHYSICAL_SCREEN_WIDTH and QBB_PHYSICAL_SCREEN_HEIGHT to values greater than zero
#endif
QT_BEGIN_NAMESPACE
static QSize determineScreenSize(screen_display_t display, bool primaryScreen)
{
int val[2];
errno = 0;
const int result = screen_get_display_property_iv(display, SCREEN_PROPERTY_PHYSICAL_SIZE, val);
if (result != 0) {
qFatal("QBBScreen: failed to query display physical size, errno=%d", errno);
return QSize(150, 90);
}
if (val[0] > 0 && val[1] > 0)
return QSize(val[0], val[1]);
qWarning("QBBScreen: screen_get_display_property_iv() reported an invalid physical screen size (%dx%d). Falling back to QBB_PHYSICAL_SCREEN_SIZE environment variable.", val[0], val[1]);
const QString envPhySizeStr = qgetenv("QBB_PHYSICAL_SCREEN_SIZE");
if (!envPhySizeStr.isEmpty()) {
const QStringList envPhySizeStrList = envPhySizeStr.split(QLatin1Char(','));
const int envWidth = envPhySizeStrList.size() == 2 ? envPhySizeStrList[0].toInt() : -1;
const int envHeight = envPhySizeStrList.size() == 2 ? envPhySizeStrList[1].toInt() : -1;
if (envWidth <= 0 || envHeight <= 0) {
qFatal("QBBScreen: The value of QBB_PHYSICAL_SCREEN_SIZE must be in the format \"width,height\" in mm, with width, height > 0. Example: QBB_PHYSICAL_SCREEN_SIZE=150,90");
return QSize(150, 90);
}
return QSize(envWidth, envHeight);
}
#if defined(QBB_PHYSICAL_SCREEN_SIZE_DEFINED)
const QSize defSize(QBB_PHYSICAL_SCREEN_WIDTH, QBB_PHYSICAL_SCREEN_HEIGHT);
qWarning("QBBScreen: QBB_PHYSICAL_SCREEN_SIZE variable not set. Falling back to defines QBB_PHYSICAL_SCREEN_WIDTH/QBB_PHYSICAL_SCREEN_HEIGHT (%dx%d)", defSize.width(), defSize.height());
return defSize;
#else
if (primaryScreen)
qFatal("QBBScreen: QBB_PHYSICAL_SCREEN_SIZE variable not set. Could not determine physical screen size.");
return QSize(150, 90);
#endif
}
QBBScreen::QBBScreen(screen_context_t context, screen_display_t display, int screenIndex)
: mContext(context),
mDisplay(display),
mPosted(false),
mUsingOpenGL(false),
mPrimaryDisplay(screenIndex == 0),
mKeyboardHeight(0),
mScreenIndex(screenIndex),
mCursor(new QBBCursor(this))
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::QBBScreen";
#endif
// cache initial orientation of this display
// TODO: use ORIENTATION environment variable?
errno = 0;
int result = screen_get_display_property_iv(mDisplay, SCREEN_PROPERTY_ROTATION, &mStartRotation);
if (result != 0) {
qFatal("QBBScreen: failed to query display rotation, errno=%d", errno);
}
mCurrentRotation = mStartRotation;
// cache size of this display in pixels
// TODO: use WIDTH and HEIGHT environment variables?
errno = 0;
int val[2];
result = screen_get_display_property_iv(mDisplay, SCREEN_PROPERTY_SIZE, val);
if (result != 0) {
qFatal("QBBScreen: failed to query display size, errno=%d", errno);
}
mCurrentGeometry = mStartGeometry = QRect(0, 0, val[0], val[1]);
// Cache size of this display in millimeters
mStartPhysicalSize = determineScreenSize(mDisplay, mPrimaryDisplay);
// swap physical dimensions when rotated orthogonally
if (mStartRotation == 90 || mStartRotation == 270)
mStartPhysicalSize.transpose();
mCurrentPhysicalSize = mStartPhysicalSize;
// We only create the root window if we are not the primary display.
if (mPrimaryDisplay)
mRootWindow = QSharedPointer<QBBRootWindow>(new QBBRootWindow(this));
}
QBBScreen::~QBBScreen()
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::~QBBScreen";
#endif
}
static int defaultDepth()
{
static int defaultDepth = 0;
if (defaultDepth == 0) {
// check if display depth was specified in environment variable;
// use default value if no valid value found
defaultDepth = qgetenv("QBB_DISPLAY_DEPTH").toInt();
if (defaultDepth != 16 && defaultDepth != 32) {
defaultDepth = 32;
}
}
return defaultDepth;
}
void QBBScreen::ensureDisplayCreated()
{
if (!mRootWindow)
mRootWindow = QSharedPointer<QBBRootWindow>(new QBBRootWindow(this));
}
void QBBScreen::newWindowCreated(screen_window_t window)
{
Q_ASSERT(thread() == QThread::currentThread());
screen_display_t display = 0;
if (screen_get_window_property_pv(window, SCREEN_PROPERTY_DISPLAY, (void**)&display) != 0) {
qWarning("QBBScreen: Failed to get screen for window, errno=%d", errno);
return;
}
if (display == nativeDisplay()) {
// A window was created on this screen. If we don't know about this window yet, it means
// it was not created by Qt, but by some foreign library like the multimedia renderer, which
// creates an overlay window when playing a video.
// Treat all foreign windows as overlays here.
if (!findWindow(window))
addOverlayWindow(window);
}
}
void QBBScreen::windowClosed(screen_window_t window)
{
Q_ASSERT(thread() == QThread::currentThread());
removeOverlayWindow(window);
}
QRect QBBScreen::availableGeometry() const
{
// available geometry = total geometry - keyboard
return QRect(mCurrentGeometry.x(), mCurrentGeometry.y(),
mCurrentGeometry.width(), mCurrentGeometry.height() - mKeyboardHeight);
}
int QBBScreen::depth() const
{
return defaultDepth();
}
/*!
Check if the supplied angles are perpendicular to each other.
*/
static bool isOrthogonal(int angle1, int angle2)
{
return ((angle1 - angle2) % 180) != 0;
}
void QBBScreen::setRotation(int rotation)
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::setRotation, o=" << rotation;
#endif
// check if rotation changed
if (mCurrentRotation != rotation) {
// update rotation of root window
if (mRootWindow)
mRootWindow->setRotation(rotation);
const QRect previousScreenGeometry = geometry();
// swap dimensions if we've rotated 90 or 270 from initial orientation
if (isOrthogonal(mStartRotation, rotation)) {
mCurrentGeometry = QRect(0, 0, mStartGeometry.height(), mStartGeometry.width());
mCurrentPhysicalSize = QSize(mStartPhysicalSize.height(), mStartPhysicalSize.width());
} else {
mCurrentGeometry = QRect(0, 0, mStartGeometry.width(), mStartGeometry.height());
mCurrentPhysicalSize = mStartPhysicalSize;
}
// resize app window if we've rotated 90 or 270 from previous orientation
if (isOrthogonal(mCurrentRotation, rotation)) {
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::setRotation - resize, s=" << mCurrentGeometry.size();
#endif
if (mRootWindow)
mRootWindow->resize(mCurrentGeometry.size());
if (mPrimaryDisplay)
resizeWindows(previousScreenGeometry);
} else {
// TODO: find one global place to flush display updates
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::setRotation - flush";
#endif
// force immediate display update if no geometry changes required
if (mRootWindow)
mRootWindow->flush();
}
// save new rotation
mCurrentRotation = rotation;
// TODO: check if other screens are supposed to rotate as well and/or whether this depends
// on if clone mode is being used.
// Rotating only the primary screen is what we had in the navigator event handler before refactoring
if (mPrimaryDisplay)
QWindowSystemInterface::handleScreenGeometryChange(mScreenIndex);
// Flush everything, so that the windows rotations are applied properly.
// Needed for non-maximized windows
screen_flush_context(mContext, 0);
}
}
void QBBScreen::resizeNativeWidgetWindow(QBBWindow *w, const QRect &previousScreenGeometry) const
{
const qreal relativeX = static_cast<qreal>(w->geometry().topLeft().x()) / previousScreenGeometry.width();
const qreal relativeY = static_cast<qreal>(w->geometry().topLeft().y()) / previousScreenGeometry.height();
const qreal relativeWidth = static_cast<qreal>(w->geometry().width()) / previousScreenGeometry.width();
const qreal relativeHeight = static_cast<qreal>(w->geometry().height()) / previousScreenGeometry.height();
const QRect windowGeometry(relativeX * geometry().width(), relativeY * geometry().height(),
relativeWidth * geometry().width(), relativeHeight * geometry().height());
w->widget()->setGeometry(windowGeometry);
}
/*!
Resize the given window to fit the screen geometry
*/
void QBBScreen::resizeTopLevelWindow(QBBWindow *w, const QRect &previousScreenGeometry) const
{
QRect windowGeometry = w->geometry();
const qreal relativeCenterX = static_cast<qreal>(w->geometry().center().x()) / previousScreenGeometry.width();
const qreal relativeCenterY = static_cast<qreal>(w->geometry().center().y()) / previousScreenGeometry.height();
const QPoint newCenter(relativeCenterX * geometry().width(), relativeCenterY * geometry().height());
windowGeometry.moveCenter(newCenter);
// adjust center position in case the window
// is clipped
if (!geometry().contains(windowGeometry)) {
const int x1 = windowGeometry.x();
const int y1 = windowGeometry.y();
const int x2 = x1 + windowGeometry.width();
const int y2 = y1 + windowGeometry.height();
if (x1 < 0) {
const int centerX = qMin(qAbs(x1) + windowGeometry.center().x(),
geometry().center().x());
windowGeometry.moveCenter(QPoint(centerX, windowGeometry.center().y()));
}
if (y1 < 0) {
const int centerY = qMin(qAbs(y1) + windowGeometry.center().y(),
geometry().center().y());
windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), centerY));
}
if (x2 > geometry().width()) {
const int centerX = qMax(windowGeometry.center().x() - (x2 - geometry().width()),
geometry().center().x());
windowGeometry.moveCenter(QPoint(centerX, windowGeometry.center().y()));
}
if (y2 > geometry().height()) {
const int centerY = qMax(windowGeometry.center().y() - (y2 - geometry().height()),
geometry().center().y());
windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), centerY));
}
}
// at this point, if the window is still clipped,
// it means that it's too big to fit on the screen,
// so we need to proportionally shrink it
if (!geometry().contains(windowGeometry)) {
QSize newSize = windowGeometry.size();
newSize.scale(geometry().size(), Qt::KeepAspectRatio);
windowGeometry.setSize(newSize);
if (windowGeometry.x() < 0)
windowGeometry.moveCenter(QPoint(geometry().center().x(), windowGeometry.center().y()));
if (windowGeometry.y() < 0)
windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), geometry().center().y()));
}
w->widget()->setGeometry(windowGeometry);
}
/*!
Adjust windows to the new screen geometry.
*/
void QBBScreen::resizeWindows(const QRect &previousScreenGeometry)
{
Q_FOREACH (QBBWindow *w, mChildren) {
if (w->widget()->windowState() & Qt::WindowFullScreen || w->widget()->windowState() & Qt::WindowMaximized)
continue;
if (w->widget()->parent()) {
// This is a native (non-alien) widget window
resizeNativeWidgetWindow(w, previousScreenGeometry);
} else {
// This is a toplevel window
resizeTopLevelWindow(w, previousScreenGeometry);
}
}
}
QBBWindow *QBBScreen::findWindow(screen_window_t windowHandle)
{
Q_FOREACH (QBBWindow *window, mChildren) {
QBBWindow * const result = window->findWindow(windowHandle);
if (result)
return result;
}
return 0;
}
void QBBScreen::addWindow(QBBWindow* window)
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::addWindow=" << window;
#endif
if (mChildren.contains(window))
return;
// Ensure that the desktop window is at the bottom of the zorder.
// If we do not do this then we may end up activating the desktop
// when the navigator service gets an event that our window group
// has been activated (see QBBScreen::activateWindowGroup()).
// Such a situation would strangely break focus handling due to the
// invisible desktop widget window being layered on top of normal
// windows
if (window->widget()->windowType() == Qt::Desktop)
mChildren.push_front(window);
else
mChildren.push_back(window);
updateHierarchy();
}
void QBBScreen::removeWindow(QBBWindow* window)
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::removeWindow=" << window;
#endif
const int numWindowsRemoved = mChildren.removeAll(window);
if (numWindowsRemoved > 0)
updateHierarchy();
}
void QBBScreen::raiseWindow(QBBWindow* window)
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::raise window=" << window;
#endif
removeWindow(window);
mChildren.push_back(window);
updateHierarchy();
}
void QBBScreen::lowerWindow(QBBWindow* window)
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::lower window=" << window;
#endif
removeWindow(window);
mChildren.push_front(window);
updateHierarchy();
}
void QBBScreen::updateHierarchy()
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << "QBBScreen::updateHierarchy";
#endif
QList<QBBWindow*>::const_iterator it;
int topZorder = 1; // root window is z-order 0, all "top" level windows are "above" it
for (it = mChildren.constBegin(); it != mChildren.constEnd(); ++it) {
(*it)->updateZorder(topZorder);
}
topZorder++;
Q_FOREACH (screen_window_t overlay, mOverlays) {
// Do nothing when this fails. This can happen if we have stale windows in mOverlays,
// which in turn can happen because a window was removed but we didn't get a notification
// yet.
screen_set_window_property_iv(overlay, SCREEN_PROPERTY_ZORDER, &topZorder);
topZorder++;
}
// After a hierarchy update, we need to force a flush on all screens.
// Right now, all screens share a context.
screen_flush_context( mContext, 0 );
}
void QBBScreen::onWindowPost(QBBWindow* window)
{
Q_UNUSED(window)
// post app window (so navigator will show it) after first child window
// has posted; this only needs to happen once as the app window's content
// never changes
if (!mPosted && mRootWindow) {
mRootWindow->post();
mPosted = true;
}
}
void QBBScreen::adjustOrientation()
{
if (!mPrimaryDisplay)
return;
bool ok = false;
const int rotation = qgetenv("ORIENTATION").toInt(&ok);
if (ok)
setRotation(rotation);
}
QPlatformCursor * QBBScreen::cursor() const
{
return mCursor;
}
void QBBScreen::keyboardHeightChanged(int height)
{
if (height == mKeyboardHeight)
return;
mKeyboardHeight = height;
QWindowSystemInterface::handleScreenAvailableGeometryChange(mScreenIndex);
}
void QBBScreen::addOverlayWindow(screen_window_t window)
{
mOverlays.append(window);
updateHierarchy();
}
void QBBScreen::removeOverlayWindow(screen_window_t window)
{
const int numOverlaysRemoved = mOverlays.removeAll(window);
if (numOverlaysRemoved > 0)
updateHierarchy();
}
void QBBScreen::windowGroupStateChanged(const QByteArray &id, Qt::WindowState state)
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
if (!rootWindow() || id != rootWindow()->groupName())
return;
QWidget * const window = topMostChildWindow();
if (!window)
return;
QWindowSystemInterface::handleWindowStateChanged(window, state);
}
void QBBScreen::activateWindowGroup(const QByteArray &id)
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
if (!rootWindow() || id != rootWindow()->groupName())
return;
QWidget * const window = topMostChildWindow();
if (!window)
return;
QWindowSystemInterface::handleWindowActivated(window);
}
void QBBScreen::deactivateWindowGroup(const QByteArray &id)
{
#if defined(QBBSCREEN_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
if (!rootWindow() || id != rootWindow()->groupName())
return;
QWindowSystemInterface::handleWindowActivated(0);
}
QWidget * QBBScreen::topMostChildWindow() const
{
if (!mChildren.isEmpty()) {
// We're picking up the last window of the list here
// because this list is ordered by stacking order.
// Last window is effectively the one on top.
return mChildren.last()->widget();
}
return 0;
}
QT_END_NAMESPACE

View file

@ -1,139 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBSCREEN_H
#define QBBSCREEN_H
#include <QtGui/QPlatformScreen>
#include "qbbrootwindow.h"
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
class QBBWindow;
class QPlatformCursor;
class QBBScreen : public QPlatformScreen
{
Q_OBJECT
public:
QBBScreen(screen_context_t context, screen_display_t display, int screenIndex);
virtual ~QBBScreen();
virtual QRect geometry() const { return mCurrentGeometry; }
virtual QRect availableGeometry() const;
virtual int depth() const;
virtual QImage::Format format() const { return (depth() == 32) ? QImage::Format_RGB32 : QImage::Format_RGB16; }
virtual QSize physicalSize() const { return mCurrentPhysicalSize; }
int rotation() const { return mCurrentRotation; }
int nativeFormat() const { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; }
screen_display_t nativeDisplay() const { return mDisplay; }
screen_context_t nativeContext() const { return mContext; }
const char *windowGroupName() const { return mRootWindow->groupName().constData(); }
QBBWindow *findWindow(screen_window_t windowHandle);
/* Window hierarchy management */
void addWindow(QBBWindow* child);
void removeWindow(QBBWindow* child);
void raiseWindow(QBBWindow* window);
void lowerWindow(QBBWindow* window);
void updateHierarchy();
void onWindowPost(QBBWindow* window);
void adjustOrientation();
void ensureDisplayCreated();
QSharedPointer<QBBRootWindow> rootWindow() const { return mRootWindow; }
QPlatformCursor *cursor() const;
public Q_SLOTS:
void setRotation(int rotation);
void newWindowCreated(screen_window_t window);
void windowClosed(screen_window_t window);
void windowGroupStateChanged(const QByteArray &id, Qt::WindowState state);
void activateWindowGroup(const QByteArray &id);
void deactivateWindowGroup(const QByteArray &id);
private Q_SLOTS:
void keyboardHeightChanged(int height);
private:
void resizeNativeWidgetWindow(QBBWindow *w, const QRect &previousScreenGeometry) const;
void resizeTopLevelWindow(QBBWindow *w, const QRect &previousScreenGeometry) const;
void resizeWindows(const QRect &previousScreenGeometry);
void addOverlayWindow(screen_window_t window);
void removeOverlayWindow(screen_window_t window);
QWidget *topMostChildWindow() const;
screen_context_t mContext;
screen_display_t mDisplay;
QSharedPointer<QBBRootWindow> mRootWindow;
bool mPosted;
bool mUsingOpenGL;
bool mPrimaryDisplay;
int mStartRotation;
int mCurrentRotation;
int mKeyboardHeight;
QSize mStartPhysicalSize;
QSize mCurrentPhysicalSize;
QRect mStartGeometry;
QRect mCurrentGeometry;
QList<QBBWindow*> mChildren;
QList<screen_window_t> mOverlays;
int mScreenIndex;
QPlatformCursor *mCursor;
bool isPrimaryDisplay() { return mPrimaryDisplay; }
};
QT_END_NAMESPACE
#endif // QBBSCREEN_H

View file

@ -1,581 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBSCREENEVENTHANDLER_DEBUG
#include "qbbscreeneventhandler.h"
#include "qbbscreen.h"
#include "qbbintegration.h"
#include "qbbinputcontext.h"
#include "qbbkeytranslator.h"
#include <QApplication>
#include <QDebug>
#include <errno.h>
#include <sys/keycodes.h>
QT_BEGIN_NAMESPACE
QBBScreenEventHandler::QBBScreenEventHandler(QBBIntegration *integration)
: mBBIntegration(integration)
, mLastButtonState(Qt::NoButton)
, mLastMouseWindow(0)
{
// initialize array of touch points
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
// map array index to id
mTouchPoints[i].id = i;
// first finger is primary
mTouchPoints[i].isPrimary = (i == 0);
// pressure is not supported - use default
mTouchPoints[i].pressure = 1.0;
// nothing touching
mTouchPoints[i].state = Qt::TouchPointReleased;
}
}
bool QBBScreenEventHandler::handleEvent(screen_event_t event)
{
// get the event type
errno = 0;
int qnxType;
int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType);
if (result)
qFatal("QBB: failed to query event type, errno=%d", errno);
return handleEvent(event, qnxType);
}
bool QBBScreenEventHandler::handleEvent(screen_event_t event, int qnxType)
{
switch (qnxType) {
case SCREEN_EVENT_MTOUCH_TOUCH:
case SCREEN_EVENT_MTOUCH_MOVE:
case SCREEN_EVENT_MTOUCH_RELEASE:
handleTouchEvent(event, qnxType);
break;
case SCREEN_EVENT_KEYBOARD:
handleKeyboardEvent(event);
break;
case SCREEN_EVENT_POINTER:
handlePointerEvent(event);
break;
case SCREEN_EVENT_CLOSE:
handleCloseEvent(event);
break;
case SCREEN_EVENT_CREATE:
handleCreateEvent(event);
break;
case SCREEN_EVENT_DISPLAY:
handleDisplayEvent(event);
break;
default:
// event ignored
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: QNX unknown event";
#endif
return false;
}
return true;
}
void QBBScreenEventHandler::handleKeyboardEvent(screen_event_t event)
{
// get flags of key event
errno = 0;
int flags;
int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags);
if (result) {
qFatal("QBB: failed to query event flags, errno=%d", errno);
}
// get key code
errno = 0;
int sym;
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym);
if (result) {
qFatal("QBB: failed to query event sym, errno=%d", errno);
}
int modifiers;
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers);
if (result) {
qFatal("QBB: failed to query event modifiers, errno=%d", errno);
}
int scan;
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan);
if (result) {
qFatal("QBB: failed to query event modifiers, errno=%d", errno);
}
int cap;
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap);
if (result) {
qFatal("QBB: failed to query event cap, errno=%d", errno);
}
// Let the input context have a stab at it first.
QWidget *focusWidget = QApplication::focusWidget();
if (focusWidget) {
QInputContext* inputContext = focusWidget->inputContext();
if (inputContext) {
QBBInputContext *qbbInputContext = dynamic_cast<QBBInputContext *>(inputContext);
if (qbbInputContext && qbbInputContext->handleKeyboardEvent(flags, sym, modifiers, scan, cap))
return;
}
}
injectKeyboardEvent(flags, sym, modifiers, scan, cap);
}
void QBBScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifiers, int scan, int cap)
{
Q_UNUSED(scan);
Qt::KeyboardModifiers qtMod = Qt::NoModifier;
if (modifiers & KEYMOD_SHIFT)
qtMod |= Qt::ShiftModifier;
if (modifiers & KEYMOD_CTRL)
qtMod |= Qt::ControlModifier;
if (modifiers & KEYMOD_ALT)
qtMod |= Qt::AltModifier;
// determine event type
QEvent::Type type = (flags & KEY_DOWN) ? QEvent::KeyPress : QEvent::KeyRelease;
// Check if the key cap is valid
if (flags & KEY_CAP_VALID) {
Qt::Key key;
QString keyStr;
if (cap >= 0x20 && cap <= 0x0ff) {
key = Qt::Key(std::toupper(cap)); // Qt expects the CAP to be upper case.
if ( qtMod & Qt::ControlModifier ) {
keyStr = QChar((int)(key & 0x3f));
} else {
if (flags & KEY_SYM_VALID) {
keyStr = QChar(sym);
}
}
} else if ((cap > 0x0ff && cap < UNICODE_PRIVATE_USE_AREA_FIRST) || cap > UNICODE_PRIVATE_USE_AREA_LAST) {
key = (Qt::Key)cap;
keyStr = QChar(sym);
} else {
if (isKeypadKey(cap))
qtMod |= Qt::KeypadModifier; // Is this right?
key = keyTranslator(cap);
}
QWindowSystemInterface::handleExtendedKeyEvent(QApplication::activeWindow(), type, key, qtMod,
scan, sym, modifiers, keyStr);
#if defined(QBBScreenEventHandler_DEBUG)
qDebug() << "QBB: Qt key t=" << type << ", k=" << key << ", s=" << keyStr;
#endif
}
}
void QBBScreenEventHandler::injectPointerMoveEvent(int x, int y)
{
#if defined(QBBScreenEventHandler_DEBUG)
qDebug() << "Injecting mouse event..." << x << y;
#endif
QWidget *w = qApp->topLevelAt(x, y);
void *qnxWindow = w ? w->platformWindow() : 0;
// Generate enter and leave events as needed.
if (qnxWindow != mLastMouseWindow) {
QWidget* wOld = QWidget::find( (WId)mLastMouseWindow );
if (wOld) {
QWindowSystemInterface::handleLeaveEvent(wOld);
#if defined(QBBScreenEventHandler_DEBUG)
qDebug() << "QBB: Qt leave, w=" << wOld;
#endif
}
if (w) {
QWindowSystemInterface::handleEnterEvent(w);
#if defined(QBBScreenEventHandler_DEBUG)
qDebug() << "QBB: Qt enter, w=" << w;
#endif
}
}
mLastMouseWindow = qnxWindow;
// convert point to local coordinates
QPoint globalPoint(x, y);
QPoint localPoint(x, y);
if (w)
localPoint = QPoint(x - w->x(), y - w->y());
// Convert buttons.
Qt::MouseButtons buttons = mLastButtonState;
if (w) {
// Inject mouse event into Qt only if something has changed.
if (mLastGlobalMousePoint != globalPoint ||
mLastLocalMousePoint != localPoint ||
mLastButtonState != buttons) {
QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
#if defined(QBBScreenEventHandler_DEBUG)
qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << (int)buttons;
#endif
}
}
mLastGlobalMousePoint = globalPoint;
mLastLocalMousePoint = localPoint;
mLastButtonState = buttons;
}
void QBBScreenEventHandler::handlePointerEvent(screen_event_t event)
{
errno = 0;
// Query the window that was clicked
void *qnxWindow;
int result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &qnxWindow);
if (result) {
qFatal("QBB: failed to query event window, errno=%d", errno);
}
// Query the button states
int buttonState = 0;
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState);
if (result) {
qFatal("QBB: failed to query event button state, errno=%d", errno);
}
// Query the window position
int windowPos[2];
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos);
if (result) {
qFatal("QBB: failed to query event window position, errno=%d", errno);
}
// Query the screen position
int pos[2];
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos);
if (result) {
qFatal("QBB: failed to query event position, errno=%d", errno);
}
// Query the wheel delta
int wheelDelta = 0;
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta);
if (result) {
qFatal("QBB: failed to query event wheel delta, errno=%d", errno);
}
// map window to top-level widget
QWidget* w = QWidget::find( (WId)qnxWindow );
// Generate enter and leave events as needed.
if (qnxWindow != mLastMouseWindow) {
QWidget* wOld = QWidget::find( (WId)mLastMouseWindow );
if (wOld) {
QWindowSystemInterface::handleLeaveEvent(wOld);
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: Qt leave, w=" << wOld;
#endif
}
if (w) {
QWindowSystemInterface::handleEnterEvent(w);
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: Qt enter, w=" << w;
#endif
}
}
mLastMouseWindow = qnxWindow;
// Apply scaling to wheel delta and invert value for Qt. We'll probably want to scale
// this via a system preference at some point. But for now this is a sane value and makes
// the wheel usable.
wheelDelta *= -10;
// convert point to local coordinates
QPoint globalPoint(pos[0], pos[1]);
QPoint localPoint(windowPos[0], windowPos[1]);
// Convert buttons.
// Some QNX header files invert 'Right Button versus "Left Button' ('Right' == 0x01). But they also offer a 'Button Swap' bit,
// so we may receive events as shown. (If this is wrong, the fix is easy.)
// QNX Button mask is 8 buttons wide, with a maximum value of 0x80.
Qt::MouseButtons buttons = Qt::NoButton;
if (buttonState & 0x01)
buttons |= Qt::LeftButton;
if (buttonState & 0x02)
buttons |= Qt::MidButton;
if (buttonState & 0x04)
buttons |= Qt::RightButton;
if (buttonState & 0x08)
buttons |= Qt::XButton1;
if (buttonState & 0x10)
buttons |= Qt::XButton2;
if (w) {
// Inject mouse event into Qt only if something has changed.
if (mLastGlobalMousePoint != globalPoint ||
mLastLocalMousePoint != localPoint ||
mLastButtonState != buttons) {
QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << (int)buttons;
#endif
}
if (wheelDelta) {
// Screen only supports a single wheel, so we will assume Vertical orientation for
// now since that is pretty much standard.
QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, wheelDelta, Qt::Vertical);
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: Qt wheel, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), d=" << (int)wheelDelta;
#endif
}
}
mLastGlobalMousePoint = globalPoint;
mLastLocalMousePoint = localPoint;
mLastButtonState = buttons;
}
void QBBScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType)
{
// get display coordinates of touch
errno = 0;
int pos[2];
int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos);
if (result) {
qFatal("QBB: failed to query event position, errno=%d", errno);
}
QCursor::setPos(pos[0], pos[1]);
// get window coordinates of touch
errno = 0;
int windowPos[2];
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos);
if (result) {
qFatal("QBB: failed to query event window position, errno=%d", errno);
}
// determine which finger touched
errno = 0;
int touchId;
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, &touchId);
if (result) {
qFatal("QBB: failed to query event touch id, errno=%d", errno);
}
// determine which window was touched
errno = 0;
void *qnxWindow;
result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &qnxWindow);
if (result) {
qFatal("QBB: failed to query event window, errno=%d", errno);
}
// check if finger is valid
if (touchId < MAX_TOUCH_POINTS) {
// map window to top-level widget
QWidget* w = QWidget::find( (WId)qnxWindow );
// Generate enter and leave events as needed.
if (qnxWindow != mLastMouseWindow) {
QWidget* wOld = QWidget::find( (WId)mLastMouseWindow );
if (wOld) {
QWindowSystemInterface::handleLeaveEvent(wOld);
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: Qt leave, w=" << wOld;
#endif
}
if (w) {
QWindowSystemInterface::handleEnterEvent(w);
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: Qt enter, w=" << w;
#endif
}
}
mLastMouseWindow = qnxWindow;
if (w) {
// convert primary touch to mouse event
if (touchId == 0) {
// convert point to local coordinates
QPoint globalPoint(pos[0], pos[1]);
QPoint localPoint(windowPos[0], windowPos[1]);
// map touch state to button state
Qt::MouseButtons buttons = (qnxType == SCREEN_EVENT_MTOUCH_RELEASE) ? Qt::NoButton : Qt::LeftButton;
// inject event into Qt
QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << buttons;
#endif
}
// get size of screen which contains window
QPlatformScreen* platformScreen = QPlatformScreen::platformScreenForWidget(w);
QSize screenSize = platformScreen->physicalSize();
// update cached position of current touch point
mTouchPoints[touchId].normalPosition = QPointF( ((qreal)pos[0]) / screenSize.width(), ((qreal)pos[1]) / screenSize.height() );
mTouchPoints[touchId].area = QRectF( pos[0], pos[1], 0.0, 0.0 );
// determine event type and update state of current touch point
QEvent::Type type = QEvent::None;
switch (qnxType) {
case SCREEN_EVENT_MTOUCH_TOUCH:
mTouchPoints[touchId].state = Qt::TouchPointPressed;
type = QEvent::TouchBegin;
break;
case SCREEN_EVENT_MTOUCH_MOVE:
mTouchPoints[touchId].state = Qt::TouchPointMoved;
type = QEvent::TouchUpdate;
break;
case SCREEN_EVENT_MTOUCH_RELEASE:
mTouchPoints[touchId].state = Qt::TouchPointReleased;
type = QEvent::TouchEnd;
break;
}
// build list of active touch points
QList<QWindowSystemInterface::TouchPoint> pointList;
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
if (i == touchId) {
// current touch point is always active
pointList.append(mTouchPoints[i]);
} else if (mTouchPoints[i].state != Qt::TouchPointReleased) {
// finger is down but did not move
mTouchPoints[i].state = Qt::TouchPointStationary;
pointList.append(mTouchPoints[i]);
}
}
// inject event into Qt
QWindowSystemInterface::handleTouchEvent(w, type, QTouchEvent::TouchScreen, pointList);
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << "QBB: Qt touch, w=" << w << ", p=(" << pos[0] << "," << pos[1] << "), t=" << type;
#endif
}
}
}
void QBBScreenEventHandler::handleCloseEvent(screen_event_t event)
{
screen_window_t window = 0;
if (screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0)
qFatal("QBB: failed to query event window property, errno=%d", errno);
emit windowClosed(window);
// map window to top-level widget
QWidget* w = QWidget::find( (WId)window );
if (w != NULL)
QWindowSystemInterface::handleCloseEvent(w);
}
void QBBScreenEventHandler::handleCreateEvent(screen_event_t event)
{
screen_window_t window = 0;
if (screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0)
qFatal("QBB: failed to query event window property, errno=%d", errno);
emit newWindowCreated(window);
}
void QBBScreenEventHandler::handleDisplayEvent(screen_event_t event)
{
screen_display_t nativeDisplay = 0;
if (screen_get_event_property_pv(event, SCREEN_PROPERTY_DISPLAY, (void **)&nativeDisplay) != 0) {
qWarning("QBB: failed to query display property, errno=%d", errno);
return;
}
int isAttached = 0;
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_ATTACHED, &isAttached) != 0) {
qWarning("QBB: failed to query display attached property, errno=%d", errno);
return;
}
#if defined(QBBSCREENEVENTHANDLER_DEBUG)
qDebug() << Q_FUNC_INFO << "display attachment is now:" << isAttached;
#endif
QBBScreen *screen = mBBIntegration->screenForNative(nativeDisplay);
if (!screen) {
if (isAttached)
mBBIntegration->createDisplay(nativeDisplay, false /* not primary, we assume */);
} else if (!isAttached) {
// libscreen display is deactivated, let's remove the QBBScreen / QScreen
mBBIntegration->removeDisplay(screen);
}
}
#include "moc_qbbscreeneventhandler.cpp"
QT_END_NAMESPACE

View file

@ -1,93 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBSCREENEVENTHANDLER_H
#define QBBSCREENEVENTHANDLER_H
#include <QWindowSystemInterface>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
class QBBIntegration;
class QBBScreenEventHandler : public QObject
{
Q_OBJECT
public:
explicit QBBScreenEventHandler(QBBIntegration *integration);
static void injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
void injectPointerMoveEvent(int x, int y);
bool handleEvent(screen_event_t event);
bool handleEvent(screen_event_t event, int qnxType);
Q_SIGNALS:
void newWindowCreated(screen_window_t window);
void windowClosed(screen_window_t window);
private:
void handleKeyboardEvent(screen_event_t event);
void handlePointerEvent(screen_event_t event);
void handleTouchEvent(screen_event_t event, int type);
void handleCloseEvent(screen_event_t event);
void handleCreateEvent(screen_event_t event);
void handleDisplayEvent(screen_event_t event);
private:
enum {
MAX_TOUCH_POINTS = 10
};
QBBIntegration *mBBIntegration;
QPoint mLastGlobalMousePoint;
QPoint mLastLocalMousePoint;
Qt::MouseButtons mLastButtonState;
void* mLastMouseWindow;
QWindowSystemInterface::TouchPoint mTouchPoints[MAX_TOUCH_POINTS];
};
QT_END_NAMESPACE
#endif // QBBSCREENEVENTHANDLER_H

View file

@ -1,165 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
// #define QBBSCREENEVENTTHREAD_DEBUG
#include "qbbscreeneventthread.h"
#include "qbbscreeneventhandler.h"
#include <QDebug>
#include <errno.h>
QT_BEGIN_NAMESPACE
QBBScreenEventThread::QBBScreenEventThread(screen_context_t context, QBBScreenEventHandler *eventHandler)
: mContext(context),
mQuit(false),
mEventHandler(eventHandler)
{
}
QBBScreenEventThread::~QBBScreenEventThread()
{
// block until thread terminates
shutdown();
}
void QBBScreenEventThread::injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
{
QBBScreenEventHandler::injectKeyboardEvent(flags, sym, mod, scan, cap);
}
void QBBScreenEventThread::injectPointerMoveEvent(int x, int y)
{
mEventHandler->injectPointerMoveEvent(x, y);
}
void QBBScreenEventThread::run()
{
screen_event_t event;
// create screen event
errno = 0;
int result = screen_create_event(&event);
if (result)
qFatal("QBB: failed to create screen event, errno=%d", errno);
#if defined(QBBSCREENEVENTTHREAD_DEBUG)
qDebug() << "QBB: screen event thread started";
#endif
// loop indefinitely
while (!mQuit) {
// block until screen event is available
errno = 0;
result = screen_get_event(mContext, event, -1);
if (result)
qFatal("QBB: failed to get screen event, errno=%d", errno);
// process received event
errno = 0;
int qnxType;
int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType);
if (result)
qFatal("QBB: failed to query screen event type, errno=%d", errno);
if (qnxType == SCREEN_EVENT_USER) {
// treat all screen user events as shutdown requests
#if defined(QBBSCREENEVENTTHREAD_DEBUG)
qDebug() << "QBB: QNX screen user event";
#endif
mQuit = true;
} else {
mEventHandler->handleEvent(event, qnxType);
}
}
#if defined(QBBSCREENEVENTTHREAD_DEBUG)
qDebug() << "QBB: screen event thread stopped";
#endif
// cleanup
screen_destroy_event(event);
}
void QBBScreenEventThread::shutdown()
{
screen_event_t event;
// create screen event
errno = 0;
int result = screen_create_event(&event);
if (result)
qFatal("QBB: failed to create screen event, errno=%d", errno);
// set the event type as user
errno = 0;
int type = SCREEN_EVENT_USER;
result = screen_set_event_property_iv(event, SCREEN_PROPERTY_TYPE, &type);
if (result)
qFatal("QBB: failed to set screen event type, errno=%d", errno);
// NOTE: ignore SCREEN_PROPERTY_USER_DATA; treat all user events as shutdown events
// post event to event loop so it will wake up and die
errno = 0;
result = screen_send_event(mContext, event, getpid());
if (result)
qFatal("QBB: failed to set screen event type, errno=%d", errno);
// cleanup
screen_destroy_event(event);
#if defined(QBBSCREENEVENTTHREAD_DEBUG)
qDebug() << "QBB: screen event thread shutdown begin";
#endif
// block until thread terminates
wait();
#if defined(QBBSCREENEVENTTHREAD_DEBUG)
qDebug() << "QBB: screen event thread shutdown end";
#endif
}
QT_END_NAMESPACE

View file

@ -1,75 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBEVENTTHREAD_H
#define QBBEVENTTHREAD_H
#include <QThread>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
class QBBScreenEventHandler;
class QBBScreenEventThread : public QThread
{
public:
QBBScreenEventThread(screen_context_t context, QBBScreenEventHandler *eventHandler);
virtual ~QBBScreenEventThread();
static void injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
void injectPointerMoveEvent(int x, int y);
protected:
virtual void run();
private:
screen_context_t mContext;
bool mQuit;
QBBScreenEventHandler *mEventHandler;
void shutdown();
};
QT_END_NAMESPACE
#endif // QBBEVENTTHREAD_H

View file

@ -1,215 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBVIRTUALKEYBOARD_DEBUG
#include "qbbvirtualkeyboardbps.h"
#include <QDebug>
#include <bps/event.h>
#include <bps/locale.h>
#include <bps/virtualkeyboard.h>
QT_BEGIN_NAMESPACE
QBBVirtualKeyboardBps::QBBVirtualKeyboardBps(QObject *parent)
: QBBAbstractVirtualKeyboard(parent)
{
if (locale_request_events(0) != BPS_SUCCESS)
qWarning("QBB: Failed to register for locale events");
if (virtualkeyboard_request_events(0) != BPS_SUCCESS)
qWarning("QBB: Failed to register for virtual keyboard events");
int height = 0;
if (virtualkeyboard_get_height(&height) != BPS_SUCCESS)
qWarning("QBB: Failed to get virtual keyboard height");
setHeight(height);
}
bool QBBVirtualKeyboardBps::handleEvent(bps_event_t *event)
{
const int eventDomain = bps_event_get_domain(event);
if (eventDomain == locale_get_domain())
return handleLocaleEvent(event);
if (eventDomain == virtualkeyboard_get_domain())
return handleVirtualKeyboardEvent(event);
return false;
}
bool QBBVirtualKeyboardBps::showKeyboard()
{
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "current visibility=" << isVisible();
#endif
// They keyboard's mode is global between applications, we have to set it each time
if (!isVisible())
applyKeyboardMode(keyboardMode());
virtualkeyboard_show();
return true;
}
bool QBBVirtualKeyboardBps::hideKeyboard()
{
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "current visibility=" << isVisible();
#endif
virtualkeyboard_hide();
return true;
}
void QBBVirtualKeyboardBps::applyKeyboardMode(KeyboardMode mode)
{
virtualkeyboard_layout_t layout = VIRTUALKEYBOARD_LAYOUT_DEFAULT;
switch (mode) {
case Url:
layout = VIRTUALKEYBOARD_LAYOUT_URL;
break;
case Email:
layout = VIRTUALKEYBOARD_LAYOUT_EMAIL;
break;
case Web:
layout = VIRTUALKEYBOARD_LAYOUT_WEB;
break;
case NumPunc:
layout = VIRTUALKEYBOARD_LAYOUT_NUM_PUNC;
break;
case Symbol:
layout = VIRTUALKEYBOARD_LAYOUT_SYMBOL;
break;
case Phone:
layout = VIRTUALKEYBOARD_LAYOUT_PHONE;
break;
case Pin:
layout = VIRTUALKEYBOARD_LAYOUT_PIN;
break;
case Default: // fall through
default:
layout = VIRTUALKEYBOARD_LAYOUT_DEFAULT;
break;
}
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "mode=" << mode;
#endif
virtualkeyboard_change_options(layout, VIRTUALKEYBOARD_ENTER_DEFAULT);
}
bool QBBVirtualKeyboardBps::handleLocaleEvent(bps_event_t *event)
{
if (bps_event_get_code(event) == LOCALE_INFO) {
const QString language = QString::fromAscii(locale_event_get_language(event));
const QString country = QString::fromAscii(locale_event_get_country(event));
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "current language/country" << languageId() << "/" << countryId()
<< "new language/country=" << language << "/" << country;
#endif
setLanguage(language);
setCountry(country);
return true;
}
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << "QBB: Unhandled locale event. code=" << bps_event_get_code(event);
#endif
return false;
}
bool QBBVirtualKeyboardBps::handleVirtualKeyboardEvent(bps_event_t *event)
{
switch (bps_event_get_code(event)) {
case VIRTUALKEYBOARD_EVENT_VISIBLE:
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "EVENT VISIBLE: current visibility=" << isVisible();
#endif
setVisible(true);
break;
case VIRTUALKEYBOARD_EVENT_HIDDEN:
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "EVENT HIDDEN: current visibility=" << isVisible();
#endif
setVisible(false);
break;
case VIRTUALKEYBOARD_EVENT_INFO: {
const int newHeight = virtualkeyboard_event_get_height(event);
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << Q_FUNC_INFO << "EVENT INFO: current height=" << getHeight() << "new height=" << newHeight;
#endif
setHeight(newHeight);
break;
}
default:
#if defined(QBBVIRTUALKEYBOARD_DEBUG)
qDebug() << "QBB: Unhandled virtual keyboard event. code=" << bps_event_get_code(event);
#endif
return false;
}
return true;
}
QT_END_NAMESPACE

View file

@ -1,72 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBVIRTUALKEYBOARDBPS_H
#define QBBVIRTUALKEYBOARDBPS_H
#include "qbbabstractvirtualkeyboard.h"
struct bps_event_t;
QT_BEGIN_NAMESPACE
class QBBVirtualKeyboardBps : public QBBAbstractVirtualKeyboard
{
Q_OBJECT
public:
explicit QBBVirtualKeyboardBps(QObject *parent = 0);
bool handleEvent(bps_event_t *event);
bool showKeyboard();
bool hideKeyboard();
protected:
void applyKeyboardMode(KeyboardMode mode);
private:
bool handleLocaleEvent(bps_event_t *event);
bool handleVirtualKeyboardEvent(bps_event_t *event);
};
QT_END_NAMESPACE
#endif // QBBVIRTUALKEYBOARDBPS_H

View file

@ -1,430 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//#define QBBVIRTUALKEYBOARD_DEBUG
#include "qbbvirtualkeyboardpps.h"
#include <QDebug>
#include <QSocketNotifier>
#include <QtCore/qcore_unix_p.h>
#include <QtGui/QApplication>
#include <QtGui/QPlatformScreen>
#include <QtGui/QPlatformWindow>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/iomsg.h>
#include <sys/pps.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
QT_BEGIN_NAMESPACE
const char *QBBVirtualKeyboardPps::sPPSPath = "/pps/services/input/control";
const size_t QBBVirtualKeyboardPps::sBufferSize = 2048;
// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP.
#define KEYBOARD_SHADOW_HEIGHT 8
QBBVirtualKeyboardPps::QBBVirtualKeyboardPps()
: mEncoder(0),
mDecoder(0),
mBuffer(0),
mFd(-1),
mReadNotifier(0)
{
}
QBBVirtualKeyboardPps::~QBBVirtualKeyboardPps()
{
close();
}
void QBBVirtualKeyboardPps::start()
{
#ifdef QBBVIRTUALKEYBOARD_DEBUG
qDebug() << "QBB: starting keyboard event processing";
#endif
if (!connect())
return;
}
void QBBVirtualKeyboardPps::applyKeyboardMode(KeyboardMode mode)
{
applyKeyboardModeOptions(mode);
}
void QBBVirtualKeyboardPps::close()
{
delete mReadNotifier;
mReadNotifier = 0;
if (mFd != -1) {
// any reads will fail after we close the fd, which is basically what we want.
::close(mFd);
mFd = -1;
}
if (mDecoder) {
pps_decoder_cleanup(mDecoder);
delete mDecoder;
mDecoder = 0;
}
if (mEncoder) {
pps_encoder_cleanup(mEncoder);
delete mEncoder;
mEncoder = 0;
}
delete [] mBuffer;
mBuffer = 0;
}
bool QBBVirtualKeyboardPps::connect()
{
close();
mEncoder = new pps_encoder_t;
mDecoder = new pps_decoder_t;
pps_encoder_initialize(mEncoder, false);
pps_decoder_initialize(mDecoder, NULL);
errno = 0;
mFd = ::open(sPPSPath, O_RDWR);
if (mFd == -1) {
qCritical("QBBVirtualKeyboard: Unable to open \"%s\" for keyboard: %s (%d).",
sPPSPath, strerror(errno), errno);
close();
return false;
}
mBuffer = new char[sBufferSize];
if (!mBuffer) {
qCritical("QBBVirtualKeyboard: Unable to allocate buffer of %d bytes. Size is unavailable.", sBufferSize);
return false;
}
if (!queryPPSInfo())
return false;
mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read);
QObject::connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(ppsDataReady()));
return true;
}
bool QBBVirtualKeyboardPps::queryPPSInfo()
{
// Request info, requires id to regenerate res message.
pps_encoder_add_string(mEncoder, "msg", "info");
pps_encoder_add_string(mEncoder, "id", "libWebView");
if (::write(mFd, pps_encoder_buffer(mEncoder), pps_encoder_length(mEncoder)) == -1) {
close();
return false;
}
pps_encoder_reset(mEncoder);
return true;
}
void QBBVirtualKeyboardPps::ppsDataReady()
{
ssize_t nread = qt_safe_read(mFd, mBuffer, sBufferSize - 1);
#ifdef QBBVIRTUALKEYBOARD_DEBUG
qDebug() << "QBB: keyboardMessage size: " << nread;
#endif
if (nread < 0) {
connect(); // reconnect
return;
}
// We sometimes get spurious read notifications when no data is available.
// Bail out early in this case
if (nread == 0)
return;
// nread is the real space necessary, not the amount read.
if (static_cast<size_t>(nread) > sBufferSize - 1) {
qCritical("QBBVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1);
connect(); // reconnect
return;
}
mBuffer[nread] = 0;
pps_decoder_parse_pps_str(mDecoder, mBuffer);
pps_decoder_push(mDecoder, NULL);
#ifdef QBBVIRTUALKEYBOARD_DEBUG
pps_decoder_dump_tree(mDecoder, stderr);
#endif
const char* value;
if (pps_decoder_get_string(mDecoder, "error", &value) == PPS_DECODER_OK) {
qCritical("QBBVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]");
return;
}
if (pps_decoder_get_string(mDecoder, "msg", &value) == PPS_DECODER_OK) {
if (strcmp(value, "show") == 0)
setVisible(true);
else if (strcmp(value, "hide") == 0)
setVisible(false);
else if (strcmp(value, "info") == 0)
handleKeyboardInfoMessage();
else if (strcmp(value, "connect") == 0) { }
else
qCritical("QBBVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value : "[null]");
} else if (pps_decoder_get_string(mDecoder, "res", &value) == PPS_DECODER_OK) {
if (strcmp(value, "info") == 0)
handleKeyboardInfoMessage();
else
qCritical("QBBVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value : "[null]");
} else {
qCritical("QBBVirtualKeyboard: Unexpected keyboard PPS message type");
}
}
void QBBVirtualKeyboardPps::handleKeyboardInfoMessage()
{
int newHeight = 0;
const char* value;
if (pps_decoder_push(mDecoder, "dat") != PPS_DECODER_OK) {
qCritical("QBBVirtualKeyboard: Keyboard PPS dat object not found");
return;
}
if (pps_decoder_get_int(mDecoder, "size", &newHeight) != PPS_DECODER_OK) {
qCritical("QBBVirtualKeyboard: Keyboard PPS size field not found");
return;
}
if (pps_decoder_push(mDecoder, "locale") != PPS_DECODER_OK) {
qCritical("QBBVirtualKeyboard: Keyboard PPS locale object not found");
return;
}
if (pps_decoder_get_string(mDecoder, "languageId", &value) != PPS_DECODER_OK) {
qCritical("QBBVirtualKeyboard: Keyboard PPS languageId field not found");
return;
}
setLanguage(QString::fromLatin1(value));
if (pps_decoder_get_string(mDecoder, "countryId", &value) != PPS_DECODER_OK) {
qCritical("QBBVirtualKeyboard: Keyboard PPS size countryId not found");
return;
}
setCountry(QString::fromLatin1(value));
// HUGE hack, should be removed ASAP.
newHeight -= KEYBOARD_SHADOW_HEIGHT; // We want to ignore the 8 pixel shadow above the keyboard. (PR 88400)
setHeight(newHeight);
#ifdef QBBVIRTUALKEYBOARD_DEBUG
qDebug() << "QBB: handleKeyboardInfoMessage size=" << getHeight() << "languageId=" << languageId() << " countryId=" << countryId();
#endif
}
bool QBBVirtualKeyboardPps::showKeyboard()
{
#ifdef QBBVIRTUALKEYBOARD_DEBUG
qDebug() << "QBB: showKeyboard()";
#endif
// Try to connect.
if (mFd == -1 && !connect())
return false;
// NOTE: This must be done everytime the keyboard is shown even if there is no change because
// hiding the keyboard wipes the setting.
applyKeyboardModeOptions(keyboardMode());
pps_encoder_reset(mEncoder);
// Send the show message.
pps_encoder_add_string(mEncoder, "msg", "show");
if (::write(mFd, pps_encoder_buffer(mEncoder), pps_encoder_length(mEncoder)) == -1) {
close();
return false;
}
pps_encoder_reset(mEncoder);
// Return true if no error occurs. Sizing response will be triggered when confirmation of
// the change arrives.
return true;
}
bool QBBVirtualKeyboardPps::hideKeyboard()
{
#ifdef QBBVIRTUALKEYBOARD_DEBUG
qDebug() << "QBB: hideKeyboard()";
#endif
if (mFd == -1 && !connect())
return false;
pps_encoder_add_string(mEncoder, "msg", "hide");
if (::write(mFd, pps_encoder_buffer(mEncoder), pps_encoder_length(mEncoder)) == -1) {
close();
//Try again.
if (connect()) {
if (::write(mFd, pps_encoder_buffer(mEncoder), pps_encoder_length(mEncoder)) == -1) {
close();
return false;
}
} else {
return false;
}
}
pps_encoder_reset(mEncoder);
// Return true if no error occurs. Sizing response will be triggered when confirmation of
// the change arrives.
return true;
}
void QBBVirtualKeyboardPps::applyKeyboardModeOptions(KeyboardMode mode)
{
// Try to connect.
if (mFd == -1 && !connect())
return;
// Send the options message.
pps_encoder_add_string(mEncoder, "msg", "options");
pps_encoder_start_object(mEncoder, "dat");
switch (mode) {
case Url:
addUrlModeOptions();
break;
case Email:
addEmailModeOptions();
break;
case Web:
addWebModeOptions();
break;
case NumPunc:
addNumPuncModeOptions();
break;
case Symbol:
addSymbolModeOptions();
break;
case Phone:
addPhoneModeOptions();
break;
case Pin:
addPinModeOptions();
break;
case Default: // fall through
default:
addDefaultModeOptions();
break;
}
pps_encoder_end_object(mEncoder);
if (::write(mFd, pps_encoder_buffer(mEncoder), pps_encoder_length(mEncoder)) == -1)
close();
pps_encoder_reset(mEncoder);
}
void QBBVirtualKeyboardPps::addDefaultModeOptions()
{
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "default");
}
void QBBVirtualKeyboardPps::addUrlModeOptions()
{
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "url");
}
void QBBVirtualKeyboardPps::addEmailModeOptions()
{
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "email");
}
void QBBVirtualKeyboardPps::addWebModeOptions()
{
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "web");
}
void QBBVirtualKeyboardPps::addNumPuncModeOptions()
{
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "numPunc");
}
void QBBVirtualKeyboardPps::addPhoneModeOptions()
{
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "phone");
}
void QBBVirtualKeyboardPps::addPinModeOptions()
{
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "pin");
}
void QBBVirtualKeyboardPps::addSymbolModeOptions()
{
pps_encoder_add_string(mEncoder, "enter", "enter.default");
pps_encoder_add_string(mEncoder, "type", "symbol");
}
QT_END_NAMESPACE

View file

@ -1,101 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBVIRTUALKEYBOARDPPS_H_
#define QBBVIRTUALKEYBOARDPPS_H_
#include "qbbabstractvirtualkeyboard.h"
#include <sys/pps.h>
QT_BEGIN_NAMESPACE
class QSocketNotifier;
/* Shamelessly copied from the browser - this should be rewritten once we have a proper PPS wrapper class */
class QBBVirtualKeyboardPps : public QBBAbstractVirtualKeyboard
{
Q_OBJECT
public:
QBBVirtualKeyboardPps();
~QBBVirtualKeyboardPps();
bool showKeyboard();
bool hideKeyboard();
public Q_SLOTS:
void start();
protected:
void applyKeyboardMode(KeyboardMode mode);
private Q_SLOTS:
void ppsDataReady();
private:
pps_encoder_t *mEncoder;
pps_decoder_t *mDecoder;
char *mBuffer;
int mFd;
QSocketNotifier *mReadNotifier;
// Path to keyboardManager in PPS.
static const char *sPPSPath;
static const size_t sBufferSize;
// Will be called internally if needed.
bool connect();
void close();
bool queryPPSInfo();
void handleKeyboardInfoMessage();
void applyKeyboardModeOptions(KeyboardMode mode);
void addDefaultModeOptions();
void addUrlModeOptions();
void addEmailModeOptions();
void addWebModeOptions();
void addNumPuncModeOptions();
void addSymbolModeOptions();
void addPhoneModeOptions();
void addPinModeOptions();
};
#endif /* QBBVIRTUALKEYBOARDPPS_H_ */

View file

@ -1,736 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
// #define QBBWINDOW_DEBUG
#include "qbbwindow.h"
#include "qbbglcontext.h"
#include "qbbscreen.h"
#include <QtGui/QWidget>
#include <QDebug>
#include <QtGui/QPlatformWindowFormat>
#include <QtGui/QWindowSystemInterface>
#include <errno.h>
QT_BEGIN_NAMESPACE
QBBWindow::QBBWindow(QWidget *window, screen_context_t context, QBBScreen *screen)
: QPlatformWindow(window),
mContext(context),
mCurrentBufferIndex(-1),
mPreviousBufferIndex(-1),
mPlatformGlContext(NULL),
mScreen(NULL),
mParent(NULL),
mVisible(true)
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::QBBWindow - w=" << window << ", s=" << window->size();
#endif
int result;
// create child QNX window
errno = 0;
result = screen_create_window_type(&mWindow, mContext, SCREEN_CHILD_WINDOW);
if (result != 0) {
qFatal("QBBWindow: failed to create window, errno=%d", errno);
}
// set window buffer usage based on rendering API
int val;
QPlatformWindowFormat format = widget()->platformWindowFormat();
switch (format.windowApi()) {
case QPlatformWindowFormat::Raster:
val = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE;
break;
case QPlatformWindowFormat::OpenGL:
val = SCREEN_USAGE_OPENGL_ES2;
break;
default:
qFatal("QBBWindow: unsupported window API");
break;
}
errno = 0;
result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_USAGE, &val);
if (result != 0) {
qFatal("QBBWindow: failed to set window buffer usage, errno=%d", errno);
}
// alpha channel is always pre-multiplied if present
errno = 0;
val = SCREEN_PRE_MULTIPLIED_ALPHA;
result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_ALPHA_MODE, &val);
if (result != 0) {
qFatal("QBBWindow: failed to set window alpha mode, errno=%d", errno);
}
// make the window opaque
errno = 0;
val = SCREEN_TRANSPARENCY_NONE;
result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_TRANSPARENCY, &val);
if (result != 0) {
qFatal("QBBWindow: failed to set window transparency, errno=%d", errno);
}
// set the window swap interval
errno = 0;
val = 1;
result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_SWAP_INTERVAL, &val);
if (result != 0) {
qFatal("QBBWindow: failed to set window swap interval, errno=%d", errno);
}
// Set the screen to the primary display (this is the default specified by screen).
setScreen(screen);
// Qt somtimes doesn't call these setters after creating the window, so we need to do that
// ourselves here
if (window->parentWidget() && window->parentWidget()->platformWindow())
setParent(window->parentWidget()->platformWindow());
setGeometry(window->geometry());
setVisible(window->isVisible());
}
QBBWindow::~QBBWindow()
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::~QBBWindow - w=" << widget();
#endif
// Qt should have already deleted the children before deleting the parent.
Q_ASSERT(mChildren.size() == 0);
// Remove from parent's Hierarchy.
removeFromParent();
mScreen->updateHierarchy();
// cleanup OpenGL context if it exists
if (mPlatformGlContext != NULL) {
delete mPlatformGlContext;
}
// cleanup QNX window and its buffers
screen_destroy_window(mWindow);
}
void QBBWindow::setGeometry(const QRect &rect)
{
int val[2];
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::setGeometry - w=" << widget() << ", (" << rect.x() << "," << rect.y() << "," << rect.width() << "," << rect.height() << ")";
#endif
QRect oldGeometry = geometry();
// call parent method
QPlatformWindow::setGeometry(rect);
// set window geometry equal to widget geometry
errno = 0;
val[0] = rect.x();
val[1] = rect.y();
int result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_POSITION, val);
if (result != 0) {
qFatal("QBBWindow: failed to set window position, errno=%d", errno);
}
errno = 0;
val[0] = rect.width();
val[1] = rect.height();
result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_SIZE, val);
if (result != 0) {
qFatal("QBBWindow: failed to set window size, errno=%d", errno);
}
// set viewport size equal to window size
errno = 0;
result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_SOURCE_SIZE, val);
if (result != 0) {
qFatal("QBBWindow: failed to set window source size, errno=%d", errno);
}
// Now move all children.
QPoint offset;
if (!oldGeometry.isEmpty()) {
offset = rect.topLeft();
offset -= oldGeometry.topLeft();
QList<QBBWindow*>::iterator it;
for (it = mChildren.begin(); it != mChildren.end(); it++) {
(*it)->offset(offset);
}
}
}
void QBBWindow::offset(const QPoint &offset)
{
// Move self and then children.
QRect newGeometry = geometry();
newGeometry.translate(offset);
// call the base class
QPlatformWindow::setGeometry(newGeometry);
int val[2];
errno = 0;
val[0] = newGeometry.x();
val[1] = newGeometry.y();
int result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_POSITION, val);
if (result != 0) {
qFatal("QBBWindow: failed to set window position, errno=%d", errno);
}
QList<QBBWindow*>::iterator it;
for (it = mChildren.begin(); it != mChildren.end(); it++) {
(*it)->offset(offset);
}
}
void QBBWindow::setVisible(bool visible)
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::setVisible - w=" << widget() << ", v=" << visible;
#endif
mVisible = visible;
QBBWindow* root = this;
while (root->mParent)
root = root->mParent;
root->updateVisibility(root->mVisible);
widget()->activateWindow();
// Flush the context when invisible, otherwise it won't disappear immediately,
// but still allow navigator to capture screenshot (thumbnail) when minimized
if (!visible && !(widget()->windowState() & Qt::WindowMinimized))
screen_flush_context(mContext, 0);
}
void QBBWindow::updateVisibility(bool parentVisible)
{
// set window visibility
errno = 0;
int val = (mVisible && parentVisible) ? 1 : 0;
int result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_VISIBLE, &val);
if (result != 0) {
qFatal("QBBWindow: failed to set window visibility, errno=%d", errno);
}
QList<QBBWindow*>::iterator it;
for (it = mChildren.begin(); it != mChildren.end(); it++) {
(*it)->updateVisibility(mVisible && parentVisible);
}
}
void QBBWindow::setOpacity(qreal level)
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::setOpacity - w=" << widget() << ", o=" << level;
#endif
// set window global alpha
errno = 0;
int val = (int)(level * 255);
int result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_GLOBAL_ALPHA, &val);
if (result != 0) {
qFatal("QBBWindow: failed to set window global alpha, errno=%d", errno);
}
// TODO: How to handle children of this window? If we change all the visibilities, then
// the transparency will look wrong...
}
void QBBWindow::setBufferSize(const QSize &size)
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::setBufferSize - w=" << widget() << ", s=" << size;
#endif
// set window buffer size
errno = 0;
int val[2] = { size.width(), size.height() };
int result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_BUFFER_SIZE, val);
if (result != 0) {
qFatal("QBBWindow: failed to set window buffer size, errno=%d", errno);
}
// create window buffers if they do not exist
if (!hasBuffers()) {
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::setBufferSize - create buffers";
#endif
// get pixel format from EGL config if using OpenGL;
// otherwise inherit pixel format of window's screen
if (mPlatformGlContext != NULL) {
val[0] = platformWindowFormatToNativeFormat(mPlatformGlContext->platformWindowFormat());
} else {
val[0] = mScreen->nativeFormat();
}
errno = 0;
result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_FORMAT, val);
if (result != 0) {
qFatal("QBBWindow: failed to set window pixel format, errno=%d", errno);
}
errno = 0;
result = screen_create_window_buffers(mWindow, MAX_BUFFER_COUNT);
if (result != 0) {
qFatal("QBBWindow: failed to create window buffers, errno=%d", errno);
}
// check if there are any buffers available
int bufferCount = 0;
result = screen_get_window_property_iv(mWindow, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount);
if (result != 0) {
qFatal("QBBWindow: failed to query window buffer count, errno=%d", errno);
}
if (bufferCount != MAX_BUFFER_COUNT) {
qFatal("QBBWindow: invalid buffer count. Expected = %d, got = %d", MAX_BUFFER_COUNT, bufferCount);
}
}
// cache new buffer size
mBufferSize = size;
// buffers were destroyed; reacquire them
mCurrentBufferIndex = -1;
mPreviousDirty = QRegion();
mScrolled = QRegion();
}
QBBBuffer &QBBWindow::renderBuffer()
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::renderBuffer - w=" << widget();
#endif
return buffer(BACK_BUFFER);
}
QBBBuffer &QBBWindow::frontBuffer()
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::frontBuffer - w=" << widget();
#endif
return buffer(FRONT_BUFFER);
}
QBBBuffer &QBBWindow::buffer(QBBWindow::Buffer bufferIndex)
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::buffer - w=" << widget();
#endif
// check if render buffer is invalid
if (mCurrentBufferIndex == -1) {
// get all buffers available for rendering
errno = 0;
screen_buffer_t buffers[MAX_BUFFER_COUNT];
const int result = screen_get_window_property_pv(mWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers);
if (result != 0) {
qFatal("QBBWindow: failed to query window buffers, errno=%d", errno);
}
// wrap each buffer
for (int i = 0; i < MAX_BUFFER_COUNT; i++) {
mBuffers[i] = QBBBuffer(buffers[i]);
}
// use the first available render buffer
mCurrentBufferIndex = 0;
mPreviousBufferIndex = -1;
}
if (bufferIndex == BACK_BUFFER) {
return mBuffers[mCurrentBufferIndex];
} else if (bufferIndex == FRONT_BUFFER) {
int buf = mCurrentBufferIndex - 1;
if (buf < 0)
buf = MAX_BUFFER_COUNT - 1;
return mBuffers[buf];
}
qFatal("QBBWindow::buffer() - invalid buffer index. Aborting");
// never happens
return mBuffers[mCurrentBufferIndex];
}
void QBBWindow::scroll(const QRegion &region, int dx, int dy, bool flush)
{
copyBack(region, dx, dy, flush);
mScrolled += region;
}
void QBBWindow::post(const QRegion &dirty)
{
// check if render buffer exists and something was rendered
if (mCurrentBufferIndex != -1 && !dirty.isEmpty()) {
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::post - w=" << widget();
#endif
QBBBuffer &currentBuffer = mBuffers[mCurrentBufferIndex];
// copy unmodified region from old render buffer to new render buffer;
// required to allow partial updates
QRegion preserve = mPreviousDirty - dirty - mScrolled;
copyBack(preserve, 0, 0);
// calculate region that changed
QRegion modified = preserve + dirty + mScrolled;
QRect rect = modified.boundingRect();
int dirtyRect[4] = { rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height() };
// update the display with contents of render buffer
errno = 0;
int result = screen_post_window(mWindow, currentBuffer.nativeBuffer(), 1, dirtyRect, 0);
if (result != 0) {
qFatal("QBBWindow: failed to post window buffer, errno=%d", errno);
}
// advance to next nender buffer
mPreviousBufferIndex = mCurrentBufferIndex++;
if (mCurrentBufferIndex >= MAX_BUFFER_COUNT) {
mCurrentBufferIndex = 0;
}
// save modified region and clear scrolled region
mPreviousDirty = dirty;
mScrolled = QRegion();
// notify screen that window posted
if (mScreen != NULL) {
mScreen->onWindowPost(this);
}
}
}
QPlatformGLContext *QBBWindow::glContext() const
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::glContext - w=" << widget();
#endif
// create opengl context on first access if rendering API is correct
QPlatformWindowFormat format = widget()->platformWindowFormat();
if (mPlatformGlContext == NULL && format.windowApi() == QPlatformWindowFormat::OpenGL) {
mPlatformGlContext = new QBBGLContext( const_cast<QBBWindow*>(this) );
}
return mPlatformGlContext;
}
void QBBWindow::setScreen(QBBScreen *platformScreen)
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::setScreen - w=" << widget();
#endif
if (mScreen == platformScreen)
return;
if (mScreen)
mScreen->removeWindow(this);
platformScreen->addWindow(this);
mScreen = platformScreen;
// The display may not have a root (desktop) window yet so we must ensure that one has been
// created before we can join its group or get its native display property.
mScreen->ensureDisplayCreated();
// move window to proper display
errno = 0;
screen_display_t display = platformScreen->nativeDisplay();
int result = screen_set_window_property_pv(mWindow, SCREEN_PROPERTY_DISPLAY, (void **)&display);
if (result != 0) {
qFatal("QBBWindow: failed to set window display, errno=%d", errno);
}
// add window to display's window group
errno = 0;
result = screen_join_window_group(mWindow, platformScreen->windowGroupName());
if (result != 0) {
qFatal("QBBWindow: failed to join window group, errno=%d", errno);
}
QList<QBBWindow*>::iterator it;
for (it = mChildren.begin(); it != mChildren.end(); it++) {
// Only subwindows and tooltips need necessarily be moved to another display with
// the window.
if ((widget()->windowType() & Qt::WindowType_Mask) == Qt::SubWindow ||
(widget()->windowType() & Qt::WindowType_Mask) == Qt::ToolTip)
(*it)->setScreen(platformScreen);
}
mScreen->updateHierarchy();
}
void QBBWindow::removeFromParent()
{
// Remove from old Hierarchy position
if (mParent) {
if (mParent->mChildren.removeAll(this))
mParent = 0;
else
qFatal("QBBWindow: Window Hierarchy broken; window has parent, but parent hasn't got child.");
} else {
mScreen->removeWindow(this);
}
}
void QBBWindow::setParent(const QPlatformWindow *window)
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::setParent - w=" << widget() << " p=" << window;
#endif
// Cast away the const, we need to modify the Hierarchy.
QBBWindow* newParent = 0;
if (window)
newParent = static_cast<QBBWindow*>((QPlatformWindow *)window);
if (newParent == mParent)
return;
removeFromParent();
mParent = newParent;
// Add to new Hierarchy position.
if (mParent) {
if (mParent->mScreen != mScreen)
setScreen(mParent->mScreen);
mParent->mChildren.push_back(this);
} else {
mScreen->addWindow(this);
}
mScreen->updateHierarchy();
}
void QBBWindow::raise()
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::raise - w=" << widget();
#endif
if (mParent) {
mParent->mChildren.removeAll(this);
mParent->mChildren.push_back(this);
} else {
mScreen->raiseWindow(this);
}
mScreen->updateHierarchy();
}
void QBBWindow::lower()
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::lower - w=" << widget();
#endif
if (mParent) {
mParent->mChildren.removeAll(this);
mParent->mChildren.push_front(this);
} else {
mScreen->lowerWindow(this);
}
mScreen->updateHierarchy();
}
void QBBWindow::requestActivateWindow()
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::requestActivateWindow - w=" << widget();
#endif
// TODO: Tell screen to set keyboard focus to this window.
// Notify that we gained focus.
gainedFocus();
}
void QBBWindow::gainedFocus()
{
#if defined(QBBWINDOW_DEBUG)
qDebug() << "QBBWindow::gainedFocus - w=" << widget();
#endif
// Got focus
QWindowSystemInterface::handleWindowActivated(widget());
}
QBBWindow *QBBWindow::findWindow(screen_window_t windowHandle)
{
if (mWindow == windowHandle)
return this;
Q_FOREACH (QBBWindow *window, mChildren) {
QBBWindow * const result = window->findWindow(windowHandle);
if (result)
return result;
}
return 0;
}
void QBBWindow::updateZorder(int &topZorder)
{
errno = 0;
int result = screen_set_window_property_iv(mWindow, SCREEN_PROPERTY_ZORDER, &topZorder);
topZorder++;
if (result != 0)
qFatal("QBBWindow: failed to set window z-order=%d, errno=%d, mWindow=0x%08x", topZorder, errno, mWindow);
QList<QBBWindow*>::const_iterator it;
for (it = mChildren.begin(); it != mChildren.end(); it++)
(*it)->updateZorder(topZorder);
}
void QBBWindow::copyBack(const QRegion &region, int dx, int dy, bool flush)
{
int result;
// abort if previous buffer is invalid
if (mPreviousBufferIndex == -1) {
return;
}
// abort if nothing to copy
if (region.isEmpty()) {
return;
}
QBBBuffer &currentBuffer = mBuffers[mCurrentBufferIndex];
QBBBuffer &previousBuffer = mBuffers[mPreviousBufferIndex];
// break down region into non-overlapping rectangles
QVector<QRect> rects = region.rects();
for (int i = rects.size() - 1; i >= 0; i--) {
// clip rectangle to bounds of target
QRect rect = rects[i].intersected( currentBuffer.rect() );
if (rect.isEmpty())
continue;
// setup blit operation
int attribs[] = { SCREEN_BLIT_SOURCE_X, rect.x(),
SCREEN_BLIT_SOURCE_Y, rect.y(),
SCREEN_BLIT_SOURCE_WIDTH, rect.width(),
SCREEN_BLIT_SOURCE_HEIGHT, rect.height(),
SCREEN_BLIT_DESTINATION_X, rect.x() + dx,
SCREEN_BLIT_DESTINATION_Y, rect.y() + dy,
SCREEN_BLIT_DESTINATION_WIDTH, rect.width(),
SCREEN_BLIT_DESTINATION_HEIGHT, rect.height(),
SCREEN_BLIT_END };
// queue blit operation
errno = 0;
result = screen_blit(mContext, currentBuffer.nativeBuffer(), previousBuffer.nativeBuffer(), attribs);
if (result != 0) {
qFatal("QBBWindow: failed to blit buffers, errno=%d", errno);
}
}
// check if flush requested
if (flush) {
// wait for all blits to complete
errno = 0;
result = screen_flush_blits(mContext, SCREEN_WAIT_IDLE);
if (result != 0) {
qFatal("QBBWindow: failed to flush blits, errno=%d", errno);
}
// buffer was modified outside the CPU
currentBuffer.invalidateInCache();
}
}
int QBBWindow::platformWindowFormatToNativeFormat(const QPlatformWindowFormat &format)
{
// extract size of colour channels from window format
int redSize = format.redBufferSize();
if (redSize == -1) {
qFatal("QBBWindow: red size not defined");
}
int greenSize = format.greenBufferSize();
if (greenSize == -1) {
qFatal("QBBWindow: green size not defined");
}
int blueSize = format.blueBufferSize();
if (blueSize == -1) {
qFatal("QBBWindow: blue size not defined");
}
// select matching native format
if (redSize == 5 && greenSize == 6 && blueSize == 5) {
return SCREEN_FORMAT_RGB565;
} else if (redSize == 8 && greenSize == 8 && blueSize == 8) {
return SCREEN_FORMAT_RGBA8888;
} else {
qFatal("QBBWindow: unsupported pixel format");
return 0;
}
}
QT_END_NAMESPACE

View file

@ -1,137 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBBWINDOW_H
#define QBBWINDOW_H
#include "qbbbuffer.h"
#include <QImage>
#include <QtGui/QPlatformWindow>
#include <screen/screen.h>
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
class QPlatformWindowFormat;
class QBBGLContext;
class QBBScreen;
class QBBWindow : public QPlatformWindow
{
friend class QBBScreen;
public:
QBBWindow(QWidget *window, screen_context_t context, QBBScreen *screen);
virtual ~QBBWindow();
virtual void setGeometry(const QRect &rect);
virtual void setVisible(bool visible);
virtual void setOpacity(qreal level);
virtual WId winId() const { return (WId)mWindow; }
void setBufferSize(const QSize &size);
QSize bufferSize() const { return mBufferSize; }
bool hasBuffers() const { return !mBufferSize.isEmpty(); }
QBBBuffer &renderBuffer();
QBBBuffer &frontBuffer();
void scroll(const QRegion &region, int dx, int dy, bool flush=false);
void post(const QRegion &dirty);
void setScreen(QBBScreen *platformScreen);
virtual QPlatformGLContext *glContext() const;
virtual void setParent(const QPlatformWindow *window);
virtual void raise();
virtual void lower();
virtual void requestActivateWindow();
void gainedFocus();
QBBScreen* screen() const { return mScreen; }
const QList<QBBWindow*>& children() const { return mChildren; }
QBBWindow *findWindow(screen_window_t windowHandle);
private:
enum Buffer {
BACK_BUFFER,
FRONT_BUFFER,
MAX_BUFFER_COUNT
};
QBBBuffer &buffer(QBBWindow::Buffer bufferIndex);
screen_context_t mContext;
screen_window_t mWindow;
QSize mBufferSize;
QBBBuffer mBuffers[MAX_BUFFER_COUNT];
int mCurrentBufferIndex;
int mPreviousBufferIndex;
QRegion mPreviousDirty;
QRegion mScrolled;
mutable QBBGLContext* mPlatformGlContext;
QBBScreen* mScreen;
QList<QBBWindow*> mChildren;
QBBWindow *mParent;
bool mVisible;
void removeFromParent();
void offset(const QPoint &offset);
void updateVisibility(bool parentVisible);
void updateZorder(int &topZorder);
void fetchBuffers();
void copyBack(const QRegion &region, int dx, int dy, bool flush=false);
static int platformWindowFormatToNativeFormat(const QPlatformWindowFormat &format);
};
QT_END_NAMESPACE
#endif // QBBWINDOW_H

View file

@ -1,29 +0,0 @@
TARGET = qcocoa
include(../../qpluginbase.pri)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
OBJECTIVE_SOURCES = main.mm \
qcocoaintegration.mm \
qcocoawindowsurface.mm \
qcocoawindow.mm \
qnsview.mm \
qcocoaeventloopintegration.mm \
qcocoaautoreleasepool.mm \
qnswindowdelegate.mm
OBJECTIVE_HEADERS = qcocoaintegration.h \
qcocoawindowsurface.h \
qcocoawindow.h \
qnsview.h \
qcocoaeventloopintegration.h \
qcocoaautoreleasepool.h \
qnswindowdelegate.h
#add libz for freetype.
LIBS += -lz
LIBS += -framework cocoa
include(../fontdatabases/coretext/coretext.pri)
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target

View file

@ -1,74 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <Cocoa/Cocoa.h>
#include <QtGui/QPlatformIntegrationPlugin>
#include "qcocoaintegration.h"
QT_BEGIN_NAMESPACE
class QCocoaIntegrationPlugin : public QPlatformIntegrationPlugin
{
public:
QStringList keys() const;
QPlatformIntegration *create(const QString&, const QStringList&);
};
QStringList QCocoaIntegrationPlugin::keys() const
{
QStringList list;
list << "Cocoa";
return list;
}
QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
if (system.toLower() == "cocoa")
return new QCocoaIntegration;
return 0;
}
Q_EXPORT_PLUGIN2(Cocoa, QCocoaIntegrationPlugin)
QT_END_NAMESPACE

View file

@ -1,57 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QCOCOAAUTORELEASEPOOL_H
#define QCOCOAAUTORELEASEPOOL_H
#include <Cocoa/Cocoa.h>
class QCocoaAutoReleasePool
{
public:
QCocoaAutoReleasePool();
~QCocoaAutoReleasePool();
private:
NSAutoreleasePool *pool;
};
#endif // QCOCOAAUTORELEASEPOOL_H

View file

@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qcocoaautoreleasepool.h"
QCocoaAutoReleasePool::QCocoaAutoReleasePool()
{
pool = [[NSAutoreleasePool alloc] init];
}
QCocoaAutoReleasePool::~QCocoaAutoReleasePool()
{
[pool release];
}

View file

@ -1,65 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QCOCAEVENTLOOPINTEGRATION_H
#define QCOCAEVENTLOOPINTEGRATION_H
#include <Cocoa/Cocoa.h>
#include <QPlatformEventLoopIntegration>
class QCocoaEventLoopIntegration : public QPlatformEventLoopIntegration
{
public:
QCocoaEventLoopIntegration();
void startEventLoop();
void quitEventLoop();
void qtNeedsToProcessEvents();
private:
CFRunLoopSourceContext m_sourceContext;
CFRunLoopTimerContext m_timerContext;
CFRunLoopSourceRef m_source;
};
#endif // QCOCAEVENTLOOPINTEGRATION_H

View file

@ -1,112 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qcocoaeventloopintegration.h"
#import <Cocoa/Cocoa.h>
#include "qcocoaautoreleasepool.h"
#include <QtCore/QElapsedTimer>
#include <QDebug>
#include <QApplication>
void wakeupCallback ( void * ) {
QPlatformEventLoopIntegration::processEvents();
}
void timerCallback( CFRunLoopTimerRef timer, void *info)
{
QPlatformEventLoopIntegration::processEvents();
QCocoaEventLoopIntegration *eventLoopIntegration =
static_cast<QCocoaEventLoopIntegration *>(info);
qint64 nextTime = eventLoopIntegration->nextTimerEvent();
CFAbsoluteTime nexttime = CFAbsoluteTimeGetCurrent();
nexttime = nexttime + (double(nextTime)/1000);
CFRunLoopTimerSetNextFireDate(timer,nexttime);
}
QCocoaEventLoopIntegration::QCocoaEventLoopIntegration() :
QPlatformEventLoopIntegration()
{
[NSApplication sharedApplication];
m_sourceContext.version = 0;
m_sourceContext.info = this;
m_sourceContext.retain = 0;
m_sourceContext.release = 0;
m_sourceContext.copyDescription = 0;
m_sourceContext.equal = 0;
m_sourceContext.hash = 0;
m_sourceContext.schedule = 0;
m_sourceContext.cancel = 0;
m_sourceContext.perform = wakeupCallback;
m_source = CFRunLoopSourceCreate(0,0,&m_sourceContext);
CFRunLoopAddSource(CFRunLoopGetMain(),m_source,kCFRunLoopCommonModes);
m_timerContext.version = 0;
m_timerContext.info = this;
m_timerContext.retain = 0;
m_timerContext.release = 0;
m_timerContext.copyDescription = 0;
CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent ();
CFTimeInterval interval = 30;
CFRunLoopTimerRef m_timerSource = CFRunLoopTimerCreate(0,fireDate,interval,0,0,timerCallback,&m_timerContext);
CFRunLoopAddTimer(CFRunLoopGetMain(),m_timerSource,kCFRunLoopCommonModes);
}
void QCocoaEventLoopIntegration::startEventLoop()
{
[[NSApplication sharedApplication] run];
}
void QCocoaEventLoopIntegration::quitEventLoop()
{
[[NSApplication sharedApplication] terminate:nil];
}
void QCocoaEventLoopIntegration::qtNeedsToProcessEvents()
{
CFRunLoopSourceSignal(m_source);
}

View file

@ -1,99 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QPLATFORMINTEGRATION_COCOA_H
#define QPLATFORMINTEGRATION_COCOA_H
#include <Cocoa/Cocoa.h>
#include "qcocoaautoreleasepool.h"
#include <QtGui/QPlatformIntegration>
QT_BEGIN_NAMESPACE
class QCocoaScreen : public QPlatformScreen
{
public:
QCocoaScreen(int screenIndex);
~QCocoaScreen();
QRect geometry() const { return m_geometry; }
int depth() const { return m_depth; }
QImage::Format format() const { return m_format; }
QSize physicalSize() const { return m_physicalSize; }
public:
NSScreen *m_screen;
QRect m_geometry;
int m_depth;
QImage::Format m_format;
QSize m_physicalSize;
};
class QCocoaIntegration : public QPlatformIntegration
{
public:
QCocoaIntegration();
~QCocoaIntegration();
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
QList<QPlatformScreen *> screens() const { return mScreens; }
QPlatformFontDatabase *fontDatabase() const;
QPlatformEventLoopIntegration *createEventLoopIntegration() const;
private:
QList<QPlatformScreen *> mScreens;
QPlatformFontDatabase *mFontDb;
QCocoaAutoReleasePool *mPool;
};
QT_END_NAMESPACE
#endif

View file

@ -1,132 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qcocoaintegration.h"
#include "qcocoawindow.h"
#include "qcocoawindowsurface.h"
#include "qcocoaeventloopintegration.h"
#include "qcoretextfontdatabase.h"
#include <QtGui/QApplication>
#include <private/qpixmap_raster_p.h>
QT_BEGIN_NAMESPACE
QCocoaScreen::QCocoaScreen(int screenIndex)
:QPlatformScreen()
{
m_screen = [[NSScreen screens] objectAtIndex:screenIndex];
NSRect rect = [m_screen frame];
m_geometry = QRect(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
m_format = QImage::Format_ARGB32;
m_depth = NSBitsPerPixelFromDepth([m_screen depth]);
const int dpi = 72;
const qreal inch = 25.4;
m_physicalSize = QSize(qRound(m_geometry.width() * inch / dpi), qRound(m_geometry.height() *inch / dpi));
}
QCocoaScreen::~QCocoaScreen()
{
}
QCocoaIntegration::QCocoaIntegration()
: mFontDb(new QCoreTextFontDatabase())
{
mPool = new QCocoaAutoReleasePool;
//Make sure we have a nsapplication :)
[NSApplication sharedApplication];
// [[OurApplication alloc] init];
NSArray *screens = [NSScreen screens];
for (uint i = 0; i < [screens count]; i++) {
QCocoaScreen *screen = new QCocoaScreen(i);
mScreens.append(screen);
}
}
QCocoaIntegration::~QCocoaIntegration()
{
delete mPool;
}
bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case ThreadedPixmaps: return true;
default: return QPlatformIntegration::hasCapability(cap);
}
}
QPixmapData *QCocoaIntegration::createPixmapData(QPixmapData::PixelType type) const
{
return new QRasterPixmapData(type);
}
QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
return new QCocoaWindow(widget);
}
QWindowSurface *QCocoaIntegration::createWindowSurface(QWidget *widget, WId winId) const
{
return new QCocoaWindowSurface(widget,winId);
}
QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const
{
return mFontDb;
}
QPlatformEventLoopIntegration *QCocoaIntegration::createEventLoopIntegration() const
{
return new QCocoaEventLoopIntegration();
}
QT_END_NAMESPACE

View file

@ -1,75 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QCOCOAWINDOW_H
#define QCOCOAWINDOW_H
#include <Cocoa/Cocoa.h>
#include <QPlatformWindow>
QT_BEGIN_NAMESPACE
class QCocoaWindow : public QPlatformWindow
{
public:
QCocoaWindow(QWidget *tlw);
~QCocoaWindow();
void setGeometry(const QRect &rect);
void setVisible(bool visible);
WId winId() const;
NSView *contentView() const;
void setContentView(NSView *contentView);
void windowDidResize();
private:
NSWindow *m_nsWindow;
};
QT_END_NAMESPACE
#endif // QCOCOAWINDOW_H

View file

@ -1,115 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qcocoawindow.h"
#include "qnswindowdelegate.h"
#include "qcocoaautoreleasepool.h"
#include <QWidget>
#include <QtGui/QApplication>
#include <QWindowSystemInterface>
#include <QDebug>
QCocoaWindow::QCocoaWindow(QWidget *tlw)
: QPlatformWindow(tlw)
{
QCocoaAutoReleasePool pool;
const QRect geo = tlw->geometry();
NSRect frame = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
m_nsWindow = [[NSWindow alloc] initWithContentRect:frame
styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:YES];
QNSWindowDelegate *delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this];
[m_nsWindow setDelegate:delegate];
[m_nsWindow makeKeyAndOrderFront:nil];
[m_nsWindow setAcceptsMouseMovedEvents:YES];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if ([m_nsWindow respondsToSelector:@selector(setRestorable:)])
[m_nsWindow setRestorable: NO];
#endif
}
QCocoaWindow::~QCocoaWindow()
{
}
void QCocoaWindow::setGeometry(const QRect &rect)
{
QPlatformWindow::setGeometry(rect);
NSRect bounds = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
[[m_nsWindow contentView]setFrameSize:bounds.size];
}
void QCocoaWindow::setVisible(bool visible)
{
Q_UNUSED(visible);
}
WId QCocoaWindow::winId() const
{
return WId([m_nsWindow windowNumber]);
}
NSView *QCocoaWindow::contentView() const
{
return [m_nsWindow contentView];
}
void QCocoaWindow::setContentView(NSView *contentView)
{
[m_nsWindow setContentView:contentView];
}
void QCocoaWindow::windowDidResize()
{
//jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing...
NSRect rect = [[m_nsWindow contentView]frame];
QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
QWindowSystemInterface::handleGeometryChange(widget(),geo);
}

View file

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSURFACE_COCOA_H
#define QWINDOWSURFACE_COCOA_H
#include <Cocoa/Cocoa.h>
#include "qcocoawindow.h"
#include "qnsview.h"
#include <QtGui/private/qwindowsurface_p.h>
QT_BEGIN_NAMESPACE
class QCocoaWindowSurface : public QWindowSurface
{
public:
QCocoaWindowSurface(QWidget *window, WId wid);
~QCocoaWindowSurface();
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void resize (const QSize &size);
private:
QCocoaWindow *m_cocoaWindow;
QImage *m_image;
QNSView *m_contentView;
};
QT_END_NAMESPACE
#endif

View file

@ -1,103 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qcocoawindowsurface.h"
#include <QtCore/qdebug.h>
#include <QtGui/QPainter>
QT_BEGIN_NAMESPACE
QRect flipedRect(const QRect &sourceRect,int height)
{
if (!sourceRect.isValid())
return QRect();
QRect flippedRect = sourceRect;
flippedRect.moveTop(height - sourceRect.y());
return flippedRect;
}
QCocoaWindowSurface::QCocoaWindowSurface(QWidget *window, WId wId)
: QWindowSurface(window)
{
m_cocoaWindow = static_cast<QCocoaWindow *>(window->platformWindow());
const QRect geo = window->geometry();
NSRect rect = NSMakeRect(geo.x(),geo.y(),geo.width(),geo.height());
m_contentView = [[QNSView alloc] initWithWidget:window];
m_cocoaWindow->setContentView(m_contentView);
m_image = new QImage(window->size(),QImage::Format_ARGB32);
}
QCocoaWindowSurface::~QCocoaWindowSurface()
{
delete m_image;
}
QPaintDevice *QCocoaWindowSurface::paintDevice()
{
return m_image;
}
void QCocoaWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(widget);
Q_UNUSED(offset);
QRect geo = region.boundingRect();
NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
[m_contentView displayRect:rect];
}
void QCocoaWindowSurface::resize(const QSize &size)
{
QWindowSurface::resize(size);
delete m_image;
m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied);
NSSize newSize = NSMakeSize(size.width(),size.height());
[m_contentView setImage:m_image];
}
QT_END_NAMESPACE

View file

@ -1,79 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNSVIEW_H
#define QNSVIEW_H
#include <Cocoa/Cocoa.h>
#include <QtGui/QImage>
@interface QNSView : NSView {
CGImageRef m_cgImage;
QWidget *m_widget;
Qt::MouseButtons m_buttons;
}
- (id)init;
- (id)initWithWidget:(QWidget *)widget;
- (void)setImage:(QImage *)image;
- (void)drawRect:(NSRect)dirtyRect;
- (BOOL)isFlipped;
- (void)handleMouseEvent:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)theEvent;
- (void)mouseUp:(NSEvent *)theEvent;
- (void)mouseMoved:(NSEvent *)theEvent;
- (void)mouseEntered:(NSEvent *)theEvent;
- (void)mouseExited:(NSEvent *)theEvent;
- (void)rightMouseDown:(NSEvent *)theEvent;
- (void)rightMouseDragged:(NSEvent *)theEvent;
- (void)rightMouseUp:(NSEvent *)theEvent;
- (void)otherMouseDown:(NSEvent *)theEvent;
- (void)otherMouseDragged:(NSEvent *)theEvent;
- (void)otherMouseUp:(NSEvent *)theEvent;
@end
#endif //QNSVIEW_H

View file

@ -1,211 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qnsview.h"
#include <QtGui/QWindowSystemInterface>
#include <QtCore/QDebug>
@implementation QNSView
- (id) init
{
self = [super init];
if (self) {
m_cgImage = 0;
m_widget = 0;
m_buttons = Qt::NoButton;
}
return self;
}
- (id)initWithWidget:(QWidget *)widget {
self = [self init];
if (self) {
m_widget = widget;
}
return self;
}
- (void) setImage:(QImage *)image
{
CGImageRelease(m_cgImage);
const uchar *imageData = image->bits();
int bitDepth = image->depth();
int colorBufferSize = 8;
int bytesPrLine = image->bytesPerLine();
int width = image->width();
int height = image->height();
CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB();
CGDataProviderRef cgDataProviderRef = CGDataProviderCreateWithData(
NULL,
imageData,
image->byteCount(),
NULL);
m_cgImage = CGImageCreate(width,
height,
colorBufferSize,
bitDepth,
bytesPrLine,
cgColourSpaceRef,
kCGImageAlphaNone,
cgDataProviderRef,
NULL,
false,
kCGRenderingIntentDefault);
CGColorSpaceRelease(cgColourSpaceRef);
}
- (void) drawRect:(NSRect)dirtyRect
{
if (!m_cgImage)
return;
CGRect dirtyCGRect = NSRectToCGRect(dirtyRect);
NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext];
CGContextRef cgContext = (CGContextRef) [nsGraphicsContext graphicsPort];
CGContextSaveGState( cgContext );
int dy = dirtyCGRect.origin.y + CGRectGetMaxY(dirtyCGRect);
CGContextTranslateCTM(cgContext, 0, dy);
CGContextScaleCTM(cgContext, 1, -1);
CGImageRef subImage = CGImageCreateWithImageInRect(m_cgImage, dirtyCGRect);
CGContextDrawImage(cgContext,dirtyCGRect,subImage);
CGContextRestoreGState(cgContext);
CGImageRelease(subImage);
}
- (BOOL) isFlipped
{
return YES;
}
- (void)handleMouseEvent:(NSEvent *)theEvent;
{
NSPoint point = [self convertPoint: [theEvent locationInWindow] fromView: nil];
QPoint qt_localPoint(point.x,point.y);
NSTimeInterval timestamp = [theEvent timestamp];
ulong qt_timestamp = timestamp * 1000;
QWindowSystemInterface::handleMouseEvent(m_widget,qt_timestamp,qt_localPoint,QPoint(),m_buttons);
}
- (void)mouseDown:(NSEvent *)theEvent
{
m_buttons |= Qt::LeftButton;
[self handleMouseEvent:theEvent];
}
- (void)mouseDragged:(NSEvent *)theEvent
{
if (!(m_buttons & Qt::LeftButton))
qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
[self handleMouseEvent:theEvent];
}
- (void)mouseUp:(NSEvent *)theEvent
{
m_buttons &= QFlag(~int(Qt::LeftButton));
[self handleMouseEvent:theEvent];
}
- (void)mouseMoved:(NSEvent *)theEvent
{
qDebug() << "mouseMove";
[self handleMouseEvent:theEvent];
}
- (void)mouseEntered:(NSEvent *)theEvent
{
Q_UNUSED(theEvent);
QWindowSystemInterface::handleEnterEvent(m_widget);
}
- (void)mouseExited:(NSEvent *)theEvent
{
Q_UNUSED(theEvent);
QWindowSystemInterface::handleLeaveEvent(m_widget);
}
- (void)rightMouseDown:(NSEvent *)theEvent
{
m_buttons |= Qt::RightButton;
[self handleMouseEvent:theEvent];
}
- (void)rightMouseDragged:(NSEvent *)theEvent
{
if (!(m_buttons & Qt::LeftButton))
qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
[self handleMouseEvent:theEvent];
}
- (void)rightMouseUp:(NSEvent *)theEvent
{
m_buttons &= QFlag(~int(Qt::RightButton));
[self handleMouseEvent:theEvent];
}
- (void)otherMouseDown:(NSEvent *)theEvent
{
m_buttons |= Qt::RightButton;
[self handleMouseEvent:theEvent];
}
- (void)otherMouseDragged:(NSEvent *)theEvent
{
if (!(m_buttons & Qt::LeftButton))
qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
[self handleMouseEvent:theEvent];
}
- (void)otherMouseUp:(NSEvent *)theEvent
{
m_buttons &= QFlag(~int(Qt::MiddleButton));
[self handleMouseEvent:theEvent];
}
@end

View file

@ -1,61 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNSWINDOWDELEGATE_H
#define QNSWINDOWDELEGATE_H
#include <Cocoa/Cocoa.h>
#include "qcocoawindow.h"
@interface QNSWindowDelegate : NSObject <NSWindowDelegate>
{
QCocoaWindow *m_cocoaWindow;
}
- (id)initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow;
- (void)windowDidResize:(NSNotification *)notification;
- (void)windowWillClose:(NSNotification *)notification;
@end
#endif // QNSWINDOWDELEGATE_H

View file

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qnswindowdelegate.h"
#include <QDebug>
#include <QWindowSystemInterface>
@implementation QNSWindowDelegate
- (id) initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow
{
self = [super init];
if (self) {
m_cocoaWindow = cocoaWindow;
}
return self;
}
- (void)windowDidResize:(NSNotification *)notification
{
Q_UNUSED(notification);
if (m_cocoaWindow) {
m_cocoaWindow->windowDidResize();
}
}
- (void)windowWillClose:(NSNotification *)notification
{
Q_UNUSED(notification);
QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->widget());
}
@end

View file

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtGui/QPlatformIntegrationPlugin>
#include "qminimalintegration.h"
QT_BEGIN_NAMESPACE
class QMinimalIntegrationPlugin : public QPlatformIntegrationPlugin
{
public:
QStringList keys() const;
QPlatformIntegration *create(const QString&, const QStringList&);
};
QStringList QMinimalIntegrationPlugin::keys() const
{
QStringList list;
list << "Minimal";
return list;
}
QPlatformIntegration *QMinimalIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
if (system.toLower() == "minimal")
return new QMinimalIntegration;
return 0;
}
Q_EXPORT_PLUGIN2(minimal, QMinimalIntegrationPlugin)
QT_END_NAMESPACE

View file

@ -1,13 +0,0 @@
TARGET = qminimal
include(../../qpluginbase.pri)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
SOURCES = main.cpp \
qminimalintegration.cpp \
qminimalwindowsurface.cpp
HEADERS = qminimalintegration.h \
qminimalwindowsurface.h
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target

View file

@ -1,82 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qminimalintegration.h"
#include "qminimalwindowsurface.h"
#include <QtGui/qpixmap_raster_p.h>
#include <QtGui/QPlatformWindow>
QMinimalIntegration::QMinimalIntegration()
{
QMinimalScreen *mPrimaryScreen = new QMinimalScreen();
mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320);
mPrimaryScreen->mDepth = 32;
mPrimaryScreen->mFormat = QImage::Format_ARGB32_Premultiplied;
mScreens.append(mPrimaryScreen);
}
bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case ThreadedPixmaps: return true;
default: return QPlatformIntegration::hasCapability(cap);
}
}
QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) const
{
return new QRasterPixmapData(type);
}
QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
return new QPlatformWindow(widget);
}
QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
return new QMinimalWindowSurface(widget);
}

View file

@ -1,86 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QPLATFORMINTEGRATION_MINIMAL_H
#define QPLATFORMINTEGRATION_MINIMAL_H
#include <QtGui/QPlatformIntegration>
#include <QtGui/QPlatformScreen>
QT_BEGIN_NAMESPACE
class QMinimalScreen : public QPlatformScreen
{
public:
QMinimalScreen()
: mDepth(32), mFormat(QImage::Format_ARGB32_Premultiplied) {}
QRect geometry() const { return mGeometry; }
int depth() const { return mDepth; }
QImage::Format format() const { return mFormat; }
public:
QRect mGeometry;
int mDepth;
QImage::Format mFormat;
QSize mPhysicalSize;
};
class QMinimalIntegration : public QPlatformIntegration
{
public:
QMinimalIntegration();
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
QList<QPlatformScreen *> screens() const { return mScreens; }
private:
QList<QPlatformScreen *> mScreens;
};
QT_END_NAMESPACE
#endif

View file

@ -1,86 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qminimalwindowsurface.h"
#include <QtCore/qdebug.h>
#include <QtGui/qapplication_p.h>
QT_BEGIN_NAMESPACE
QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window)
: QWindowSurface(window)
{
//qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this;
}
QMinimalWindowSurface::~QMinimalWindowSurface()
{
}
QPaintDevice *QMinimalWindowSurface::paintDevice()
{
//qDebug() << "QMinimalWindowSurface::paintDevice";
return &mImage;
}
void QMinimalWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(widget);
Q_UNUSED(region);
Q_UNUSED(offset);
static int c = 0;
QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0'));
qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData();
mImage.save(filename);
}
void QMinimalWindowSurface::resize(const QSize &size)
{
//qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect;
QWindowSurface::resize(size);
QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format();
if (mImage.size() != size)
mImage = QImage(size, format);
}
QT_END_NAMESPACE

View file

@ -1,67 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSURFACE_MINIMAL_H
#define QWINDOWSURFACE_MINIMAL_H
#include <QtGui/qwindowsurface_p.h>
#include <QtGui/QPlatformWindow>
QT_BEGIN_NAMESPACE
class QMinimalWindowSurface : public QWindowSurface
{
public:
QMinimalWindowSurface(QWidget *window);
~QMinimalWindowSurface();
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void resize(const QSize &size);
private:
QImage mImage;
};
QT_END_NAMESPACE
#endif

View file

@ -1,11 +0,0 @@
TEMPLATE = subdirs
SUBDIRS += minimal
contains(QT_CONFIG, wayland) {
SUBDIRS += wayland
}
qnx {
SUBDIRS += blackberry
}

View file

@ -1,38 +0,0 @@
if(WITH_OPENGL AND OPENGL_FOUND)
set(WAYLANDPLUGIN_DEFINITIONS
${WAYLANDPLUGIN_DEFINITIONS}
-DQT_WAYLAND_GL_SUPPORT
)
endif()
set(WAYLANDPLUGIN_HEADERS
${WAYLANDPLUGIN_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/qwaylandglintegration.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
)
set(WAYLANDPLUGIN_SOURCES
${WAYLANDPLUGIN_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/qwaylandglintegration.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
)
# TODO: automatically choose the best one for the platform
set(WAYLANDPLUGIN_INTEGRATION "xcomposite_glx")
if(WITH_OPENGLES2)
if(${WAYLANDPLUGIN_INTEGRATION} STREQUAL "wayland_egl")
include(wayland_egl/wayland_egl.cmake)
elseif(${WAYLANDPLUGIN_INTEGRATION} STREQUAL "readback")
include(readback_egl/readback_egl.cmake)
else()
include(xcomposite_egl/xcomposite_egl.cmake)
endif()
else()
if(${WAYLANDPLUGIN_INTEGRATION} STREQUAL "readback")
include(readback_glx/readback_glx.cmake)
else()
include(xcomposite_glx/xcomposite_glx.cmake)
endif()
endif()

View file

@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandglintegration.h"
QWaylandGLIntegration::QWaylandGLIntegration()
{
}
QWaylandGLIntegration::~QWaylandGLIntegration()
{
}

View file

@ -1,62 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDGLINTEGRATION_H
#define QWAYLANDGLINTEGRATION_H
class QWaylandWindow;
class QWaylandDisplay;
class QWidget;
class QWaylandGLIntegration
{
public:
QWaylandGLIntegration();
virtual ~QWaylandGLIntegration();
virtual void initialize() = 0;
virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0;
static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay);
};
#endif // QWAYLANDGLINTEGRATION_H

View file

@ -1,184 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandglwindowsurface.h"
#include "qwaylanddisplay.h"
#include "qwaylandwindow.h"
#include "qwaylandscreen.h"
#include <QtOpenGL/QGLFramebufferObject>
#include <QtOpenGL/qgl.h>
#include <QtOpenGL/qglengineshadermanager_p.h>
QT_BEGIN_NAMESPACE
static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br)
{
#if !defined(QT_OPENGL_ES_2)
QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
#endif
const GLenum target = GL_TEXTURE_2D;
QRectF src = br.isEmpty()
? QRectF(QPointF(), texSize)
: QRectF(QPointF(br.x(), texSize.height() - br.bottom()), br.size());
if (target == GL_TEXTURE_2D) {
qreal width = texSize.width();
qreal height = texSize.height();
src.setLeft(src.left() / width);
src.setRight(src.right() / width);
src.setTop(src.top() / height);
src.setBottom(src.bottom() / height);
}
const GLfloat tx1 = src.left();
const GLfloat tx2 = src.right();
const GLfloat ty1 = src.top();
const GLfloat ty2 = src.bottom();
GLfloat texCoordArray[4*2] = {
tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1
};
GLfloat vertexArray[4*2];
vertexArray[0] = rect.left(); vertexArray[1] = rect.top();
vertexArray[2] = rect.right(); vertexArray[3] = rect.top();
vertexArray[4] = rect.right(); vertexArray[5] = rect.bottom();
vertexArray[6] = rect.left(); vertexArray[7] = rect.bottom();
glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexArray);
glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, texCoordArray);
glBindTexture(target, tex_id);
glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
glBindTexture(target, 0);
}
static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect)
{
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
glViewport(0, 0, viewport.width(), viewport.height());
QGLShaderProgram *blitProgram =
QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram();
blitProgram->bind();
blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/);
// The shader manager's blit program does not multiply the
// vertices by the pmv matrix, so we need to do the effect
// of the orthographic projection here ourselves.
QRectF r;
qreal w = viewport.width();
qreal h = viewport.height();
r.setLeft((targetRect.left() / w) * 2.0f - 1.0f);
if (targetRect.right() == (viewport.width() - 1))
r.setRight(1.0f);
else
r.setRight((targetRect.right() / w) * 2.0f - 1.0f);
r.setBottom((targetRect.top() / h) * 2.0f - 1.0f);
if (targetRect.bottom() == (viewport.height() - 1))
r.setTop(1.0f);
else
r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f);
drawTexture(r, texture, texSize, sourceRect);
}
QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWidget *window)
: QWindowSurface(window)
, mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
, mPaintDevice(0)
{
}
QWaylandGLWindowSurface::~QWaylandGLWindowSurface()
{
delete mPaintDevice;
}
QPaintDevice *QWaylandGLWindowSurface::paintDevice()
{
return mPaintDevice;
}
void QWaylandGLWindowSurface::beginPaint(const QRegion &)
{
window()->platformWindow()->glContext()->makeCurrent();
glClearColor(0,0,0,0xff);
glClear(GL_COLOR_BUFFER_BIT);
}
void QWaylandGLWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(offset);
Q_UNUSED(region);
QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow();
if (mPaintDevice->isBound())
mPaintDevice->release();
QRect rect(0,0,size().width(),size().height());
QGLContext *ctx = QGLContext::fromPlatformGLContext(ww->glContext());
blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect);
ww->glContext()->swapBuffers();
}
void QWaylandGLWindowSurface::resize(const QSize &size)
{
QWindowSurface::resize(size);
window()->platformWindow()->glContext()->makeCurrent();
delete mPaintDevice;
mPaintDevice = new QGLFramebufferObject(size,QGLFramebufferObject::CombinedDepthStencil);
}
QT_END_NAMESPACE

View file

@ -1,69 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDDRMSURFACE_H
#define QWAYLANDDRMSURFACE_H
#include "qwaylanddisplay.h"
#include <QtGui/qwindowsurface_p.h>
class QGLFramebufferObject;
class QWaylandGLWindowSurface : public QWindowSurface
{
public:
QWaylandGLWindowSurface(QWidget *window);
~QWaylandGLWindowSurface();
void beginPaint(const QRegion &);
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void resize(const QSize &size);
private:
QWaylandDisplay *mDisplay;
QGLFramebufferObject *mPaintDevice;
};
#endif // QWAYLANDDRMSURFACE_H

View file

@ -1,174 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandreadbackeglcontext.h"
#include "../../../eglconvenience/qeglconvenience.h"
#include <QtOpenGL/qgl.h>
#include <QtOpenGL/qglextensions_p.h>
#include "qwaylandshmsurface.h"
#include <QtCore/QDebug>
static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type)
{
const int width = img.width();
const int height = img.height();
if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV
|| (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
{
for (int i = 0; i < height; ++i) {
uint *p = (uint *) img.scanLine(i);
for (int x = 0; x < width; ++x)
p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
}
} else {
for (int i = 0; i < height; ++i) {
uint *p = (uint *) img.scanLine(i);
for (int x = 0; x < width; ++x)
p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff);
}
}
}
QWaylandReadbackEglContext::QWaylandReadbackEglContext(QWaylandReadbackEglIntegration *eglIntegration, QWaylandReadbackEglWindow *window)
: mEglIntegration(eglIntegration)
, mWindow(window)
, mBuffer(0)
, mPixmap(0)
, mConfig(q_configFromQPlatformWindowFormat(eglIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_PIXMAP_BIT))
, mPixmapSurface(EGL_NO_SURFACE)
{
QVector<EGLint> eglContextAttrs;
eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
eglContextAttrs.append(2);
eglContextAttrs.append(EGL_NONE);
mContext = eglCreateContext(eglIntegration->eglDisplay(),mConfig,0,eglContextAttrs.constData());
geometryChanged();
}
QWaylandReadbackEglContext::~QWaylandReadbackEglContext()
{
eglDestroyContext(mEglIntegration->eglDisplay(),mContext);
}
void QWaylandReadbackEglContext::makeCurrent()
{
QPlatformGLContext::makeCurrent();
mWindow->waitForFrameSync();
eglMakeCurrent(mEglIntegration->eglDisplay(),mPixmapSurface,mPixmapSurface,mContext);
}
void QWaylandReadbackEglContext::doneCurrent()
{
QPlatformGLContext::doneCurrent();
eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
}
void QWaylandReadbackEglContext::swapBuffers()
{
eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface);
if (QPlatformGLContext::currentContext() != this) {
makeCurrent();
}
QSize size = mWindow->geometry().size();
QImage img(size,QImage::Format_ARGB32);
const uchar *constBits = img.bits();
void *pixels = const_cast<uchar *>(constBits);
glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels);
img = img.mirrored();
qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV);
constBits = img.bits();
const uchar *constDstBits = mBuffer->image()->bits();
uchar *dstBits = const_cast<uchar *>(constDstBits);
memcpy(dstBits,constBits,(img.width()*4) * img.height());
mWindow->damage(QRegion(QRect(QPoint(0,0),size)));
}
void * QWaylandReadbackEglContext::getProcAddress(const QString &procName)
{
return (void *) eglGetProcAddress(procName.toLatin1().data());
}
QPlatformWindowFormat QWaylandReadbackEglContext::platformWindowFormat() const
{
return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
}
void QWaylandReadbackEglContext::geometryChanged()
{
QSize size(mWindow->geometry().size());
if (size.isEmpty()) {
//QGLWidget wants a context for a window without geometry
size = QSize(1,1);
}
mWindow->waitForFrameSync();
delete mBuffer;
if (mPixmap)
XFreePixmap(mEglIntegration->xDisplay(),mPixmap);
mBuffer = new QWaylandShmBuffer(mEglIntegration->waylandDisplay(),size,QImage::Format_ARGB32);
mWindow->attach(mBuffer);
mPixmap = XCreatePixmap(mEglIntegration->xDisplay(),mEglIntegration->rootWindow(),size.width(),size.height(),mEglIntegration->depth());
XSync(mEglIntegration->xDisplay(),False);
mPixmapSurface = eglCreatePixmapSurface(mEglIntegration->eglDisplay(),mConfig,mPixmap,0);
if (mPixmapSurface == EGL_NO_SURFACE) {
qDebug() << "Could not make egl surface out of pixmap :(";
}
}

View file

@ -1,80 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDREADBACKEGLGLCONTEXT_H
#define QWAYLANDREADBACKEGLGLCONTEXT_H
#include <QPlatformGLContext>
#include <QtGui/QWidget>
#include "qwaylandreadbackeglintegration.h"
#include "qwaylandreadbackeglwindow.h"
class QWaylandShmBuffer;
class QWaylandReadbackEglContext : public QPlatformGLContext
{
public:
QWaylandReadbackEglContext(QWaylandReadbackEglIntegration *eglIntegration, QWaylandReadbackEglWindow *window);
~QWaylandReadbackEglContext();
void makeCurrent();
void doneCurrent();
void swapBuffers();
void* getProcAddress(const QString& procName);
virtual QPlatformWindowFormat platformWindowFormat() const;
void geometryChanged();
private:
QWaylandReadbackEglIntegration *mEglIntegration;
QWaylandReadbackEglWindow *mWindow;
QWaylandShmBuffer *mBuffer;
Pixmap mPixmap;
EGLConfig mConfig;
EGLContext mContext;
EGLSurface mPixmapSurface;
};
#endif // QWAYLANDREADBACKEGLGLCONTEXT_H

View file

@ -1,112 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandreadbackeglintegration.h"
#include <QDebug>
#include "qwaylandreadbackeglwindow.h"
QWaylandReadbackEglIntegration::QWaylandReadbackEglIntegration(QWaylandDisplay *display)
: QWaylandGLIntegration()
, mWaylandDisplay(display)
{
qDebug() << "Using Readback-EGL";
char *display_name = getenv("DISPLAY");
mDisplay = XOpenDisplay(display_name);
mScreen = XDefaultScreen(mDisplay);
mRootWindow = XDefaultRootWindow(mDisplay);
XSync(mDisplay, False);
}
QWaylandReadbackEglIntegration::~QWaylandReadbackEglIntegration()
{
XCloseDisplay(mDisplay);
}
QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
{
return new QWaylandReadbackEglIntegration(waylandDisplay);
}
void QWaylandReadbackEglIntegration::initialize()
{
eglBindAPI(EGL_OPENGL_ES_API);
mEglDisplay = eglGetDisplay(mDisplay);
EGLint major, minor;
EGLBoolean initialized = eglInitialize(mEglDisplay,&major,&minor);
if (initialized) {
qDebug() << "EGL initialized successfully" << major << "," << minor;
} else {
qDebug() << "EGL could not initialized. All EGL and GL operations will fail";
}
}
QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWidget *widget)
{
return new QWaylandReadbackEglWindow(widget,this);
}
EGLDisplay QWaylandReadbackEglIntegration::eglDisplay()
{
return mEglDisplay;
}
Window QWaylandReadbackEglIntegration::rootWindow() const
{
return mRootWindow;
}
int QWaylandReadbackEglIntegration::depth() const
{
return XDefaultDepth(mDisplay,mScreen);
}
Display * QWaylandReadbackEglIntegration::xDisplay() const
{
return mDisplay;
}
QWaylandDisplay * QWaylandReadbackEglIntegration::waylandDisplay() const
{
return mWaylandDisplay;
}

View file

@ -1,82 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDREADBACKEGLINTEGRATION_H
#define QWAYLANDREADBACKEGLINTEGRATION_H
#include "gl_integration/qwaylandglintegration.h"
#include <QtCore/QTextStream>
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
#include <QtGui/QWidget>
#include <X11/Xlib.h>
#include <EGL/egl.h>
class QWaylandReadbackEglIntegration : public QWaylandGLIntegration
{
public:
QWaylandReadbackEglIntegration(QWaylandDisplay *display);
~QWaylandReadbackEglIntegration();
void initialize();
QWaylandWindow *createEglWindow(QWidget *widget);
QWaylandDisplay *waylandDisplay() const;
Display *xDisplay() const;
Window rootWindow() const;
int depth() const;
EGLDisplay eglDisplay();
private:
QWaylandDisplay *mWaylandDisplay;
Display *mDisplay;
int mScreen;
Window mRootWindow;
EGLDisplay mEglDisplay;
};
#endif // QWAYLANDREADBACKEGLINTEGRATION_H

View file

@ -1,76 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandreadbackeglwindow.h"
#include "qwaylandreadbackeglcontext.h"
QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration)
: QWaylandShmWindow(window)
, mEglIntegration(eglIntegration)
, mContext(0)
{
}
QWaylandWindow::WindowType QWaylandReadbackEglWindow::windowType() const
{
//We'r lying, maybe we should add a type, but for now it will do
//since this is primarly used by the windowsurface.
return QWaylandWindow::Egl;
}
QPlatformGLContext *QWaylandReadbackEglWindow::glContext() const
{
if (!mContext) {
QWaylandReadbackEglWindow *that = const_cast<QWaylandReadbackEglWindow *>(this);
that->mContext = new QWaylandReadbackEglContext(mEglIntegration,that);
}
return mContext;
}
void QWaylandReadbackEglWindow::setGeometry(const QRect &rect)
{
QPlatformWindow::setGeometry(rect);
if (mContext)
mContext->geometryChanged();
}

View file

@ -1,66 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDREADBACKEGLWINDOW_H
#define QWAYLANDREADBACKEGLWINDOW_H
#include "qwaylandshmwindow.h"
#include "qwaylandreadbackeglintegration.h"
class QWaylandReadbackEglContext;
class QWaylandReadbackEglWindow : public QWaylandShmWindow
{
public:
QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration);
WindowType windowType() const;
QPlatformGLContext *glContext() const;
void setGeometry(const QRect &rect);
private:
QWaylandReadbackEglIntegration *mEglIntegration;
QWaylandReadbackEglContext *mContext;
};
#endif // QWAYLANDREADBACKEGLWINDOW_H

View file

@ -1,23 +0,0 @@
set(EXTRA_WAYLANDPLUGIN_LIBS
${EXTRA_WAYLANDPLUGIN_LIBS}
# TODO: unhardcode
X11
Xext
EGL
)
set(WAYLANDPLUGIN_HEADERS
${WAYLANDPLUGIN_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h
${CMAKE_CURRENT_SOURCE_DIR}/platforms/eglconvenience/qeglconvenience.h
)
set(WAYLANDPLUGIN_SOURCES
${WAYLANDPLUGIN_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/readback_egl//qwaylandreadbackeglwindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/readback_egl//qwaylandreadbackeglcontext.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platforms/eglconvenience/qeglconvenience.cpp
)

View file

@ -1,163 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandreadbackglxcontext.h"
#include "qwaylandshmsurface.h"
#include "qwaylandreadbackglxwindow.h"
#include <QtCore/QDebug>
static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type)
{
const int width = img.width();
const int height = img.height();
if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV
|| (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
{
for (int i = 0; i < height; ++i) {
uint *p = (uint *) img.scanLine(i);
for (int x = 0; x < width; ++x)
p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
}
} else {
for (int i = 0; i < height; ++i) {
uint *p = (uint *) img.scanLine(i);
for (int x = 0; x < width; ++x)
p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff);
}
}
}
QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegration *glxIntegration, QWaylandReadbackGlxWindow *window)
: QPlatformGLContext()
, mGlxIntegration(glxIntegration)
, mWindow(window)
, mBuffer(0)
, mPixmap(0)
, mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat(),GLX_PIXMAP_BIT))
, mGlxPixmap(0)
{
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig);
mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE);
geometryChanged();
}
void QWaylandReadbackGlxContext::makeCurrent()
{
QPlatformGLContext::makeCurrent();
glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext);
}
void QWaylandReadbackGlxContext::doneCurrent()
{
QPlatformGLContext::doneCurrent();
}
void QWaylandReadbackGlxContext::swapBuffers()
{
if (QPlatformGLContext::currentContext() != this) {
makeCurrent();
}
QSize size = mWindow->geometry().size();
QImage img(size,QImage::Format_ARGB32);
const uchar *constBits = img.bits();
void *pixels = const_cast<uchar *>(constBits);
glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels);
img = img.mirrored();
qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV);
constBits = img.bits();
const uchar *constDstBits = mBuffer->image()->bits();
uchar *dstBits = const_cast<uchar *>(constDstBits);
memcpy(dstBits,constBits,(img.width()*4) * img.height());
mWindow->damage(QRegion(QRect(QPoint(0,0),size)));
mWindow->waitForFrameSync();
}
void * QWaylandReadbackGlxContext::getProcAddress(const QString &procName)
{
return (void *) glXGetProcAddress(reinterpret_cast<GLubyte *>(procName.toLatin1().data()));
}
QPlatformWindowFormat QWaylandReadbackGlxContext::platformWindowFormat() const
{
return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext);
}
void QWaylandReadbackGlxContext::geometryChanged()
{
QSize size(mWindow->geometry().size());
if (size.isEmpty()) {
//QGLWidget wants a context for a window without geometry
size = QSize(1,1);
}
mWindow->waitForFrameSync();
delete mBuffer;
//XFreePixmap deletes the glxPixmap as well
if (mPixmap) {
XFreePixmap(mGlxIntegration->xDisplay(),mPixmap);
}
mBuffer = new QWaylandShmBuffer(mGlxIntegration->waylandDisplay(),size,QImage::Format_ARGB32);
mWindow->attach(mBuffer);
int depth = XDefaultDepth(mGlxIntegration->xDisplay(),mGlxIntegration->screen());
mPixmap = XCreatePixmap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),size.width(),size.height(),depth);
XSync(mGlxIntegration->xDisplay(),False);
mGlxPixmap = glXCreatePixmap(mGlxIntegration->xDisplay(),mConfig,mPixmap,0);
if (!mGlxPixmap) {
qDebug() << "Could not make egl surface out of pixmap :(";
}
}

View file

@ -1,79 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDREADBACKGLXCONTEXT_H
#define QWAYLANDREADBACKGLXCONTEXT_H
#include <QPlatformGLContext>
#include "qwaylandreadbackglxintegration.h"
#include "qglxconvenience.h"
class QWaylandReadbackGlxWindow;
class QWaylandShmBuffer;
class QWaylandReadbackGlxContext : public QPlatformGLContext
{
public:
QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegration *glxIntegration, QWaylandReadbackGlxWindow *window);
void makeCurrent();
void doneCurrent();
void swapBuffers();
void* getProcAddress(const QString& procName);
QPlatformWindowFormat platformWindowFormat() const;
void geometryChanged();
private:
QWaylandReadbackGlxIntegration *mGlxIntegration;
QWaylandReadbackGlxWindow *mWindow;
QWaylandShmBuffer *mBuffer;
Pixmap mPixmap;
GLXFBConfig mConfig;
GLXContext mContext;
GLXPixmap mGlxPixmap;
};
#endif // QWAYLANDREADBACKGLXCONTEXT_H

View file

@ -1,97 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandreadbackglxintegration.h"
#include "qwaylandreadbackglxwindow.h"
#include <QtCore/QDebug>
QWaylandReadbackGlxIntegration::QWaylandReadbackGlxIntegration(QWaylandDisplay * waylandDispaly)
: QWaylandGLIntegration()
, mWaylandDisplay(waylandDispaly)
{
qDebug() << "Using Readback-GLX";
char *display_name = getenv("DISPLAY");
mDisplay = XOpenDisplay(display_name);
mScreen = XDefaultScreen(mDisplay);
mRootWindow = XDefaultRootWindow(mDisplay);
XSync(mDisplay, False);
}
QWaylandReadbackGlxIntegration::~QWaylandReadbackGlxIntegration()
{
XCloseDisplay(mDisplay);
}
void QWaylandReadbackGlxIntegration::initialize()
{
}
QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWidget *widget)
{
return new QWaylandReadbackGlxWindow(widget,this);
}
QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
{
return new QWaylandReadbackGlxIntegration(waylandDisplay);
}
Display * QWaylandReadbackGlxIntegration::xDisplay() const
{
return mDisplay;
}
int QWaylandReadbackGlxIntegration::screen() const
{
return mScreen;
}
Window QWaylandReadbackGlxIntegration::rootWindow() const
{
return mRootWindow;
}
QWaylandDisplay * QWaylandReadbackGlxIntegration::waylandDisplay() const
{
return mWaylandDisplay;
}

View file

@ -1,80 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDREADBACKGLXINTEGRATION_H
#define QWAYLANDREADBACKGLXINTEGRATION_H
#include "gl_integration/qwaylandglintegration.h"
#include <QtCore/QTextStream>
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
#include <QtGui/QWidget>
#include <X11/Xlib.h>
class QWaylandReadbackGlxIntegration : public QWaylandGLIntegration
{
public:
QWaylandReadbackGlxIntegration(QWaylandDisplay * waylandDispaly);
~QWaylandReadbackGlxIntegration();
void initialize();
QWaylandWindow *createEglWindow(QWidget *widget);
QWaylandDisplay *waylandDisplay() const;
Display *xDisplay() const;
int screen() const;
Window rootWindow() const;
private:
QWaylandDisplay *mWaylandDisplay;
Display *mDisplay;
int mScreen;
Window mRootWindow;
};
#endif // QWAYLANDREADBACKGLXINTEGRATION_H

View file

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandreadbackglxwindow.h"
QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration)
: QWaylandShmWindow(window)
, mGlxIntegration(glxIntegration)
, mContext(0)
{
}
QWaylandWindow::WindowType QWaylandReadbackGlxWindow::windowType() const
{
//yeah. this type needs a new name
return QWaylandWindow::Egl;
}
QPlatformGLContext * QWaylandReadbackGlxWindow::glContext() const
{
if (!mContext) {
QWaylandReadbackGlxWindow *that = const_cast<QWaylandReadbackGlxWindow *>(this);
that->mContext = new QWaylandReadbackGlxContext(mGlxIntegration,that);
}
return mContext;
}
void QWaylandReadbackGlxWindow::setGeometry(const QRect &rect)
{
QWaylandShmWindow::setGeometry(rect);
if (mContext) {
mContext->geometryChanged();
}
}

View file

@ -1,65 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDREADBACKGLXWINDOW_H
#define QWAYLANDREADBACKGLXWINDOW_H
#include "qwaylandshmwindow.h"
#include "qwaylandreadbackglxintegration.h"
#include "qwaylandreadbackglxcontext.h"
class QWaylandReadbackGlxWindow : public QWaylandShmWindow
{
public:
QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration);
WindowType windowType() const;
QPlatformGLContext *glContext() const;
void setGeometry(const QRect &rect);
private:
QWaylandReadbackGlxIntegration *mGlxIntegration;
QWaylandReadbackGlxContext *mContext;
};
#endif // QWAYLANDREADBACKGLXWINDOW_H

View file

@ -1,12 +0,0 @@
include (../../../glxconvenience/glxconvenience.pri)
HEADERS += \
$$PWD/qwaylandreadbackglxintegration.h \
$$PWD/qwaylandreadbackglxwindow.h \
$$PWD/qwaylandreadbackglxcontext.h
SOURCES += \
$$PWD/qwaylandreadbackglxintegration.cpp \
$$PWD/qwaylandreadbackglxwindow.cpp \
$$PWD/qwaylandreadbackglxcontext.cpp
LIBS += -lX11

View file

@ -1,17 +0,0 @@
set(EXTRA_WAYLANDPLUGIN_LIBS
${EXTRA_WAYLANDPLUGIN_LIBS}
# TODO: unhardcode
X11
Xext
EGL
)
set(WAYLANDPLUGIN_HEADERS
${WAYLANDPLUGIN_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/readback_egl/
)
set(WAYLANDPLUGIN_SOURCES
${WAYLANDPLUGIN_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/platforms/wayland/gl_integration/readback_egl/
)

Some files were not shown because too many files have changed in this diff Show more