wlmaker
Loading...
Searching...
No Matches
Macros | Functions | Variables
config.c File Reference
#include "config.h"
#include <libbase/libbase.h>
#include <libbase/plist.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <wlr/types/wlr_keyboard.h>
#include "default_configuration.h"
#include "default_state.h"
#include "../etc/style.h"
Include dependency graph for config.c:

Functions

static bspl_object_t * _wlmaker_plist_load (const char *name_ptr, const char *fname_ptr, const uint8_t *default_data_ptr, size_t default_data_size)
 
static bspl_dict_t * _wlmaker_config_from_plist (const char *fname_ptr)
 
static bool _wlmaker_config_decode_fill_style (bspl_object_t *object_ptr, const union bspl_desc_value *desc_value_ptr, void *value_ptr)
 
bspl_object_t * wlmaker_config_object_load (wlmaker_files_t *files_ptr, const char *name_ptr, const char *arg_fname_ptr, const char *xdg_config_fname_ptr, const uint8_t *default_data_ptr, size_t default_data_size)
 
bspl_dict_t * wlmaker_config_load (wlmaker_files_t *files_ptr, const char *fname_ptr)
 
bspl_dict_t * wlmaker_state_load (wlmaker_files_t *files_ptr, const char *fname_ptr)
 
static void test_embedded (bs_test_t *test_ptr)
 
static void test_file (bs_test_t *test_ptr)
 
static void test_style_file (bs_test_t *test_ptr)
 
static void test_decode_fill (bs_test_t *test_ptr)
 
static void test_decode_font (bs_test_t *test_ptr)
 

Variables

const float config_output_scale = 1.0
 
static const bspl_enum_desc_t _wlmaker_config_fill_type_desc []
 
static const bspl_enum_desc_t _wlmaker_config_font_weight_desc []
 
static const bspl_desc_t _wlmaker_config_fill_style_desc []
 
static const bspl_desc_t _wlmaker_config_style_color_solid_desc []
 
static const bspl_desc_t _wlmaker_config_style_color_gradient_desc []
 
static const bspl_desc_t _wlmaker_config_tile_style_desc []
 
static const bspl_desc_t _wlmaker_config_margin_style_desc []
 
static const bspl_desc_t _wlmaker_config_dock_style_desc []
 
static const bspl_desc_t _wlmaker_config_font_style_desc []
 
static const bspl_desc_t _wlmaker_config_window_titlebar_style_desc []
 
static const bspl_desc_t _wlmaker_config_window_resize_style_desc []
 
static const bspl_desc_t _wlmaker_config_window_style_desc []
 
static const bspl_desc_t _wlmaker_config_menu_item_style_desc []
 
static const bspl_desc_t _wlmaker_config_menu_style_desc []
 
static const bspl_desc_t _wlmaker_task_list_style_desc []
 
static const bspl_desc_t _wlmaker_clip_style_desc []
 
static const bspl_desc_t _wlmaker_cursor_style_desc []
 
const bspl_desc_t wlmaker_config_style_desc []
 
static const bs_test_case_t wlmaker_config_test_cases []
 
const bs_test_set_t wlmaker_config_test_set
 

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.

Configurables for wlmaker. Currently, this file lists hardcoded entities, and mainly serves as a catalog about which entities should be dynamically configurable.

Function Documentation

◆ _wlmaker_config_decode_fill_style()

bool _wlmaker_config_decode_fill_style ( bspl_object_t *  object_ptr,
const union bspl_desc_value *  desc_value_ptr,
void *  value_ptr 
)
static

Custom decoder for fill style struct from a plist dict.

Parameters
object_ptr
desc_value_ptr
value_ptr
Returns
true on success.

◆ _wlmaker_config_from_plist()

bspl_dict_t * _wlmaker_config_from_plist ( const char *  fname_ptr)
static

Loads a plist dict from fname_ptr. Returns NULL on error.

◆ _wlmaker_plist_load()

bspl_object_t * _wlmaker_plist_load ( const char *  name_ptr,
const char *  fname_ptr,
const uint8_t *  default_data_ptr,
size_t  default_data_size 
)
static

Loads a plist object from the file or the default data.

◆ test_decode_fill()

void test_decode_fill ( bs_test_t *  test_ptr)
static

Tests the decoder for the fill style.

◆ test_decode_font()

void test_decode_font ( bs_test_t *  test_ptr)
static

Tests the decoder for a font descriptor.

◆ test_embedded()

void test_embedded ( bs_test_t *  test_ptr)
static

Verifies that the embedded config loads.

◆ test_file()

void test_file ( bs_test_t *  test_ptr)
static

Verifies that the (example) config files are loading.

◆ test_style_file()

void test_style_file ( bs_test_t *  test_ptr)
static

Loads and decodes the style file.

◆ wlmaker_config_load()

bspl_dict_t * wlmaker_config_load ( wlmaker_files_t files_ptr,
const char *  fname_ptr 
)

Loads the configuration for wlmaker.

Parameters
files_ptr
fname_ptrOptional: Name of the file to load it from. May be NULL.
Returns
A dict object, or NULL on error. Errors will already be logged. The caller must free the associated resources by calling bspl_object_unref().

◆ wlmaker_config_object_load()

bspl_object_t * wlmaker_config_object_load ( wlmaker_files_t files_ptr,
const char *  name_ptr,
const char *  arg_fname_ptr,
const char *  xdg_config_fname_ptr,
const uint8_t *  default_data_ptr,
size_t  default_data_size 
)

Loads a plist object from the given config file or data.

Useful to load configuration files from the provided name in fname_ptr or an in-memory buffer, as a compiled-in fallback option.

Parameters
files_ptr
name_ptrName to use when logging about the plist.
arg_fname_ptrExplicit filename to use for loading the file, eg. from the commandline. Or NULL.
xdg_config_fname_ptrFile name relative to XDG config home. See wlmaker_files_xdg_config_find.
default_data_ptrPoints to in-memory plist data, or NULL. Will be used if fname_ptr was NULL.
default_data_sizeThe size of the in-memory plist data.
Returns
a bspl_object_t on success, or NULL if none of the options had data, or if there was a file or parsing error.

◆ wlmaker_state_load()

bspl_dict_t * wlmaker_state_load ( wlmaker_files_t files_ptr,
const char *  fname_ptr 
)

Loads the state for wlmaker.

Behaviour is similar to wlmaker_config_load.

Parameters
files_ptr
fname_ptr
Returns
A dict object or NULL on error.

Variable Documentation

◆ _wlmaker_clip_style_desc

const bspl_desc_t _wlmaker_clip_style_desc[]
static
Initial value:
= {
BSPL_DESC_DICT(
"Font", true, wlmaker_config_clip_style_t, font, font,
BSPL_DESC_ARGB32(
"TextColor", true, wlmaker_config_clip_style_t,
text_color, text_color, 0),
}
static const bspl_desc_t _wlmaker_config_font_style_desc[]
Definition config.c:132
Definition config.h:58

Descriptor for decoding the "Clip" dictionary.

◆ _wlmaker_config_dock_style_desc

const bspl_desc_t _wlmaker_config_dock_style_desc[]
static
Initial value:
= {
BSPL_DESC_DICT(
"Margin", true, wlmtk_dock_style_t, margin, margin,
}
static const bspl_desc_t _wlmaker_config_margin_style_desc[]
Definition config.c:115
Definition style.h:120

Plist decoding descriptor of the dock's style.

◆ _wlmaker_config_fill_style_desc

const bspl_desc_t _wlmaker_config_fill_style_desc[]
static
Initial value:
= {
BSPL_DESC_ENUM("Type", true, wlmtk_style_fill_t, type, type,
}
static const bspl_enum_desc_t _wlmaker_config_fill_type_desc[]
Definition config.c:60
Definition style.h:73
@ WLMTK_STYLE_COLOR_SOLID
Definition style.h:33

Plist decoding descriptor of the fill style.

◆ _wlmaker_config_fill_type_desc

const bspl_enum_desc_t _wlmaker_config_fill_type_desc[]
static
Initial value:
= {
BSPL_ENUM("SOLID", WLMTK_STYLE_COLOR_SOLID),
BSPL_ENUM("HGRADIENT", WLMTK_STYLE_COLOR_HGRADIENT),
BSPL_ENUM("VGRADIENT", WLMTK_STYLE_COLOR_VGRADIENT),
BSPL_ENUM("DGRADIENT", WLMTK_STYLE_COLOR_DGRADIENT),
BSPL_ENUM("ADGRADIENT", WLMTK_STYLE_COLOR_ADGRADIENT),
}
@ WLMTK_STYLE_COLOR_VGRADIENT
Definition style.h:37
@ WLMTK_STYLE_COLOR_ADGRADIENT
Definition style.h:55
@ WLMTK_STYLE_COLOR_HGRADIENT
Definition style.h:35
@ WLMTK_STYLE_COLOR_DGRADIENT
Definition style.h:45

Plist decoding descriptor of the fill type.

◆ _wlmaker_config_font_style_desc

const bspl_desc_t _wlmaker_config_font_style_desc[]
static
Initial value:
= {
BSPL_DESC_CHARBUF(
"Face", true, wlmtk_style_font_t, face, face,
BSPL_DESC_ENUM(
"Weight", true, wlmtk_style_font_t, weight, weight,
WLMTK_FONT_WEIGHT_NORMAL, _wlmaker_config_font_weight_desc),
BSPL_DESC_UINT64(
"Size", true, wlmtk_style_font_t, size, size, 10),
}
static const bspl_enum_desc_t _wlmaker_config_font_weight_desc[]
Definition config.c:70
Definition style.h:101
#define WLMTK_STYLE_FONT_FACE_LENGTH
Definition style.h:92

Descriptor for decoding "Font" sections.

◆ _wlmaker_config_font_weight_desc

const bspl_enum_desc_t _wlmaker_config_font_weight_desc[]
static
Initial value:
= {
BSPL_ENUM("Normal", WLMTK_FONT_WEIGHT_NORMAL),
BSPL_ENUM("Bold", WLMTK_FONT_WEIGHT_BOLD),
}

Plist decoding descriptor for font weight.

◆ _wlmaker_config_margin_style_desc

const bspl_desc_t _wlmaker_config_margin_style_desc[]
static
Initial value:
= {
BSPL_DESC_UINT64(
"Width", true, wlmtk_margin_style_t, width, width, 0),
BSPL_DESC_ARGB32(
"Color", true, wlmtk_margin_style_t, color, color, 0xff000000),
}
Definition style.h:112

Plist decoding descriptor of a margin's style.

◆ _wlmaker_config_menu_item_style_desc

const bspl_desc_t _wlmaker_config_menu_item_style_desc[]
static
Initial value:
= {
BSPL_DESC_CUSTOM(
"Fill", true, wlmtk_menu_item_style_t, fill, fill,
BSPL_DESC_CUSTOM(
"HighlightedFill", true, wlmtk_menu_item_style_t, highlighted_fill,
highlighted_fill, _wlmaker_config_decode_fill_style, NULL, NULL, NULL),
BSPL_DESC_DICT(
"Font", true, wlmtk_menu_item_style_t, font, font,
BSPL_DESC_ARGB32(
"EnabledTextColor", true, wlmtk_menu_item_style_t,
enabled_text_color, enabled_text_color, 0),
BSPL_DESC_ARGB32(
"HighlightedTextColor", true, wlmtk_menu_item_style_t,
highlighted_text_color, highlighted_text_color, 0),
BSPL_DESC_ARGB32(
"DisabledTextColor", true, wlmtk_menu_item_style_t,
disabled_text_color, disabled_text_color, 0),
BSPL_DESC_UINT64(
"Height", true, wlmtk_menu_item_style_t, height, height, 20),
BSPL_DESC_UINT64(
"BezelWidth", true, wlmtk_menu_item_style_t,
bezel_width, bezel_width, 1),
BSPL_DESC_UINT64(
"Width", true, wlmtk_menu_item_style_t, width, width, 80),
}
static bool _wlmaker_config_decode_fill_style(bspl_object_t *object_ptr, const union bspl_desc_value *desc_value_ptr, void *value_ptr)
Definition config.c:432
Definition style.h:126

Descriptor for decoding the "Item" dictionary.

◆ _wlmaker_config_menu_style_desc

const bspl_desc_t _wlmaker_config_menu_style_desc[]
static
Initial value:
= {
BSPL_DESC_DICT(
"Item", true, wlmtk_menu_style_t, item, item,
BSPL_DESC_DICT(
"Margin", true, wlmtk_menu_style_t, margin, margin,
BSPL_DESC_DICT(
"Border", true, wlmtk_menu_style_t, border, border,
}
static const bspl_desc_t _wlmaker_config_menu_item_style_desc[]
Definition config.c:206
Definition menu.h:44

Descriptor for decoding the "Menu" dictionary.

◆ _wlmaker_config_style_color_gradient_desc

const bspl_desc_t _wlmaker_config_style_color_gradient_desc[]
static
Initial value:
= {
BSPL_DESC_ARGB32(
"From", true, wlmtk_style_color_gradient_data_t, from, from, 0),
BSPL_DESC_ARGB32(
"To", true, wlmtk_style_color_gradient_data_t, to, to, 0),
}

Plist decoding descriptor of a color gradient.

◆ _wlmaker_config_style_color_solid_desc

const bspl_desc_t _wlmaker_config_style_color_solid_desc[]
static
Initial value:
= {
BSPL_DESC_ARGB32(
"Color", true, wlmtk_style_color_solid_data_t, color, color, 0),
}
Definition style.h:59

Plist decoding descriptor of the solid color.

◆ _wlmaker_config_tile_style_desc

const bspl_desc_t _wlmaker_config_tile_style_desc[]
static
Initial value:
= {
BSPL_DESC_UINT64(
"Size", true, wlmtk_tile_style_t, size, size, 64),
BSPL_DESC_UINT64(
"ContentSize", true, wlmtk_tile_style_t, content_size, content_size, 48),
BSPL_DESC_UINT64(
"BezelWidth", true, wlmtk_tile_style_t, bezel_width, bezel_width, 2),
BSPL_DESC_CUSTOM(
"Fill", true, wlmtk_tile_style_t, fill, fill,
}
Definition tile.h:40

Plist decoding descriptor of a tile style.

◆ _wlmaker_config_window_resize_style_desc

const bspl_desc_t _wlmaker_config_window_resize_style_desc[]
static
Initial value:
= {
BSPL_DESC_CUSTOM(
"Fill", true, wlmtk_resizebar_style_t, fill, fill,
BSPL_DESC_UINT64(
"Height", true, wlmtk_resizebar_style_t, height, height, 7),
BSPL_DESC_UINT64(
"BezelWidth", true, wlmtk_resizebar_style_t, bezel_width, bezel_width,
1),
BSPL_DESC_UINT64(
"CornerWidth", true, wlmtk_resizebar_style_t, corner_width,
corner_width, 1),
}
Definition style.h:148

Descroptor for decoding the "TitleBar" dict below "Window".

◆ _wlmaker_config_window_style_desc

const bspl_desc_t _wlmaker_config_window_style_desc[]
static
Initial value:
= {
BSPL_DESC_DICT(
"TitleBar", true, wlmtk_window_style_t, titlebar, titlebar,
BSPL_DESC_DICT(
"ResizeBar", true, wlmtk_window_style_t, resizebar, resizebar,
BSPL_DESC_DICT(
"Border", true, wlmtk_window_style_t, border, border,
BSPL_DESC_DICT(
"Margin", true, wlmtk_window_style_t, margin, margin,
}
static const bspl_desc_t _wlmaker_config_window_titlebar_style_desc[]
Definition config.c:145
static const bspl_desc_t _wlmaker_config_window_resize_style_desc[]
Definition config.c:173
Definition style.h:180

Descriptor for decoding the "Window" dictionary.

◆ _wlmaker_config_window_titlebar_style_desc

const bspl_desc_t _wlmaker_config_window_titlebar_style_desc[]
static
Initial value:
= {
BSPL_DESC_CUSTOM(
"FocussedFill", true, wlmtk_titlebar_style_t, focussed_fill,
focussed_fill, _wlmaker_config_decode_fill_style, NULL, NULL, NULL),
BSPL_DESC_ARGB32(
"FocussedTextColor", true, wlmtk_titlebar_style_t,
focussed_text_color, focussed_text_color, 0),
BSPL_DESC_CUSTOM(
"BlurredFill", true, wlmtk_titlebar_style_t, blurred_fill,
blurred_fill, _wlmaker_config_decode_fill_style, NULL, NULL, NULL),
BSPL_DESC_ARGB32(
"BlurredTextColor", true, wlmtk_titlebar_style_t,
blurred_text_color, blurred_text_color, 0),
BSPL_DESC_UINT64(
"Height", true, wlmtk_titlebar_style_t, height, height, 22),
BSPL_DESC_UINT64(
"BezelWidth", true, wlmtk_titlebar_style_t, bezel_width, bezel_width,
1),
BSPL_DESC_DICT(
"Margin", true, wlmtk_titlebar_style_t, margin, margin,
BSPL_DESC_DICT(
"Font", true, wlmtk_titlebar_style_t, font, font,
}
Definition style.h:160

Descroptor for decoding the "TitleBar" dict below "Window".

◆ _wlmaker_cursor_style_desc

const bspl_desc_t _wlmaker_cursor_style_desc[]
static
Initial value:
= {
BSPL_DESC_STRING(
"Name", true, wlmaker_config_cursor_style_t, name_ptr, name_ptr,
"default"),
BSPL_DESC_UINT64(
"Size", true, wlmaker_config_cursor_style_t, size, size, 24),
}
Definition config.h:66

Descriptor for decoding the "Cursor" dictionary.

◆ _wlmaker_task_list_style_desc

const bspl_desc_t _wlmaker_task_list_style_desc[]
static
Initial value:
= {
BSPL_DESC_CUSTOM(
"Fill", true, wlmaker_config_task_list_style_t, fill, fill,
BSPL_DESC_DICT(
"Font", true, wlmaker_config_task_list_style_t, font, font,
BSPL_DESC_ARGB32(
text_color, text_color, 0),
}
Definition config.h:48

Descriptor for decoding the "TaskList" dictionary.

◆ config_output_scale

const float config_output_scale = 1.0

Overall scale of output.

◆ wlmaker_config_style_desc

const bspl_desc_t wlmaker_config_style_desc[]
Initial value:
= {
BSPL_DESC_ARGB32(
"BackgroundColor", true, wlmaker_config_style_t, background_color,
background_color, 0),
BSPL_DESC_DICT(
"Tile", true, wlmaker_config_style_t, tile, tile,
BSPL_DESC_DICT(
"Dock", true, wlmaker_config_style_t, dock, dock,
BSPL_DESC_DICT(
"Window", true, wlmaker_config_style_t, window, window,
BSPL_DESC_DICT(
"Menu", true, wlmaker_config_style_t, menu, menu,
BSPL_DESC_DICT(
"TaskList", true, wlmaker_config_style_t, task_list, task_list,
BSPL_DESC_DICT(
"Clip", true, wlmaker_config_style_t, clip, clip,
BSPL_DESC_DICT(
"Cursor", true, wlmaker_config_style_t, cursor, cursor,
}
static const bspl_desc_t _wlmaker_task_list_style_desc[]
Definition config.c:250
static const bspl_desc_t _wlmaker_cursor_style_desc[]
Definition config.c:275
static const bspl_desc_t _wlmaker_config_tile_style_desc[]
Definition config.c:101
static const bspl_desc_t _wlmaker_config_window_style_desc[]
Definition config.c:189
static const bspl_desc_t _wlmaker_config_dock_style_desc[]
Definition config.c:124
static const bspl_desc_t _wlmaker_clip_style_desc[]
Definition config.c:264
static const bspl_desc_t _wlmaker_config_menu_style_desc[]
Definition config.c:236
Definition config.h:74

Desciptor for decoding the style information from a plist.

◆ wlmaker_config_test_cases

const bs_test_case_t wlmaker_config_test_cases[]
static
Initial value:
= {
{ true, "embedded", test_embedded },
{ true, "file", test_file },
{ true, "style_file", test_style_file },
{ true, "decode_fill", test_decode_fill },
{ true, "decode_font", test_decode_font },
}
static void test_file(bs_test_t *test_ptr)
Definition config.c:534
static void test_style_file(bs_test_t *test_ptr)
Definition config.c:564
static void test_embedded(bs_test_t *test_ptr)
Definition config.c:506
static void test_decode_font(bs_test_t *test_ptr)
Definition config.c:649
static void test_decode_fill(bs_test_t *test_ptr)
Definition config.c:597

Unit test cases.

◆ wlmaker_config_test_set

const bs_test_set_t wlmaker_config_test_set
Initial value:
= BS_TEST_SET(
true, "config", wlmaker_config_test_cases)
static const bs_test_case_t wlmaker_config_test_cases[]
Definition config.c:489

Unit test set.