mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 14:37:50 +00:00
sculpt: manage leitzentrale window layout
With this patch, the sculpt manager takes over the role the window layouter of the leitzentrale, which eliminates the need to manually position and size the inspect window.
This commit is contained in:
parent
c1d2388c76
commit
3372c1a7b2
@ -38,7 +38,6 @@ _/src/e2fsprogs-minimal
|
||||
_/src/nvme_drv
|
||||
_/src/wm
|
||||
_/src/themed_decorator
|
||||
_/src/floating_window_layouter
|
||||
_/src/libpng
|
||||
_/src/zlib
|
||||
_/src/menu_view
|
||||
|
@ -279,10 +279,11 @@ install_config {
|
||||
|
||||
</config>}
|
||||
|
||||
file copy -force [genode_dir]/repos/gems/recipes/raw/fonts_fs/fonts_fs.config [run_dir]/genode/fonts.config
|
||||
file copy -force [genode_dir]/repos/gems/run/sculpt/fonts.config [run_dir]/genode/
|
||||
file copy -force [genode_dir]/repos/gems/run/sculpt/leitzentrale.config [run_dir]/genode/
|
||||
file copy -force [genode_dir]/repos/gems/run/sculpt/vimrc [run_dir]/genode/
|
||||
file copy -force [genode_dir]/repos/gems/src/app/backdrop/genode_logo.png [run_dir]/genode/
|
||||
file copy -force [genode_dir]/repos/gems/run/sculpt/drop_shadow.png [run_dir]/genode/
|
||||
|
||||
proc install_rom_module { name content } {
|
||||
set fd [open [run_dir]/genode/$name w]
|
||||
|
@ -447,6 +447,7 @@ file copy -force [genode_dir]/repos/gems/recipes/raw/depot_download/depot_downlo
|
||||
file copy -force [genode_dir]/VERSION [run_dir]/genode/
|
||||
|
||||
file copy -force [genode_dir]/repos/gems/src/app/backdrop/genode_logo.png [run_dir]/genode/
|
||||
file copy -force [genode_dir]/repos/gems/run/sculpt/drop_shadow.png [run_dir]/genode/
|
||||
|
||||
exec gzip -dc [genode_dir]/repos/gems/run/sculpt/machine.vdi.gz > [run_dir]/genode/machine.vdi
|
||||
|
||||
|
BIN
repos/gems/run/sculpt/drop_shadow.png
Normal file
BIN
repos/gems/run/sculpt/drop_shadow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -20,4 +20,7 @@
|
||||
|
||||
<!-- policy when using this file as fonts-fs config -->
|
||||
<default-policy root="/fonts" />
|
||||
|
||||
<!-- color definition when this file is used as terminal config -->
|
||||
<color index="0" bg="#1c2232"/>
|
||||
</config>
|
||||
|
@ -90,17 +90,15 @@
|
||||
<service name="ROM"/>
|
||||
</provides>
|
||||
<config verbose="no">
|
||||
<policy label="layouter -> window_list" report="wm -> window_list"/>
|
||||
<policy label="layouter -> focus_request" report="wm -> focus_request"/>
|
||||
<policy label="decorator -> window_layout" report="layouter -> window_layout"/>
|
||||
<policy label="wm -> resize_request" report="layouter -> resize_request"/>
|
||||
<policy label="decorator -> window_layout" report="manager -> window_layout"/>
|
||||
<policy label="wm -> resize_request" report="manager -> window_layout"/>
|
||||
<policy label="wm -> focus" report="manager -> wm_focus"/>
|
||||
<policy label="decorator -> pointer" report="wm -> pointer"/>
|
||||
<policy label="layouter -> hover" report="decorator -> hover"/>
|
||||
<policy label="layouter -> decorator_margins" report="decorator -> decorator_margins"/>
|
||||
<policy label="wm -> focus" report="layouter -> focus"/>
|
||||
<policy label="gui -> config" report="manager -> gui_config"/>
|
||||
<policy label="gui -> menu_view -> dialog" report="manager -> menu_dialog"/>
|
||||
<policy label="manager -> menu_view_hover" report="gui -> menu_view -> hover"/>
|
||||
<policy label="manager -> window_list" report="wm -> window_list"/>
|
||||
<policy label="manager -> decorator_margins" report="decorator -> decorator_margins"/>
|
||||
<policy label="nitpicker -> focus" report="manager -> focus"/>
|
||||
</config>
|
||||
</start>
|
||||
@ -110,7 +108,6 @@
|
||||
<provides> <service name="Nitpicker"/> </provides>
|
||||
<config>
|
||||
<policy label_prefix="decorator" role="decorator"/>
|
||||
<policy label_prefix="layouter" role="layouter"/>
|
||||
</config>
|
||||
<route>
|
||||
<service name="ROM" label="resize_request"> <child name="report_rom"/> </service>
|
||||
@ -121,29 +118,26 @@
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="layouter">
|
||||
<binary name="floating_window_layouter"/>
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<config/>
|
||||
<route>
|
||||
<service name="ROM" label="window_list"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="focus_request"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="hover"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="decorator_margins"> <child name="report_rom"/> </service>
|
||||
<service name="Report"> <child name="report_rom"/> </service>
|
||||
<service name="Nitpicker"> <child name="wm"/> </service>
|
||||
<any-service> <child name="wm"/> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="decorator" caps="200">
|
||||
<binary name="themed_decorator"/>
|
||||
<resource name="RAM" quantum="8M"/>
|
||||
<config>
|
||||
<libc/>
|
||||
<vfs> <tar name="plain_decorator_theme.tar"/> </vfs>
|
||||
<vfs>
|
||||
<dir name="theme">
|
||||
<inline name="metadata">
|
||||
<theme>
|
||||
<aura top="5" bottom="5" left="5" right="5"/>
|
||||
<decor top="6" bottom="6" left="6" right="6"/>
|
||||
</theme>
|
||||
</inline>
|
||||
<rom name="default.png"/>
|
||||
</dir>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</config>
|
||||
<route>
|
||||
<service name="ROM" label="default.png"> <parent label="drop_shadow.png"/> </service>
|
||||
<service name="ROM" label="window_layout"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="pointer"> <child name="report_rom"/> </service>
|
||||
<service name="Report" label="decorator_margins"> <child name="report_rom"/> </service>
|
||||
@ -164,7 +158,7 @@
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="manager" caps="200">
|
||||
<start name="manager" caps="300">
|
||||
<binary name="sculpt_manager"/>
|
||||
<resource name="RAM" quantum="3M"/>
|
||||
<provides> <service name="Nitpicker"/> </provides>
|
||||
@ -190,6 +184,8 @@
|
||||
<service name="ROM" label="nitpicker_hover"> <parent/> </service>
|
||||
<service name="ROM" label_prefix="report ->"> <parent/> </service>
|
||||
<service name="ROM" label="menu_view_hover"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="window_list"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="decorator_margins"> <child name="report_rom"/> </service>
|
||||
<service name="Nitpicker"> <parent/> </service>
|
||||
<any-service> <parent/> </any-service>
|
||||
</route>
|
||||
@ -208,7 +204,7 @@
|
||||
|
||||
<start name="gui" caps="1400">
|
||||
<binary name="init"/>
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<resource name="RAM" quantum="14M"/>
|
||||
<route>
|
||||
<service name="ROM" label="config"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label_last="dialog"> <child name="report_rom"/> </service>
|
||||
@ -223,9 +219,9 @@
|
||||
<binary name="nit_fb"/>
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="Framebuffer"/> <service name="Input"/> </provides>
|
||||
<config origin="top_right" xpos="-412" ypos="2" width="410" height="-4"/>
|
||||
<config origin="top_right" xpos="-412" ypos="2" initial_width="400" initial_height="400"/>
|
||||
<route>
|
||||
<service name="Nitpicker"> <child name="nitpicker"/> </service>
|
||||
<service name="Nitpicker"> <child name="wm" label="log"/> </service>
|
||||
<any-service> <parent/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
@ -235,6 +231,8 @@
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="Terminal"/> </provides>
|
||||
<config>
|
||||
<color index="0" bg="#2f3953"/>
|
||||
<color index="8" bg="#2f3953"/>
|
||||
<vfs>
|
||||
<rom name="VeraMono.ttf"/>
|
||||
<dir name="fonts">
|
||||
|
@ -27,7 +27,7 @@ void Sculpt::Gui::_gen_menu_view_start_content(Xml_generator &xml,
|
||||
{
|
||||
xml.attribute("version", version.value);
|
||||
|
||||
gen_common_start_content(xml, label, Cap_quota{150}, Ram_quota{8*1024*1024});
|
||||
gen_common_start_content(xml, label, Cap_quota{150}, Ram_quota{9*1024*1024});
|
||||
|
||||
gen_named_node(xml, "binary", "menu_view");
|
||||
|
||||
@ -98,6 +98,11 @@ void Sculpt::Gui::_generate_config(Xml_generator &xml) const
|
||||
gen_parent_service<::File_system::Session>(xml);
|
||||
});
|
||||
|
||||
xml.node("resource", [&] () {
|
||||
xml.attribute("name", "RAM");
|
||||
xml.attribute("preserve", "1M");
|
||||
});
|
||||
|
||||
xml.node("start", [&] () {
|
||||
_gen_menu_view_start_content(xml, "menu_view", Point(0, 0)); });
|
||||
}
|
||||
|
@ -48,6 +48,11 @@ struct Sculpt::Gui
|
||||
_config.generate([&] (Xml_generator &xml) { _generate_config(xml); });
|
||||
}
|
||||
|
||||
void font_size(float px)
|
||||
{
|
||||
menu_width = max(px*21, 320.0);
|
||||
}
|
||||
|
||||
Gui(Env &env) : _env(env) { }
|
||||
};
|
||||
|
||||
|
@ -64,7 +64,24 @@ struct Sculpt::Main : Input_event_handler,
|
||||
Managed_config<Main> _fonts_config {
|
||||
_env, "config", "fonts", *this, &Main::_handle_fonts_config };
|
||||
|
||||
void _handle_fonts_config(Xml_node) { _handle_nitpicker_mode(); }
|
||||
void _handle_fonts_config(Xml_node config)
|
||||
{
|
||||
/*
|
||||
* Obtain font size from manually maintained fonts configuration
|
||||
* so that we can adjust the GUI layout accordingly.
|
||||
*/
|
||||
config.for_each_sub_node("vfs", [&] (Xml_node vfs) {
|
||||
vfs.for_each_sub_node("dir", [&] (Xml_node dir) {
|
||||
if (dir.attribute_value("name", String<16>()) == "fonts") {
|
||||
dir.for_each_sub_node("dir", [&] (Xml_node type) {
|
||||
if (type.attribute_value("name", String<16>()) == "text") {
|
||||
type.for_each_sub_node("ttf", [&] (Xml_node ttf) {
|
||||
float const px = ttf.attribute_value("size_px", 0.0);
|
||||
if (px > 0.0)
|
||||
_gui.font_size(px); }); } }); } }); });
|
||||
|
||||
_handle_nitpicker_mode();
|
||||
}
|
||||
|
||||
Managed_config<Main> _input_filter_config {
|
||||
_env, "config", "input_filter", *this, &Main::_handle_input_filter_config };
|
||||
@ -337,6 +354,22 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_gui.generate_config();
|
||||
}
|
||||
|
||||
void _handle_window_layout();
|
||||
|
||||
Attached_rom_dataspace _window_list { _env, "window_list" };
|
||||
|
||||
Signal_handler<Main> _window_list_handler {
|
||||
_env.ep(), *this, &Main::_handle_window_layout };
|
||||
|
||||
Expanding_reporter _wm_focus { _env, "focus", "wm_focus" };
|
||||
|
||||
Attached_rom_dataspace _decorator_margins { _env, "decorator_margins" };
|
||||
|
||||
Signal_handler<Main> _decorator_margins_handler {
|
||||
_env.ep(), *this, &Main::_handle_window_layout };
|
||||
|
||||
Expanding_reporter _window_layout { _env, "window_layout", "window_layout" };
|
||||
|
||||
Main(Env &env) : _env(env)
|
||||
{
|
||||
_runtime_state.sigh(_runtime_state_handler);
|
||||
@ -345,10 +378,12 @@ struct Sculpt::Main : Input_event_handler,
|
||||
/*
|
||||
* Subscribe to reports
|
||||
*/
|
||||
_update_state_rom.sigh(_update_state_handler);
|
||||
_update_state_rom .sigh(_update_state_handler);
|
||||
_nitpicker_hover .sigh(_nitpicker_hover_handler);
|
||||
_hover_rom .sigh(_hover_handler);
|
||||
_pci_devices .sigh(_pci_devices_handler);
|
||||
_window_list .sigh(_window_list_handler);
|
||||
_decorator_margins.sigh(_decorator_margins_handler);
|
||||
|
||||
/*
|
||||
* Generate initial configurations
|
||||
@ -368,15 +403,125 @@ struct Sculpt::Main : Input_event_handler,
|
||||
};
|
||||
|
||||
|
||||
void Sculpt::Main::_handle_nitpicker_mode()
|
||||
void Sculpt::Main::_handle_window_layout()
|
||||
{
|
||||
if (!_fonts_config.try_generate_manually_managed()) {
|
||||
struct Decorator_margins
|
||||
{
|
||||
unsigned top = 0, bottom = 0, left = 0, right = 0;
|
||||
|
||||
Decorator_margins(Xml_node node)
|
||||
{
|
||||
if (!node.has_sub_node("floating"))
|
||||
return;
|
||||
|
||||
Xml_node const floating = node.sub_node("floating");
|
||||
|
||||
top = floating.attribute_value("top", 0UL);
|
||||
bottom = floating.attribute_value("bottom", 0UL);
|
||||
left = floating.attribute_value("left", 0UL);
|
||||
right = floating.attribute_value("right", 0UL);
|
||||
}
|
||||
};
|
||||
|
||||
/* read decorator margins from the decorator's report */
|
||||
_decorator_margins.update();
|
||||
Decorator_margins const margins(_decorator_margins.xml());
|
||||
|
||||
unsigned const log_min_w = 400, log_min_h = 200;
|
||||
|
||||
if (!_nitpicker.constructed())
|
||||
return;
|
||||
|
||||
Framebuffer::Mode const mode = _nitpicker->mode();
|
||||
|
||||
typedef Nitpicker::Rect Rect;
|
||||
|
||||
Rect avail(Point(_gui.menu_width, 0),
|
||||
Point(mode.width() - 1, mode.height() - 1));
|
||||
|
||||
/*
|
||||
* When the screen width is at least twice the log width, place the
|
||||
* log at the right side of the screen. Otherwise, with resolutions
|
||||
* as low as 1024x768, place it to the bottom to allow the inspect
|
||||
* window to use the available screen width to the maximum extend.
|
||||
*/
|
||||
bool const log_at_right =
|
||||
(avail.w() > 2*(log_min_w + margins.left + margins.right));
|
||||
|
||||
/* the upper-left point depends on whether the log is at the right or bottom */
|
||||
Point const log_p1 =
|
||||
log_at_right ? Point(avail.x2() - log_min_w - margins.right + 1,
|
||||
margins.top)
|
||||
: Point(_gui.menu_width + margins.left,
|
||||
avail.y2() - log_min_h - margins.bottom + 1);
|
||||
|
||||
/* the lower-right point (p2) of the log is always the same */
|
||||
Point const log_p2(mode.width() - margins.right - 1,
|
||||
mode.height() - margins.bottom - 1);
|
||||
|
||||
/* position of the inspect window */
|
||||
Point const inspect_p1(avail.x1() + margins.right, margins.top);
|
||||
|
||||
Point const inspect_p2 =
|
||||
log_at_right ? Point(log_p1.x() - margins.right - margins.left - 1, log_p2.y())
|
||||
: Point(log_p2.x(), log_p1.y() - margins.bottom - margins.top - 1);
|
||||
|
||||
typedef String<128> Label;
|
||||
Label const inspect_label("runtime -> leitzentrale -> storage browser");
|
||||
|
||||
_window_list.update();
|
||||
_window_layout.generate([&] (Xml_generator &xml) {
|
||||
|
||||
_window_list.xml().for_each_sub_node("window", [&] (Xml_node win) {
|
||||
|
||||
Label const label = win.attribute_value("label", Label());
|
||||
|
||||
/**
|
||||
* Generate window with 'rect' geometry if label matches 'match'
|
||||
*/
|
||||
auto gen_matching_window = [&] (Label const &match, Rect rect) {
|
||||
if (label == match && rect.valid()) {
|
||||
xml.node("window", [&] () {
|
||||
xml.attribute("id", win.attribute_value("id", 0UL));
|
||||
xml.attribute("xpos", rect.x1());
|
||||
xml.attribute("ypos", rect.y1());
|
||||
xml.attribute("width", rect.w());
|
||||
xml.attribute("height", rect.h());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
gen_matching_window("log", Rect(log_p1, log_p2));
|
||||
gen_matching_window(inspect_label, Rect(inspect_p1, inspect_p2));
|
||||
});
|
||||
});
|
||||
|
||||
/* define window-manager focus */
|
||||
_wm_focus.generate([&] (Xml_generator &xml) {
|
||||
_window_list.xml().for_each_sub_node("window", [&] (Xml_node win) {
|
||||
Label const label = win.attribute_value("label", Label());
|
||||
if (label == inspect_label)
|
||||
xml.node("window", [&] () {
|
||||
xml.attribute("id", win.attribute_value("id", 0UL)); });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Sculpt::Main::_handle_nitpicker_mode()
|
||||
{
|
||||
if (!_nitpicker.constructed())
|
||||
return;
|
||||
|
||||
Framebuffer::Mode const mode = _nitpicker->mode();
|
||||
|
||||
_handle_window_layout();
|
||||
|
||||
if (!_fonts_config.try_generate_manually_managed()) {
|
||||
|
||||
float const text_size = (float)mode.height() / 60.0;
|
||||
|
||||
_gui.menu_width = text_size*21;
|
||||
_gui.font_size(text_size);
|
||||
|
||||
_fonts_config.generate([&] (Xml_generator &xml) {
|
||||
xml.node("vfs", [&] () {
|
||||
@ -403,6 +548,18 @@ void Sculpt::Main::_handle_nitpicker_mode()
|
||||
});
|
||||
});
|
||||
xml.node("default-policy", [&] () { xml.attribute("root", "/fonts"); });
|
||||
|
||||
auto gen_color = [&] (unsigned index, Color color) {
|
||||
xml.node("color", [&] () {
|
||||
xml.attribute("index", index);
|
||||
xml.attribute("bg", String<16>(color));
|
||||
});
|
||||
};
|
||||
|
||||
Color const background(0x1c, 0x22, 0x32);
|
||||
|
||||
gen_color(0, background);
|
||||
gen_color(8, background);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace Sculpt {
|
||||
|
||||
void Sculpt::gen_nit_fb_start(Xml_generator &xml, Rom_name const &name)
|
||||
{
|
||||
gen_common_start_content(xml, name, Cap_quota{100}, Ram_quota{4*1024*1024});
|
||||
gen_common_start_content(xml, name, Cap_quota{100}, Ram_quota{8*1024*1024});
|
||||
|
||||
gen_named_node(xml, "binary", "nit_fb");
|
||||
|
||||
@ -43,10 +43,7 @@ void Sculpt::gen_nit_fb_start(Xml_generator &xml, Rom_name const &name)
|
||||
gen_service_node<Input::Session>(xml, [&] () {});
|
||||
});
|
||||
|
||||
xml.node("config", [&] () {
|
||||
xml.attribute("initial_width", "600");
|
||||
xml.attribute("initial_height", "500");
|
||||
});
|
||||
xml.node("config", [&] () { });
|
||||
|
||||
xml.node("route", [&] () {
|
||||
gen_parent_rom_route(xml, "nit_fb");
|
||||
|
Loading…
Reference in New Issue
Block a user