qt5: remove deprecated APIs

Issue #3162
This commit is contained in:
Christian Prochaska 2019-02-18 18:29:24 +01:00 committed by Christian Helmuth
parent 0e0b6bdde7
commit ee423e5bf1
20 changed files with 89 additions and 205 deletions

View File

@ -19,20 +19,22 @@
#include "main_window.h"
enum { THREAD_STACK_SIZE = 2 * 1024 * sizeof(long) };
enum { SIGNAL_EP_STACK_SIZE = 16*1024 };
struct Report_thread : Genode::Thread
struct Report_handler
{
QMember<Report_proxy> proxy;
Genode::Attached_rom_dataspace channels_rom;
Genode::Signal_receiver sig_rec;
Genode::Signal_dispatcher<Report_thread> channels_dispatcher;
Genode::Entrypoint sig_ep;
Genode::Signal_handler<Report_handler> channels_handler;
Genode::Lock _report_lock { Genode::Lock::LOCKED };
bool window_connected { false };
void _report(char const *data, size_t size)
{
Genode::Xml_node node(data, size);
@ -42,34 +44,25 @@ struct Report_thread : Genode::Thread
_report_lock.lock();
}
void _handle_channels(unsigned)
void _handle_channels()
{
if (!window_connected)
return;
channels_rom.update();
if (channels_rom.valid())
_report(channels_rom.local_addr<char>(), channels_rom.size());
}
Report_thread(Genode::Env &env)
Report_handler(Genode::Env &env)
:
Genode::Thread(env, "report_thread", THREAD_STACK_SIZE),
channels_rom(env, "channel_list"),
channels_dispatcher(sig_rec, *this, &Report_thread::_handle_channels)
sig_ep(env, SIGNAL_EP_STACK_SIZE, "signal ep",
Genode::Affinity::Location()),
channels_handler(sig_ep, *this, &Report_handler::_handle_channels)
{
channels_rom.sigh(channels_dispatcher);
}
void entry() override
{
using namespace Genode;
while (true) {
Signal sig = sig_rec.wait_for_signal();
int num = sig.num();
Signal_dispatcher_base *dispatcher;
dispatcher = dynamic_cast<Signal_dispatcher_base *>(sig.context());
dispatcher->dispatch(num);
}
channels_rom.sigh(channels_handler);
}
void connect_window(Main_window *win)
@ -77,6 +70,8 @@ struct Report_thread : Genode::Thread
QObject::connect(proxy, SIGNAL(report_changed(void *,void const*)),
win, SLOT(report_changed(void *, void const*)),
Qt::QueuedConnection);
window_connected = true;
}
};
@ -107,10 +102,10 @@ void Libc::Component::construct(Libc::Env &env)
int argc = 1;
char const *argv[] = { "mixer_gui_qt", 0 };
Report_thread *report_thread;
try { report_thread = new Report_thread(env); }
Report_handler *report_handler;
try { report_handler = new Report_handler(env); }
catch (...) {
Genode::error("Could not create Report_thread");
Genode::error("Could not create Report_handler");
return -1;
}
@ -121,8 +116,7 @@ void Libc::Component::construct(Libc::Env &env)
QMember<Main_window> main_window(env);
main_window->show();
report_thread->connect_window(main_window);
report_thread->start();
report_handler->connect_window(main_window);
app.connect(&app, SIGNAL(lastWindowClosed()), SLOT(quit()));

View File

@ -16,7 +16,6 @@
/* Genode includes */
#include <base/env.h>
#include <base/printf.h>
#include <base/lock.h>
#include <util/xml_node.h>

View File

@ -21,11 +21,12 @@ struct Main
{
Libc::Env &env;
Genode_signal_dispatcher dispatcher { env };
Genode::Entrypoint signal_ep { env, 0x4000, "signal ep",
Genode::Affinity::Location() };
QApplication &app { qt5_initialization(env) };
QMember<Panel> widget { env, dispatcher.signal_receiver() };
QMember<Panel> widget { env, signal_ep };
Main(Libc::Env &env) : env(env)
{

View File

@ -86,10 +86,10 @@ void App_bar::_handle_apps()
}
App_bar::App_bar(Genode::Env &env, Genode::Signal_receiver &sig_rec)
App_bar::App_bar(Genode::Env &env, Genode::Entrypoint &sig_ep)
:
_apps(env, "apps"), _content_request(env, "content_request"),
_apps_proxy(sig_rec)
_apps_proxy(sig_ep)
{
_content_request.enabled(true);
@ -116,10 +116,10 @@ void Panel::_wifi_toggled(bool checked)
}
Panel::Panel(Genode::Env &env, Genode::Signal_receiver &sig_rec)
Panel::Panel(Genode::Env &env, Genode::Entrypoint &sig_ep)
:
_overlay(env, "overlay"), _overlay_request(env, "overlay_request"),
_panel_button("Panel"), _app_bar(env, sig_rec)
_panel_button("Panel"), _app_bar(env, sig_ep)
{
_layout->addWidget(_panel_button);
_layout->addWidget(new Spacer(), 1);

View File

@ -77,7 +77,7 @@ class App_bar : public Compound_widget<QWidget, QHBoxLayout>
public:
App_bar(Genode::Env &, Genode::Signal_receiver &);
App_bar(Genode::Env &, Genode::Entrypoint &);
~App_bar();
};
@ -102,7 +102,7 @@ class Panel : public Compound_widget<QWidget, QHBoxLayout>
public:
Panel(Genode::Env &, Genode::Signal_receiver &);
Panel(Genode::Env &, Genode::Entrypoint &);
~Panel();
};

View File

@ -41,25 +41,25 @@ typedef Genode::String<32> Name;
* Genode signal to queued Qt signal proxy
*/
class Genode_signal_proxy : public QObject,
public Genode::Signal_dispatcher<Genode_signal_proxy>
public Genode::Signal_handler<Genode_signal_proxy>
{
Q_OBJECT
public:
Genode_signal_proxy(Genode::Signal_receiver &sig_rec)
Genode_signal_proxy(Genode::Entrypoint &sig_ep)
:
Genode::Signal_dispatcher<Genode_signal_proxy>(
sig_rec, *this, &Genode_signal_proxy::handle_genode_signal)
Genode::Signal_handler<Genode_signal_proxy>(
sig_ep, *this, &Genode_signal_proxy::handle_genode_signal)
{
connect(this, SIGNAL(internal_signal()),
this, SIGNAL(signal()),
Qt::QueuedConnection);
}
/* called by signal dispatcher / emits internal signal in context of
* signal-dispatcher thread */
void handle_genode_signal(unsigned = 0) { Q_EMIT internal_signal(); }
/* called by signal handler / emits internal signal in context of
* signal-entrypoint thread */
void handle_genode_signal() { Q_EMIT internal_signal(); }
Q_SIGNALS:
@ -71,41 +71,6 @@ class Genode_signal_proxy : public QObject,
};
/*
* Genode signal dispatcher thread
*/
class Genode_signal_dispatcher : public Genode::Thread
{
private:
Genode::Signal_receiver _sig_rec;
void entry()
{
/* dispatch signals */
while (true) {
Genode::Signal sig = _sig_rec.wait_for_signal();
Genode::Signal_dispatcher_base *dispatcher {
dynamic_cast<Genode::Signal_dispatcher_base *>(sig.context()) };
if (dispatcher)
dispatcher->dispatch(sig.num());
}
}
public:
Genode_signal_dispatcher(Genode::Env &env)
:
Genode::Thread(env, "signal_dispatcher", 0x4000)
{
start();
}
Genode::Signal_receiver &signal_receiver() { return _sig_rec; }
};
/*
* Qt initialization
*/

View File

@ -48,7 +48,7 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
bool _framebuffer_changed;
bool _geometry_changed;
Framebuffer::Mode _current_mode;
Genode::Signal_receiver &_signal_receiver;
Genode::Entrypoint &_signal_ep;
Nitpicker::Session::View_handle _view_handle;
Input::Session_client _input_session;
Genode::Attached_dataspace _ev_buf;
@ -66,8 +66,8 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
_mouse_position.y() - geometry().y());
}
Genode::Signal_dispatcher<QNitpickerPlatformWindow> _input_signal_dispatcher;
Genode::Signal_dispatcher<QNitpickerPlatformWindow> _mode_changed_signal_dispatcher;
Genode::Signal_handler<QNitpickerPlatformWindow> _input_signal_handler;
Genode::Signal_handler<QNitpickerPlatformWindow> _mode_changed_signal_handler;
QVector<QWindowSystemInterface::TouchPoint> _touch_points { 16 };
QTouchDevice *_touch_device;
@ -82,18 +82,18 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
private Q_SLOTS:
void _handle_input(unsigned int);
void _handle_mode_changed(unsigned int);
void _handle_input();
void _handle_mode_changed();
Q_SIGNALS:
void _input(unsigned int);
void _mode_changed(unsigned int);
void _input();
void _mode_changed();
public:
QNitpickerPlatformWindow(Genode::Env &env, QWindow *window,
Genode::Signal_receiver &signal_receiver,
Genode::Entrypoint &signal_ep,
int screen_width, int screen_height);
~QNitpickerPlatformWindow();

View File

@ -16,11 +16,9 @@ SRC_CC += main.cpp \
qnitpickerintegration.cpp \
qnitpickerplatformwindow.cpp \
qnitpickerwindowsurface.cpp \
qsignalhandlerthread.cpp \
moc_qnitpickerplatformwindow.cpp \
moc_qnitpickerwindowsurface.cpp \
moc_qnitpickerintegrationplugin.cpp \
moc_qsignalhandlerthread.cpp
moc_qnitpickerintegrationplugin.cpp
ifeq ($(CONTRIB_DIR),)

View File

@ -40,15 +40,6 @@ struct Qt_launchpad_namespace::Local_env : Genode::Env
Pd_session_capability pd_session_cap() override { return genode_env.pd_session_cap(); }
Id_space<Parent::Client> &id_space() override { return genode_env.id_space(); }
/*
* \deprecated
*
* Emulation of deprecated part of the 'Env' interface. To be
* removed once they are removed from 'Genode::Env'.
*/
Pd_session &ram() override { return pd(); }
Pd_session_capability ram_session_cap() override { return pd_session_cap(); }
Session_capability session(Parent::Service_name const &service_name,
Parent::Client::Id id,
Parent::Session_args const &session_args,
@ -88,7 +79,7 @@ void Libc::Component::construct(Libc::Env &env)
QApplication a(argc, (char**)argv);
Qt_launchpad launchpad(local_env, env.ram().avail_ram().value);
Qt_launchpad launchpad(local_env, env.pd().avail_ram().value);
Genode::Attached_rom_dataspace config(env, "config");

View File

@ -59,7 +59,7 @@ void Qt_launchpad::_avail_quota_update()
{
static Genode::size_t _avail = 0;
Genode::size_t new_avail = _env.ram().avail_ram().value;
Genode::size_t new_avail = _env.pd().avail_ram().value;
if (new_avail != _avail)
quota(new_avail);

View File

@ -232,5 +232,5 @@ void QNitpickerViewWidget::focusInEvent(QFocusEvent *)
QNitpickerPlatformWindow *platform_window =
dynamic_cast<QNitpickerPlatformWindow*>(window()->windowHandle()->handle());
platform_window->nitpicker().focus(*nitpicker);
platform_window->nitpicker().focus(nitpicker->rpc_cap());
}

View File

@ -127,7 +127,7 @@ void PluginStarter::_start_plugin(QString &file_name, QByteArray const &file_buf
"ram_quota").ulong_value(0) +
file_size;
if (((long)_env->ram().avail_ram().value - (long)ram_quota) <
if (((long)_env->pd().avail_ram().value - (long)ram_quota) <
QPluginWidget::PRESERVED_RAM_QUOTA) {
Genode::error("Cannot donate ", ram_quota, " bytes of RAM to the plugin (quota exceeded).");
_plugin_loading_state = RAM_QUOTA_EXCEEDED_ERROR;
@ -180,7 +180,7 @@ void PluginStarter::_start_plugin(QString &file_name, QByteArray const &file_buf
} else {
Genode::size_t ram_quota = Arg_string::find_arg(_args.constData(), "ram_quota").ulong_value(0);
if (((long)_env->ram().avail_ram().value - (long)ram_quota) <
if (((long)_env->pd().avail_ram().value - (long)ram_quota) <
QPluginWidget::PRESERVED_RAM_QUOTA) {
_plugin_loading_state = RAM_QUOTA_EXCEEDED_ERROR;
return;
@ -235,7 +235,7 @@ void PluginStarter::run()
QString file_name = _plugin_url.path().remove("/");
try {
Rom_connection rc(_env, file_name.toLatin1().constData());
Rom_connection rc(*_env, file_name.toLatin1().constData());
Dataspace_capability rom_ds = rc.dataspace();

View File

@ -40,7 +40,11 @@ QPlatformIntegration *QNitpickerIntegrationPlugin::create(const QString& system,
Q_UNUSED(paramList);
if (system.toLower() == "nitpicker") {
assert(_env != nullptr);
return new QNitpickerIntegration(*_env);
Genode::Entrypoint *signal_ep =
new Genode::Entrypoint(*_env, 2*1024*sizeof(Genode::addr_t),
"QPA signal handler",
Genode::Affinity::Location());
return new QNitpickerIntegration(*_env, *signal_ep);
}
return 0;

View File

@ -27,8 +27,8 @@ QT_BEGIN_NAMESPACE
static constexpr bool verbose = false;
QGenodeClipboard::QGenodeClipboard(Genode::Env &env, Genode::Signal_receiver &sig_rcv)
: _clipboard_signal_dispatcher(sig_rcv, *this, &QGenodeClipboard::_handle_clipboard)
QGenodeClipboard::QGenodeClipboard(Genode::Env &env, Genode::Entrypoint &sig_ep)
: _clipboard_signal_handler(sig_ep, *this, &QGenodeClipboard::_handle_clipboard)
{
try {
@ -40,7 +40,7 @@ QGenodeClipboard::QGenodeClipboard(Genode::Env &env, Genode::Signal_receiver &si
_clipboard_ds = new Genode::Attached_rom_dataspace(env, "clipboard");
_clipboard_ds->sigh(_clipboard_signal_dispatcher);
_clipboard_ds->sigh(_clipboard_signal_handler);
_clipboard_ds->update();
} catch (...) { }
@ -63,7 +63,7 @@ QGenodeClipboard::~QGenodeClipboard()
}
void QGenodeClipboard::_handle_clipboard(unsigned int)
void QGenodeClipboard::_handle_clipboard()
{
emitChanged(QClipboard::Clipboard);
}

View File

@ -33,7 +33,7 @@ class QGenodeClipboard : public QPlatformClipboard
private:
Genode::Attached_rom_dataspace *_clipboard_ds = nullptr;
Genode::Signal_dispatcher<QGenodeClipboard> _clipboard_signal_dispatcher;
Genode::Signal_handler<QGenodeClipboard> _clipboard_signal_handler;
Genode::Reporter *_clipboard_reporter = nullptr;
@ -41,11 +41,11 @@ class QGenodeClipboard : public QPlatformClipboard
QMember<QMimeData> _mimedata;
void _handle_clipboard(unsigned int);
void _handle_clipboard();
public:
QGenodeClipboard(Genode::Env &env, Genode::Signal_receiver &sig_rcv);
QGenodeClipboard(Genode::Env &env, Genode::Entrypoint &sig_ep);
~QGenodeClipboard();
QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);

View File

@ -28,19 +28,12 @@ QT_BEGIN_NAMESPACE
static const bool verbose = false;
Genode::Signal_receiver &QNitpickerIntegration::_signal_receiver()
{
static Genode::Signal_receiver _inst;
return _inst;
}
QNitpickerIntegration::QNitpickerIntegration(Genode::Env &env)
QNitpickerIntegration::QNitpickerIntegration(Genode::Env &env,
Genode::Entrypoint &signal_ep)
: _env(env),
_signal_handler_thread(_signal_receiver()),
_nitpicker_screen(new QNitpickerScreen(env))
{
_signal_handler_thread.start();
}
_signal_ep(signal_ep),
_nitpicker_screen(new QNitpickerScreen(env)) { }
bool QNitpickerIntegration::hasCapability(QPlatformIntegration::Capability cap) const
@ -59,7 +52,7 @@ QPlatformWindow *QNitpickerIntegration::createPlatformWindow(QWindow *window) co
QRect screen_geometry = _nitpicker_screen->geometry();
return new QNitpickerPlatformWindow(_env, window,
_signal_receiver(),
_signal_ep,
screen_geometry.width(),
screen_geometry.height());
}
@ -102,7 +95,7 @@ QPlatformFontDatabase *QNitpickerIntegration::fontDatabase() const
#ifndef QT_NO_CLIPBOARD
QPlatformClipboard *QNitpickerIntegration::clipboard() const
{
static QGenodeClipboard cb(_env, _signal_receiver());
static QGenodeClipboard cb(_env, _signal_ep);
return &cb;
}
#endif

View File

@ -22,7 +22,6 @@
#include <qpa/qplatforminputcontext.h>
#include "qnitpickerscreen.h"
#include "qsignalhandlerthread.h"
QT_BEGIN_NAMESPACE
@ -32,7 +31,7 @@ class QNitpickerIntegration : public QPlatformIntegration
Genode::Env &_env;
QSignalHandlerThread _signal_handler_thread;
Genode::Entrypoint &_signal_ep;
QNitpickerScreen *_nitpicker_screen;
@ -47,7 +46,8 @@ class QNitpickerIntegration : public QPlatformIntegration
public:
QNitpickerIntegration(Genode::Env &env);
QNitpickerIntegration(Genode::Env &env,
Genode::Entrypoint &signal_ep);
void initialize() Q_DECL_OVERRIDE;
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;

View File

@ -185,7 +185,7 @@ static Qt::Key translate_keycode(Input::Keycode key)
}
void QNitpickerPlatformWindow::_handle_input(unsigned int)
void QNitpickerPlatformWindow::_handle_input()
{
QList<Input::Event> touch_events;
@ -316,7 +316,7 @@ void QNitpickerPlatformWindow::_handle_input(unsigned int)
}
void QNitpickerPlatformWindow::_handle_mode_changed(unsigned int)
void QNitpickerPlatformWindow::_handle_mode_changed()
{
Framebuffer::Mode mode(_nitpicker_session.mode());
@ -432,7 +432,7 @@ QString QNitpickerPlatformWindow::_sanitize_label(QString label)
QNitpickerPlatformWindow::QNitpickerPlatformWindow(Genode::Env &env, QWindow *window,
Genode::Signal_receiver &signal_receiver,
Genode::Entrypoint &signal_ep,
int screen_width, int screen_height)
: QPlatformWindow(window),
_env(env),
@ -442,16 +442,16 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(Genode::Env &env, QWindow *wi
_framebuffer(0),
_framebuffer_changed(false),
_geometry_changed(false),
_signal_receiver(signal_receiver),
_signal_ep(signal_ep),
_view_handle(_create_view()),
_input_session(env.rm(), _nitpicker_session.input_session()),
_ev_buf(env.rm(), _input_session.dataspace()),
_resize_handle(!window->flags().testFlag(Qt::Popup)),
_decoration(!window->flags().testFlag(Qt::Popup)),
_egl_surface(EGL_NO_SURFACE),
_input_signal_dispatcher(_signal_receiver, *this,
_input_signal_handler(_signal_ep, *this,
&QNitpickerPlatformWindow::_input),
_mode_changed_signal_dispatcher(_signal_receiver, *this,
_mode_changed_signal_handler(_signal_ep, *this,
&QNitpickerPlatformWindow::_mode_changed),
_touch_device(_init_touch_device())
{
@ -461,9 +461,9 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(Genode::Env &env, QWindow *wi
_nitpicker_session_label_list.append(_nitpicker_session_label);
_input_session.sigh(_input_signal_dispatcher);
_input_session.sigh(_input_signal_handler);
_nitpicker_session.mode_sigh(_mode_changed_signal_dispatcher);
_nitpicker_session.mode_sigh(_mode_changed_signal_handler);
_adjust_and_set_geometry(geometry());
@ -475,12 +475,12 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(Genode::Env &env, QWindow *wi
_nitpicker_session.execute();
}
connect(this, SIGNAL(_input(unsigned int)),
this, SLOT(_handle_input(unsigned int)),
connect(this, SIGNAL(_input()),
this, SLOT(_handle_input()),
Qt::QueuedConnection);
connect(this, SIGNAL(_mode_changed(unsigned int)),
this, SLOT(_handle_mode_changed(unsigned int)),
connect(this, SIGNAL(_mode_changed()),
this, SLOT(_handle_mode_changed()),
Qt::QueuedConnection);
}

View File

@ -1,22 +0,0 @@
/*
* \brief QPA signal handler thread
* \author Christian Prochaska
* \date 2015-09-18
*/
/*
* Copyright (C) 2015-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.
*/
#include "qsignalhandlerthread.h"
void QSignalHandlerThread::run()
{
for (;;) {
Genode::Signal s = _signal_receiver.wait_for_signal();
static_cast<Genode::Signal_dispatcher_base*>(s.context())->dispatch(s.num());
}
}

View File

@ -1,39 +0,0 @@
/*
* \brief QPA signal handler thread
* \author Christian Prochaska
* \date 2015-09-18
*/
/*
* Copyright (C) 2015-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 _QSIGNALHANDLERTHREAD_H_
#define _QSIGNALHANDLERTHREAD_H_
/* Genode includes */
#include <base/signal.h>
/* Qt includes */
#include <QThread>
class QSignalHandlerThread : public QThread
{
Q_OBJECT
private:
Genode::Signal_receiver &_signal_receiver;
public:
QSignalHandlerThread(Genode::Signal_receiver &signal_receiver)
: _signal_receiver(signal_receiver) { }
void run() override;
};
#endif /* _QSIGNALHANDLERTHREAD_H_ */