pointer: strip the last label element when matching labels

Issue #2585
This commit is contained in:
Christian Prochaska 2017-11-28 18:23:23 +01:00 committed by Christian Helmuth
parent 72dec21d8f
commit 425d18e866
6 changed files with 29 additions and 14 deletions

View File

@ -119,7 +119,7 @@ set config {
<service name="CPU"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="Report" label="shape">
<child name="pointer" label="test-label-arrow -> testnit"/>
<child name="pointer" label="test-label-arrow -> shape"/>
</service>
</route>
</start>
@ -133,7 +133,7 @@ set config {
<service name="CPU"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="Report" label="shape">
<child name="pointer" label="test-label-blade -> testnit"/>
<child name="pointer" label="test-label-blade -> shape"/>
</service>
</route>
</start>
@ -147,7 +147,7 @@ set config {
<service name="CPU"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="Report" label="shape">
<child name="pointer" label="test-label-bladex -> testnit"/>
<child name="pointer" label="test-label-bladex -> shape"/>
</service>
</route>
</start>
@ -183,7 +183,7 @@ set config {
<service name="ROM" label="smiley.config">
<child name="shape-smiley-config"/> </service>
<service name="Report" label="shape">
<child name="pointer" label="test-label-smiley -> testnit"/>
<child name="pointer" label="test-label-smiley -> shape"/>
</service>
<service name="ROM"> <parent/> </service>
<service name="CPU"> <parent/> </service>

View File

@ -20,16 +20,20 @@ with report session label rewriting:
! <service name="CPU"> <parent/> </service>
! <service name="LOG"> <parent/> </service>
! <service name="Report" label="shape">
! <child name="pointer" label="test-label-arrow -> testnit"/>
! <child name="pointer" label="test-label-arrow -> shape"/>
! </service>
! </route>
! </start>
In the example above, which is from 'pointer.run', the 'shape-arrow' component
reports an arrow shape with the label "shape". By rewriting the label of the
report, the shape will be drawn for the 'test-label-arrow' component, which
is reported by Nitpicker with the label 'test-label-arror -> testnit' when
hovered.
report, the shape will be drawn for the 'test-label-arrow' component when
its Nitpicker view is hovered.
Technically, the 'pointer' component compares the hovered label, which is
'test-label-arrow -> testnit' in this case, with the shape report label after
stripping the last element of each label, so the remaining label prefix
'test-label-arrow' is the actual match criteria.
When configured with '<config shapes="yes" verbose="yes"/>', the 'pointer'
component prints the labels of hovered Nitpicker sessions and received shape

View File

@ -100,7 +100,7 @@ class Pointer::Main : public Rom::Reader
Report::Root _report_root { _env, _sliced_heap, _rom_registry, _verbose };
String _hovered_label;
Genode::Session_label _hovered_label;
Genode::Attached_ram_dataspace _texture_pixel_ds { _env.ram(), _env.rm(),
Pointer::MAX_WIDTH *
@ -293,7 +293,11 @@ void Pointer::Main::_handle_hover()
try {
Genode::Xml_node node(_hover_ds->local_addr<char>());
String hovered_label = read_string_attribute(node, "label", String());
Genode::Session_label hovered_label { read_string_attribute(node,
"label",
String()) };
hovered_label = hovered_label.prefix();
if (_verbose)
Genode::log("hovered_label: ", hovered_label);

View File

@ -68,11 +68,18 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy
/* module does not exist yet, create one */
Genode::Session_label session_label(name);
if (session_label.last_element() != "shape")
Genode::warning("received unexpected report with label '",
session_label, "'");
/* XXX proper accounting for the used memory is missing */
/* XXX if we run out of memory, the server will abort */
Module * const module = new (&_md_alloc)
Module(_ram, _rm, name, _read_write_policy, _read_write_policy);
Module(_ram, _rm, session_label.prefix(), _read_write_policy,
_read_write_policy);
_modules.insert(module);
return *module;

View File

@ -297,7 +297,7 @@ for { set i 1} { $i <= $use_vms } { incr i} {
<service name=\"Framebuffer\"> <child name=\"nit_fb${i}\" /> </service>
<service name=\"Input\"> <child name=\"nit_fb${i}\" /> </service>
<service name=\"Report\" label=\"shape\">
<child name=\"pointer\" label=\"nit_fb${i} -> \"/>
<child name=\"pointer\" label=\"nit_fb${i} -> shape\"/>
</service>"
append config_of_app {
<service name="Report"><child name="report_rom" /></service>

View File

@ -244,7 +244,7 @@ append_if [expr $use_gui] config {
</config>
<route>
<service name="Nic"> <child name="nic_bridge"/> </service>
<service name="Report" label="shape"> <child name="pointer" label="nit_fb2 -> "/> </service>
<service name="Report" label="shape"> <child name="pointer" label="nit_fb2 -> shape"/> </service>
<service name="Report"> <child name="report_rom"/> </service>
<service name="Framebuffer"> <child name="nit_fb2" /> </service>
<service name="Input"> <child name="nit_fb2" /> </service>
@ -277,7 +277,7 @@ append_if [expr $use_bridge] config {
<service name="Nic"> <child name="nic_bridge"/> </service>}
append_if [expr $use_gui] config {
<service name="Report" label="shape"> <child name="pointer" label="nit_fb1 -> "/> </service>
<service name="Report" label="shape"> <child name="pointer" label="nit_fb1 -> shape"/> </service>
<service name="Report"> <child name="report_rom"/> </service>
<service name="Framebuffer"> <child name="nit_fb1" /> </service>
<service name="Input"> <child name="nit_fb1" /> </service>}