genode/repos/os/include/nitpicker_session/nitpicker_session.h
Norman Feske 24869bd3ff nitpicker: Support for session-focus management
This patch introduces a focus-management facility to the nitpicker
session interface. As a side effect of this change, we remove the notion
of a "focused view". There can only be a "focused session". This makes
sense because input is directed to sessions, not views.

Issue #1168
2014-08-11 15:55:32 +02:00

135 lines
4.0 KiB
C++

/*
* \brief Nitpicker session interface
* \author Norman Feske
* \date 2006-08-10
*
* A Nitpicker session handles exactly one buffer.
*/
/*
* Copyright (C) 2006-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 _INCLUDE__NITPICKER_SESSION__NITPICKER_SESSION_H_
#define _INCLUDE__NITPICKER_SESSION__NITPICKER_SESSION_H_
#include <session/session.h>
#include <framebuffer_session/capability.h>
#include <input_session/capability.h>
#include <nitpicker_view/capability.h>
namespace Nitpicker {
using Genode::size_t;
struct Session;
}
struct Nitpicker::Session : Genode::Session
{
static const char *service_name() { return "Nitpicker"; }
/**
* Exception type
*/
struct Out_of_metadata : Genode::Exception { };
virtual ~Session() { }
/**
* Request framebuffer sub-session
*/
virtual Framebuffer::Session_capability framebuffer_session() = 0;
/**
* Request input sub-session
*/
virtual Input::Session_capability input_session() = 0;
/**
* Create a new view at the buffer
*
* \param parent parent view
*
* \return capability to a new view
*
* The 'parent' argument allows the client to use the location of an
* existing view as the coordinate origin for the to-be-created view.
* If an invalid capability is specified (default), the view will be a
* top-level view.
*/
virtual View_capability create_view(View_capability parent = View_capability()) = 0;
/**
* Destroy view
*/
virtual void destroy_view(View_capability view) = 0;
/**
* Define view that is used as desktop background
*/
virtual int background(View_capability view) = 0;
/**
* Return physical screen mode
*/
virtual Framebuffer::Mode mode() = 0;
/**
* Define dimensions of virtual framebuffer
*
* \throw Out_of_metadata session quota does not suffice for specified
* buffer dimensions
*/
virtual void buffer(Framebuffer::Mode mode, bool use_alpha) = 0;
/**
* Set focused session
*
* Normally, the focused session is defined by the user by clicking on a
* view. The 'focus' function allows a client to set the focus without user
* action. However, the change of the focus is performed only is the
* currently focused session belongs to a child or the same process as the
* called session. This relationship is checked by comparing the session
* labels of the currently focused session and the caller. This way, a
* common parent can manage the focus among its child processes. But a
* session cannot steal the focus from an unrelated session.
*/
virtual void focus(Genode::Capability<Session> focused) = 0;
/**
* Return number of bytes needed for virtual framebuffer of specified size
*/
static size_t ram_quota(Framebuffer::Mode mode, bool use_alpha)
{
/*
* If alpha blending is used, each pixel requires an additional byte
* for the alpha value and a byte holding the input mask.
*/
return (mode.bytes_per_pixel() + 2*use_alpha)*mode.width()*mode.height();
}
/*********************
** RPC declaration **
*********************/
GENODE_RPC(Rpc_framebuffer_session, Framebuffer::Session_capability, framebuffer_session);
GENODE_RPC(Rpc_input_session, Input::Session_capability, input_session);
GENODE_RPC(Rpc_create_view, View_capability, create_view, View_capability);
GENODE_RPC(Rpc_destroy_view, void, destroy_view, View_capability);
GENODE_RPC(Rpc_background, int, background, View_capability);
GENODE_RPC(Rpc_mode, Framebuffer::Mode, mode);
GENODE_RPC(Rpc_focus, void, focus, Genode::Capability<Session>);
GENODE_RPC_THROW(Rpc_buffer, void, buffer, GENODE_TYPE_LIST(Out_of_metadata),
Framebuffer::Mode, bool);
GENODE_RPC_INTERFACE(Rpc_framebuffer_session, Rpc_input_session,
Rpc_create_view, Rpc_destroy_view, Rpc_background,
Rpc_mode, Rpc_buffer, Rpc_focus);
};
#endif /* _INCLUDE__NITPICKER_SESSION__NITPICKER_SESSION_H_ */