2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Launchpad window interface
|
|
|
|
* \date 2006-08-30
|
|
|
|
* \author Norman Feske
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2006-2017 Genode Labs GmbH
|
2011-12-22 16:19:25 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LAUNCHPAD_WINDOW_H_
|
|
|
|
#define _LAUNCHPAD_WINDOW_H_
|
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
#include <base/env.h>
|
|
|
|
#include <dataspace/capability.h>
|
|
|
|
|
2013-12-30 01:21:53 +01:00
|
|
|
#include <scout/platform.h>
|
|
|
|
#include <scout/window.h>
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
#include "elements.h"
|
|
|
|
#include "widgets.h"
|
|
|
|
#include "sky_texture.h"
|
|
|
|
#include "scrollbar.h"
|
|
|
|
#include "fade_icon.h"
|
|
|
|
#include "titlebar.h"
|
|
|
|
|
|
|
|
#include "launch_entry.h"
|
|
|
|
#include "status_entry.h"
|
|
|
|
#include "child_entry.h"
|
|
|
|
#include "section.h"
|
|
|
|
|
|
|
|
#include <launchpad/launchpad.h>
|
|
|
|
|
|
|
|
template <typename PT>
|
2013-12-30 01:21:53 +01:00
|
|
|
class Launchpad_window : public Scout::Scrollbar_listener,
|
2011-12-22 16:19:25 +01:00
|
|
|
public Launchpad,
|
2013-12-30 01:21:53 +01:00
|
|
|
public Scout::Window
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
/*
|
|
|
|
* Noncopyable
|
|
|
|
*/
|
|
|
|
Launchpad_window(Launchpad_window const &);
|
|
|
|
Launchpad_window &operator = (Launchpad_window const &);
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/**
|
|
|
|
* Constants
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
_TH = 32, /* height of title bar */
|
|
|
|
_SB_XPAD = 5, /* hor. pad of scrollbar */
|
|
|
|
_SB_YPAD = 10, /* vert. pad of scrollbar */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Widgets
|
|
|
|
*/
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
Scout::Titlebar<PT> _titlebar { };
|
|
|
|
Scout::Sky_texture<PT, 512, 512> _texture { };
|
|
|
|
Scout::Fade_icon<PT, 32, 32> _sizer { };
|
|
|
|
Scout::Scrollbar<PT> _scrollbar { };
|
|
|
|
Genode::List<Child_entry<PT> > _child_entry_list { };
|
|
|
|
Scout::Docview _docview { };
|
|
|
|
Scout::Spacer _spacer { };
|
|
|
|
Scout::Document _document { };
|
2011-12-22 16:19:25 +01:00
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
Section<PT> _info_section { };
|
|
|
|
Section<PT> _launch_section { };
|
|
|
|
Section<PT> _kiddy_section { };
|
2011-12-22 16:19:25 +01:00
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
Status_entry<PT> _status_entry { };
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* \param initial_quota maximum value of quota displays
|
|
|
|
*/
|
2016-11-23 17:07:49 +01:00
|
|
|
Launchpad_window(Genode::Env &env,
|
|
|
|
Scout::Graphics_backend &gfx_backend,
|
2013-12-30 01:21:53 +01:00
|
|
|
Scout::Point position, Scout::Area size,
|
|
|
|
Scout::Area max_size, unsigned long inital_quota);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Define vertical scroll offset of document
|
|
|
|
*
|
|
|
|
* \param update_scrollbar if set to one, adjust scrollbar properties
|
|
|
|
* to the new view position.
|
|
|
|
*/
|
|
|
|
void ypos_sb(int ypos, int update_scrollbar = 1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Window interface
|
|
|
|
*/
|
2019-02-14 22:39:08 +01:00
|
|
|
void format(Scout::Area) override;
|
|
|
|
void ypos(int ypos) override { ypos_sb(ypos, 1); }
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Element interface
|
|
|
|
*/
|
2019-02-14 22:39:08 +01:00
|
|
|
void draw(Scout::Canvas_base &canvas, Scout::Point abs_position) override
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2013-12-30 01:21:53 +01:00
|
|
|
using namespace Scout;
|
|
|
|
|
|
|
|
Parent_element::draw(canvas, abs_position);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* border */
|
2013-12-30 01:21:53 +01:00
|
|
|
Color color(0, 0, 0);
|
|
|
|
canvas.draw_box(0, 0, _size.w(), 1, color);
|
|
|
|
canvas.draw_box(0, _size.h() - 1, _size.w(), 1, color);
|
|
|
|
canvas.draw_box(0, 1, 1, _size.h() - 2, color);
|
|
|
|
canvas.draw_box(_size.w() - 1, 1, 1, _size.h() - 2, color);
|
2011-12-22 16:19:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scrollbar listener interface
|
|
|
|
*/
|
2019-02-14 22:39:08 +01:00
|
|
|
void handle_scroll(int view_pos) override;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Launchpad interface
|
|
|
|
*/
|
2019-02-14 22:39:08 +01:00
|
|
|
void quota(unsigned long quota) override
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
_status_entry.max_value(initial_quota() / 1024);
|
|
|
|
_status_entry.value(quota / 1024);
|
|
|
|
_status_entry.refresh();
|
|
|
|
}
|
|
|
|
|
Capability quota accounting and trading
This patch mirrors the accounting and trading scheme that Genode employs
for physical memory to the accounting of capability allocations.
Capability quotas must now be explicitly assigned to subsystems by
specifying a 'caps=<amount>' attribute to init's start nodes.
Analogously to RAM quotas, cap quotas can be traded between clients and
servers as part of the session protocol. The capability budget of each
component is maintained by the component's corresponding PD session at
core.
At the current stage, the accounting is applied to RPC capabilities,
signal-context capabilities, and dataspace capabilities. Capabilities
that are dynamically allocated via core's CPU and TRACE service are not
yet covered. Also, the capabilities allocated by resource multiplexers
outside of core (like nitpicker) must be accounted by the respective
servers, which is not covered yet.
If a component runs out of capabilities, core's PD service prints a
warning to the log. To observe the consumption of capabilities per
component in detail, the PD service is equipped with a diagnostic
mode, which can be enabled via the 'diag' attribute in the target
node of init's routing rules. E.g., the following route enables the
diagnostic mode for the PD session of the "timer" component:
<default-route>
<service name="PD" unscoped_label="timer">
<parent diag="yes"/>
</service>
...
</default-route>
For subsystems based on a sub-init instance, init can be configured
to report the capability-quota information of its subsystems by
adding the attribute 'child_caps="yes"' to init's '<report>'
config node. Init's own capability quota can be reported by adding
the attribute 'init_caps="yes"'.
Fixes #2398
2017-05-08 21:35:43 +02:00
|
|
|
void add_launcher(Launchpad_child::Name const &name, Cap_quota caps,
|
2011-12-22 16:19:25 +01:00
|
|
|
unsigned long default_quota,
|
2016-11-23 17:07:49 +01:00
|
|
|
Genode::Dataspace_capability config_ds = Genode::Dataspace_capability()) override
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
Launch_entry<PT> *le;
|
Capability quota accounting and trading
This patch mirrors the accounting and trading scheme that Genode employs
for physical memory to the accounting of capability allocations.
Capability quotas must now be explicitly assigned to subsystems by
specifying a 'caps=<amount>' attribute to init's start nodes.
Analogously to RAM quotas, cap quotas can be traded between clients and
servers as part of the session protocol. The capability budget of each
component is maintained by the component's corresponding PD session at
core.
At the current stage, the accounting is applied to RPC capabilities,
signal-context capabilities, and dataspace capabilities. Capabilities
that are dynamically allocated via core's CPU and TRACE service are not
yet covered. Also, the capabilities allocated by resource multiplexers
outside of core (like nitpicker) must be accounted by the respective
servers, which is not covered yet.
If a component runs out of capabilities, core's PD service prints a
warning to the log. To observe the consumption of capabilities per
component in detail, the PD service is equipped with a diagnostic
mode, which can be enabled via the 'diag' attribute in the target
node of init's routing rules. E.g., the following route enables the
diagnostic mode for the PD session of the "timer" component:
<default-route>
<service name="PD" unscoped_label="timer">
<parent diag="yes"/>
</service>
...
</default-route>
For subsystems based on a sub-init instance, init can be configured
to report the capability-quota information of its subsystems by
adding the attribute 'child_caps="yes"' to init's '<report>'
config node. Init's own capability quota can be reported by adding
the attribute 'init_caps="yes"'.
Fixes #2398
2017-05-08 21:35:43 +02:00
|
|
|
le = new Launch_entry<PT>(name, caps.value, default_quota / 1024,
|
2011-12-22 16:19:25 +01:00
|
|
|
initial_quota() / 1024,
|
|
|
|
this, config_ds);
|
|
|
|
_launch_section.append(le);
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
void add_child(Launchpad_child::Name const &name,
|
2011-12-22 16:19:25 +01:00
|
|
|
unsigned long quota,
|
2016-11-23 17:07:49 +01:00
|
|
|
Launchpad_child &launchpad_child,
|
|
|
|
Genode::Allocator &alloc) override
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
Child_entry<PT> *ce;
|
2016-11-23 17:07:49 +01:00
|
|
|
ce = new (alloc) Child_entry<PT>(name, quota / 1024,
|
2011-12-22 16:19:25 +01:00
|
|
|
initial_quota() / 1024,
|
2016-11-23 17:07:49 +01:00
|
|
|
*this, launchpad_child);
|
2011-12-22 16:19:25 +01:00
|
|
|
_child_entry_list.insert(ce);
|
|
|
|
_kiddy_section.append(ce);
|
2013-12-30 01:21:53 +01:00
|
|
|
format(_size);
|
2011-12-22 16:19:25 +01:00
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
void remove_child(Launchpad_child::Name const &name,
|
|
|
|
Genode::Allocator &alloc) override
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
/* lookup child entry by its name */
|
|
|
|
Child_entry<PT> *ce = _child_entry_list.first();
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
for ( ; ce; ce = ce->next())
|
2016-11-23 17:07:49 +01:00
|
|
|
if (name == ce->name())
|
2011-12-22 16:19:25 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (!ce) {
|
2019-01-21 14:27:12 +01:00
|
|
|
Genode::warning("child entry lookup failed");
|
2011-12-22 16:19:25 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_child_entry_list.remove(ce);
|
|
|
|
_kiddy_section.forget(ce);
|
|
|
|
destroy(alloc, ce);
|
2013-12-30 01:21:53 +01:00
|
|
|
format(_size);
|
2011-12-22 16:19:25 +01:00
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|