forked from genodelabs/genode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
window_layouter: modernized coding style
Replace the use of pointers and the copying of XML nodes by the 'with_' pattern. Use plain struct where appropriate, replace constructors by { } initialization. Use C++20 function template syntax. Replace accessors by public constants where possible. Follow 'from_xml' convention. Follow usual 'Action' interface naming. Issue genodelabs#5390
- Loading branch information
Showing
14 changed files
with
426 additions
and
568 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* \brief Command triggered via the keyboard | ||
* \author Norman Feske | ||
* \date 2016-02-01 | ||
*/ | ||
|
||
/* | ||
* Copyright (C) 2016-2017 Genode Labs GmbH | ||
* | ||
* This file is part of the Genode OS framework, which is distributed | ||
* under the terms of the GNU Affero General Public License version 3. | ||
*/ | ||
|
||
#ifndef _COMMAND_H_ | ||
#define _COMMAND_H_ | ||
|
||
#include <target.h> | ||
|
||
namespace Window_layouter { class Command; } | ||
|
||
|
||
struct Window_layouter::Command | ||
{ | ||
enum Type { NONE, NEXT_WINDOW, PREV_WINDOW, RAISE_WINDOW, TOGGLE_FULLSCREEN, | ||
NEXT_TAB, PREV_TAB, SCREEN, RELEASE_GRAB, }; | ||
|
||
Type type; | ||
Target::Name target; | ||
|
||
static Command from_xml(Xml_node const &node) | ||
{ | ||
auto from_string = [] (auto const &string) -> Type | ||
{ | ||
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; | ||
if (string == "screen") return SCREEN; | ||
if (string == "release_grab") return RELEASE_GRAB; | ||
|
||
warning("cannot convert \"", string, "\" to action type"); | ||
return NONE; | ||
}; | ||
|
||
return { | ||
.type = from_string(node.attribute_value("action", String<32>())), | ||
.target = node.attribute_value("target", Name()) | ||
}; | ||
} | ||
}; | ||
|
||
#endif /* _COMMAND_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.