wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
action.c File Reference
#include "action.h"
#include "default_configuration.h"
#include "server.h"
#include "conf/decode.h"
#include "conf/plist.h"
#include <xkbcommon/xkbcommon.h>
#include <wlr/backend/session.h>
#include <wlr/types/wlr_keyboard.h>
Include dependency graph for action.c:

Classes

struct  _wlmaker_action_handle_t
 
struct  _wlmaker_action_binding_t
 

Functions

static bool _wlmaker_keybindings_parse (const char *string_ptr, uint32_t *modifiers_ptr, xkb_keysym_t *keysym_ptr)
 
static bool _wlmaker_keybindings_bind_item (const char *key_ptr, wlmcfg_object_t *object_ptr, void *userdata_ptr)
 
static bool _wlmaker_action_bound_callback (const wlmaker_key_combo_t *binding_ptr)
 
static void _wlmaker_action_switch_to_vt (wlmaker_server_t *server_ptr, unsigned vt_num)
 
wlmaker_action_handle_twlmaker_action_bind_keys (wlmaker_server_t *server_ptr, wlmcfg_dict_t *keybindings_dict_ptr)
 
void wlmaker_action_unbind_keys (wlmaker_action_handle_t *handle_ptr)
 
void wlmaker_action_execute (wlmaker_server_t *server_ptr, wlmaker_action_t action)
 
static void test_keybindings_parse (bs_test_t *test_ptr)
 
static void test_default_keybindings (bs_test_t *test_ptr)
 

Variables

const char * wlmaker_action_config_dict_key = "KeyBindings"
 
static const wlmcfg_enum_desc_t _wlmaker_keybindings_modifiers []
 
const wlmcfg_enum_desc_t wlmaker_action_desc []
 
const bs_test_case_t wlmaker_action_test_cases []
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ _wlmaker_action_bound_callback()

bool _wlmaker_action_bound_callback ( const wlmaker_key_combo_t * key_combo_ptr)
static

Callback for when the bound key is triggered: Executes the corresponding action.

Parameters
key_combo_ptr
Returns
true always.

◆ _wlmaker_action_switch_to_vt()

void _wlmaker_action_switch_to_vt ( wlmaker_server_t * server_ptr,
unsigned vt_num )
static

Switches to the given virtual terminal, if a wlroots session is available.

Logs if wlr_session_change_vt() fails, but ignores the errors.

Parameters
server_ptr
vt_num

◆ _wlmaker_keybindings_bind_item()

bool _wlmaker_keybindings_bind_item ( const char * key_ptr,
wlmcfg_object_t * object_ptr,
void * userdata_ptr )
static

Binds an action for one item of the 'KeyBindings' dict.

Parameters
key_ptrName of the action to bind the key to.
object_ptrConfiguration object, must be a string and contain a parse-able modifier + keysym.
userdata_ptrPoints to wlmaker_server_t.
Returns
true on success.

◆ _wlmaker_keybindings_parse()

bool _wlmaker_keybindings_parse ( const char * string_ptr,
uint32_t * modifiers_ptr,
xkb_keysym_t * keysym_ptr )
static

Parses a keybinding string: Tokenizes into modifiers and keysym.

Parameters
string_ptr
modifiers_ptr
keysym_ptr
Returns
true on success.

◆ test_default_keybindings()

void test_default_keybindings ( bs_test_t * test_ptr)
static

Tests the default configuration's 'KeyBindings' section.

◆ test_keybindings_parse()

void test_keybindings_parse ( bs_test_t * test_ptr)
static

◆ wlmaker_action_bind_keys()

wlmaker_action_handle_t * wlmaker_action_bind_keys ( wlmaker_server_t * server_ptr,
wlmcfg_dict_t * keybindings_dict_ptr )

Binds the actions specified in the config dictionary.

Parameters
server_ptr
keybindings_dict_ptr
Returns
A bound action handle, or NULL on error.

◆ wlmaker_action_execute()

void wlmaker_action_execute ( wlmaker_server_t * server_ptr,
wlmaker_action_t action )

Executes the given action on wlmaker.

Parameters
server_ptr
action

◆ wlmaker_action_unbind_keys()

void wlmaker_action_unbind_keys ( wlmaker_action_handle_t * handle_ptr)

Unbinds actions previously bound by wlmaker_action_bind_keys.

Parameters
handle_ptr

Variable Documentation

◆ _wlmaker_keybindings_modifiers

const wlmcfg_enum_desc_t _wlmaker_keybindings_modifiers[]
static
Initial value:
= {
WLMCFG_ENUM("Shift", WLR_MODIFIER_SHIFT),
WLMCFG_ENUM("Ctrl", WLR_MODIFIER_CTRL),
WLMCFG_ENUM("Alt", WLR_MODIFIER_ALT),
WLMCFG_ENUM("Mod2", WLR_MODIFIER_MOD2),
WLMCFG_ENUM("Mod3", WLR_MODIFIER_MOD3),
WLMCFG_ENUM("Logo", WLR_MODIFIER_LOGO),
WLMCFG_ENUM("Mod5", WLR_MODIFIER_MOD5),
}
#define WLMCFG_ENUM_SENTINEL()
Definition decode.h:49
#define WLMCFG_ENUM(_name, _value)
Definition decode.h:52

Supported modifiers for key bindings.

◆ wlmaker_action_config_dict_key

const char* wlmaker_action_config_dict_key = "KeyBindings"

Key to lookup the dict from the config dictionary.

◆ wlmaker_action_desc

const wlmcfg_enum_desc_t wlmaker_action_desc[]

The actions that can be bound.

◆ wlmaker_action_test_cases

const bs_test_case_t wlmaker_action_test_cases[]
Initial value:
= {
{ 1, "parse", test_keybindings_parse },
{ 1, "default_keybindings", test_default_keybindings },
{ 0, NULL, NULL }
}
static void test_default_keybindings(bs_test_t *test_ptr)
Definition action.c:493
static void test_keybindings_parse(bs_test_t *test_ptr)
Definition action.c:455

Test cases for key bindings.