qt5: pointer shape support

Fixes #2586
This commit is contained in:
Christian Prochaska 2017-11-24 20:23:45 +01:00 committed by Christian Helmuth
parent b0b436acef
commit a0a54df74c
17 changed files with 201 additions and 8 deletions

View File

@ -85,13 +85,15 @@ append config {
<policy label="layouter -> decorator_margins" report="decorator -> decorator_margins"/>
<policy label="mixer_gui_qt -> channel_list" report="mixer -> channel_list"/>
<policy label="mixer -> channel_list" report="mixer_gui_qt -> channel_list"/>
<policy label="pointer -> hover" report="nitpicker -> hover"/>
<policy label="pointer -> xray" report="nitpicker -> xray"/>
</config>
</start>
<start name="nitpicker">
<resource name="RAM" quantum="4M"/>
<provides><service name="Nitpicker"/></provides>
<config>
<report focus="yes" xray="yes" />
<report focus="yes" hover="yes" xray="yes" />
<domain name="pointer" layer="1" content="client" label="no" origin="pointer" />
<domain name="default" layer="2" content="client" label="no" hover="always" focus="click"/>
@ -107,8 +109,12 @@ append config {
</start>
<start name="pointer">
<resource name="RAM" quantum="1M"/>
<provides> <service name="Report"/> </provides>
<config shapes="yes"/>
<route>
<service name="Nitpicker"> <child name="nitpicker"/> </service>
<service name="ROM" label="hover"> <child name="report_rom"/> </service>
<service name="ROM" label="xray"> <child name="report_rom"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
@ -203,6 +209,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> mixer_gui_qt -> shape"/>
</service>
<service name="ROM" label="channel_list"> <child name="dynamic_rom" /> </service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent/> <any-child/> </any-service>

View File

@ -11,6 +11,7 @@ SRC_CC = qgenericunixeventdispatcher.cpp \
SRC_CC += main.cpp \
qgenodeclipboard.cpp \
qnitpickercursor.cpp \
qnitpickerglcontext.cpp \
qnitpickerintegration.cpp \
qnitpickerplatformwindow.cpp \

View File

@ -72,6 +72,15 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="calculatorform -> shape">
<child name="pointer" label="wm -> qt_launchpad -> calculatorform -> shape"/>
</service>
<service name="Report" label="tetrix -> shape">
<child name="pointer" label="wm -> qt_launchpad -> tetrix -> shape"/>
</service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> qt_launchpad -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -64,6 +64,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> qt_avplay -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -51,6 +51,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> calculatorform -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -68,7 +68,7 @@ proc qt5_start_nodes { feature_arg } {
<any-service> <parent /> <any-child /> </any-service>
</route>
<config>
<report focus="yes"/>
<report focus="yes" hover="yes" xray="yes"/>
<domain name="pointer" layer="1" label="no" content="client" origin="pointer" />
<domain name="default" layer="2" label="no" content="client" focus="click" hover="always" />
@ -80,8 +80,12 @@ proc qt5_start_nodes { feature_arg } {
<start name="pointer">
<resource name="RAM" quantum="1M"/>
<provides> <service name="Report"/> </provides>
<config shapes="yes"/>
<route>
<service name="Nitpicker"> <child name="nitpicker"/> </service>
<service name="ROM" label="hover"> <child name="report_rom"/> </service>
<service name="ROM" label="xray"> <child name="report_rom"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
@ -102,6 +106,8 @@ proc qt5_start_nodes { feature_arg } {
<policy label="wm -> focus" report="layouter -> focus"/>
<policy label="clipboard -> focus" report="nitpicker -> focus"/>
<policy label="layouter -> decorator_margins" report="decorator -> decorator_margins"/>
<policy label="pointer -> hover" report="nitpicker -> hover"/>
<policy label="pointer -> xray" report="nitpicker -> xray"/>
</config>
</start>

View File

@ -33,7 +33,7 @@ append config {
</parent-provides>
<default caps="100"/>
<default-route>
<any-service> <parent/> <child name="wm"/> <any-child/> </any-service>
<any-service> <parent/> <any-child/> </any-service>
</default-route>}
append config [qt5_start_nodes feature]
@ -42,8 +42,12 @@ append config {
<start name="openglwindow" caps="200">
<resource name="RAM" quantum="80M"/>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> openglwindow -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <child name="wm" /> <any-child/> </any-service>
<any-service> <parent /> <any-child/> </any-service>
</route>
<config>
<vfs>

View File

@ -69,6 +69,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> test-qpluginwidget -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -51,6 +51,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> qt_quicktest -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -51,6 +51,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> samegame -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -50,6 +50,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> tetrix -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -100,6 +100,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> textedit -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>
@ -117,6 +120,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> textedit2 -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -52,6 +52,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> basic -> shape"/>
</service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>
<any-service> <parent /> <any-child/> </any-service>
</route>

View File

@ -0,0 +1,79 @@
/*
* \brief QNitpickerCursor
* \author Christian Prochaska
* \date 2017-11-13
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <base/log.h>
/* Qt includes */
#include <QtGui/QBitmap>
#include "qnitpickercursor.h"
QT_BEGIN_NAMESPACE
QNitpickerCursor::QNitpickerCursor(Genode::Env &env)
{
try {
_shape_report_connection.construct(env, "shape", sizeof(Pointer::Shape_report));
_shape_report_ds.construct(env.rm(), _shape_report_connection->dataspace());
_shape_report = _shape_report_ds->local_addr<Pointer::Shape_report>();
} catch (Genode::Service_denied) { }
}
void QNitpickerCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
{
Q_UNUSED(window);
#ifndef QT_NO_CURSOR
if (!_shape_report)
return;
const Qt::CursorShape shape = widgetCursor ?
widgetCursor->shape() :
Qt::ArrowCursor;
_shape_report->visible = (shape != Qt::BlankCursor);
QImage cursor;
if (shape == Qt::BitmapCursor) {
// application supplied cursor
cursor = widgetCursor->pixmap().toImage();
_shape_report->x_hot = widgetCursor->hotSpot().x();
_shape_report->y_hot = widgetCursor->hotSpot().y();
} else {
// system cursor
QPlatformCursorImage platformImage(0, 0, 0, 0, 0, 0);
platformImage.set(shape);
cursor = *platformImage.image();
_shape_report->x_hot = platformImage.hotspot().x();
_shape_report->y_hot = platformImage.hotspot().y();
}
cursor = cursor.convertToFormat(QImage::Format_RGBA8888);
_shape_report->width = cursor.width();
_shape_report->height = cursor.height();
memcpy(_shape_report->shape, cursor.constBits(),
cursor.width() * cursor.height() * 4);
_shape_report_connection->submit(sizeof(Pointer::Shape_report));
#else // !QT_NO_CURSOR
Q_UNUSED(widgetCursor);
#endif
}
QT_END_NAMESPACE

View File

@ -0,0 +1,45 @@
/*
* \brief QNitpickerCursor
* \author Christian Prochaska
* \date 2017-11-13
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _QNITPICKERCURSOR_H_
#define _QNITPICKERCURSOR_H_
/* Genode includes */
#include <base/attached_dataspace.h>
#include <report_session/connection.h>
#include <pointer/shape_report.h>
/* Qt includes */
#include <qpa/qplatformcursor.h>
QT_BEGIN_NAMESPACE
class QNitpickerCursor : public QPlatformCursor
{
private:
Genode::Constructible<Report::Connection> _shape_report_connection;
Genode::Constructible<Genode::Attached_dataspace> _shape_report_ds;
Pointer::Shape_report *_shape_report { nullptr };
public:
QNitpickerCursor(Genode::Env &env);
virtual void changeCursor(QCursor *widgetCursor, QWindow *window) override;
};
QT_END_NAMESPACE
#endif /* _QNITPICKERCURSOR_H_ */

View File

@ -15,12 +15,15 @@
#ifndef _QNITPICKERSCREEN_H_
#define _QNITPICKERSCREEN_H_
/* Genode includes */
#include <nitpicker_session/connection.h>
/* Qt includes */
#include <qpa/qplatformscreen.h>
#include <QDebug>
/* Genode includes */
#include <nitpicker_session/connection.h>
#include "qnitpickercursor.h"
QT_BEGIN_NAMESPACE
@ -28,11 +31,12 @@ class QNitpickerScreen : public QPlatformScreen
{
private:
QRect _geometry;
Genode::Env &_env;
QRect _geometry;
public:
QNitpickerScreen(Genode::Env &env)
QNitpickerScreen(Genode::Env &env) : _env(env)
{
Nitpicker::Connection _nitpicker(env);
@ -49,6 +53,12 @@ class QNitpickerScreen : public QPlatformScreen
int depth() const { return 16; }
QImage::Format format() const { return QImage::Format_RGB16; }
QDpi logicalDpi() const { return QDpi(80, 80); };
QPlatformCursor *cursor() const
{
static QNitpickerCursor instance(_env);
return &instance;
}
};
QT_END_NAMESPACE

View File

@ -99,6 +99,9 @@ append config {
</config>
<route>
<service name="Nitpicker"> <child name="wm"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="wm -> arora -> shape"/>
</service>
<service name="Report"> <child name="clipboard"/> </service>
<service name="ROM" label="clipboard"> <child name="clipboard"/> </service>
<service name="ROM" label="egl_drv.lib.so"> <parent label="egl_swrast.lib.so" /> </service>