mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 03:45:24 +00:00
parent
4539eb7512
commit
363ffe40a0
@ -29,13 +29,6 @@ static const bool qnpw_verbose = false/*true*/;
|
||||
|
||||
void QNitpickerPlatformWindow::_process_mouse_event(Input::Event *ev)
|
||||
{
|
||||
#if 0
|
||||
/* liquid_fb-specific calculation */
|
||||
QPoint local_position(ev->ax(), ev->ay());
|
||||
QPoint global_position (geometry().x() + local_position.x(),
|
||||
geometry().y() + local_position.y());
|
||||
#endif
|
||||
|
||||
QPoint global_position(ev->ax(), ev->ay());
|
||||
QPoint local_position(global_position.x() - geometry().x(),
|
||||
global_position.y() - geometry().y());
|
||||
@ -175,7 +168,10 @@ void QNitpickerPlatformWindow::_adjust_and_set_geometry(const QRect &rect)
|
||||
Framebuffer::Mode::RGB565);
|
||||
_nitpicker_session.buffer(mode, false);
|
||||
|
||||
_current_mode = mode;
|
||||
|
||||
_framebuffer_changed = true;
|
||||
_geometry_changed = true;
|
||||
|
||||
emit framebuffer_changed();
|
||||
}
|
||||
@ -186,6 +182,7 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(QWindow *window, Genode::Rpc_
|
||||
_framebuffer_session(_nitpicker_session.framebuffer_session()),
|
||||
_framebuffer(0),
|
||||
_framebuffer_changed(false),
|
||||
_geometry_changed(false),
|
||||
_view_handle(_create_view()),
|
||||
_input_session(_nitpicker_session.input_session()),
|
||||
_timer(this),
|
||||
@ -198,6 +195,9 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(QWindow *window, Genode::Rpc_
|
||||
if (window->transientParent())
|
||||
qDebug() << "QNitpickerPlatformWindow(): child window of" << window->transientParent();
|
||||
|
||||
_mode_changed_signal_context_capability = _signal_receiver.manage(&_mode_changed_signal_context);
|
||||
_nitpicker_session.mode_sigh(_mode_changed_signal_context_capability);
|
||||
|
||||
_adjust_and_set_geometry(geometry());
|
||||
|
||||
_ev_buf = static_cast<Input::Event *>
|
||||
@ -250,21 +250,6 @@ void QNitpickerPlatformWindow::setGeometry(const QRect &rect)
|
||||
|
||||
_adjust_and_set_geometry(rect);
|
||||
|
||||
if (window()->isVisible()) {
|
||||
QRect g(geometry());
|
||||
|
||||
if (window()->transientParent()) {
|
||||
/* translate global position to parent-relative position */
|
||||
g.moveTo(window()->transientParent()->mapFromGlobal(g.topLeft()));
|
||||
}
|
||||
|
||||
typedef Nitpicker::Session::Command Command;
|
||||
_nitpicker_session.enqueue<Command::Geometry>(_view_handle,
|
||||
Nitpicker::Rect(Nitpicker::Point(g.x(), g.y()),
|
||||
Nitpicker::Area(g.width(), g.height())));
|
||||
_nitpicker_session.execute();
|
||||
}
|
||||
|
||||
if (qnpw_verbose)
|
||||
qDebug() << "QNitpickerPlatformWindow::setGeometry() finished";
|
||||
}
|
||||
@ -321,15 +306,7 @@ void QNitpickerPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
|
||||
{
|
||||
if (qnpw_verbose)
|
||||
qDebug() << "QNitpickerPlatformWindow::setWindowFlags(" << flags << ")";
|
||||
#if 0
|
||||
_resize_handle = true;
|
||||
_decoration = true;
|
||||
|
||||
if (flags.testFlag(Qt::Popup)) {
|
||||
_resize_handle = false;
|
||||
_decoration = false;
|
||||
}
|
||||
#endif
|
||||
QPlatformWindow::setWindowFlags(flags);
|
||||
|
||||
if (qnpw_verbose)
|
||||
@ -563,6 +540,26 @@ void QNitpickerPlatformWindow::refresh(int x, int y, int w, int h)
|
||||
if (qnpw_verbose)
|
||||
qDebug("QNitpickerPlatformWindow::refresh(%d, %d, %d, %d)", x, y, w, h);
|
||||
|
||||
if (_geometry_changed) {
|
||||
|
||||
_geometry_changed = false;
|
||||
|
||||
if (window()->isVisible()) {
|
||||
QRect g(geometry());
|
||||
|
||||
if (window()->transientParent()) {
|
||||
/* translate global position to parent-relative position */
|
||||
g.moveTo(window()->transientParent()->mapFromGlobal(g.topLeft()));
|
||||
}
|
||||
|
||||
typedef Nitpicker::Session::Command Command;
|
||||
_nitpicker_session.enqueue<Command::Geometry>(_view_handle,
|
||||
Nitpicker::Rect(Nitpicker::Point(g.x(), g.y()),
|
||||
Nitpicker::Area(g.width(), g.height())));
|
||||
_nitpicker_session.execute();
|
||||
}
|
||||
}
|
||||
|
||||
_framebuffer_session.refresh(x, y, w, h);
|
||||
}
|
||||
|
||||
@ -584,30 +581,30 @@ Nitpicker::View_capability QNitpickerPlatformWindow::view_cap() const
|
||||
|
||||
void QNitpickerPlatformWindow::handle_events()
|
||||
{
|
||||
#if 0
|
||||
/* handle framebuffer mode change events */
|
||||
if (_window_slave_policy.mode_changed()) {
|
||||
int new_width;
|
||||
int new_height;
|
||||
_window_slave_policy.size(new_width, new_height);
|
||||
/* handle resize events */
|
||||
|
||||
if (qnpw_verbose)
|
||||
PDBG("mode change detected: %d, %d", new_width, new_height);
|
||||
if (_signal_receiver.pending()) {
|
||||
|
||||
QRect geo = geometry();
|
||||
geo.setWidth(new_width);
|
||||
geo.setHeight(new_height);
|
||||
QPlatformWindow::setGeometry(geo);
|
||||
_signal_receiver.wait_for_signal();
|
||||
|
||||
if (qnpw_verbose)
|
||||
qDebug() << "calling QWindowSystemInterface::handleGeometryChange(" << geo << ")";
|
||||
Framebuffer::Mode mode(_nitpicker_session.mode());
|
||||
|
||||
QWindowSystemInterface::handleGeometryChange(window(), geo);
|
||||
emit framebuffer_changed();
|
||||
if ((mode.width() != _current_mode.width()) ||
|
||||
(mode.height() != _current_mode.height()) ||
|
||||
(mode.format() != _current_mode.format())) {
|
||||
|
||||
QRect geo(geometry());
|
||||
geo.setWidth(mode.width());
|
||||
geo.setHeight(mode.height());
|
||||
|
||||
QWindowSystemInterface::handleGeometryChange(window(), geo);
|
||||
|
||||
setGeometry(geo);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* handle input events */
|
||||
|
||||
if (_input_session.is_pending()) {
|
||||
for (int i = 0, num_ev = _input_session.flush(); i < num_ev; i++) {
|
||||
|
||||
|
@ -37,20 +37,25 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
|
||||
|
||||
private:
|
||||
|
||||
Nitpicker::Connection _nitpicker_session;
|
||||
Framebuffer::Session_client _framebuffer_session;
|
||||
unsigned char *_framebuffer;
|
||||
bool _framebuffer_changed;
|
||||
Nitpicker::Session::View_handle _view_handle;
|
||||
Input::Session_client _input_session;
|
||||
Input::Event *_ev_buf;
|
||||
QMember<QTimer> _timer;
|
||||
Qt::MouseButtons _mouse_button_state;
|
||||
QEvdevKeyboardHandler _keyboard_handler;
|
||||
QByteArray _title;
|
||||
bool _resize_handle;
|
||||
bool _decoration;
|
||||
EGLSurface _egl_surface;
|
||||
Nitpicker::Connection _nitpicker_session;
|
||||
Framebuffer::Session_client _framebuffer_session;
|
||||
unsigned char *_framebuffer;
|
||||
bool _framebuffer_changed;
|
||||
bool _geometry_changed;
|
||||
Framebuffer::Mode _current_mode;
|
||||
Genode::Signal_context _mode_changed_signal_context;
|
||||
Genode::Signal_context_capability _mode_changed_signal_context_capability;
|
||||
Genode::Signal_receiver _signal_receiver;
|
||||
Nitpicker::Session::View_handle _view_handle;
|
||||
Input::Session_client _input_session;
|
||||
Input::Event *_ev_buf;
|
||||
QMember<QTimer> _timer;
|
||||
Qt::MouseButtons _mouse_button_state;
|
||||
QEvdevKeyboardHandler _keyboard_handler;
|
||||
QByteArray _title;
|
||||
bool _resize_handle;
|
||||
bool _decoration;
|
||||
EGLSurface _egl_surface;
|
||||
|
||||
void _process_mouse_event(Input::Event *ev);
|
||||
void _process_key_event(Input::Event *ev);
|
||||
|
@ -22,9 +22,6 @@
|
||||
/* Genode includes */
|
||||
#include <nitpicker_session/connection.h>
|
||||
|
||||
/* local includes */
|
||||
#include "window_slave_policy.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNitpickerScreen : public QPlatformScreen
|
||||
@ -44,8 +41,7 @@ class QNitpickerScreen : public QPlatformScreen
|
||||
qCritical() << "Nitpicker screen format is not RGB565";
|
||||
|
||||
_geometry.setRect(0, 0, scr_mode.width(),
|
||||
scr_mode.height() -
|
||||
Window_slave_policy::TITLE_BAR_HEIGHT);
|
||||
scr_mode.height());
|
||||
|
||||
Genode::env()->parent()->close(_nitpicker.cap());
|
||||
}
|
||||
|
@ -1,286 +0,0 @@
|
||||
/*
|
||||
* \brief Slave policy for an undecorated window
|
||||
* \author Christian Prochaska
|
||||
* \date 2013-05-08
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _UNDECORATED_WINDOW_POLICY_H_
|
||||
#define _UNDECORATED_WINDOW_POLICY_H_
|
||||
|
||||
/* Qt4 includes */
|
||||
#include <QDebug>
|
||||
#include <QDomDocument>
|
||||
#include <QDomElement>
|
||||
#include <QDomText>
|
||||
|
||||
/* Genode includes */
|
||||
#include <cap_session/connection.h>
|
||||
#include <framebuffer_session/client.h>
|
||||
#include <input/event.h>
|
||||
#include <input_session/client.h>
|
||||
#include <os/slave.h>
|
||||
|
||||
using Genode::Root_capability;
|
||||
using Genode::Allocator;
|
||||
using Genode::Server;
|
||||
using Genode::env;
|
||||
using Genode::Lock_guard;
|
||||
using Genode::Lock;
|
||||
using Genode::Signal_context;
|
||||
using Genode::Signal_receiver;
|
||||
using Genode::Signal_context_capability;
|
||||
using Genode::Dataspace_capability;
|
||||
|
||||
static const bool wsp_verbose = false;
|
||||
|
||||
class Window_slave_policy : public Genode::Slave_policy
|
||||
{
|
||||
private:
|
||||
|
||||
Framebuffer::Session_capability _framebuffer_session;
|
||||
Genode::Lock _framebuffer_ready_lock;
|
||||
unsigned char *_framebuffer;
|
||||
Signal_context _mode_change_signal_context;
|
||||
Signal_receiver _signal_receiver;
|
||||
|
||||
Input::Session_capability _input_session;
|
||||
Genode::Lock _input_ready_lock;
|
||||
Input::Event *_ev_buf;
|
||||
|
||||
QByteArray _config_byte_array;
|
||||
|
||||
const char *_config(int xpos, int ypos, int width, int height,
|
||||
const char *title, bool resize_handle = true,
|
||||
bool decoration = true)
|
||||
{
|
||||
QDomDocument config_doc;
|
||||
|
||||
QDomElement config_node = config_doc.createElement("config");
|
||||
config_doc.appendChild(config_node);
|
||||
|
||||
config_node.setAttribute("xpos", QString::number(xpos));
|
||||
config_node.setAttribute("ypos", QString::number(ypos + TITLE_BAR_HEIGHT));
|
||||
config_node.setAttribute("width", QString::number(width));
|
||||
config_node.setAttribute("height", QString::number(height));
|
||||
|
||||
/* liquid_framebuffer options */
|
||||
config_node.setAttribute("title", title);
|
||||
config_node.setAttribute("animate", "off");
|
||||
|
||||
if (resize_handle)
|
||||
config_node.setAttribute("resize_handle", "on");
|
||||
else
|
||||
config_node.setAttribute("resize_handle", "off");
|
||||
|
||||
if (decoration)
|
||||
config_node.setAttribute("decoration", "on");
|
||||
else
|
||||
config_node.setAttribute("decoration", "off");
|
||||
|
||||
_config_byte_array = config_doc.toByteArray(4);
|
||||
|
||||
if (wsp_verbose)
|
||||
qDebug() << _config_byte_array;
|
||||
|
||||
return _config_byte_array.constData();
|
||||
}
|
||||
|
||||
void _reattach_framebuffer()
|
||||
{
|
||||
Framebuffer::Session_client session_client(_framebuffer_session);
|
||||
|
||||
if (_framebuffer)
|
||||
Genode::env()->rm_session()->detach(_framebuffer);
|
||||
|
||||
Dataspace_capability framebuffer_ds = session_client.dataspace();
|
||||
if (framebuffer_ds.valid()) {
|
||||
_framebuffer = Genode::env()->rm_session()->attach(framebuffer_ds);
|
||||
Framebuffer::Mode const scr_mode = session_client.mode();
|
||||
if (wsp_verbose)
|
||||
PDBG("_framebuffer = %p, width = %d, height = %d", _framebuffer, scr_mode.width(), scr_mode.height());
|
||||
}
|
||||
else
|
||||
_framebuffer = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
const char **_permitted_services() const
|
||||
{
|
||||
static const char *permitted_services[] = {
|
||||
"CAP", "LOG", "RM", "ROM", "SIGNAL",
|
||||
"Timer", "Nitpicker", 0 };
|
||||
|
||||
return permitted_services;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/* scout widgets title bar height */
|
||||
enum { TITLE_BAR_HEIGHT = 32 };
|
||||
|
||||
Window_slave_policy(Genode::Rpc_entrypoint &ep,
|
||||
int screen_width, int screen_height)
|
||||
: Genode::Slave_policy("liquid_fb", ep, env()->ram_session()),
|
||||
_framebuffer_ready_lock(Genode::Lock::LOCKED),
|
||||
_framebuffer(0), _ev_buf(0)
|
||||
{
|
||||
/* start with an invisible window by placing it outside of the screen area */
|
||||
Slave_policy::configure(_config(100000, 0, screen_width, screen_height, "Qt window"));
|
||||
}
|
||||
|
||||
|
||||
~Window_slave_policy()
|
||||
{
|
||||
if (_framebuffer)
|
||||
Genode::env()->rm_session()->detach(_framebuffer);
|
||||
|
||||
if (_ev_buf)
|
||||
Genode::env()->rm_session()->detach(_ev_buf);
|
||||
}
|
||||
|
||||
|
||||
bool announce_service(const char *name,
|
||||
Root_capability root,
|
||||
Allocator *alloc,
|
||||
Server *server)
|
||||
{
|
||||
if (wsp_verbose)
|
||||
PDBG("name = %s", name);
|
||||
|
||||
if (Genode::strcmp(name, "Input") == 0) {
|
||||
|
||||
Genode::Session_capability session_cap =
|
||||
Genode::Root_client(root).session("ram_quota=8K",
|
||||
Genode::Affinity());
|
||||
|
||||
_input_session =
|
||||
Genode::static_cap_cast<Input::Session>(session_cap);
|
||||
|
||||
Input::Session_client session_client(_input_session);
|
||||
|
||||
_ev_buf = static_cast<Input::Event *>
|
||||
(env()->rm_session()->attach(session_client.dataspace()));
|
||||
|
||||
_input_ready_lock.unlock();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Genode::strcmp(name, "Framebuffer") == 0) {
|
||||
|
||||
Genode::Session_capability session_cap =
|
||||
Genode::Root_client(root).session("ram_quota=8K",
|
||||
Genode::Affinity());
|
||||
|
||||
_framebuffer_session =
|
||||
Genode::static_cap_cast<Framebuffer::Session>(session_cap);
|
||||
|
||||
Framebuffer::Session_client session_client(_framebuffer_session);
|
||||
|
||||
_framebuffer = Genode::env()->rm_session()->attach(session_client.dataspace());
|
||||
|
||||
Signal_context_capability mode_change_signal_context_capability =
|
||||
_signal_receiver.manage(&_mode_change_signal_context);
|
||||
|
||||
session_client.mode_sigh(mode_change_signal_context_capability);
|
||||
|
||||
Framebuffer::Mode const scr_mode = session_client.mode();
|
||||
|
||||
if (wsp_verbose)
|
||||
PDBG("_framebuffer = %p, width = %d, height = %d", _framebuffer, scr_mode.width(), scr_mode.height());
|
||||
|
||||
_framebuffer_ready_lock.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
return Slave_policy::announce_service(name, root, alloc, server);
|
||||
}
|
||||
|
||||
|
||||
void wait_for_service_announcements()
|
||||
{
|
||||
Lock_guard<Lock> framebuffer_ready_lock_guard(_framebuffer_ready_lock);
|
||||
Lock_guard<Lock> input_ready_lock_guard(_input_ready_lock);
|
||||
}
|
||||
|
||||
|
||||
void configure(int x, int y, int width, int height, const char *title,
|
||||
bool resize_handle, bool decoration)
|
||||
{
|
||||
Slave_policy::configure(_config(x, y, width, height, title, resize_handle, decoration));
|
||||
|
||||
if (wsp_verbose)
|
||||
PDBG("waiting for mode change signal");
|
||||
|
||||
_signal_receiver.wait_for_signal();
|
||||
|
||||
if (wsp_verbose)
|
||||
PDBG("received mode change signal");
|
||||
|
||||
_reattach_framebuffer();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return the current window size
|
||||
*/
|
||||
void size(int &width, int &height)
|
||||
{
|
||||
Framebuffer::Session_client session_client(_framebuffer_session);
|
||||
Framebuffer::Mode const scr_mode = session_client.mode();
|
||||
width = scr_mode.width();
|
||||
height = scr_mode.height();
|
||||
}
|
||||
|
||||
|
||||
unsigned char *framebuffer()
|
||||
{
|
||||
return _framebuffer;
|
||||
}
|
||||
|
||||
|
||||
void refresh(int x, int y, int w, int h)
|
||||
{
|
||||
Framebuffer::Session_client session_client(_framebuffer_session);
|
||||
session_client.refresh(x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
bool mode_changed()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
while (_signal_receiver.pending()) {
|
||||
_signal_receiver.wait_for_signal();
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (result == true)
|
||||
_reattach_framebuffer();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Input::Session_capability input_session()
|
||||
{
|
||||
return _input_session;
|
||||
}
|
||||
|
||||
|
||||
Input::Event *ev_buf()
|
||||
{
|
||||
return _ev_buf;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /* _UNDECORATED_WINDOW_POLICY_H_ */
|
Loading…
x
Reference in New Issue
Block a user