From 27b71a087674f6174dd001be905bd0970e3dd07f Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 4 Dec 2015 12:29:06 +0100 Subject: [PATCH] window layouter: label-dependent window policies This patch enhances the layouter to apply a label-dependent policy for the placement of new windows. The policy may contain the attributes 'xpos', 'ypos', and 'maximized'. If the latter is set to "yes", the matching window will appear in maximized state. --- .../src/app/floating_window_layouter/main.cc | 21 ++++++++++++++++--- .../app/floating_window_layouter/target.mk | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/repos/gems/src/app/floating_window_layouter/main.cc b/repos/gems/src/app/floating_window_layouter/main.cc index f766339b8..97f558481 100644 --- a/repos/gems/src/app/floating_window_layouter/main.cc +++ b/repos/gems/src/app/floating_window_layouter/main.cc @@ -38,6 +38,7 @@ namespace Floating_window_layouter { using Decorator::attribute; using Decorator::string_attribute; using Decorator::area_attribute; + using Decorator::point_attribute; static Xml_node xml_lookup_window_by_id(Xml_node node, unsigned const id) @@ -512,14 +513,28 @@ void Floating_window_layouter::Main::import_window_list(Xml_node window_list_xml win = new (env()->heap()) Window(id, maximized_window_geometry); windows.insert(win); + Point initial_position(150*id % 800, 30 + (100*id % 500)); + + Window::Label const label = string_attribute(node, "label", Window::Label("")); + win->label(label); + /* - * Define initial window position + * Evaluate policy configuration for the window label */ - win->position(Point(150*id % 800, 30 + (100*id % 500))); + try { + Session_policy const policy(label); + + if (policy.has_attribute("xpos") && policy.has_attribute("ypos")) + initial_position = point_attribute(node); + + win->is_maximized(policy.attribute_value("maximized", false)); + + } catch (Genode::Session_policy::No_policy_defined) { } + + win->position(initial_position); } win->size(area_attribute(node)); - win->label(string_attribute(node, "label", Window::Label(""))); win->title(string_attribute(node, "title", Window::Title(""))); win->has_alpha(node.has_attribute("has_alpha") && node.attribute("has_alpha").has_value("yes")); diff --git a/repos/gems/src/app/floating_window_layouter/target.mk b/repos/gems/src/app/floating_window_layouter/target.mk index af9ad4b9c..b1ffd18ff 100644 --- a/repos/gems/src/app/floating_window_layouter/target.mk +++ b/repos/gems/src/app/floating_window_layouter/target.mk @@ -1,4 +1,4 @@ TARGET = floating_window_layouter SRC_CC = main.cc -LIBS = base cxx +LIBS = base cxx config