Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add a protocol to be used by Alien
- Loading branch information
Showing
8 changed files
with
611 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
<protocol name="alien_manager"> | ||
<copyright> | ||
Copyright (C) 2014 Jolla Ltd. | ||
|
||
Permission to use, copy, modify, distribute, and sell this | ||
software and its documentation for any purpose is hereby granted | ||
without fee, provided that the above copyright notice appear in | ||
all copies and that both that copyright notice and this permission | ||
notice appear in supporting documentation, and that the name of | ||
the copyright holders not be used in advertising or publicity | ||
pertaining to distribution of the software without specific, | ||
written prior permission. The copyright holders make no | ||
representations about the suitability of this software for any | ||
purpose. It is provided "as is" without express or implied | ||
warranty. | ||
|
||
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS | ||
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN | ||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | ||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
THIS SOFTWARE. | ||
</copyright> | ||
|
||
<interface name="alien_manager" version="1"> | ||
<description summary="manager interface for alien clients"> | ||
This global interface is used by alien clients to integrate | ||
with the shell. | ||
</description> | ||
|
||
<request name="destroy" type="destructor"> | ||
<description summary="destroy the manager"> | ||
Destroy this alien_manager. All its alien_client children | ||
are inactive and should be destroyed by the client. | ||
</description> | ||
</request> | ||
|
||
<request name="create_alien_client"> | ||
<description summary="create a new alien_client handle"> | ||
This request creates a new alien_client. For each | ||
alien_client there should be a real alien application | ||
associated with it. | ||
The package parameter should be the android package of | ||
the external application. | ||
</description> | ||
<arg name="id" type="new_id" interface="alien_client"/> | ||
<arg name="package" type="string"/> | ||
</request> | ||
|
||
<request name="pong"> | ||
<description summary="respond to a ping event"> | ||
A client must respond to a ping event with a pong request or | ||
the client may be deemed unresponsive. | ||
</description> | ||
<arg name="serial" type="uint"/> | ||
</request> | ||
|
||
<event name="ping"> | ||
<description summary="ping client"> | ||
A client must respond to a ping event with a pong request or | ||
the client may be deemed unresponsive. | ||
</description> | ||
<arg name="serial" type="uint"/> | ||
</event> | ||
</interface> | ||
|
||
<interface name="alien_client" version="1"> | ||
<description summary="alien client metadata interface"> | ||
Interface used to associate one or more wl_surfaces with an | ||
external alien application. | ||
</description> | ||
|
||
<request name="destroy" type="destructor"> | ||
<description summary="destroy this alien_client"> | ||
Destroy this alien_client. All its alien_surface children | ||
are unmapped and become inactive and should be destroyed | ||
by the client. | ||
</description> | ||
</request> | ||
|
||
<request name="get_alien_surface"> | ||
<description summary="create a new alien_surface"> | ||
Extend 'surface' with the alien_surface role. | ||
|
||
If the surface has a role already a protocol error will | ||
be raised. | ||
</description> | ||
<arg name="id" type="new_id" interface="alien_surface"/> | ||
<arg name="surface" type="object" interface="wl_surface"/> | ||
</request> | ||
|
||
<event name="oom_score"> | ||
<description summary="the oom score for the client"> | ||
After receiving this event the client should set the | ||
oom score for the real application to the given value. | ||
</description> | ||
<arg name="score" type="int"/> | ||
</event> | ||
</interface> | ||
|
||
<interface name="alien_surface" version="1"> | ||
<description summary="main window interface for alien clients"> | ||
This interface extends a basic wl_surface with additional metadata | ||
needed to map it on screen. | ||
|
||
If its wl_surface is destroyed, an alien_surface becomes inactive | ||
but will not be automatically destroyed. | ||
</description> | ||
|
||
<request name="destroy" type="destructor"> | ||
<description summary="delete surface"> | ||
Deletes the surface and invalidates its object ID. | ||
|
||
The wl_surface loses its role, and all the associated properties. | ||
The surface is unmapped. | ||
</description> | ||
</request> | ||
|
||
<request name="set_title"> | ||
<description summary="set surface title"> | ||
Set a short title for the surface. | ||
|
||
This string may be used to identify the surface in a task bar, | ||
window list, or other user interface elements provided by the | ||
compositor. | ||
|
||
The string must be encoded in UTF-8. | ||
</description> | ||
<arg name="title" type="string"/> | ||
</request> | ||
|
||
<enum name="state"> | ||
<description summary="types of state on the surface"> | ||
The different state values used on the surface. They are paired with | ||
the configure event to ensure that both the client and the compositor | ||
setting the state can be synchronized. | ||
|
||
States set in this way are double-buffered. They will get applied on | ||
the next commit. | ||
</description> | ||
<entry name="hidden" value="1" summary="the surface is not visible"> | ||
The surface is hidden, it should stop drawing and free memory | ||
if possible. | ||
</entry> | ||
<entry name="cover" value="2" summary="the surface is used as a cover"> | ||
The surface is being used as a non-fullscreen cover, and cannot | ||
receive input. | ||
</entry> | ||
</enum> | ||
|
||
<event name="configure"> | ||
<description summary="suggest a surface change"> | ||
The configure event asks the client to resize its surface. | ||
|
||
The width and height arguments specify a hint to the window | ||
about how its surface should be resized in surface local | ||
coordinates. The states listed in the event specify additional | ||
information about the surface. | ||
|
||
A client should send an ack_configure request with the serial | ||
sent in this configure event before attaching a new buffer. | ||
|
||
If the client receives multiple configure events before it | ||
can respond to one, it is free to discard all but the last | ||
event it received. | ||
</description> | ||
<arg name="width" type="uint"/> | ||
<arg name="height" type="uint"/> | ||
<arg name="states" type="array"/> | ||
<arg name="serial" type="uint"/> | ||
</event> | ||
|
||
<request name="ack_configure"> | ||
<description summary="ack a configure event"> | ||
When a configure event is received, a client should then ack it | ||
using the ack_configure request to ensure that the compositor | ||
knows the client has seen the event. | ||
|
||
By this point, the state is confirmed, and the next attach should | ||
contain the buffer drawn for the configure event you are acking. | ||
</description> | ||
<arg name="serial" type="uint"/> | ||
</request> | ||
|
||
<request name="request_state"> | ||
<description summary="request a surface change"> | ||
Ask the compositor to send a configure event with the | ||
requested states. The compositor is free to ignore the | ||
request, or to send a different states value than the | ||
one requested. | ||
The value of the 'serial' argument should be the last serial | ||
the client received in an event. | ||
</description> | ||
<arg name="states" type="array"/> | ||
<arg name="serial" type="uint" summary="serial for focus stealing prevenction"/> | ||
</request> | ||
|
||
<request name="set_minimized"> | ||
<description summary="ask the server to minimize the surface"> | ||
By calling this request the client asks the compositor to minimize | ||
this surface. The actual behavior is compositor specific, the client | ||
should not assume this surface is going to be unmapped. | ||
</description> | ||
</request> | ||
|
||
<event name="close"> | ||
<description summary="request to close this surface"> | ||
This event requests the client to destroy this surface. The client is | ||
free to choose if it wants to quit or to just destroy this surface and | ||
keep running, however if the client ignores the request or takes too | ||
much time to destroy the surface the server may decide to forcefully | ||
kill it. | ||
</description> | ||
</event> | ||
</interface> | ||
</protocol> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd. | ||
** Contact: Giulio Camuffo <giulio.camuffo@jollamobile.com> | ||
** | ||
** This file is part of lipstick. | ||
** | ||
** This library is free software; you can redistribute it and/or | ||
** modify it under the terms of the GNU Lesser General Public | ||
** License version 2.1 as published by the Free Software Foundation | ||
** and appearing in the file LICENSE.LGPL included in the packaging | ||
** of this file. | ||
** | ||
****************************************************************************/ | ||
|
||
#include <QtCompositor/QWaylandSurface> | ||
|
||
#include "alienmanager.h" | ||
#include "aliensurface.h" | ||
|
||
AlienManagerGlobal::AlienManagerGlobal(QObject *parent) | ||
: QObject(parent) | ||
{ | ||
|
||
} | ||
|
||
const wl_interface *AlienManagerGlobal::interface() const | ||
{ | ||
return &alien_manager_interface; | ||
} | ||
|
||
void AlienManagerGlobal::bind(wl_client *client, uint32_t version, uint32_t id) | ||
{ | ||
new AlienManager(client, version, id, this); | ||
} | ||
|
||
|
||
|
||
AlienManager::AlienManager(wl_client *client, uint32_t version, uint32_t id, QObject *parent) | ||
: QObject(parent) | ||
, QtWaylandServer::alien_manager(client, id, version) | ||
{ | ||
} | ||
|
||
void AlienManager::ping(uint32_t serial, QWaylandSurface *surface) | ||
{ | ||
m_pings.insert(serial, surface); | ||
send_ping(serial); | ||
} | ||
|
||
void AlienManager::alien_manager_destroy_resource(Resource *resource) | ||
{ | ||
Q_UNUSED(resource) | ||
delete this; | ||
} | ||
|
||
void AlienManager::alien_manager_destroy(Resource *resource) | ||
{ | ||
wl_resource_destroy(resource->handle); | ||
} | ||
|
||
void AlienManager::alien_manager_create_alien_client(Resource *resource, uint32_t id, const QString &package) | ||
{ | ||
new AlienClient(this, resource->client(), wl_resource_get_version(resource->handle), id, package); | ||
} | ||
|
||
void AlienManager::alien_manager_pong(Resource *resource, uint32_t serial) | ||
{ | ||
Q_UNUSED(resource) | ||
QWaylandSurface *surf = m_pings.value(serial); | ||
if (surf) | ||
surf->pong(); | ||
} | ||
|
||
|
||
AlienClient::AlienClient(AlienManager *mgr, wl_client *client, uint32_t version, uint32_t id, const QString &package) | ||
: QObject(mgr) | ||
, QtWaylandServer::alien_client(client, id, version) | ||
, m_package(package) | ||
, m_manager(mgr) | ||
{ | ||
} | ||
|
||
AlienManager *AlienClient::manager() const | ||
{ | ||
return m_manager; | ||
} | ||
|
||
void AlienClient::alien_client_destroy_resource(Resource *resource) | ||
{ | ||
Q_UNUSED(resource) | ||
delete this; | ||
} | ||
|
||
void AlienClient::alien_client_destroy(Resource *resource) | ||
{ | ||
wl_resource_destroy(resource->handle); | ||
} | ||
|
||
void AlienClient::alien_client_get_alien_surface(Resource *resource, uint32_t id, ::wl_resource *surface) | ||
{ | ||
QWaylandSurface *surf = QWaylandSurface::fromResource(surface); | ||
new AlienSurface(this, surf, wl_resource_get_version(resource->handle), id, m_package); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd. | ||
** Contact: Giulio Camuffo <giulio.camuffo@jollamobile.com> | ||
** | ||
** This file is part of lipstick. | ||
** | ||
** This library is free software; you can redistribute it and/or | ||
** modify it under the terms of the GNU Lesser General Public | ||
** License version 2.1 as published by the Free Software Foundation | ||
** and appearing in the file LICENSE.LGPL included in the packaging | ||
** of this file. | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef ALIENMANAGER_H | ||
#define ALIENMANAGER_H | ||
|
||
#include <QObject> | ||
#include <QtCompositor/qwaylandglobalinterface.h> | ||
|
||
#include "qwayland-server-alien-manager.h" | ||
|
||
class AlienClient; | ||
class AlienSurface; | ||
|
||
class AlienManagerGlobal : public QObject, public QWaylandGlobalInterface | ||
{ | ||
public: | ||
explicit AlienManagerGlobal(QObject *parent = nullptr); | ||
|
||
const wl_interface *interface() const Q_DECL_OVERRIDE; | ||
void bind(wl_client *client, uint32_t version, uint32_t id) Q_DECL_OVERRIDE; | ||
}; | ||
|
||
class AlienManager : public QObject, public QtWaylandServer::alien_manager | ||
{ | ||
public: | ||
AlienManager(wl_client *client, uint32_t version, uint32_t id, QObject *parent); | ||
|
||
void ping(uint32_t serial, QWaylandSurface *surface); | ||
|
||
protected: | ||
void alien_manager_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; | ||
void alien_manager_destroy(Resource *resource) Q_DECL_OVERRIDE; | ||
void alien_manager_create_alien_client(Resource *resource, uint32_t id, const QString &package) Q_DECL_OVERRIDE; | ||
void alien_manager_pong(Resource *resource, uint32_t serial) Q_DECL_OVERRIDE; | ||
|
||
private: | ||
QMap<uint32_t, QWaylandSurface *> m_pings; | ||
}; | ||
|
||
class AlienClient : public QObject, public QtWaylandServer::alien_client | ||
{ | ||
public: | ||
AlienClient(AlienManager *mgr, wl_client *client, uint32_t version, uint32_t id, const QString &package); | ||
|
||
AlienManager *manager() const; | ||
|
||
protected: | ||
void alien_client_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; | ||
void alien_client_destroy(Resource *resource) Q_DECL_OVERRIDE; | ||
void alien_client_get_alien_surface(Resource *resource, uint32_t id, ::wl_resource *surface) Q_DECL_OVERRIDE; | ||
|
||
private: | ||
QString m_package; | ||
AlienManager *m_manager; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.