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

@ -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;