wlmaker
Loading...
Searching...
No Matches
Macros | Functions | Variables
config.c File Reference
#include "config.h"
#include <libbase/libbase.h>
#include <libbase/plist.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.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_dict_t * _wlmaker_config_from_plist (const char *fname_ptr)
 
static bool _wlmaker_config_decode_fill_style (bspl_object_t *object_ptr, void *dest_ptr)
 
bspl_object_t * wlmaker_plist_load (const char *name_ptr, const char *fname_ptr, const char **fname_defaults, const uint8_t *default_data_ptr, size_t default_data_size)
 
bspl_dict_t * wlmaker_config_load (const char *fname_ptr)
 
bspl_dict_t * wlmaker_state_load (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 char * _wlmaker_config_fname_ptrs []
 
static const char * _wlmaker_state_fname_ptrs []
 
const bs_test_case_t wlmaker_config_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.

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,
void *  dest_ptr 
)
static

Custom decoder for fill style struct from a plist dict.

Parameters
object_ptr
dest_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.

◆ 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 ( const char *  fname_ptr)

Loads the configuration for wlmaker.

If fname_ptr is give, it will attempt to load the configuration from the specified file. Otherwise, it will attempt to load the files specified in _wlmaker_config_fname_ptrs, or (at last) use the built-in default.

Parameters
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_plist_load()

bspl_object_t * wlmaker_plist_load ( const char *  name_ptr,
const char *  fname_ptr,
const char **  fname_defaults,
const uint8_t *  default_data_ptr,
size_t  default_data_size 
)

Loads a plist object from the given file(s) or data.

Useful to load configuration files from (1) the expclitly provided name in fname_ptr, (2) any of the files listed in fname_defaults, or (3) an in-memory buffer, as a compiled-in fallback option.

Parameters
name_ptrName to use when logging about the plist.
fname_ptrExplicit filename to use for loading the file, eg. from the commandline. Or NULL.
fname_defaultsNULL-terminated list of pointers to default paths & filenames to use for searching plist file(s).
default_data_ptrPoints to in-memory plist data, or NULL. Will be used if fname_ptr was NULL and no file was found at fname_defaults.
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 ( const char *  fname_ptr)

Loads the state for wlmaker.

Behaviour is similar to wlmaker_config_load.

Parameters
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:126
Definition config.h:57

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:109
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:54
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_fname_ptrs

const char* _wlmaker_config_fname_ptrs[]
static
Initial value:
= {
"~/.wlmaker.plist",
"/usr/share/wlmaker/wlmaker.plist",
NULL
}

Lookup paths for the configuration file. [LookupPathsConfig]

◆ _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:64
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),
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, void *dest_ptr)
Definition config.c:428
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:200
Definition menu.h:41

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:41

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:139
static const bspl_desc_t _wlmaker_config_window_resize_style_desc[]
Definition config.c:167
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),
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),
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:65

Descriptor for decoding the "Cursor" dictionary.

◆ _wlmaker_state_fname_ptrs

const char* _wlmaker_state_fname_ptrs[]
static
Initial value:
= {
"~/.wlmaker-state.plist",
"/usr/share/wlmaker/state.plist",
NULL
}

[LookupPathsConfig] Lookup paths for the configuration file.

◆ _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:47

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:244
static const bspl_desc_t _wlmaker_cursor_style_desc[]
Definition config.c:269
static const bspl_desc_t _wlmaker_config_tile_style_desc[]
Definition config.c:95
static const bspl_desc_t _wlmaker_config_window_style_desc[]
Definition config.c:183
static const bspl_desc_t _wlmaker_config_dock_style_desc[]
Definition config.c:118
static const bspl_desc_t _wlmaker_clip_style_desc[]
Definition config.c:258
static const bspl_desc_t _wlmaker_config_menu_style_desc[]
Definition config.c:230
Definition config.h:73

Desciptor for decoding the style information from a plist.

◆ wlmaker_config_test_cases

const bs_test_case_t wlmaker_config_test_cases[]
Initial value:
= {
{ 1, "embedded", test_embedded },
{ 1, "file", test_file },
{ 1, "style_file", test_style_file },
{ 1, "decode_fill", test_decode_fill },
{ 1, "decode_font", test_decode_font },
{ 0, NULL, NULL }
}
static void test_file(bs_test_t *test_ptr)
Definition config.c:525
static void test_style_file(bs_test_t *test_ptr)
Definition config.c:555
static void test_embedded(bs_test_t *test_ptr)
Definition config.c:497
static void test_decode_font(bs_test_t *test_ptr)
Definition config.c:639
static void test_decode_fill(bs_test_t *test_ptr)
Definition config.c:587

Unit test cases.