nitpicker: Nitpicker::Session::mode_sigh function

The new 'mode_sigh' functions allows a client to register a signal
handler that is notified each time when nitpicker's screen properties
change.
This commit is contained in:
Norman Feske 2014-07-09 10:34:02 +02:00
parent 8df93aa4d4
commit 7fef141b96
3 changed files with 34 additions and 1 deletions

View File

@ -74,6 +74,9 @@ class Nitpicker::Session_client : public Genode::Rpc_client<Session>
Framebuffer::Mode mode() override {
return call<Rpc_mode>(); }
void mode_sigh(Genode::Signal_context_capability sigh) override {
call<Rpc_mode_sigh>(sigh); }
void buffer(Framebuffer::Mode mode, bool alpha) override {
call<Rpc_buffer>(mode, alpha); }

View File

@ -252,6 +252,11 @@ struct Nitpicker::Session : Genode::Session
*/
virtual Framebuffer::Mode mode() = 0;
/**
* Register signal handler to be notified about mode changes
*/
virtual void mode_sigh(Genode::Signal_context_capability) = 0;
/**
* Define dimensions of virtual framebuffer
*
@ -304,6 +309,7 @@ struct Nitpicker::Session : Genode::Session
GENODE_RPC(Rpc_execute, void, execute);
GENODE_RPC(Rpc_background, int, background, View_capability);
GENODE_RPC(Rpc_mode, Framebuffer::Mode, mode);
GENODE_RPC(Rpc_mode_sigh, void, mode_sigh, Genode::Signal_context_capability);
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);
@ -323,10 +329,11 @@ struct Nitpicker::Session : Genode::Session
Type_tuple<Rpc_command_dataspace,
Type_tuple<Rpc_execute,
Type_tuple<Rpc_mode,
Type_tuple<Rpc_mode_sigh,
Type_tuple<Rpc_buffer,
Type_tuple<Rpc_focus,
Genode::Meta::Empty>
> > > > > > > > > > > Rpc_functions;
> > > > > > > > > > > > Rpc_functions;
};
#endif /* _INCLUDE__NITPICKER_SESSION__NITPICKER_SESSION_H_ */

View File

@ -420,6 +420,8 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
Mode &_mode;
Signal_context_capability _mode_sigh;
View &_pointer_origin;
List<Session_view_list_elem> _view_list;
@ -697,6 +699,15 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
_destroy_view(*static_cast<View *>(v));
}
/**
* Deliver mode-change signal to client
*/
void notify_mode_change()
{
if (_mode_sigh.valid())
Signal_transmitter(_mode_sigh).submit();
}
void upgrade_ram_quota(size_t ram_quota) { _session_alloc.upgrade(ram_quota); }
@ -859,6 +870,11 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
_framebuffer.mode().format());
}
void mode_sigh(Signal_context_capability sigh) override
{
_mode_sigh = sigh;
}
void buffer(Framebuffer::Mode mode, bool use_alpha) override
{
/* check if the session quota suffices for the specified mode */
@ -1294,6 +1310,13 @@ void Nitpicker::Main::handle_fb_mode(unsigned)
/* redraw */
user_state.update_all_views();
/* notify clients about the change screen mode */
for (::Session *s = session_list.first(); s; s = s->next()) {
Session_component *sc = dynamic_cast<Session_component *>(s);
if (sc)
sc->notify_mode_change();
}
}