2016-02-02 19:33:06 +01:00
|
|
|
/*
|
|
|
|
* \brief Action triggered by the user
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2016-02-01
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2016-2017 Genode Labs GmbH
|
2016-02-02 19:33:06 +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.
|
2016-02-02 19:33:06 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ACTION_H_
|
|
|
|
#define _ACTION_H_
|
|
|
|
|
2020-01-09 12:59:05 +01:00
|
|
|
#include <target.h>
|
|
|
|
|
2018-09-26 11:36:36 +02:00
|
|
|
namespace Window_layouter { class Action; }
|
2016-02-02 19:33:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Result of the application of a key event to the key-sequence tracker
|
|
|
|
*/
|
2018-09-26 11:36:36 +02:00
|
|
|
class Window_layouter::Action
|
2016-02-02 19:33:06 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
NONE,
|
|
|
|
NEXT_WINDOW,
|
|
|
|
PREV_WINDOW,
|
|
|
|
RAISE_WINDOW,
|
|
|
|
TOGGLE_FULLSCREEN,
|
|
|
|
CLOSE,
|
|
|
|
NEXT_WORKSPACE,
|
|
|
|
PREV_WORKSPACE,
|
|
|
|
MARK,
|
|
|
|
DETACH,
|
|
|
|
ATTACH,
|
|
|
|
COLUMN,
|
|
|
|
ROW,
|
|
|
|
REMOVE,
|
|
|
|
NEXT_COLUMN,
|
|
|
|
PREV_COLUMN,
|
|
|
|
NEXT_ROW,
|
|
|
|
PREV_ROW,
|
|
|
|
NEXT_TAB,
|
|
|
|
PREV_TAB,
|
|
|
|
TOOGLE_OVERLAY,
|
2020-01-09 12:59:05 +01:00
|
|
|
SCREEN,
|
2016-02-02 19:33:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2020-01-09 12:59:05 +01:00
|
|
|
Type _type;
|
|
|
|
Target::Name _target;
|
2016-02-02 19:33:06 +01:00
|
|
|
|
|
|
|
template <Genode::size_t N>
|
|
|
|
static Type _type_by_string(String<N> const &string)
|
|
|
|
{
|
|
|
|
if (string == "next_window") return NEXT_WINDOW;
|
|
|
|
if (string == "prev_window") return PREV_WINDOW;
|
|
|
|
if (string == "raise_window") return RAISE_WINDOW;
|
|
|
|
if (string == "toggle_fullscreen") return TOGGLE_FULLSCREEN;
|
2020-01-09 12:59:05 +01:00
|
|
|
if (string == "screen") return SCREEN;
|
2016-02-02 19:33:06 +01:00
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::warning("cannot convert \"", string, "\" to action type");
|
2016-02-02 19:33:06 +01:00
|
|
|
return NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2020-01-09 12:59:05 +01:00
|
|
|
Action(Type type) : _type(type), _target() { }
|
2016-02-02 19:33:06 +01:00
|
|
|
|
|
|
|
template <Genode::size_t N>
|
2020-01-09 12:59:05 +01:00
|
|
|
Action(String<N> const &string, Target::Name const &arg)
|
|
|
|
: _type(_type_by_string(string)), _target(arg) { }
|
2016-02-02 19:33:06 +01:00
|
|
|
|
|
|
|
Type type() const { return _type; }
|
2020-01-09 12:59:05 +01:00
|
|
|
Target::Name target_name() const { return _target; }
|
2016-02-02 19:33:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _ACTION_H_ */
|