mirror of
https://github.com/swaywm/sway.git
synced 2025-11-17 06:59:48 -05:00
Reorganize includes
This commit is contained in:
parent
729fdf7d91
commit
416417a54c
50 changed files with 146 additions and 154 deletions
28
include/sway/border.h
Normal file
28
include/sway/border.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef _SWAY_BORDER_H
|
||||
#define _SWAY_BORDER_H
|
||||
#include <wlc/wlc.h>
|
||||
#include "container.h"
|
||||
|
||||
/**
|
||||
* Border pixel buffer and corresponding geometry.
|
||||
*/
|
||||
struct border {
|
||||
unsigned char *buffer;
|
||||
struct wlc_geometry geometry;
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear border buffer.
|
||||
*/
|
||||
void border_clear(struct border *border);
|
||||
|
||||
/**
|
||||
* Recursively update all of the borders within a container.
|
||||
*/
|
||||
void update_container_border(swayc_t *container);
|
||||
|
||||
void render_view_borders(wlc_handle view);
|
||||
int get_font_text_height(const char *font);
|
||||
bool should_hide_top_border(swayc_t *con, double y);
|
||||
|
||||
#endif
|
||||
64
include/sway/commands.h
Normal file
64
include/sway/commands.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#ifndef _SWAY_COMMANDS_H
|
||||
#define _SWAY_COMMANDS_H
|
||||
#include <stdbool.h>
|
||||
#include <json-c/json.h>
|
||||
#include <wlc/wlc.h>
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* Indicates the result of a command's execution.
|
||||
*/
|
||||
enum cmd_status {
|
||||
CMD_SUCCESS, /**< The command was successful */
|
||||
CMD_FAILURE, /**< The command resulted in an error */
|
||||
CMD_INVALID, /**< Unknown command or parser error */
|
||||
CMD_DEFER, /**< Command execution deferred */
|
||||
// Config Blocks
|
||||
CMD_BLOCK_END,
|
||||
CMD_BLOCK_MODE,
|
||||
CMD_BLOCK_BAR,
|
||||
CMD_BLOCK_BAR_COLORS,
|
||||
CMD_BLOCK_INPUT
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores the result of executing a command.
|
||||
*/
|
||||
struct cmd_results {
|
||||
enum cmd_status status;
|
||||
char *input;
|
||||
/**
|
||||
* Human friendly error message, or NULL on success
|
||||
*/
|
||||
char *error;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse and handles a command.
|
||||
*/
|
||||
struct cmd_results *handle_command(char *command);
|
||||
/**
|
||||
* Parse and handles a command during config file loading.
|
||||
*
|
||||
* Do not use this under normal conditions.
|
||||
*/
|
||||
struct cmd_results *config_command(char *command, enum cmd_status block);
|
||||
|
||||
/**
|
||||
* Allocates a cmd_results object.
|
||||
*/
|
||||
struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...);
|
||||
/**
|
||||
* Frees a cmd_results object.
|
||||
*/
|
||||
void free_cmd_results(struct cmd_results *results);
|
||||
/**
|
||||
* Serializes cmd_results to a JSON string.
|
||||
*
|
||||
* Free the JSON string later on.
|
||||
*/
|
||||
const char *cmd_results_to_json(struct cmd_results *results);
|
||||
|
||||
void remove_view_from_scratchpad(swayc_t *);
|
||||
|
||||
#endif
|
||||
320
include/sway/config.h
Normal file
320
include/sway/config.h
Normal file
|
|
@ -0,0 +1,320 @@
|
|||
#ifndef _SWAY_CONFIG_H
|
||||
#define _SWAY_CONFIG_H
|
||||
|
||||
#define PID_WORKSPACE_TIMEOUT 60
|
||||
|
||||
#include <libinput.h>
|
||||
#include <stdint.h>
|
||||
#include <wlc/geometry.h>
|
||||
#include <wlc/wlc.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <time.h>
|
||||
#include "wayland-desktop-shell-server-protocol.h"
|
||||
#include "list.h"
|
||||
#include "layout.h"
|
||||
#include "container.h"
|
||||
|
||||
/**
|
||||
* Describes a variable created via the `set` command.
|
||||
*/
|
||||
struct sway_variable {
|
||||
char *name;
|
||||
char *value;
|
||||
};
|
||||
|
||||
/**
|
||||
* A key binding and an associated command.
|
||||
*/
|
||||
struct sway_binding {
|
||||
int order;
|
||||
bool release;
|
||||
bool bindcode;
|
||||
list_t *keys;
|
||||
uint32_t modifiers;
|
||||
char *command;
|
||||
};
|
||||
|
||||
/**
|
||||
* A mouse binding and an associated command.
|
||||
*/
|
||||
struct sway_mouse_binding {
|
||||
uint32_t button;
|
||||
char *command;
|
||||
};
|
||||
|
||||
/**
|
||||
* A "mode" of keybindings created via the `mode` command.
|
||||
*/
|
||||
struct sway_mode {
|
||||
char *name;
|
||||
list_t *bindings;
|
||||
};
|
||||
|
||||
/**
|
||||
* libinput options for input devices
|
||||
*/
|
||||
struct input_config {
|
||||
char *identifier;
|
||||
|
||||
int accel_profile;
|
||||
int click_method;
|
||||
int drag_lock;
|
||||
int dwt;
|
||||
int middle_emulation;
|
||||
int natural_scroll;
|
||||
float pointer_accel;
|
||||
int scroll_method;
|
||||
int send_events;
|
||||
int tap;
|
||||
|
||||
bool capturable;
|
||||
struct wlc_geometry region;
|
||||
};
|
||||
|
||||
/**
|
||||
* Size and position configuration for a particular output.
|
||||
*
|
||||
* This is set via the `output` command.
|
||||
*/
|
||||
struct output_config {
|
||||
char *name;
|
||||
int enabled;
|
||||
int width, height;
|
||||
int x, y;
|
||||
int scale;
|
||||
char *background;
|
||||
char *background_option;
|
||||
};
|
||||
|
||||
/**
|
||||
* Maps a workspace name to an output name.
|
||||
*
|
||||
* Set via `workspace <x> output <y>`
|
||||
*/
|
||||
struct workspace_output {
|
||||
char *output;
|
||||
char *workspace;
|
||||
};
|
||||
|
||||
struct pid_workspace {
|
||||
pid_t *pid;
|
||||
char *workspace;
|
||||
time_t *time_added;
|
||||
};
|
||||
|
||||
void pid_workspace_add(struct pid_workspace *pw);
|
||||
void free_pid_workspace(struct pid_workspace *pw);
|
||||
|
||||
struct bar_config {
|
||||
/**
|
||||
* One of "dock", "hide", "invisible"
|
||||
*
|
||||
* Always visible in dock mode. Visible only when modifier key is held in hide mode.
|
||||
* Never visible in invisible mode.
|
||||
*/
|
||||
char *mode;
|
||||
/**
|
||||
* One of "show" or "hide".
|
||||
*
|
||||
* In "show" mode, it will always be shown on top of the active workspace.
|
||||
*/
|
||||
char *hidden_state;
|
||||
/**
|
||||
* Id name used to identify the bar through IPC.
|
||||
*
|
||||
* Defaults to bar-x, where x corresponds to the position of the
|
||||
* embedding bar block in the config file (bar-0, bar-1, ...).
|
||||
*/
|
||||
char *id;
|
||||
uint32_t modifier;
|
||||
list_t *outputs;
|
||||
enum desktop_shell_panel_position position;
|
||||
list_t *bindings;
|
||||
char *status_command;
|
||||
bool pango_markup;
|
||||
char *swaybar_command;
|
||||
char *font;
|
||||
int height; // -1 not defined
|
||||
int tray_padding;
|
||||
bool workspace_buttons;
|
||||
bool wrap_scroll;
|
||||
char *separator_symbol;
|
||||
bool strip_workspace_numbers;
|
||||
bool binding_mode_indicator;
|
||||
bool verbose;
|
||||
pid_t pid;
|
||||
struct {
|
||||
char background[10];
|
||||
char statusline[10];
|
||||
char separator[10];
|
||||
char focused_workspace_border[10];
|
||||
char focused_workspace_bg[10];
|
||||
char focused_workspace_text[10];
|
||||
char active_workspace_border[10];
|
||||
char active_workspace_bg[10];
|
||||
char active_workspace_text[10];
|
||||
char inactive_workspace_border[10];
|
||||
char inactive_workspace_bg[10];
|
||||
char inactive_workspace_text[10];
|
||||
char urgent_workspace_border[10];
|
||||
char urgent_workspace_bg[10];
|
||||
char urgent_workspace_text[10];
|
||||
char binding_mode_border[10];
|
||||
char binding_mode_bg[10];
|
||||
char binding_mode_text[10];
|
||||
} colors;
|
||||
};
|
||||
|
||||
struct border_colors {
|
||||
uint32_t border;
|
||||
uint32_t background;
|
||||
uint32_t text;
|
||||
uint32_t indicator;
|
||||
uint32_t child_border;
|
||||
};
|
||||
|
||||
enum edge_border_types {
|
||||
E_NONE, /**< Don't hide edge borders */
|
||||
E_VERTICAL, /**< hide vertical edge borders */
|
||||
E_HORIZONTAL, /**< hide horizontal edge borders */
|
||||
E_BOTH /**< hide vertical and horizontal edge borders */
|
||||
};
|
||||
|
||||
/**
|
||||
* The configuration struct. The result of loading a config file.
|
||||
*/
|
||||
struct sway_config {
|
||||
list_t *symbols;
|
||||
list_t *modes;
|
||||
list_t *bars;
|
||||
list_t *cmd_queue;
|
||||
list_t *workspace_outputs;
|
||||
list_t *pid_workspaces;
|
||||
list_t *output_configs;
|
||||
list_t *input_configs;
|
||||
list_t *criteria;
|
||||
list_t *active_bar_modifiers;
|
||||
struct sway_mode *current_mode;
|
||||
struct bar_config *current_bar;
|
||||
uint32_t floating_mod;
|
||||
uint32_t dragging_key;
|
||||
uint32_t resizing_key;
|
||||
char *floating_scroll_up_cmd;
|
||||
char *floating_scroll_down_cmd;
|
||||
char *floating_scroll_left_cmd;
|
||||
char *floating_scroll_right_cmd;
|
||||
enum swayc_layouts default_orientation;
|
||||
enum swayc_layouts default_layout;
|
||||
char *font;
|
||||
int font_height;
|
||||
|
||||
// Flags
|
||||
bool focus_follows_mouse;
|
||||
bool mouse_warping;
|
||||
bool active;
|
||||
bool failed;
|
||||
bool reloading;
|
||||
bool reading;
|
||||
bool auto_back_and_forth;
|
||||
bool seamless_mouse;
|
||||
|
||||
bool edge_gaps;
|
||||
bool smart_gaps;
|
||||
int gaps_inner;
|
||||
int gaps_outer;
|
||||
|
||||
list_t *config_chain;
|
||||
const char *current_config;
|
||||
|
||||
enum swayc_border_types border;
|
||||
enum swayc_border_types floating_border;
|
||||
int border_thickness;
|
||||
int floating_border_thickness;
|
||||
enum edge_border_types hide_edge_borders;
|
||||
|
||||
// border colors
|
||||
struct {
|
||||
struct border_colors focused;
|
||||
struct border_colors focused_inactive;
|
||||
struct border_colors unfocused;
|
||||
struct border_colors urgent;
|
||||
struct border_colors placeholder;
|
||||
uint32_t background;
|
||||
} border_colors;
|
||||
|
||||
// floating view
|
||||
int32_t floating_maximum_width;
|
||||
int32_t floating_maximum_height;
|
||||
int32_t floating_minimum_width;
|
||||
int32_t floating_minimum_height;
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads the main config from the given path. is_active should be true when
|
||||
* reloading the config.
|
||||
*/
|
||||
bool load_main_config(const char *path, bool is_active);
|
||||
|
||||
/**
|
||||
* Loads an included config. Can only be used after load_main_config.
|
||||
*/
|
||||
bool load_include_configs(const char *path, struct sway_config *config);
|
||||
|
||||
/**
|
||||
* Reads the config from the given FILE.
|
||||
*/
|
||||
bool read_config(FILE *file, struct sway_config *config);
|
||||
|
||||
/**
|
||||
* Free config struct
|
||||
*/
|
||||
void free_config(struct sway_config *config);
|
||||
/**
|
||||
* Does variable replacement for a string based on the config's currently loaded variables.
|
||||
*/
|
||||
char *do_var_replacement(char *str);
|
||||
|
||||
int input_identifier_cmp(const void *item, const void *data);
|
||||
void merge_input_config(struct input_config *dst, struct input_config *src);
|
||||
void apply_input_config(struct input_config *ic, struct libinput_device *dev);
|
||||
void free_input_config(struct input_config *ic);
|
||||
|
||||
int output_name_cmp(const void *item, const void *data);
|
||||
void merge_output_config(struct output_config *dst, struct output_config *src);
|
||||
/** Sets up a WLC output handle based on a given output_config.
|
||||
*/
|
||||
void apply_output_config(struct output_config *oc, swayc_t *output);
|
||||
void free_output_config(struct output_config *oc);
|
||||
|
||||
/**
|
||||
* Updates the list of active bar modifiers
|
||||
*/
|
||||
void update_active_bar_modifiers(void);
|
||||
|
||||
int workspace_output_cmp_workspace(const void *a, const void *b);
|
||||
|
||||
int sway_binding_cmp(const void *a, const void *b);
|
||||
int sway_binding_cmp_qsort(const void *a, const void *b);
|
||||
int sway_binding_cmp_keys(const void *a, const void *b);
|
||||
void free_sway_binding(struct sway_binding *sb);
|
||||
struct sway_binding *sway_binding_dup(struct sway_binding *sb);
|
||||
|
||||
int sway_mouse_binding_cmp(const void *a, const void *b);
|
||||
int sway_mouse_binding_cmp_qsort(const void *a, const void *b);
|
||||
int sway_mouse_binding_cmp_buttons(const void *a, const void *b);
|
||||
void free_sway_mouse_binding(struct sway_mouse_binding *smb);
|
||||
|
||||
void load_swaybars();
|
||||
void terminate_swaybg(pid_t pid);
|
||||
|
||||
/**
|
||||
* Allocate and initialize default bar configuration.
|
||||
*/
|
||||
struct bar_config *default_bar_config(void);
|
||||
|
||||
/**
|
||||
* Global config singleton.
|
||||
*/
|
||||
extern struct sway_config *config;
|
||||
|
||||
#endif
|
||||
312
include/sway/container.h
Normal file
312
include/sway/container.h
Normal file
|
|
@ -0,0 +1,312 @@
|
|||
#ifndef _SWAY_CONTAINER_H
|
||||
#define _SWAY_CONTAINER_H
|
||||
#include <sys/types.h>
|
||||
#include <wlc/wlc.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
typedef struct sway_container swayc_t;
|
||||
|
||||
extern swayc_t root_container;
|
||||
|
||||
/**
|
||||
* Different kinds of containers.
|
||||
*
|
||||
* This enum is in order. A container will never be inside of a container below
|
||||
* it on this list.
|
||||
*/
|
||||
enum swayc_types {
|
||||
C_ROOT, /**< The root container. Only one of these ever exists. */
|
||||
C_OUTPUT, /**< An output (aka monitor, head, etc). */
|
||||
C_WORKSPACE, /**< A workspace. */
|
||||
C_CONTAINER, /**< A manually created container. */
|
||||
C_VIEW, /**< A view (aka window). */
|
||||
// Keep last
|
||||
C_TYPES,
|
||||
};
|
||||
|
||||
/**
|
||||
* Different ways to arrange a container.
|
||||
*/
|
||||
enum swayc_layouts {
|
||||
L_NONE, /**< Used for containers that have no layout (views, root) */
|
||||
L_HORIZ,
|
||||
L_VERT,
|
||||
L_STACKED,
|
||||
L_TABBED,
|
||||
L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */
|
||||
// Keep last
|
||||
L_LAYOUTS,
|
||||
};
|
||||
|
||||
enum swayc_border_types {
|
||||
B_NONE, /**< No border */
|
||||
B_PIXEL, /**< 1px border */
|
||||
B_NORMAL /**< Normal border with title bar */
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores information about a container.
|
||||
*
|
||||
* The tree is made of these. Views are containers that cannot have children.
|
||||
*/
|
||||
struct sway_container {
|
||||
/**
|
||||
* If this container maps to a WLC object, this is set to that object's
|
||||
* handle. Otherwise, NULL.
|
||||
*/
|
||||
wlc_handle handle;
|
||||
|
||||
enum swayc_types type;
|
||||
enum swayc_layouts layout;
|
||||
enum swayc_layouts prev_layout;
|
||||
|
||||
/**
|
||||
* Width and height of this container, without borders or gaps.
|
||||
*/
|
||||
double width, height;
|
||||
|
||||
/**
|
||||
* Views may request geometry, which is stored in this and ignored until
|
||||
* the views are floated.
|
||||
*/
|
||||
int desired_width, desired_height;
|
||||
|
||||
/**
|
||||
* The coordinates that this view appear at, relative to the output they
|
||||
* are located on (output containers have absolute coordinates).
|
||||
*/
|
||||
double x, y;
|
||||
|
||||
/**
|
||||
* Cached geometry used to store view/container geometry when switching
|
||||
* between tabbed/stacked and horizontal/vertical layouts.
|
||||
*/
|
||||
struct wlc_geometry cached_geometry;
|
||||
|
||||
/**
|
||||
* False if this view is invisible. It could be in the scratchpad or on a
|
||||
* workspace that is not shown.
|
||||
*/
|
||||
bool visible;
|
||||
bool is_floating;
|
||||
bool is_focused;
|
||||
bool sticky; // floating view always visible on its output
|
||||
|
||||
// Attributes that mostly views have.
|
||||
char *name;
|
||||
char *class;
|
||||
char *app_id;
|
||||
|
||||
// Used by output containers to keep track of swaybg child processes.
|
||||
pid_t bg_pid;
|
||||
|
||||
int gaps;
|
||||
|
||||
list_t *children;
|
||||
/**
|
||||
* Children of this container that are floated.
|
||||
*/
|
||||
list_t *floating;
|
||||
/**
|
||||
* Unmanaged view handles in this container.
|
||||
*/
|
||||
list_t *unmanaged;
|
||||
|
||||
/**
|
||||
* The parent of this container. NULL for the root container.
|
||||
*/
|
||||
struct sway_container *parent;
|
||||
/**
|
||||
* Which of this container's children has focus.
|
||||
*/
|
||||
struct sway_container *focused;
|
||||
/**
|
||||
* If this container's children include a fullscreen view, this is that view.
|
||||
*/
|
||||
struct sway_container *fullscreen;
|
||||
/**
|
||||
* If this container is a view, this may be set to the window's decoration
|
||||
* buffer (or NULL).
|
||||
*/
|
||||
struct border *border;
|
||||
enum swayc_border_types border_type;
|
||||
struct wlc_geometry border_geometry;
|
||||
struct wlc_geometry title_bar_geometry;
|
||||
struct wlc_geometry actual_geometry;
|
||||
int border_thickness;
|
||||
};
|
||||
|
||||
enum visibility_mask {
|
||||
VISIBLE = true
|
||||
} visible;
|
||||
|
||||
/**
|
||||
* Allocates a new output container.
|
||||
*/
|
||||
swayc_t *new_output(wlc_handle handle);
|
||||
/**
|
||||
* Allocates a new workspace container.
|
||||
*/
|
||||
swayc_t *new_workspace(swayc_t *output, const char *name);
|
||||
/**
|
||||
* Allocates a new container and places a child into it.
|
||||
*
|
||||
* This is used from the split command, which creates a new container with the
|
||||
* requested layout and replaces the focused container in the tree with the new
|
||||
* one. Then the removed container is added as a child of the new container.
|
||||
*/
|
||||
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
|
||||
/**
|
||||
* Allocates a new view container.
|
||||
*
|
||||
* Pass in a sibling view, or a workspace to become this container's parent.
|
||||
*/
|
||||
swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
|
||||
/**
|
||||
* Allocates a new floating view in the active workspace.
|
||||
*/
|
||||
swayc_t *new_floating_view(wlc_handle handle);
|
||||
|
||||
void floating_view_sane_size(swayc_t *view);
|
||||
|
||||
/**
|
||||
* Frees an output's container.
|
||||
*/
|
||||
swayc_t *destroy_output(swayc_t *output);
|
||||
/**
|
||||
* Destroys a workspace container and returns the parent pointer, or NULL.
|
||||
*/
|
||||
swayc_t *destroy_workspace(swayc_t *workspace);
|
||||
/**
|
||||
* Destroys a container and all empty parents. Returns the topmost non-empty
|
||||
* parent container, or NULL.
|
||||
*/
|
||||
swayc_t *destroy_container(swayc_t *container);
|
||||
/**
|
||||
* Destroys a view container and all empty parents. Returns the topmost
|
||||
* non-empty parent container, or NULL.
|
||||
*/
|
||||
swayc_t *destroy_view(swayc_t *view);
|
||||
|
||||
/**
|
||||
* Finds a container based on test criteria. Returns the first container that
|
||||
* passes the test.
|
||||
*/
|
||||
swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
|
||||
/**
|
||||
* Finds a parent container with the given swayc_type.
|
||||
*/
|
||||
swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
|
||||
/**
|
||||
* Finds a parent with the given swayc_layout.
|
||||
*/
|
||||
swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
|
||||
/**
|
||||
* Finds the bottom-most focused container of a type.
|
||||
*/
|
||||
swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
|
||||
/**
|
||||
* Finds the bottom-most focused container of a layout.
|
||||
*/
|
||||
swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
|
||||
|
||||
/**
|
||||
* Gets the swayc_t associated with a wlc_handle.
|
||||
*/
|
||||
swayc_t *swayc_by_handle(wlc_handle handle);
|
||||
/**
|
||||
* Gets the named swayc_t.
|
||||
*/
|
||||
swayc_t *swayc_by_name(const char *name);
|
||||
/**
|
||||
* Gets the active output's container.
|
||||
*/
|
||||
swayc_t *swayc_active_output(void);
|
||||
/**
|
||||
* Gets the active workspace's container.
|
||||
*/
|
||||
swayc_t *swayc_active_workspace(void);
|
||||
/**
|
||||
* Gets the workspace for the given view container.
|
||||
*/
|
||||
swayc_t *swayc_active_workspace_for(swayc_t *view);
|
||||
/**
|
||||
* Finds the container currently underneath the pointer.
|
||||
*/
|
||||
swayc_t *container_under_pointer(void);
|
||||
|
||||
/**
|
||||
* Returns true if a container is fullscreen.
|
||||
*/
|
||||
bool swayc_is_fullscreen(swayc_t *view);
|
||||
/**
|
||||
* Returns true if this view is focused.
|
||||
*/
|
||||
bool swayc_is_active(swayc_t *view);
|
||||
/**
|
||||
* Returns true if the parent is an ancestor of the child.
|
||||
*/
|
||||
bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
|
||||
/**
|
||||
* Returns true if the child is a desecendant of the parent.
|
||||
*/
|
||||
bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
|
||||
|
||||
/**
|
||||
* Returns true if this container is an empty workspace.
|
||||
*/
|
||||
bool swayc_is_empty_workspace(swayc_t *container);
|
||||
|
||||
/**
|
||||
* Returns the top most tabbed or stacked parent container. Returns NULL if
|
||||
* view is not in a tabbed/stacked layout.
|
||||
*/
|
||||
swayc_t *swayc_tabbed_stacked_ancestor(swayc_t *view);
|
||||
|
||||
/**
|
||||
* Returns the immediate tabbed or stacked parent container. Returns NULL if
|
||||
* view is not directly in a tabbed/stacked layout.
|
||||
*/
|
||||
swayc_t *swayc_tabbed_stacked_parent(swayc_t *view);
|
||||
|
||||
/**
|
||||
* Returns the gap (padding) of the container.
|
||||
*
|
||||
* This returns the inner gaps for a view, the outer gaps for a workspace, and
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int swayc_gap(swayc_t *container);
|
||||
|
||||
/**
|
||||
* Maps a container's children over a function.
|
||||
*/
|
||||
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
|
||||
|
||||
/**
|
||||
* Set a view as visible or invisible.
|
||||
*
|
||||
* This will perform the required wlc calls as well; it is not sufficient to
|
||||
* simply toggle the boolean in swayc_t.
|
||||
*/
|
||||
void set_view_visibility(swayc_t *view, void *data);
|
||||
/**
|
||||
* Set the gaps value for a view.
|
||||
*/
|
||||
void set_gaps(swayc_t *view, void *amount);
|
||||
/**
|
||||
* Add to the gaps value for a view.
|
||||
*/
|
||||
void add_gaps(swayc_t *view, void *amount);
|
||||
|
||||
/**
|
||||
* Issue wlc calls to make the visibility of a container consistent.
|
||||
*/
|
||||
void update_visibility(swayc_t *container);
|
||||
|
||||
/**
|
||||
* Close all child views of container
|
||||
*/
|
||||
void close_views(swayc_t *container);
|
||||
|
||||
#endif
|
||||
36
include/sway/criteria.h
Normal file
36
include/sway/criteria.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef _SWAY_CRITERIA_H
|
||||
#define _SWAY_CRITERIA_H
|
||||
|
||||
#include "container.h"
|
||||
#include "list.h"
|
||||
|
||||
/**
|
||||
* Maps criteria (as a list of criteria tokens) to a command list.
|
||||
*
|
||||
* A list of tokens together represent a single criteria string (e.g.
|
||||
* '[class="abc" title="xyz"]' becomes two criteria tokens).
|
||||
*
|
||||
* for_window: Views matching all criteria will have the bound command list
|
||||
* executed on them.
|
||||
*
|
||||
* Set via `for_window <criteria> <cmd list>`.
|
||||
*/
|
||||
struct criteria {
|
||||
list_t *tokens; // struct crit_token, contains compiled regex.
|
||||
char *crit_raw; // entire criteria string (for logging)
|
||||
|
||||
char *cmdlist;
|
||||
};
|
||||
|
||||
int criteria_cmp(const void *item, const void *data);
|
||||
void free_criteria(struct criteria *crit);
|
||||
|
||||
// Pouplate list with crit_tokens extracted from criteria string, returns error
|
||||
// string or NULL if successful.
|
||||
char *extract_crit_tokens(list_t *tokens, const char *criteria);
|
||||
|
||||
// Returns list of criteria that match given container. These criteria have
|
||||
// been set with `for_window` commands and have an associated cmdlist.
|
||||
list_t *criteria_for(swayc_t *cont);
|
||||
|
||||
#endif
|
||||
49
include/sway/extensions.h
Normal file
49
include/sway/extensions.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#ifndef _SWAY_EXTENSIONS_H
|
||||
#define _SWAY_EXTENSIONS_H
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlc/wlc-wayland.h>
|
||||
#include "wayland-desktop-shell-server-protocol.h"
|
||||
#include "list.h"
|
||||
|
||||
struct background_config {
|
||||
wlc_handle output;
|
||||
wlc_resource surface;
|
||||
// we need the wl_resource of the surface in the destructor
|
||||
struct wl_resource *wl_surface_res;
|
||||
struct wl_client *client;
|
||||
wlc_handle handle;
|
||||
};
|
||||
|
||||
struct panel_config {
|
||||
// wayland resource used in callbacks, is used to track this panel
|
||||
struct wl_resource *wl_resource;
|
||||
wlc_handle output;
|
||||
wlc_resource surface;
|
||||
// we need the wl_resource of the surface in the destructor
|
||||
struct wl_resource *wl_surface_res;
|
||||
enum desktop_shell_panel_position panel_position;
|
||||
// used to determine if client is a panel
|
||||
struct wl_client *client;
|
||||
// wlc handle for this panel's surface, not set until panel is created
|
||||
wlc_handle handle;
|
||||
};
|
||||
|
||||
struct desktop_shell_state {
|
||||
list_t *backgrounds;
|
||||
list_t *panels;
|
||||
list_t *lock_surfaces;
|
||||
bool is_locked;
|
||||
};
|
||||
|
||||
struct swaylock_state {
|
||||
bool active;
|
||||
wlc_handle output;
|
||||
wlc_resource surface;
|
||||
};
|
||||
|
||||
extern struct desktop_shell_state desktop_shell;
|
||||
|
||||
void register_extensions(void);
|
||||
|
||||
#endif
|
||||
43
include/sway/focus.h
Normal file
43
include/sway/focus.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef _SWAY_FOCUS_H
|
||||
#define _SWAY_FOCUS_H
|
||||
enum movement_direction {
|
||||
MOVE_LEFT,
|
||||
MOVE_RIGHT,
|
||||
MOVE_UP,
|
||||
MOVE_DOWN,
|
||||
MOVE_PARENT,
|
||||
MOVE_CHILD
|
||||
};
|
||||
|
||||
#include "container.h"
|
||||
|
||||
// focused_container - the container found by following the `focused` pointer
|
||||
// from a given container to a container with `is_focused` boolean set
|
||||
// ---
|
||||
// focused_view - the container found by following the `focused` pointer from a
|
||||
// given container to a view.
|
||||
// ---
|
||||
|
||||
swayc_t *get_focused_container(swayc_t *parent);
|
||||
swayc_t *get_focused_view(swayc_t *parent);
|
||||
swayc_t *get_focused_float(swayc_t *ws);
|
||||
|
||||
// a special-case function to get the focused view, regardless
|
||||
// of whether it's tiled or floating
|
||||
swayc_t *get_focused_view_include_floating(swayc_t *parent);
|
||||
|
||||
bool set_focused_container(swayc_t *container);
|
||||
bool set_focused_container_for(swayc_t *ancestor, swayc_t *container);
|
||||
|
||||
// lock focused container/view. locked by windows with OVERRIDE attribute
|
||||
// and unlocked when they are destroyed
|
||||
|
||||
extern bool locked_container_focus;
|
||||
|
||||
// Prevents wss from being destroyed on focus switch
|
||||
extern bool suspend_workspace_cleanup;
|
||||
|
||||
bool move_focus(enum movement_direction direction);
|
||||
|
||||
#endif
|
||||
|
||||
11
include/sway/handlers.h
Normal file
11
include/sway/handlers.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef _SWAY_HANDLERS_H
|
||||
#define _SWAY_HANDLERS_H
|
||||
#include "container.h"
|
||||
#include <stdbool.h>
|
||||
#include <wlc/wlc.h>
|
||||
|
||||
void register_wlc_handlers();
|
||||
|
||||
extern uint32_t keys_pressed[32];
|
||||
|
||||
#endif
|
||||
23
include/sway/input.h
Normal file
23
include/sway/input.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef _SWAY_INPUT_H
|
||||
#define _SWAY_INPUT_H
|
||||
|
||||
#include <libinput.h>
|
||||
#include "config.h"
|
||||
#include "list.h"
|
||||
|
||||
struct input_config *new_input_config(const char* identifier);
|
||||
|
||||
char* libinput_dev_unique_id(struct libinput_device *dev);
|
||||
|
||||
/**
|
||||
* Global input device list.
|
||||
*/
|
||||
extern list_t *input_devices;
|
||||
|
||||
/**
|
||||
* Pointer used when reading input blocked.
|
||||
* Shared so that it can be cleared from commands.c when closing the block
|
||||
*/
|
||||
extern struct input_config *current_input_config;
|
||||
|
||||
#endif
|
||||
102
include/sway/input_state.h
Normal file
102
include/sway/input_state.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#ifndef _SWAY_KEY_STATE_H
|
||||
#define _SWAY_KEY_STATE_H
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "container.h"
|
||||
|
||||
/* Keyboard state */
|
||||
|
||||
// returns true if key has been pressed, otherwise false
|
||||
bool check_key(uint32_t key_sym, uint32_t key_code);
|
||||
|
||||
// returns true if key_sym matches latest released key.
|
||||
bool check_released_key(uint32_t key_sym);
|
||||
|
||||
// sets a key as pressed
|
||||
void press_key(uint32_t key_sym, uint32_t key_code);
|
||||
|
||||
// unsets a key as pressed
|
||||
void release_key(uint32_t key_sym, uint32_t key_code);
|
||||
|
||||
|
||||
/* Pointer state */
|
||||
|
||||
enum pointer_values {
|
||||
M_LEFT_CLICK = 272,
|
||||
M_RIGHT_CLICK = 273,
|
||||
M_SCROLL_CLICK = 274,
|
||||
M_SCROLL_UP = 275,
|
||||
M_SCROLL_DOWN = 276,
|
||||
};
|
||||
|
||||
enum pointer_mode {
|
||||
// Target
|
||||
M_FLOATING = 1,
|
||||
M_TILING = 2,
|
||||
// Action
|
||||
M_DRAGGING = 4,
|
||||
M_RESIZING = 8,
|
||||
};
|
||||
|
||||
struct pointer_button_state {
|
||||
bool held;
|
||||
// state at the point it was pressed
|
||||
int x, y;
|
||||
swayc_t *view;
|
||||
};
|
||||
|
||||
extern struct pointer_state {
|
||||
// mouse clicks
|
||||
struct pointer_button_state left;
|
||||
struct pointer_button_state right;
|
||||
struct pointer_button_state scroll;
|
||||
|
||||
// change in pointer position
|
||||
struct {
|
||||
int x, y;
|
||||
} delta;
|
||||
|
||||
// view pointer is currently over
|
||||
swayc_t *view;
|
||||
|
||||
// Pointer mode
|
||||
int mode;
|
||||
} pointer_state;
|
||||
|
||||
enum modifier_state {
|
||||
MOD_STATE_UNCHANGED = 0,
|
||||
MOD_STATE_PRESSED = 1,
|
||||
MOD_STATE_RELEASED = 2
|
||||
};
|
||||
|
||||
void pointer_position_set(struct wlc_origin *new_origin, bool force_focus);
|
||||
void center_pointer_on(swayc_t *view);
|
||||
|
||||
// on button release unset mode depending on the button.
|
||||
// on button press set mode conditionally depending on the button
|
||||
void pointer_mode_set(uint32_t button, bool condition);
|
||||
|
||||
// Update mode in mouse motion
|
||||
void pointer_mode_update(void);
|
||||
|
||||
// Reset mode on any keypress;
|
||||
void pointer_mode_reset(void);
|
||||
|
||||
void input_init(void);
|
||||
|
||||
/**
|
||||
* Check if state of mod changed from current state to new_state.
|
||||
*
|
||||
* Returns MOD_STATE_UNCHANGED if the state didn't change, MOD_STATE_PRESSED if
|
||||
* the state changed to pressed and MOD_STATE_RELEASED if the state changed to
|
||||
* released.
|
||||
*/
|
||||
uint32_t modifier_state_changed(uint32_t new_state, uint32_t mod);
|
||||
|
||||
/**
|
||||
* Update the current modifiers state to new_state.
|
||||
*/
|
||||
void modifiers_state_update(uint32_t new_state);
|
||||
|
||||
#endif
|
||||
|
||||
14
include/sway/ipc-json.h
Normal file
14
include/sway/ipc-json.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _SWAY_IPC_JSON_H
|
||||
#define _SWAY_IPC_JSON_H
|
||||
|
||||
#include <json-c/json.h>
|
||||
#include "config.h"
|
||||
#include "container.h"
|
||||
|
||||
json_object *ipc_json_get_version();
|
||||
json_object *ipc_json_describe_bar_config(struct bar_config *bar);
|
||||
json_object *ipc_json_describe_container(swayc_t *c);
|
||||
json_object *ipc_json_describe_container_recursive(swayc_t *c);
|
||||
json_object *ipc_json_describe_window(swayc_t *c);
|
||||
|
||||
#endif
|
||||
41
include/sway/ipc-server.h
Normal file
41
include/sway/ipc-server.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef _SWAY_IPC_SERVER_H
|
||||
#define _SWAY_IPC_SERVER_H
|
||||
|
||||
#include <wlc/wlc.h>
|
||||
|
||||
#include "container.h"
|
||||
#include "config.h"
|
||||
#include "ipc.h"
|
||||
|
||||
void ipc_init(void);
|
||||
void ipc_terminate(void);
|
||||
struct sockaddr_un *ipc_user_sockaddr(void);
|
||||
|
||||
void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change);
|
||||
void ipc_event_barconfig_update(struct bar_config *bar);
|
||||
/**
|
||||
* Send IPC mode event to all listening clients
|
||||
*/
|
||||
void ipc_event_mode(const char *mode);
|
||||
/**
|
||||
* Send IPC window change event
|
||||
*/
|
||||
void ipc_event_window(swayc_t *window, const char *change);
|
||||
/**
|
||||
* Sends an IPC modifier event to all listening clients. The modifier event
|
||||
* includes a key 'change' with the value of state and a key 'modifier' with
|
||||
* the name of that modifier.
|
||||
*/
|
||||
void ipc_event_modifier(uint32_t modifier, const char *state);
|
||||
/**
|
||||
* Send IPC keyboard binding event.
|
||||
*/
|
||||
void ipc_event_binding_keyboard(struct sway_binding *sb);
|
||||
const char *swayc_type_string(enum swayc_types type);
|
||||
|
||||
/**
|
||||
* Send pixel data to registered clients.
|
||||
*/
|
||||
void ipc_get_pixels(wlc_handle output);
|
||||
|
||||
#endif
|
||||
78
include/sway/layout.h
Normal file
78
include/sway/layout.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#ifndef _SWAY_LAYOUT_H
|
||||
#define _SWAY_LAYOUT_H
|
||||
|
||||
#include <wlc/wlc.h>
|
||||
#include "log.h"
|
||||
#include "list.h"
|
||||
#include "container.h"
|
||||
#include "focus.h"
|
||||
|
||||
extern list_t *scratchpad;
|
||||
|
||||
extern int min_sane_w;
|
||||
extern int min_sane_h;
|
||||
|
||||
// Set initial values for root_container
|
||||
void init_layout(void);
|
||||
|
||||
// Returns the index of child for its parent
|
||||
int index_child(const swayc_t *child);
|
||||
|
||||
// Adds child to parent, if parent has no focus, it is set to child
|
||||
// parent must be of type C_WORKSPACE or C_CONTAINER
|
||||
void add_child(swayc_t *parent, swayc_t *child);
|
||||
|
||||
// Adds child to parent at index, if parent has no focus, it is set to child
|
||||
// parent must be of type C_WORKSPACE or C_CONTAINER
|
||||
void insert_child(swayc_t *parent, swayc_t *child, int index);
|
||||
|
||||
// Adds child as floating window to ws, if there is no focus it is set to child.
|
||||
// ws must be of type C_WORKSPACE
|
||||
void add_floating(swayc_t *ws, swayc_t *child);
|
||||
|
||||
// insert child after sibling in parents children.
|
||||
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
|
||||
|
||||
// Replace child with new_child in parents children
|
||||
// new_child will inherit childs geometry, childs geometry will be reset
|
||||
// if parents focus is on child, it will be changed to new_child
|
||||
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
||||
|
||||
// Remove child from its parent, if focus is on child, focus will be changed to
|
||||
// a sibling, or to a floating window, or NULL
|
||||
swayc_t *remove_child(swayc_t *child);
|
||||
|
||||
// 2 containers are swapped, they inherit eachothers focus
|
||||
void swap_container(swayc_t *a, swayc_t *b);
|
||||
|
||||
// 2 Containers geometry are swapped, used with `swap_container`
|
||||
void swap_geometry(swayc_t *a, swayc_t *b);
|
||||
|
||||
void move_container(swayc_t* container, enum movement_direction direction);
|
||||
void move_container_to(swayc_t* container, swayc_t* destination);
|
||||
void move_workspace_to(swayc_t* workspace, swayc_t* destination);
|
||||
|
||||
// Layout
|
||||
/**
|
||||
* Update child container geometries when switching between layouts.
|
||||
*/
|
||||
void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout);
|
||||
void update_geometry(swayc_t *view);
|
||||
void arrange_windows(swayc_t *container, double width, double height);
|
||||
void arrange_backgrounds(void);
|
||||
|
||||
swayc_t *get_focused_container(swayc_t *parent);
|
||||
swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir);
|
||||
swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_direction dir, swayc_t *limit);
|
||||
|
||||
void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge edge);
|
||||
|
||||
void layout_log(const swayc_t *c, int depth);
|
||||
void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4)));
|
||||
|
||||
/**
|
||||
* Get default layout.
|
||||
*/
|
||||
enum swayc_layouts default_layout(swayc_t *output);
|
||||
|
||||
#endif
|
||||
24
include/sway/output.h
Normal file
24
include/sway/output.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef _SWAY_OUTPUT_H
|
||||
#define _SWAY_OUTPUT_H
|
||||
|
||||
#include "container.h"
|
||||
#include "focus.h"
|
||||
|
||||
// Position is absolute coordinates on the edge where the adjacent output
|
||||
// should be searched for.
|
||||
swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos);
|
||||
swayc_t *swayc_adjacent_output(swayc_t *output, enum movement_direction dir, const struct wlc_point *abs_pos, bool pick_closest);
|
||||
|
||||
// Place absolute coordinates for given container into given wlc_point.
|
||||
void get_absolute_position(swayc_t *container, struct wlc_point *point);
|
||||
|
||||
// Place absolute coordinates for the center point of given container into
|
||||
// given wlc_point.
|
||||
void get_absolute_center_position(swayc_t *container, struct wlc_point *point);
|
||||
|
||||
// stable sort workspaces on this output
|
||||
void sort_workspaces(swayc_t *output);
|
||||
|
||||
void output_get_scaled_size(wlc_handle handle, struct wlc_size *size);
|
||||
|
||||
#endif
|
||||
14
include/sway/resize.h
Normal file
14
include/sway/resize.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _SWAY_RESIZE_H
|
||||
#define _SWAY_RESIZE_H
|
||||
#include <stdbool.h>
|
||||
|
||||
enum resize_dim_types {
|
||||
RESIZE_DIM_PX,
|
||||
RESIZE_DIM_PPT,
|
||||
RESIZE_DIM_DEFAULT,
|
||||
};
|
||||
|
||||
bool set_size(int dimension, bool use_width);
|
||||
bool resize(int dimension, bool use_width, enum resize_dim_types dim_type);
|
||||
|
||||
#endif
|
||||
22
include/sway/workspace.h
Normal file
22
include/sway/workspace.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef _SWAY_WORKSPACE_H
|
||||
#define _SWAY_WORKSPACE_H
|
||||
|
||||
#include <wlc/wlc.h>
|
||||
#include <unistd.h>
|
||||
#include "list.h"
|
||||
#include "layout.h"
|
||||
|
||||
extern char *prev_workspace_name;
|
||||
|
||||
char *workspace_next_name(const char *output_name);
|
||||
swayc_t *workspace_create(const char*);
|
||||
swayc_t *workspace_by_name(const char*);
|
||||
swayc_t *workspace_by_number(const char*);
|
||||
bool workspace_switch(swayc_t*);
|
||||
swayc_t *workspace_output_next();
|
||||
swayc_t *workspace_next();
|
||||
swayc_t *workspace_output_prev();
|
||||
swayc_t *workspace_prev();
|
||||
swayc_t *workspace_for_pid(pid_t pid);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue