qt5: forward window title to nitpicker
This enables Qt5 applications to set a Genode label via 'setWindowTitle' from within Qt5 applications, and thus, making them identifiable to other Genode components, like a layout manager. fixes #3046
This commit is contained in:
parent
13be339d81
commit
91225fbcca
|
@ -40,6 +40,8 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
|
|||
private:
|
||||
|
||||
Genode::Env &_env;
|
||||
QString _nitpicker_session_label;
|
||||
static QStringList _nitpicker_session_label_list;
|
||||
Nitpicker::Connection _nitpicker_session;
|
||||
Framebuffer::Session_client _framebuffer_session;
|
||||
unsigned char *_framebuffer;
|
||||
|
@ -76,6 +78,8 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
|
|||
Nitpicker::Session::View_handle _create_view();
|
||||
void _adjust_and_set_geometry(const QRect &rect);
|
||||
|
||||
QString _sanitize_label(QString label);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void _handle_input(unsigned int);
|
||||
|
@ -92,6 +96,8 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
|
|||
Genode::Signal_receiver &signal_receiver,
|
||||
int screen_width, int screen_height);
|
||||
|
||||
~QNitpickerPlatformWindow();
|
||||
|
||||
QWindow *window() const;
|
||||
|
||||
QPlatformWindow *parent() const;
|
||||
|
|
|
@ -1 +1 @@
|
|||
755ed511de17500de4c67cca27cc7d31a65dd2c8
|
||||
82600d0dfdfcb7a3693ea2cdd3e5591276e3ae22
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
diff --git a/qtbase/src/widgets/kernel/qwidgetwindow.cpp b/qtbase/src/widgets/kernel/qwidgetwindow.cpp
|
||||
index b91fbcf..3221bf3 100644
|
||||
--- a/qtbase/src/widgets/kernel/qwidgetwindow.cpp
|
||||
+++ b/qtbase/src/widgets/kernel/qwidgetwindow.cpp
|
||||
@@ -122,6 +122,7 @@ QWidgetWindow::QWidgetWindow(QWidget *widget)
|
||||
: QWindow(*new QWidgetWindowPrivate(), 0)
|
||||
, m_widget(widget)
|
||||
{
|
||||
+ setTitle(widget->windowTitle());
|
||||
updateObjectName();
|
||||
// Enable QOpenGLWidget/QQuickWidget children if the platform plugin supports it,
|
||||
// and the application developer has not explicitly disabled it.
|
|
@ -14,6 +14,7 @@ qtbase_genode.patch
|
|||
qtbase_genode_qtscriptclassic.patch
|
||||
qtbase_genode_textedit_example.patch
|
||||
qtbase_genode_openglwindow_example.patch
|
||||
qtbase_qwindow_title.patch
|
||||
qtdeclarative_genode.patch
|
||||
qtwebkit_genode.patch
|
||||
host_tools.patch
|
||||
|
|
|
@ -27,6 +27,8 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
static const bool qnpw_verbose = false/*true*/;
|
||||
|
||||
QStringList QNitpickerPlatformWindow::_nitpicker_session_label_list;
|
||||
|
||||
QTouchDevice * QNitpickerPlatformWindow::_init_touch_device()
|
||||
{
|
||||
QVector<QWindowSystemInterface::TouchPoint>::iterator i = _touch_points.begin();
|
||||
|
@ -398,12 +400,44 @@ void QNitpickerPlatformWindow::_adjust_and_set_geometry(const QRect &rect)
|
|||
emit framebuffer_changed();
|
||||
}
|
||||
|
||||
|
||||
QString QNitpickerPlatformWindow::_sanitize_label(QString label)
|
||||
{
|
||||
enum { MAX_LABEL = 25 };
|
||||
|
||||
/* remove any occurences of '"' */
|
||||
label.remove("\"");
|
||||
|
||||
/* truncate label and append '..' */
|
||||
if (label.length() > MAX_LABEL) {
|
||||
label.truncate(MAX_LABEL - 2);
|
||||
label.append("..");
|
||||
}
|
||||
|
||||
/* Make sure that the window is distinguishable by the layouter */
|
||||
if (label.isEmpty())
|
||||
label = QString("Untitled Window");
|
||||
|
||||
if (_nitpicker_session_label_list.contains(label))
|
||||
for (unsigned int i = 2; ; i++) {
|
||||
QString versioned_label = label + "." + QString::number(i);
|
||||
if (!_nitpicker_session_label_list.contains(versioned_label)) {
|
||||
label = versioned_label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
QNitpickerPlatformWindow::QNitpickerPlatformWindow(Genode::Env &env, QWindow *window,
|
||||
Genode::Signal_receiver &signal_receiver,
|
||||
int screen_width, int screen_height)
|
||||
: QPlatformWindow(window),
|
||||
_env(env),
|
||||
_nitpicker_session(env),
|
||||
_nitpicker_session_label(_sanitize_label(window->title())),
|
||||
_nitpicker_session(env, _nitpicker_session_label.toStdString().c_str()),
|
||||
_framebuffer_session(_nitpicker_session.framebuffer_session()),
|
||||
_framebuffer(0),
|
||||
_framebuffer_changed(false),
|
||||
|
@ -425,6 +459,8 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(Genode::Env &env, QWindow *wi
|
|||
if (window->transientParent())
|
||||
qDebug() << "QNitpickerPlatformWindow(): child window of" << window->transientParent();
|
||||
|
||||
_nitpicker_session_label_list.append(_nitpicker_session_label);
|
||||
|
||||
_input_session.sigh(_input_signal_dispatcher);
|
||||
|
||||
_nitpicker_session.mode_sigh(_mode_changed_signal_dispatcher);
|
||||
|
@ -448,6 +484,11 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(Genode::Env &env, QWindow *wi
|
|||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
QNitpickerPlatformWindow::~QNitpickerPlatformWindow()
|
||||
{
|
||||
_nitpicker_session_label_list.removeOne(_nitpicker_session_label);
|
||||
}
|
||||
|
||||
QWindow *QNitpickerPlatformWindow::window() const
|
||||
{
|
||||
if (qnpw_verbose)
|
||||
|
|
Loading…
Reference in New Issue