include: add config/types.h

This commit is contained in:
John Lindgren 2025-08-17 16:01:50 -04:00 committed by Hiroaki Yamamoto
parent 6dea8c0dcc
commit 9d49d19cd2
54 changed files with 414 additions and 368 deletions

View file

@ -3,29 +3,17 @@
#define LABWC_RCXML_H
#include <stdbool.h>
#include <stdio.h>
#include <wayland-server-core.h>
#include <wlr/util/box.h>
#include <libxml/tree.h>
#include "common/border.h"
#include "common/buf.h"
#include "common/font.h"
#include "common/three-state.h"
#include "config/touch.h"
#include "config/tablet.h"
#include "config/tablet-tool.h"
#include "config/libinput.h"
#include "resize-indicator.h"
#include "config/types.h"
#include "ssd.h"
#include "theme.h"
enum view_placement_policy {
LAB_PLACE_INVALID = 0,
LAB_PLACE_CENTER,
LAB_PLACE_CURSOR,
LAB_PLACE_AUTOMATIC,
LAB_PLACE_CASCADE,
};
#define BUTTON_MAP_MAX 16
enum adaptive_sync_mode {
LAB_ADAPTIVE_SYNC_DISABLED,
@ -33,6 +21,12 @@ enum adaptive_sync_mode {
LAB_ADAPTIVE_SYNC_FULLSCREEN,
};
enum resize_indicator_mode {
LAB_RESIZE_INDICATOR_NEVER = 0,
LAB_RESIZE_INDICATOR_ALWAYS,
LAB_RESIZE_INDICATOR_NON_PIXEL
};
enum tearing_mode {
LAB_TEARING_DISABLED = 0,
LAB_TEARING_ENABLED,
@ -48,6 +42,11 @@ enum tiling_events_mode {
(LAB_TILING_EVENTS_REGION | LAB_TILING_EVENTS_EDGE),
};
struct button_map_entry {
uint32_t from;
uint32_t to;
};
struct title_button {
enum ssd_part_type type;
struct wl_list link;
@ -72,7 +71,7 @@ struct rcxml {
enum tearing_mode allow_tearing;
bool auto_enable_outputs;
bool reuse_output_mode;
enum view_placement_policy placement_policy;
enum lab_placement_policy placement_policy;
bool xwayland_persistence;
bool primary_selection;
int placement_cascade_offset_x;
@ -110,7 +109,7 @@ struct rcxml {
/* keyboard */
int repeat_rate;
int repeat_delay;
enum three_state kb_numlock_enable;
enum lab_tristate kb_numlock_enable;
bool kb_layout_per_window;
struct wl_list keybinds; /* struct keybind.link */
@ -126,12 +125,12 @@ struct rcxml {
bool force_mouse_emulation;
char *output_name;
struct wlr_fbox box;
enum rotation rotation;
enum lab_rotation rotation;
uint16_t button_map_count;
struct button_map_entry button_map[BUTTON_MAP_MAX];
} tablet;
struct tablet_tool_config {
enum motion motion;
enum lab_motion motion;
double relative_motion_sensitivity;
} tablet_tool;

View file

@ -2,13 +2,8 @@
#ifndef LABWC_TABLET_TOOL_CONFIG_H
#define LABWC_TABLET_TOOL_CONFIG_H
#include <stdint.h>
#include "config/types.h"
enum motion {
LAB_TABLET_MOTION_ABSOLUTE = 0,
LAB_TABLET_MOTION_RELATIVE,
};
enum motion tablet_parse_motion(const char *name);
enum lab_motion tablet_parse_motion(const char *name);
#endif /* LABWC_TABLET_TOOL_CONFIG_H */

View file

@ -3,22 +3,10 @@
#define LABWC_TABLET_CONFIG_H
#include <stdint.h>
enum rotation {
LAB_ROTATE_NONE = 0,
LAB_ROTATE_90,
LAB_ROTATE_180,
LAB_ROTATE_270,
};
#define BUTTON_MAP_MAX 16
struct button_map_entry {
uint32_t from;
uint32_t to;
};
#include "config/types.h"
double tablet_get_dbl_if_positive(const char *content, const char *name);
enum rotation tablet_parse_rotation(int value);
enum lab_rotation tablet_parse_rotation(int value);
uint32_t tablet_button_from_str(const char *button);
void tablet_button_mapping_add(uint32_t from, uint32_t to);
void tablet_load_default_button_mappings(void);

118
include/config/types.h Normal file
View file

@ -0,0 +1,118 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_CONFIG_TYPES_H
#define LABWC_CONFIG_TYPES_H
/*
* Shared (basic) types related to user configuration.
*
* Please try to keep dependencies on other headers minimal,
* since config/types.h gets included in many source files.
*
* For the full config struct, see config/rcxml.h.
*/
/**
* Edges to which a view can be snapped. "Any" is used as
* a catch-all for every valid edge in order to simplify certain
* types of conditionals, but it is only valid for a selection
* of options in rc.xml.
*/
enum lab_edge {
LAB_EDGE_INVALID = 0,
LAB_EDGE_LEFT = (1 << 0),
LAB_EDGE_RIGHT = (1 << 1),
LAB_EDGE_UP = (1 << 2),
LAB_EDGE_DOWN = (1 << 3),
LAB_EDGE_CENTER = (1 << 4),
LAB_EDGE_ANY = (1 << 5),
LAB_EDGE_UPLEFT = (LAB_EDGE_UP | LAB_EDGE_LEFT),
LAB_EDGE_UPRIGHT = (LAB_EDGE_UP | LAB_EDGE_RIGHT),
LAB_EDGE_DOWNLEFT = (LAB_EDGE_DOWN | LAB_EDGE_LEFT),
LAB_EDGE_DOWNRIGHT = (LAB_EDGE_DOWN | LAB_EDGE_RIGHT),
};
enum lab_motion {
LAB_MOTION_ABSOLUTE = 0,
LAB_MOTION_RELATIVE,
};
enum lab_placement_policy {
LAB_PLACE_INVALID = 0,
LAB_PLACE_CENTER,
LAB_PLACE_CURSOR,
LAB_PLACE_AUTOMATIC,
LAB_PLACE_CASCADE,
};
enum lab_rotation {
LAB_ROTATE_NONE = 0,
LAB_ROTATE_90,
LAB_ROTATE_180,
LAB_ROTATE_270,
};
enum lab_ssd_mode {
LAB_SSD_MODE_INVALID,
LAB_SSD_MODE_NONE,
LAB_SSD_MODE_BORDER,
LAB_SSD_MODE_FULL,
};
enum lab_tristate {
LAB_STATE_UNSPECIFIED = 0,
LAB_STATE_ENABLED,
LAB_STATE_DISABLED
};
/* All criteria is applied in AND logic */
enum lab_view_criteria {
/* No filter -> all focusable views */
LAB_VIEW_CRITERIA_NONE = 0,
/*
* Includes always-on-top views, e.g.
* what is visible on the current workspace
*/
LAB_VIEW_CRITERIA_CURRENT_WORKSPACE = 1 << 0,
/* Positive criteria */
LAB_VIEW_CRITERIA_FULLSCREEN = 1 << 1,
LAB_VIEW_CRITERIA_ALWAYS_ON_TOP = 1 << 2,
LAB_VIEW_CRITERIA_ROOT_TOPLEVEL = 1 << 3,
/* Negative criteria */
LAB_VIEW_CRITERIA_NO_ALWAYS_ON_TOP = 1 << 6,
LAB_VIEW_CRITERIA_NO_SKIP_WINDOW_SWITCHER = 1 << 7,
LAB_VIEW_CRITERIA_NO_OMNIPRESENT = 1 << 8,
};
/*
* Window types are based on the NET_WM constants from X11. See:
* https://specifications.freedesktop.org/wm-spec/1.4/ar01s05.html#id-1.6.7
*
* The enum constants are intended to match wlr_xwayland_net_wm_window_type.
* Redefining the same constants here may seem redundant, but is necessary
* to make them available even in builds with xwayland support disabled.
*/
enum lab_window_type {
LAB_WINDOW_TYPE_DESKTOP = 0,
LAB_WINDOW_TYPE_DOCK,
LAB_WINDOW_TYPE_TOOLBAR,
LAB_WINDOW_TYPE_MENU,
LAB_WINDOW_TYPE_UTILITY,
LAB_WINDOW_TYPE_SPLASH,
LAB_WINDOW_TYPE_DIALOG,
LAB_WINDOW_TYPE_DROPDOWN_MENU,
LAB_WINDOW_TYPE_POPUP_MENU,
LAB_WINDOW_TYPE_TOOLTIP,
LAB_WINDOW_TYPE_NOTIFICATION,
LAB_WINDOW_TYPE_COMBO,
LAB_WINDOW_TYPE_DND,
LAB_WINDOW_TYPE_NORMAL,
LAB_WINDOW_TYPE_LEN
};
#endif /* LABWC_CONFIG_TYPES_H */