genode/repos/os/src/server/nitpicker/global_keys.h
Norman Feske 7c968d4c60 nitpicker: externalize xray policy
This patch removes the policy for controlling the X-Ray mode from
nitpicker to the separate component os/app/xray_trigger.

Fixes #1690
2015-11-04 14:09:28 +01:00

57 lines
1.1 KiB
C++

/*
* \brief Global keys policy
* \author Norman Feske
* \date 2013-09-06
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _GLOBAL_KEYS_H_
#define _GLOBAL_KEYS_H_
/* Genode includes */
#include <input/keycodes.h>
/* local includes */
#include "session.h"
class Global_keys
{
private:
struct Policy
{
Session *_session = nullptr;
bool defined() const { return _session != nullptr; }
void client(Session *s) { _session = s; }
};
enum { NUM_POLICIES = Input::KEY_MAX + 1 };
Policy _policies[NUM_POLICIES];
/**
* Lookup policy that matches the specified key name
*/
Policy *_lookup_policy(char const *key_name);
bool _valid(Input::Keycode key) const {
return key >= 0 && key <= Input::KEY_MAX; }
public:
Session *global_receiver(Input::Keycode key) {
return _valid(key) ? _policies[key]._session : 0; }
void apply_config(Session_list &session_list);
};
#endif /* _GLOBAL_KEYS_H_ */