wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
action.c File Reference
#include "action.h"
#include <libbase/libbase.h>
#include <libbase/plist.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wayland-server-core.h>
#include <xkbcommon/xkbcommon-keysyms.h>
#include <xkbcommon/xkbcommon.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_keyboard.h>
#include "backend/backend.h"
#include "cursor.h"
#include "default_configuration.h"
#include "idle.h"
#include "keyboard.h"
#include "root_menu.h"
#include "server.h"
#include "toolkit/toolkit.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, bspl_object_t *object_ptr, void *userdata_ptr)
 
static bool _wlmaker_action_bound_callback (const wlmaker_key_combo_t *binding_ptr)
 
wlmaker_action_handle_twlmaker_action_bind_keys (wlmaker_server_t *server_ptr, bspl_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, void *arg_ptr)
 
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 bspl_enum_desc_t _wlmaker_keybindings_modifiers []
 
const bspl_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_keybindings_bind_item()

bool _wlmaker_keybindings_bind_item ( const char *  key_ptr,
bspl_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,
bspl_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,
void *  arg_ptr 
)

Executes the given action on wlmaker.

Parameters
server_ptr
action
arg_ptr

◆ 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 bspl_enum_desc_t _wlmaker_keybindings_modifiers[]
static
Initial value:
= {
BSPL_ENUM("Shift", WLR_MODIFIER_SHIFT),
BSPL_ENUM("Ctrl", WLR_MODIFIER_CTRL),
BSPL_ENUM("Alt", WLR_MODIFIER_ALT),
BSPL_ENUM("Mod2", WLR_MODIFIER_MOD2),
BSPL_ENUM("Mod3", WLR_MODIFIER_MOD3),
BSPL_ENUM("Logo", WLR_MODIFIER_LOGO),
BSPL_ENUM("Mod5", WLR_MODIFIER_MOD5),
BSPL_ENUM_SENTINEL(),
}

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 bspl_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:600
static void test_keybindings_parse(bs_test_t *test_ptr)
Definition action.c:562

Test cases for key bindings.