2013-08-09 13:04:52 +00:00
|
|
|
/*
|
2020-06-12 09:23:57 +00:00
|
|
|
* \brief A Qt Widget that shows a Genode GUI view
|
2013-08-09 13:04:52 +00:00
|
|
|
* \author Christian Prochaska
|
|
|
|
* \date 2010-08-26
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2020-06-28 12:21:09 +00:00
|
|
|
* Copyright (C) 2010-2020 Genode Labs GmbH
|
2013-08-09 13:04:52 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2013-08-09 13:04:52 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-12 09:23:57 +00:00
|
|
|
#ifndef QGENODEVIEWWIDGET_H
|
|
|
|
#define QGENODEVIEWWIDGET_H
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
#include <QtWidgets>
|
|
|
|
|
2020-06-11 12:27:20 +00:00
|
|
|
#include <gui_session/client.h>
|
2013-08-09 13:04:52 +00:00
|
|
|
|
2014-06-11 14:22:44 +00:00
|
|
|
|
|
|
|
class QEmbeddedViewWidget : public QWidget
|
2013-08-09 13:04:52 +00:00
|
|
|
{
|
2014-06-11 14:22:44 +00:00
|
|
|
Q_OBJECT
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
private:
|
2014-06-11 14:22:44 +00:00
|
|
|
|
|
|
|
QHash<QScrollBar*, bool> _scrollbars;
|
|
|
|
|
|
|
|
int _orig_w = 0;
|
|
|
|
int _orig_h = 0;
|
|
|
|
int _orig_buf_x = 0;
|
|
|
|
int _orig_buf_y = 0;
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
private slots:
|
2014-06-11 14:22:44 +00:00
|
|
|
|
|
|
|
void valueChanged();
|
|
|
|
void destroyed(QObject *obj = 0);
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
protected:
|
2014-06-06 15:26:53 +00:00
|
|
|
|
2014-06-11 14:22:44 +00:00
|
|
|
struct View_geometry
|
|
|
|
{
|
|
|
|
int x, y, w, h, buf_x, buf_y;
|
|
|
|
};
|
|
|
|
|
|
|
|
QEmbeddedViewWidget(QWidget *parent = 0);
|
2014-06-06 15:26:53 +00:00
|
|
|
|
2014-06-11 14:22:44 +00:00
|
|
|
virtual ~QEmbeddedViewWidget();
|
2013-08-09 13:04:52 +00:00
|
|
|
|
2014-06-11 14:22:44 +00:00
|
|
|
void _orig_geometry(int w, int h, int buf_x, int buf_y)
|
|
|
|
{
|
|
|
|
_orig_w = w;
|
|
|
|
_orig_h = h;
|
|
|
|
_orig_buf_x = buf_x;
|
|
|
|
_orig_buf_y = buf_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
View_geometry _calc_view_geometry();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-06-12 09:23:57 +00:00
|
|
|
class QGenodeViewWidget : public QEmbeddedViewWidget
|
2014-06-11 14:22:44 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2020-06-12 09:23:57 +00:00
|
|
|
Gui::Session_client *gui;
|
|
|
|
Gui::Session::View_handle view_handle;
|
2014-06-11 14:22:44 +00:00
|
|
|
|
|
|
|
virtual void showEvent(QShowEvent *event);
|
|
|
|
virtual void hideEvent(QHideEvent *event);
|
|
|
|
virtual void paintEvent(QPaintEvent *event);
|
2014-12-04 15:20:56 +00:00
|
|
|
virtual void focusInEvent(QFocusEvent * event);
|
2013-08-09 13:04:52 +00:00
|
|
|
|
|
|
|
public:
|
2014-06-11 14:22:44 +00:00
|
|
|
|
2020-06-12 09:23:57 +00:00
|
|
|
QGenodeViewWidget(QWidget *parent =0);
|
|
|
|
~QGenodeViewWidget();
|
|
|
|
void setGenodeView(Gui::Session_client *gui,
|
|
|
|
Gui::Session::View_handle view_handle,
|
|
|
|
int buf_x, int buf_y, int w, int h);
|
2013-08-09 13:04:52 +00:00
|
|
|
};
|
|
|
|
|
2020-06-28 12:21:09 +00:00
|
|
|
class QGenodeViewWidgetInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual QWidget *createWidget(QWidget *parent = 0) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_INTERFACE(QGenodeViewWidgetInterface, "org.genode.QGenodeViewWidgetInterface")
|
|
|
|
|
|
|
|
|
|
|
|
class QGenodeViewWidgetPlugin : public QObject, public QGenodeViewWidgetInterface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PLUGIN_METADATA(IID "org.genode.QGenodeViewWidgetInterface" FILE "qgenodeviewwidget.json")
|
|
|
|
Q_INTERFACES(QGenodeViewWidgetInterface)
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit QGenodeViewWidgetPlugin(QObject *parent = 0) : QObject(parent) { }
|
|
|
|
|
|
|
|
QWidget *createWidget(QWidget *parent = 0)
|
|
|
|
{
|
|
|
|
return new QGenodeViewWidget(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-06-12 09:23:57 +00:00
|
|
|
#endif // QGENODEVIEWWIDGET_H
|