aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/background-image.h20
-rw-r--r--include/cairo.h (renamed from include/client/cairo.h)10
-rw-r--r--include/client/buffer.h8
-rw-r--r--include/client/pango.h16
-rw-r--r--include/client/registry.h75
-rw-r--r--include/client/window.h67
-rw-r--r--include/ipc.h1
-rw-r--r--include/log.h33
-rw-r--r--include/meson.build1
-rw-r--r--include/pango.h16
-rw-r--r--include/pool-buffer.h22
-rw-r--r--include/sway.h6
-rw-r--r--include/sway/border.h28
-rw-r--r--include/sway/commands.h45
-rw-r--r--include/sway/config.h159
-rw-r--r--include/sway/container.h357
-rw-r--r--include/sway/criteria.h8
-rw-r--r--include/sway/debug.h7
-rw-r--r--include/sway/desktop.h4
-rw-r--r--include/sway/extensions.h56
-rw-r--r--include/sway/focus.h45
-rw-r--r--include/sway/handlers.h11
-rw-r--r--include/sway/input.h23
-rw-r--r--include/sway/input/cursor.h36
-rw-r--r--include/sway/input/input-manager.h64
-rw-r--r--include/sway/input/keyboard.h30
-rw-r--r--include/sway/input/seat.h111
-rw-r--r--include/sway/input_state.h102
-rw-r--r--include/sway/ipc-json.h13
-rw-r--r--include/sway/ipc-server.h38
-rw-r--r--include/sway/layers.h25
-rw-r--r--include/sway/layout.h85
-rw-r--r--include/sway/output.h53
-rw-r--r--include/sway/server.h57
-rw-r--r--include/sway/tree/container.h192
-rw-r--r--include/sway/tree/layout.h78
-rw-r--r--include/sway/tree/output.h0
-rw-r--r--include/sway/tree/view.h186
-rw-r--r--include/sway/tree/workspace.h26
-rw-r--r--include/sway/workspace.h22
-rw-r--r--include/swaybar/bar.h110
-rw-r--r--include/swaybar/config.h59
-rw-r--r--include/swaybar/event_loop.h4
-rw-r--r--include/swaybar/ipc.h26
-rw-r--r--include/swaybar/render.h22
-rw-r--r--include/swaybar/status_line.h78
-rw-r--r--include/swaylock/seat.h38
-rw-r--r--include/swaylock/swaylock.h98
-rw-r--r--include/unicode.h33
49 files changed, 1328 insertions, 1276 deletions
diff --git a/include/background-image.h b/include/background-image.h
new file mode 100644
index 00000000..15935ffd
--- /dev/null
+++ b/include/background-image.h
@@ -0,0 +1,20 @@
+#ifndef _SWAY_BACKGROUND_IMAGE_H
+#define _SWAY_BACKGROUND_IMAGE_H
+#include "cairo.h"
+
+enum background_mode {
+ BACKGROUND_MODE_STRETCH,
+ BACKGROUND_MODE_FILL,
+ BACKGROUND_MODE_FIT,
+ BACKGROUND_MODE_CENTER,
+ BACKGROUND_MODE_TILE,
+ BACKGROUND_MODE_SOLID_COLOR,
+ BACKGROUND_MODE_INVALID,
+};
+
+enum background_mode parse_background_mode(const char *mode);
+cairo_surface_t *load_background_image(const char *path);
+void render_background_image(cairo_t *cairo, cairo_surface_t *image,
+ enum background_mode mode, int buffer_width, int buffer_height);
+
+#endif
diff --git a/include/client/cairo.h b/include/cairo.h
index e7ef7c7e..31672705 100644
--- a/include/client/cairo.h
+++ b/include/cairo.h
@@ -1,17 +1,19 @@
#ifndef _SWAY_CAIRO_H
#define _SWAY_CAIRO_H
-
#include <stdint.h>
#include <cairo/cairo.h>
void cairo_set_source_u32(cairo_t *cairo, uint32_t color);
-cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image, int width, int height);
+cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
+ int width, int height);
-#ifdef WITH_GDK_PIXBUF
+#include "config.h"
+#ifdef HAVE_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>
-cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdkbuf);
+cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(
+ const GdkPixbuf *gdkbuf);
#endif //WITH_GDK_PIXBUF
#endif
diff --git a/include/client/buffer.h b/include/client/buffer.h
deleted file mode 100644
index eb9973ed..00000000
--- a/include/client/buffer.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _BUFFER_H
-#define _BUFFER_H
-
-#include "client/window.h"
-
-struct buffer *get_next_buffer(struct window *state);
-
-#endif
diff --git a/include/client/pango.h b/include/client/pango.h
deleted file mode 100644
index dd2f53c3..00000000
--- a/include/client/pango.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _SWAY_CLIENT_PANGO_H
-#define _SWAY_CLIENT_PANGO_H
-
-#include <cairo/cairo.h>
-#include <pango/pangocairo.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text,
- int32_t scale, bool markup);
-void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
- int32_t scale, bool markup, const char *fmt, ...);
-void pango_printf(cairo_t *cairo, const char *font, int32_t scale, bool markup, const char *fmt, ...);
-
-#endif
diff --git a/include/client/registry.h b/include/client/registry.h
deleted file mode 100644
index 9dfbd835..00000000
--- a/include/client/registry.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef _SWAY_CLIENT_REGISTRY_H
-#define _SWAY_CLIENT_REGISTRY_H
-
-#include <wayland-client.h>
-#include <xkbcommon/xkbcommon.h>
-#include "wayland-desktop-shell-client-protocol.h"
-#include "wayland-swaylock-client-protocol.h"
-#include "list.h"
-
-enum mod_bit {
- MOD_SHIFT = 1<<0,
- MOD_CAPS = 1<<1,
- MOD_CTRL = 1<<2,
- MOD_ALT = 1<<3,
- MOD_MOD2 = 1<<4,
- MOD_MOD3 = 1<<5,
- MOD_LOGO = 1<<6,
- MOD_MOD5 = 1<<7,
-};
-
-enum mask {
- MASK_SHIFT,
- MASK_CAPS,
- MASK_CTRL,
- MASK_ALT,
- MASK_MOD2,
- MASK_MOD3,
- MASK_LOGO,
- MASK_MOD5,
- MASK_LAST
-};
-
-struct output_state {
- struct wl_output *output;
- uint32_t flags;
- uint32_t width, height;
- uint32_t scale;
-};
-
-struct xkb {
- struct xkb_state *state;
- struct xkb_context *context;
- struct xkb_keymap *keymap;
- xkb_mod_mask_t masks[MASK_LAST];
-};
-
-struct input {
- struct xkb xkb;
-
- xkb_keysym_t sym;
- uint32_t code;
- uint32_t last_code;
- uint32_t modifiers;
-
- void (*notify)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code, uint32_t codepoint);
-};
-
-struct registry {
- struct wl_compositor *compositor;
- struct wl_display *display;
- struct wl_pointer *pointer;
- struct wl_keyboard *keyboard;
- struct wl_seat *seat;
- struct wl_shell *shell;
- struct wl_shm *shm;
- struct desktop_shell *desktop_shell;
- struct lock *swaylock;
- struct input *input;
- list_t *outputs;
-};
-
-struct registry *registry_poll(void);
-void registry_teardown(struct registry *registry);
-
-#endif
diff --git a/include/client/window.h b/include/client/window.h
deleted file mode 100644
index 8af8225c..00000000
--- a/include/client/window.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef _CLIENT_H
-#define _CLIENT_H
-
-#include <wayland-client.h>
-#include "wayland-desktop-shell-client-protocol.h"
-#include <cairo/cairo.h>
-#include <pango/pangocairo.h>
-#include <stdbool.h>
-#include "list.h"
-#include "client/registry.h"
-
-struct window;
-
-struct buffer {
- struct wl_buffer *buffer;
- cairo_surface_t *surface;
- cairo_t *cairo;
- PangoContext *pango;
- uint32_t width, height;
- bool busy;
-};
-
-struct cursor {
- struct wl_surface *surface;
- struct wl_cursor_theme *cursor_theme;
- struct wl_cursor *cursor;
- struct wl_pointer *pointer;
-};
-
-enum scroll_direction {
- SCROLL_UP,
- SCROLL_DOWN,
- SCROLL_LEFT,
- SCROLL_RIGHT,
-};
-
-struct pointer_input {
- int last_x;
- int last_y;
-
- void (*notify_button)(struct window *window, int x, int y, uint32_t button, uint32_t state_w);
- void (*notify_scroll)(struct window *window, enum scroll_direction direction);
-};
-
-struct window {
- struct registry *registry;
- struct buffer buffers[2];
- struct buffer *buffer;
- struct wl_surface *surface;
- struct wl_shell_surface *shell_surface;
- struct wl_callback *frame_cb;
- struct cursor cursor;
- uint32_t width, height;
- int32_t scale;
- char *font;
- cairo_t *cairo;
- struct pointer_input pointer_input;
-};
-
-struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height,
- int32_t scale, bool shell_surface);
-void window_teardown(struct window *state);
-int window_prerender(struct window *state);
-int window_render(struct window *state);
-void window_make_shell(struct window *window);
-
-#endif
diff --git a/include/ipc.h b/include/ipc.h
index 2b16dc50..9665a88d 100644
--- a/include/ipc.h
+++ b/include/ipc.h
@@ -23,7 +23,6 @@ enum ipc_command_type {
IPC_EVENT_BINDING = ((1<<31) | 5),
IPC_EVENT_MODIFIER = ((1<<31) | 6),
IPC_EVENT_INPUT = ((1<<31) | 7),
- IPC_SWAY_GET_PIXELS = 0x81
};
#endif
diff --git a/include/log.h b/include/log.h
index a1e33fa2..a9748127 100644
--- a/include/log.h
+++ b/include/log.h
@@ -1,38 +1,15 @@
#ifndef _SWAY_LOG_H
#define _SWAY_LOG_H
#include <stdbool.h>
+#include <wlr/util/log.h>
-typedef enum {
- L_SILENT = 0,
- L_ERROR = 1,
- L_INFO = 2,
- L_DEBUG = 3,
-} log_importance_t;
-
-void init_log(log_importance_t verbosity);
-void set_log_level(log_importance_t verbosity);
-log_importance_t get_log_level(void);
-void reset_log_level(void);
-// returns whether debug logging is on after switching.
-bool toggle_debug_logging(void);
-void sway_log_colors(int mode);
-void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3)));
-
-void _sway_abort(const char *filename, int line, const char* format, ...) __attribute__((format(printf,3,4)));
+void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
#define sway_abort(FMT, ...) \
- _sway_abort(__FILE__, __LINE__, FMT, ##__VA_ARGS__)
+ _sway_abort("[%s:%d] " FMT, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
-bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) __attribute__((format(printf,4,5)));
+bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
#define sway_assert(COND, FMT, ...) \
- _sway_assert(COND, __FILE__, __LINE__, "%s:" FMT, __PRETTY_FUNCTION__, ##__VA_ARGS__)
-
-void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) __attribute__((format(printf,4,5)));
-
-#define sway_log(VERBOSITY, FMT, ...) \
- _sway_log(__FILE__, __LINE__, VERBOSITY, FMT, ##__VA_ARGS__)
-
-#define sway_vlog(VERBOSITY, FMT, VA_ARGS) \
- _sway_vlog(__FILE__, __LINE__, VERBOSITY, FMT, VA_ARGS)
+ _sway_assert(COND, "[%s:%d] %s:" FMT, wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
void error_handler(int sig);
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 00000000..65ed027a
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1 @@
+configure_file(output: 'config.h', configuration: conf_data)
diff --git a/include/pango.h b/include/pango.h
new file mode 100644
index 00000000..f6325f28
--- /dev/null
+++ b/include/pango.h
@@ -0,0 +1,16 @@
+#ifndef _SWAY_PANGO_H
+#define _SWAY_PANGO_H
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <cairo/cairo.h>
+#include <pango/pangocairo.h>
+
+PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
+ const char *text, int32_t scale, bool markup);
+void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
+ int32_t scale, bool markup, const char *fmt, ...);
+void pango_printf(cairo_t *cairo, const char *font,
+ int32_t scale, bool markup, const char *fmt, ...);
+
+#endif
diff --git a/include/pool-buffer.h b/include/pool-buffer.h
new file mode 100644
index 00000000..856f7c8c
--- /dev/null
+++ b/include/pool-buffer.h
@@ -0,0 +1,22 @@
+#ifndef _SWAY_BUFFERS_H
+#define _SWAY_BUFFERS_H
+#include <cairo/cairo.h>
+#include <pango/pangocairo.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <wayland-client.h>
+
+struct pool_buffer {
+ struct wl_buffer *buffer;
+ cairo_surface_t *surface;
+ cairo_t *cairo;
+ PangoContext *pango;
+ uint32_t width, height;
+ bool busy;
+};
+
+struct pool_buffer *get_next_buffer(struct wl_shm *shm,
+ struct pool_buffer pool[static 2], uint32_t width, uint32_t height);
+void destroy_buffer(struct pool_buffer *buffer);
+
+#endif
diff --git a/include/sway.h b/include/sway.h
deleted file mode 100644
index b5cfb668..00000000
--- a/include/sway.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _SWAY_SWAY_H
-#define _SWAY_SWAY_H
-
-void sway_terminate(int exit_code);
-
-#endif
diff --git a/include/sway/border.h b/include/sway/border.h
deleted file mode 100644
index c30c9da3..00000000
--- a/include/sway/border.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#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
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 660da2c2..dbebaa49 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -1,12 +1,7 @@
#ifndef _SWAY_COMMANDS_H
#define _SWAY_COMMANDS_H
-#include <stdbool.h>
-#include <json-c/json.h>
-#include <wlc/wlc.h>
-#include "config.h"
-// Container that a called command should act upon. Only valid in command functions.
-extern swayc_t *current_container;
+#include "config.h"
/**
* Indicates the result of a command's execution.
@@ -22,6 +17,7 @@ enum cmd_status {
CMD_BLOCK_BAR,
CMD_BLOCK_BAR_COLORS,
CMD_BLOCK_INPUT,
+ CMD_BLOCK_SEAT,
CMD_BLOCK_COMMANDS,
CMD_BLOCK_IPC,
CMD_BLOCK_IPC_EVENTS,
@@ -46,18 +42,13 @@ enum expected_args {
EXPECTED_EQUAL_TO
};
-struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val);
-struct cmd_results *add_color(const char*, char*, const char*);
-void input_cmd_apply(struct input_config *input);
-void hide_view_in_scratchpad(swayc_t *sp_view);
-
-swayc_t *sp_view;
-int sp_index;
+struct cmd_results *checkarg(int argc, const char *name,
+ enum expected_args type, int val);
/**
- * Parse and handles a command.
+ * Parse and executes a command.
*/
-struct cmd_results *handle_command(char *command, enum command_context context);
+struct cmd_results *execute_command(char *command, struct sway_seat *seat);
/**
* Parse and handles a command during config file loading.
*
@@ -68,7 +59,6 @@ struct cmd_results *config_command(char *command, enum cmd_status block);
* Parses a command policy rule.
*/
struct cmd_results *config_commands_command(char *exec);
-
/**
* Allocates a cmd_results object.
*/
@@ -84,11 +74,8 @@ void free_cmd_results(struct cmd_results *results);
*/
const char *cmd_results_to_json(struct cmd_results *results);
-void remove_view_from_scratchpad(swayc_t *);
-
-/**
- * Actual command function signatures for individual .c files in commands/ directory.
- */
+struct cmd_results *add_color(const char *name,
+ char *buffer, const char *color);
typedef struct cmd_results *sway_cmd(int argc, char **argv);
@@ -108,6 +95,7 @@ sway_cmd cmd_commands;
sway_cmd cmd_debuglog;
sway_cmd cmd_default_border;
sway_cmd cmd_default_floating_border;
+sway_cmd cmd_default_orientation;
sway_cmd cmd_exec;
sway_cmd cmd_exec_always;
sway_cmd cmd_exit;
@@ -126,6 +114,7 @@ sway_cmd cmd_gaps;
sway_cmd cmd_hide_edge_borders;
sway_cmd cmd_include;
sway_cmd cmd_input;
+sway_cmd cmd_seat;
sway_cmd cmd_ipc;
sway_cmd cmd_kill;
sway_cmd cmd_layout;
@@ -134,10 +123,10 @@ sway_cmd cmd_mark;
sway_cmd cmd_mode;
sway_cmd cmd_mouse_warping;
sway_cmd cmd_move;
+sway_cmd cmd_opacity;
sway_cmd cmd_new_float;
sway_cmd cmd_new_window;
sway_cmd cmd_no_focus;
-sway_cmd cmd_orientation;
sway_cmd cmd_output;
sway_cmd cmd_permit;
sway_cmd cmd_reject;
@@ -153,6 +142,7 @@ sway_cmd cmd_splith;
sway_cmd cmd_splitt;
sway_cmd cmd_splitv;
sway_cmd cmd_sticky;
+sway_cmd cmd_swaybg_command;
sway_cmd cmd_unmark;
sway_cmd cmd_workspace;
sway_cmd cmd_ws_auto_back_and_forth;
@@ -195,17 +185,28 @@ sway_cmd bar_colors_cmd_statusline;
sway_cmd bar_colors_cmd_focused_statusline;
sway_cmd bar_colors_cmd_urgent_workspace;
+sway_cmd input_cmd_seat;
sway_cmd input_cmd_accel_profile;
sway_cmd input_cmd_click_method;
sway_cmd input_cmd_drag_lock;
sway_cmd input_cmd_dwt;
sway_cmd input_cmd_events;
sway_cmd input_cmd_left_handed;
+sway_cmd input_cmd_map_to_output;
sway_cmd input_cmd_middle_emulation;
sway_cmd input_cmd_natural_scroll;
sway_cmd input_cmd_pointer_accel;
sway_cmd input_cmd_scroll_method;
sway_cmd input_cmd_tap;
+sway_cmd input_cmd_xkb_layout;
+sway_cmd input_cmd_xkb_model;
+sway_cmd input_cmd_xkb_options;
+sway_cmd input_cmd_xkb_rules;
+sway_cmd input_cmd_xkb_variant;
+
+sway_cmd seat_cmd_attach;
+sway_cmd seat_cmd_fallback;
+sway_cmd seat_cmd_cursor;
sway_cmd cmd_ipc_cmd;
sway_cmd cmd_ipc_events;
diff --git a/include/sway/config.h b/include/sway/config.h
index a05d5ede..ed49fbbd 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -1,18 +1,18 @@
#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 <string.h>
#include <time.h>
-#include "wayland-desktop-shell-server-protocol.h"
+#include <wlr/types/wlr_box.h>
+#include <xkbcommon/xkbcommon.h>
#include "list.h"
-#include "layout.h"
-#include "container.h"
+#include "tree/layout.h"
+#include "tree/container.h"
+#include "wlr-layer-shell-unstable-v1-protocol.h"
+
+// TODO: Refactor this shit
/**
* Describes a variable created via the `set` command.
@@ -47,11 +47,12 @@ struct sway_mouse_binding {
*/
struct sway_mode {
char *name;
- list_t *bindings;
+ list_t *keysym_bindings;
+ list_t *keycode_bindings;
};
/**
- * libinput options for input devices
+ * options for input devices
*/
struct input_config {
char *identifier;
@@ -68,8 +69,33 @@ struct input_config {
int send_events;
int tap;
+ char *xkb_layout;
+ char *xkb_model;
+ char *xkb_options;
+ char *xkb_rules;
+ char *xkb_variant;
+
+ char *mapped_output;
+
bool capturable;
- struct wlc_geometry region;
+ struct wlr_box region;
+};
+
+/**
+ * Options for misc device configurations that happen in the seat block
+ */
+struct seat_attachment_config {
+ char *identifier;
+ // TODO other things are configured here for some reason
+};
+
+/**
+ * Options for multiseat and other misc device configurations
+ */
+struct seat_config {
+ char *name;
+ int fallback; // -1 means not set
+ list_t *attachments; // list of seat_attachment configs
};
/**
@@ -81,8 +107,11 @@ struct output_config {
char *name;
int enabled;
int width, height;
+ float refresh_rate;
int x, y;
- int scale;
+ float scale;
+ int32_t transform;
+
char *background;
char *background_option;
};
@@ -126,24 +155,13 @@ struct bar_config {
char *id;
uint32_t modifier;
list_t *outputs;
- enum desktop_shell_panel_position position;
+ char *position;
list_t *bindings;
char *status_command;
bool pango_markup;
char *swaybar_command;
char *font;
int height; // -1 not defined
-
-#ifdef ENABLE_TRAY
- // Tray
- char *tray_output;
- char *icon_theme;
- uint32_t tray_padding;
- uint32_t activate_button;
- uint32_t context_button;
- uint32_t secondary_button;
-#endif
-
bool workspace_buttons;
bool wrap_scroll;
char *separator_symbol;
@@ -260,11 +278,13 @@ struct sway_config {
list_t *pid_workspaces;
list_t *output_configs;
list_t *input_configs;
+ list_t *seat_configs;
list_t *criteria;
list_t *no_focus;
list_t *active_bar_modifiers;
struct sway_mode *current_mode;
struct bar_config *current_bar;
+ char *swaybg_command;
uint32_t floating_mod;
uint32_t dragging_key;
uint32_t resizing_key;
@@ -272,8 +292,8 @@ struct sway_config {
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;
+ enum sway_container_layout default_orientation;
+ enum sway_container_layout default_layout;
char *font;
int font_height;
@@ -286,7 +306,6 @@ struct sway_config {
bool reloading;
bool reading;
bool auto_back_and_forth;
- bool seamless_mouse;
bool show_marks;
bool edge_gaps;
@@ -297,8 +316,8 @@ struct sway_config {
list_t *config_chain;
const char *current_config;
- enum swayc_border_types border;
- enum swayc_border_types floating_border;
+ enum sway_container_border border;
+ enum sway_container_border floating_border;
int border_thickness;
int floating_border_thickness;
enum edge_border_types hide_edge_borders;
@@ -323,6 +342,14 @@ struct sway_config {
list_t *command_policies;
list_t *feature_policies;
list_t *ipc_policies;
+
+ // Context for command handlers
+ struct {
+ struct input_config *input_config;
+ struct seat_config *seat_config;
+ struct sway_seat *seat;
+ struct sway_container *current_container;
+ } handler_context;
};
void pid_workspace_add(struct pid_workspace *pw);
@@ -348,6 +375,11 @@ bool read_config(FILE *file, struct sway_config *config);
* Free config struct
*/
void free_config(struct sway_config *config);
+
+void config_clear_handler_context(struct sway_config *config);
+
+void free_sway_variable(struct sway_variable *var);
+
/**
* Does variable replacement for a string based on the config's currently loaded variables.
*/
@@ -356,51 +388,74 @@ char *do_var_replacement(char *str);
struct cmd_results *check_security_config();
int input_identifier_cmp(const void *item, const void *data);
+
+struct input_config *new_input_config(const char* identifier);
+
void merge_input_config(struct input_config *dst, struct input_config *src);
-void apply_input_config(struct input_config *ic, struct libinput_device *dev);
+
+struct input_config *copy_input_config(struct input_config *ic);
+
void free_input_config(struct input_config *ic);
+void apply_input_config(struct input_config *input);
+
+int seat_name_cmp(const void *item, const void *data);
+
+struct seat_config *new_seat_config(const char* name);
+
+void merge_seat_config(struct seat_config *dst, struct seat_config *src);
+
+struct seat_config *copy_seat_config(struct seat_config *seat);
+
+void free_seat_config(struct seat_config *ic);
+
+struct seat_attachment_config *seat_attachment_config_new();
+
+struct seat_attachment_config *seat_config_get_attachment(
+ struct seat_config *seat_config, char *identifier);
+
+void apply_seat_config(struct seat_config *seat);
+
int output_name_cmp(const void *item, const void *data);
+
+void output_get_identifier(char *identifier, size_t len,
+ struct sway_output *output);
+
+struct output_config *new_output_config(const char *name);
+
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);
+void apply_output_config(struct output_config *oc,
+ struct sway_container *output);
+
+void free_output_config(struct output_config *oc);
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);
+struct sway_binding *sway_binding_dup(struct sway_binding *sb);
void load_swaybars();
+
+void invoke_swaybar(struct bar_config *bar);
+
void terminate_swaybg(pid_t pid);
-/**
- * Allocate and initialize default bar configuration.
- */
struct bar_config *default_bar_config(void);
-/**
- * Global config singleton.
- */
+void free_bar_config(struct bar_config *bar);
+
+/* Global config singleton. */
extern struct sway_config *config;
-/**
- * Config file currently being read.
- */
+/* Config file currently being read */
extern const char *current_config_path;
#endif
diff --git a/include/sway/container.h b/include/sway/container.h
deleted file mode 100644
index 37192ce3..00000000
--- a/include/sway/container.h
+++ /dev/null
@@ -1,357 +0,0 @@
-#ifndef _SWAY_CONTAINER_H
-#define _SWAY_CONTAINER_H
-#include <sys/types.h>
-#include <wlc/wlc.h>
-#include <stdint.h>
-
-#include "list.h"
-
-typedef struct sway_container swayc_t;
-
-extern swayc_t root_container;
-extern swayc_t *current_focus;
-
-/**
- * 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 */
-
- /* Awesome/Monad style auto layouts */
- L_AUTO_LEFT,
- L_AUTO_RIGHT,
- L_AUTO_TOP,
- L_AUTO_BOTTOM,
-
- L_AUTO_FIRST = L_AUTO_LEFT,
- L_AUTO_LAST = L_AUTO_BOTTOM,
-
- // 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;
-
- /**
- * A unique ID to identify this container. Primarily used in the
- * get_tree JSON output.
- */
- size_t id;
-
- enum swayc_types type;
- enum swayc_layouts layout;
- enum swayc_layouts prev_layout;
- enum swayc_layouts workspace_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 *instance;
- 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;
-
- /**
- * Number of master views in auto layouts.
- */
- size_t nb_master;
-
- /**
- * Number of slave groups (e.g. columns) in auto layouts.
- */
- size_t nb_slave_groups;
-
- /**
- * Marks applied to the container, list_t of char*.
- */
- list_t *marks;
-};
-
-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);
-/**
- * Finds the first container following a callback.
- */
-swayc_t *container_find(swayc_t *container, bool (*f)(swayc_t *, const void *), const void *data);
-
-/**
- * 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);
-
-/**
- * Assign layout to a container. Needed due to workspace container specifics.
- * Workspace should always have either L_VERT or L_HORIZ layout.
- */
-swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout);
-
-#endif
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index c5ed9857..ec256ddb 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -1,7 +1,7 @@
#ifndef _SWAY_CRITERIA_H
#define _SWAY_CRITERIA_H
-#include "container.h"
+#include "tree/container.h"
#include "list.h"
/**
@@ -31,12 +31,12 @@ 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);
+list_t *criteria_for(struct sway_container *cont);
// Returns a list of all containers that match the given list of tokens.
-list_t *container_for(list_t *tokens);
+list_t *container_for_crit_tokens(list_t *tokens);
// Returns true if any criteria in the given list matches this container
-bool criteria_any(swayc_t *cont, list_t *criteria);
+bool criteria_any(struct sway_container *cont, list_t *criteria);
#endif
diff --git a/include/sway/debug.h b/include/sway/debug.h
new file mode 100644
index 00000000..2430d319
--- /dev/null
+++ b/include/sway/debug.h
@@ -0,0 +1,7 @@
+#ifndef SWAY_DEBUG_H
+#define SWAY_DEBUG_H
+
+extern bool enable_debug_tree;
+void update_debug_tree();
+
+#endif
diff --git a/include/sway/desktop.h b/include/sway/desktop.h
new file mode 100644
index 00000000..f1ad759a
--- /dev/null
+++ b/include/sway/desktop.h
@@ -0,0 +1,4 @@
+#include <wlr/types/wlr_surface.h>
+
+void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
+ bool whole);
diff --git a/include/sway/extensions.h b/include/sway/extensions.h
deleted file mode 100644
index 5212eb3a..00000000
--- a/include/sway/extensions.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#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;
-};
-
-struct decoration_state {
- list_t *csd_resources;
-};
-
-extern struct desktop_shell_state desktop_shell;
-extern struct decoration_state decoration_state;
-
-void register_extensions(void);
-
-void server_decoration_enable_csd(wlc_handle handle);
-
-#endif
diff --git a/include/sway/focus.h b/include/sway/focus.h
deleted file mode 100644
index 652cdccc..00000000
--- a/include/sway/focus.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef _SWAY_FOCUS_H
-#define _SWAY_FOCUS_H
-enum movement_direction {
- MOVE_LEFT,
- MOVE_RIGHT,
- MOVE_UP,
- MOVE_DOWN,
- MOVE_PARENT,
- MOVE_CHILD,
- MOVE_NEXT,
- MOVE_PREV,
- MOVE_FIRST
-};
-
-#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
diff --git a/include/sway/handlers.h b/include/sway/handlers.h
deleted file mode 100644
index 956b98f4..00000000
--- a/include/sway/handlers.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#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
diff --git a/include/sway/input.h b/include/sway/input.h
deleted file mode 100644
index 4ed9bffe..00000000
--- a/include/sway/input.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#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
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h
new file mode 100644
index 00000000..fcd94437
--- /dev/null
+++ b/include/sway/input/cursor.h
@@ -0,0 +1,36 @@
+#ifndef _SWAY_INPUT_CURSOR_H
+#define _SWAY_INPUT_CURSOR_H
+#include <stdint.h>
+#include "sway/input/seat.h"
+
+struct sway_cursor {
+ struct sway_seat *seat;
+ struct wlr_cursor *cursor;
+ struct wlr_xcursor_manager *xcursor_manager;
+
+ struct wl_client *image_client;
+
+ struct wl_listener motion;
+ struct wl_listener motion_absolute;
+ struct wl_listener button;
+ struct wl_listener axis;
+
+ struct wl_listener touch_down;
+ struct wl_listener touch_up;
+ struct wl_listener touch_motion;
+
+ struct wl_listener tool_axis;
+ struct wl_listener tool_tip;
+ struct wl_listener tool_button;
+ uint32_t tool_buttons;
+
+ struct wl_listener request_set_cursor;
+};
+
+void sway_cursor_destroy(struct sway_cursor *cursor);
+struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
+void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time);
+void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
+ uint32_t button, enum wlr_button_state state);
+
+#endif
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
new file mode 100644
index 00000000..89a3ac71
--- /dev/null
+++ b/include/sway/input/input-manager.h
@@ -0,0 +1,64 @@
+#ifndef _SWAY_INPUT_INPUT_MANAGER_H
+#define _SWAY_INPUT_INPUT_MANAGER_H
+#include <libinput.h>
+#include <wlr/types/wlr_input_inhibitor.h>
+#include "sway/server.h"
+#include "sway/config.h"
+#include "list.h"
+
+/**
+ * The global singleton input manager
+ * TODO: make me not a global
+ */
+extern struct sway_input_manager *input_manager;
+
+struct sway_input_device {
+ char *identifier;
+ struct wlr_input_device *wlr_device;
+ struct wl_list link;
+ struct wl_listener device_destroy;
+};
+
+struct sway_input_manager {
+ struct sway_server *server;
+ struct wl_list devices;
+ struct wl_list seats;
+
+ struct wlr_input_inhibit_manager *inhibit;
+
+ struct wl_listener new_input;
+ struct wl_listener inhibit_activate;
+ struct wl_listener inhibit_deactivate;
+};
+
+struct sway_input_manager *input_manager_create(struct sway_server *server);
+
+bool input_manager_has_focus(struct sway_input_manager *input,
+ struct sway_container *container);
+
+void input_manager_set_focus(struct sway_input_manager *input,
+ struct sway_container *container);
+
+void input_manager_configure_xcursor(struct sway_input_manager *input);
+
+void input_manager_apply_input_config(struct sway_input_manager *input,
+ struct input_config *input_config);
+
+void input_manager_apply_seat_config(struct sway_input_manager *input,
+ struct seat_config *seat_config);
+
+struct sway_seat *input_manager_get_default_seat(
+ struct sway_input_manager *input);
+
+struct sway_seat *input_manager_get_seat(struct sway_input_manager *input,
+ const char *seat_name);
+
+/**
+ * Gets the last seat the user interacted with
+ */
+struct sway_seat *input_manager_current_seat(struct sway_input_manager *input);
+
+struct input_config *input_device_get_config(struct sway_input_device *device);
+
+
+#endif
diff --git a/include/sway/input/keyboard.h b/include/sway/input/keyboard.h
new file mode 100644
index 00000000..8ec3eb35
--- /dev/null
+++ b/include/sway/input/keyboard.h
@@ -0,0 +1,30 @@
+#ifndef _SWAY_INPUT_KEYBOARD_H
+#define _SWAY_INPUT_KEYBOARD_H
+
+#include "sway/input/seat.h"
+
+#define SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP 32
+
+struct sway_keyboard {
+ struct sway_seat_device *seat_device;
+
+ struct xkb_keymap *keymap;
+
+ struct wl_listener keyboard_key;
+ struct wl_listener keyboard_modifiers;
+
+ xkb_keysym_t pressed_keysyms_translated[SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP];
+ uint32_t modifiers_translated;
+
+ xkb_keysym_t pressed_keysyms_raw[SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP];
+ uint32_t modifiers_raw;
+};
+
+struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat,
+ struct sway_seat_device *device);
+
+void sway_keyboard_configure(struct sway_keyboard *keyboard);
+
+void sway_keyboard_destroy(struct sway_keyboard *keyboard);
+
+#endif
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
new file mode 100644
index 00000000..ff76841e
--- /dev/null
+++ b/include/sway/input/seat.h
@@ -0,0 +1,111 @@
+#ifndef _SWAY_INPUT_SEAT_H
+#define _SWAY_INPUT_SEAT_H
+
+#include <wlr/types/wlr_layer_shell.h>
+#include <wlr/types/wlr_seat.h>
+#include "sway/input/input-manager.h"
+
+struct sway_seat_device {
+ struct sway_seat *sway_seat;
+ struct sway_input_device *input_device;
+ struct sway_keyboard *keyboard;
+ struct wl_list link; // sway_seat::devices
+};
+
+struct sway_seat_container {
+ struct sway_seat *seat;
+ struct sway_container *container;
+
+ struct wl_list link; // sway_seat::focus_stack
+
+ struct wl_listener destroy;
+};
+
+struct sway_seat {
+ struct wlr_seat *wlr_seat;
+ struct sway_cursor *cursor;
+ struct sway_input_manager *input;
+
+ bool has_focus;
+ struct wl_list focus_stack; // list of containers in focus order
+
+ // If the focused layer is set, views cannot receive keyboard focus
+ struct wlr_layer_surface *focused_layer;
+
+ // If exclusive_client is set, no other clients will receive input events
+ struct wl_client *exclusive_client;
+
+ struct wl_listener focus_destroy;
+ struct wl_listener new_container;
+
+ struct wl_list devices; // sway_seat_device::link
+
+ struct wl_list link; // input_manager::seats
+};
+
+struct sway_seat *seat_create(struct sway_input_manager *input,
+ const char *seat_name);
+
+void seat_destroy(struct sway_seat *seat);
+
+void seat_add_device(struct sway_seat *seat,
+ struct sway_input_device *device);
+
+void seat_configure_device(struct sway_seat *seat,
+ struct sway_input_device *device);
+
+void seat_remove_device(struct sway_seat *seat,
+ struct sway_input_device *device);
+
+void seat_configure_xcursor(struct sway_seat *seat);
+
+void seat_set_focus(struct sway_seat *seat, struct sway_container *container);
+
+void seat_set_focus_warp(struct sway_seat *seat,
+ struct sway_container *container, bool warp);
+
+void seat_set_focus_surface(struct sway_seat *seat,
+ struct wlr_surface *surface);
+
+void seat_set_focus_layer(struct sway_seat *seat,
+ struct wlr_layer_surface *layer);
+
+void seat_set_exclusive_client(struct sway_seat *seat,
+ struct wl_client *client);
+
+struct sway_container *seat_get_focus(struct sway_seat *seat);
+
+/**
+ * Return the last container to be focused for the seat (or the most recently
+ * opened if no container has received focused) that is a child of the given
+ * container. The focus-inactive container of the root window is the focused
+ * container for the seat (if the seat does have focus). This function can be
+ * used to determine what container gets focused next if the focused container
+ * is destroyed, or focus moves to a container with children and we need to
+ * descend into the next leaf in focus order.
+ */
+struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
+ struct sway_container *container);
+
+/**
+ * Descend into the focus stack to find the focus-inactive view. Useful for
+ * container placement when they change position in the tree.
+ */
+struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat,
+ struct sway_container *container);
+
+/**
+ * Iterate over the focus-inactive children of the container calling the
+ * function on each.
+ */
+void seat_focus_inactive_children_for_each(struct sway_seat *seat,
+ struct sway_container *container,
+ void (*f)(struct sway_container *container, void *data), void *data);
+
+void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
+
+struct seat_config *seat_get_config(struct sway_seat *seat);
+
+bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
+
+#endif
diff --git a/include/sway/input_state.h b/include/sway/input_state.h
deleted file mode 100644
index fd5a3a25..00000000
--- a/include/sway/input_state.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#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(double new_x, double new_y, 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
-
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h
index 3a5af0f5..7d87d377 100644
--- a/include/sway/ipc-json.h
+++ b/include/sway/ipc-json.h
@@ -1,15 +1,14 @@
#ifndef _SWAY_IPC_JSON_H
#define _SWAY_IPC_JSON_H
-
#include <json-c/json.h>
-#include "config.h"
-#include "container.h"
+#include "sway/tree/container.h"
+#include "sway/input/input-manager.h"
json_object *ipc_json_get_version();
+
+json_object *ipc_json_describe_container(struct sway_container *c);
+json_object *ipc_json_describe_container_recursive(struct sway_container *c);
+json_object *ipc_json_describe_input(struct sway_input_device *device);
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);
-json_object *ipc_json_describe_input(struct libinput_device *device);
#endif
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h
index 1d199134..c3389fe8 100644
--- a/include/sway/ipc-server.h
+++ b/include/sway/ipc-server.h
@@ -1,41 +1,21 @@
#ifndef _SWAY_IPC_SERVER_H
#define _SWAY_IPC_SERVER_H
+#include <sys/socket.h>
+#include "sway/tree/container.h"
+#include "ipc.h"
-#include <wlc/wlc.h>
+struct sway_server;
-#include "container.h"
-#include "config.h"
-#include "ipc.h"
+void ipc_init(struct sway_server *server);
-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_workspace(struct sway_container *old,
+ struct sway_container *new, const char *change);
+void ipc_event_window(struct sway_container *window, 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
diff --git a/include/sway/layers.h b/include/sway/layers.h
new file mode 100644
index 00000000..ee47c5ad
--- /dev/null
+++ b/include/sway/layers.h
@@ -0,0 +1,25 @@
+#ifndef _SWAY_LAYERS_H
+#define _SWAY_LAYERS_H
+#include <stdbool.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_surface.h>
+#include <wlr/types/wlr_layer_shell.h>
+
+struct sway_layer_surface {
+ struct wlr_layer_surface *layer_surface;
+ struct wl_list link;
+
+ struct wl_listener destroy;
+ struct wl_listener map;
+ struct wl_listener unmap;
+ struct wl_listener surface_commit;
+ struct wl_listener output_destroy;
+
+ bool configured;
+ struct wlr_box geo;
+};
+
+struct sway_output;
+void arrange_layers(struct sway_output *output);
+
+#endif
diff --git a/include/sway/layout.h b/include/sway/layout.h
deleted file mode 100644
index f0791588..00000000
--- a/include/sway/layout.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#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, int move_amt);
-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);
-
-bool is_auto_layout(enum swayc_layouts layout);
-int auto_group_start_index(const swayc_t *container, int index);
-int auto_group_end_index(const swayc_t *container, int index);
-size_t auto_group_count(const swayc_t *container);
-size_t auto_group_index(const swayc_t *container, int index);
-bool auto_group_bounds(const swayc_t *container, size_t group_index, int *start, int *end);
-
-#endif
diff --git a/include/sway/output.h b/include/sway/output.h
index e1bdd3f0..56571548 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -1,25 +1,48 @@
#ifndef _SWAY_OUTPUT_H
#define _SWAY_OUTPUT_H
+#include <time.h>
+#include <unistd.h>
+#include <wayland-server.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_output.h>
+#include "sway/tree/view.h"
-#include "container.h"
-#include "focus.h"
+struct sway_server;
+struct sway_container;
-// 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_opposite_output(enum movement_direction dir, 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);
+struct sway_output {
+ struct wlr_output *wlr_output;
+ struct sway_container *swayc;
+ struct sway_server *server;
-// Place absolute coordinates for given container into given wlc_point.
-void get_absolute_position(swayc_t *container, struct wlc_point *point);
+ struct wl_list layers[4]; // sway_layer_surface::link
+ struct wlr_box usable_area;
-// 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);
+ struct timespec last_frame;
+ struct wlr_output_damage *damage;
-// stable sort workspaces on this output
-void sort_workspaces(swayc_t *output);
+ struct wl_listener destroy;
+ struct wl_listener mode;
+ struct wl_listener transform;
+ struct wl_listener scale;
-void output_get_scaled_size(wlc_handle handle, struct wlc_size *size);
+ struct wl_listener damage_destroy;
+ struct wl_listener damage_frame;
+
+ pid_t bg_pid;
+};
+
+void output_damage_whole(struct sway_output *output);
+
+void output_damage_surface(struct sway_output *output, double ox, double oy,
+ struct wlr_surface *surface, bool whole);
+
+void output_damage_view(struct sway_output *output, struct sway_view *view,
+ bool whole);
+
+void output_damage_whole_container(struct sway_output *output,
+ struct sway_container *con);
+
+struct sway_container *output_by_name(const char *name);
#endif
diff --git a/include/sway/server.h b/include/sway/server.h
new file mode 100644
index 00000000..296fbf22
--- /dev/null
+++ b/include/sway/server.h
@@ -0,0 +1,57 @@
+#ifndef _SWAY_SERVER_H
+#define _SWAY_SERVER_H
+#include <stdbool.h>
+#include <wayland-server.h>
+#include <wlr/backend.h>
+#include <wlr/backend/session.h>
+#include <wlr/types/wlr_compositor.h>
+#include <wlr/types/wlr_data_device.h>
+#include <wlr/types/wlr_layer_shell.h>
+#include <wlr/types/wlr_xdg_shell_v6.h>
+#include <wlr/render/wlr_renderer.h>
+// TODO WLR: make Xwayland optional
+#include <wlr/xwayland.h>
+
+struct sway_server {
+ struct wl_display *wl_display;
+ struct wl_event_loop *wl_event_loop;
+ const char *socket;
+
+ struct wlr_backend *backend;
+
+ struct wlr_compositor *compositor;
+ struct wlr_data_device_manager *data_device_manager;
+
+ struct sway_input_manager *input;
+
+ struct wl_listener new_output;
+
+ struct wlr_layer_shell *layer_shell;
+ struct wl_listener layer_shell_surface;
+
+ struct wlr_xdg_shell_v6 *xdg_shell_v6;
+ struct wl_listener xdg_shell_v6_surface;
+
+ struct wlr_xwayland *xwayland;
+ struct wlr_xcursor_manager *xcursor_manager;
+ struct wl_listener xwayland_surface;
+ struct wl_listener xwayland_ready;
+
+ struct wlr_wl_shell *wl_shell;
+ struct wl_listener wl_shell_surface;
+};
+
+struct sway_server server;
+
+bool server_init(struct sway_server *server);
+void server_fini(struct sway_server *server);
+void server_run(struct sway_server *server);
+
+void handle_new_output(struct wl_listener *listener, void *data);
+
+void handle_layer_shell_surface(struct wl_listener *listener, void *data);
+void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
+void handle_xwayland_surface(struct wl_listener *listener, void *data);
+void handle_wl_shell_surface(struct wl_listener *listener, void *data);
+
+#endif
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
new file mode 100644
index 00000000..2a8b8aba
--- /dev/null
+++ b/include/sway/tree/container.h
@@ -0,0 +1,192 @@
+#ifndef _SWAY_CONTAINER_H
+#define _SWAY_CONTAINER_H
+#include <stdint.h>
+#include <sys/types.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_surface.h>
+#include "list.h"
+
+extern struct sway_container root_container;
+
+struct sway_view;
+struct sway_seat;
+
+/**
+ * Different kinds of containers.
+ *
+ * This enum is in order. A container will never be inside of a container below
+ * it on this list.
+ */
+enum sway_container_type {
+ C_ROOT,
+ C_OUTPUT,
+ C_WORKSPACE,
+ C_CONTAINER,
+ C_VIEW,
+
+ // Keep last
+ C_TYPES,
+};
+
+enum sway_container_layout {
+ L_NONE,
+ L_HORIZ,
+ L_VERT,
+ L_STACKED,
+ L_TABBED,
+ L_FLOATING,
+};
+
+enum sway_container_border {
+ B_NONE,
+ B_PIXEL,
+ B_NORMAL,
+};
+
+struct sway_root;
+struct sway_output;
+struct sway_view;
+
+struct sway_container {
+ union {
+ // TODO: Encapsulate state for other node types as well like C_CONTAINER
+ struct sway_root *sway_root;
+ struct sway_output *sway_output;
+ struct sway_view *sway_view;
+ };
+
+ /**
+ * A unique ID to identify this container. Primarily used in the
+ * get_tree JSON output.
+ */
+ size_t id;
+
+ char *name;
+
+ enum sway_container_type type;
+ enum sway_container_layout layout;
+ enum sway_container_layout prev_layout;
+ enum sway_container_layout workspace_layout;
+
+ // For C_ROOT, this has no meaning
+ // For C_OUTPUT, this is the output position in layout coordinates
+ // For other types, this is the position in output-local coordinates
+ double x, y;
+ // does not include borders or gaps.
+ double width, height;
+
+ list_t *children;
+
+ struct sway_container *parent;
+
+ list_t *marks; // list of char*
+
+ float alpha;
+
+ struct {
+ struct wl_signal destroy;
+ // Raised after the tree updates, but before arrange_windows
+ // Passed the previous parent
+ struct wl_signal reparent;
+ } events;
+};
+
+struct sway_container *container_create(enum sway_container_type type);
+
+const char *container_type_to_str(enum sway_container_type type);
+
+struct sway_container *output_create(struct sway_output *sway_output);
+
+/**
+ * Create a new container container. A container container can be a a child of
+ * a workspace container or another container container.
+ */
+struct sway_container *container_container_create();
+
+/**
+ * Create a new output. Outputs are children of the root container and have no
+ * order in the tree structure.
+ */
+struct sway_container *output_create(struct sway_output *sway_output);
+
+/**
+ * Create a new workspace container. Workspaces are children of an output
+ * container and are ordered alphabetically by name.
+ */
+struct sway_container *workspace_create(struct sway_container *output,
+ const char *name);
+
+/*
+ * Create a new view container. A view can be a child of a workspace container
+ * or a container container and are rendered in the order and structure of
+ * how they are attached to the tree.
+ */
+struct sway_container *container_view_create(
+ struct sway_container *sibling, struct sway_view *sway_view);
+
+struct sway_container *container_destroy(struct sway_container *container);
+
+struct sway_container *container_close(struct sway_container *container);
+
+void container_descendants(struct sway_container *root,
+ enum sway_container_type type,
+ void (*func)(struct sway_container *item, void *data), void *data);
+
+/**
+ * Search a container's descendants a container based on test criteria. Returns
+ * the first container that passes the test.
+ */
+struct sway_container *container_find(struct sway_container *container,
+ bool (*test)(struct sway_container *view, void *data), void *data);
+
+/**
+ * Finds a parent container with the given struct sway_containerype.
+ */
+struct sway_container *container_parent(struct sway_container *container,
+ enum sway_container_type type);
+
+/**
+ * Find a container at the given coordinates. Returns the the surface and
+ * surface-local coordinates of the given layout coordinates if the container
+ * is a view and the view contains a surface at those coordinates.
+ */
+struct sway_container *container_at(struct sway_container *container,
+ double lx, double ly, struct wlr_surface **surface,
+ double *sx, double *sy);
+
+/**
+ * Apply the function for each descendant of the container breadth first.
+ */
+void container_for_each_descendant_bfs(struct sway_container *container,
+ void (*f)(struct sway_container *container, void *data), void *data);
+
+/**
+ * Apply the function for each child of the container depth first.
+ */
+void container_for_each_descendant_dfs(struct sway_container *container,
+ void (*f)(struct sway_container *container, void *data), void *data);
+
+/**
+ * Returns true if the given container is an ancestor of this container.
+ */
+bool container_has_anscestor(struct sway_container *container,
+ struct sway_container *anscestor);
+
+/**
+ * Returns true if the given container is a child descendant of this container.
+ */
+bool container_has_child(struct sway_container *con,
+ struct sway_container *child);
+
+void container_create_notify(struct sway_container *container);
+
+void container_damage_whole(struct sway_container *container);
+
+bool container_reap_empty(struct sway_container *con);
+
+struct sway_container *container_reap_empty_recursive(
+ struct sway_container *con);
+
+struct sway_container *container_flatten(struct sway_container *container);
+
+#endif
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h
new file mode 100644
index 00000000..49ae00e4
--- /dev/null
+++ b/include/sway/tree/layout.h
@@ -0,0 +1,78 @@
+#ifndef _SWAY_LAYOUT_H
+#define _SWAY_LAYOUT_H
+#include <wlr/types/wlr_output_layout.h>
+#include <wlr/render/wlr_texture.h>
+#include "sway/tree/container.h"
+
+enum movement_direction {
+ MOVE_LEFT,
+ MOVE_RIGHT,
+ MOVE_UP,
+ MOVE_DOWN,
+ MOVE_PARENT,
+ MOVE_CHILD,
+};
+
+enum resize_edge {
+ RESIZE_EDGE_LEFT,
+ RESIZE_EDGE_RIGHT,
+ RESIZE_EDGE_TOP,
+ RESIZE_EDGE_BOTTOM,
+};
+
+struct sway_container;
+
+struct sway_root {
+ struct wlr_output_layout *output_layout;
+
+ struct wl_listener output_layout_change;
+
+ struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link
+
+ struct wlr_texture *debug_tree;
+
+ struct {
+ struct wl_signal new_container;
+ } events;
+};
+
+void layout_init(void);
+
+void container_add_child(struct sway_container *parent,
+ struct sway_container *child);
+
+struct sway_container *container_add_sibling(struct sway_container *parent,
+ struct sway_container *child);
+
+struct sway_container *container_remove_child(struct sway_container *child);
+
+struct sway_container *container_replace_child(struct sway_container *child,
+ struct sway_container *new_child);
+
+struct sway_container *container_set_layout(struct sway_container *container,
+ enum sway_container_layout layout);
+
+void container_move_to(struct sway_container* container,
+ struct sway_container* destination);
+
+void container_move(struct sway_container *container,
+ enum movement_direction dir, int move_amt);
+
+enum sway_container_layout container_get_default_layout(
+ struct sway_container *con);
+
+void container_sort_workspaces(struct sway_container *output);
+
+void arrange_windows(struct sway_container *container,
+ double width, double height);
+
+struct sway_container *container_get_in_direction(struct sway_container
+ *container, struct sway_seat *seat, enum movement_direction dir);
+
+struct sway_container *container_split(struct sway_container *child,
+ enum sway_container_layout layout);
+
+void container_recursive_resize(struct sway_container *container,
+ double amount, enum resize_edge edge);
+
+#endif
diff --git a/include/sway/tree/output.h b/include/sway/tree/output.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/include/sway/tree/output.h
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
new file mode 100644
index 00000000..b51c54b5
--- /dev/null
+++ b/include/sway/tree/view.h
@@ -0,0 +1,186 @@
+#ifndef _SWAY_VIEW_H
+#define _SWAY_VIEW_H
+#include <wayland-server.h>
+#include <wlr/types/wlr_surface.h>
+#include <wlr/types/wlr_xdg_shell_v6.h>
+#include <wlr/xwayland.h>
+#include "sway/input/input-manager.h"
+#include "sway/input/seat.h"
+
+struct sway_container;
+
+enum sway_view_type {
+ SWAY_VIEW_WL_SHELL,
+ SWAY_VIEW_XDG_SHELL_V6,
+ SWAY_VIEW_XWAYLAND,
+};
+
+enum sway_view_prop {
+ VIEW_PROP_TITLE,
+ VIEW_PROP_APP_ID,
+ VIEW_PROP_CLASS,
+ VIEW_PROP_INSTANCE,
+};
+
+struct sway_view_impl {
+ const char *(*get_prop)(struct sway_view *view,
+ enum sway_view_prop prop);
+ void (*configure)(struct sway_view *view, double ox, double oy, int width,
+ int height);
+ void (*set_activated)(struct sway_view *view, bool activated);
+ void (*for_each_surface)(struct sway_view *view,
+ wlr_surface_iterator_func_t iterator, void *user_data);
+ void (*close)(struct sway_view *view);
+ void (*destroy)(struct sway_view *view);
+};
+
+struct sway_view {
+ enum sway_view_type type;
+ const struct sway_view_impl *impl;
+
+ struct sway_container *swayc; // NULL for unmanaged views
+ struct wlr_surface *surface; // NULL for unmapped views
+ int width, height;
+
+ union {
+ struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
+ struct wlr_xwayland_surface *wlr_xwayland_surface;
+ struct wlr_wl_shell_surface *wlr_wl_shell_surface;
+ };
+
+ struct {
+ struct wl_signal unmap;
+ } events;
+
+ struct wl_listener surface_new_subsurface;
+ struct wl_listener container_reparent;
+};
+
+struct sway_xdg_shell_v6_view {
+ struct sway_view view;
+
+ struct wl_listener commit;
+ struct wl_listener request_move;
+ struct wl_listener request_resize;
+ struct wl_listener request_maximize;
+ struct wl_listener new_popup;
+ struct wl_listener map;
+ struct wl_listener unmap;
+ struct wl_listener destroy;
+
+ int pending_width, pending_height;
+};
+
+struct sway_xwayland_view {
+ struct sway_view view;
+
+ struct wl_listener commit;
+ struct wl_listener request_move;
+ struct wl_listener request_resize;
+ struct wl_listener request_maximize;
+ struct wl_listener request_configure;
+ struct wl_listener map;
+ struct wl_listener unmap;
+ struct wl_listener destroy;
+
+ int pending_width, pending_height;
+};
+
+struct sway_xwayland_unmanaged {
+ struct wlr_xwayland_surface *wlr_xwayland_surface;
+ struct wl_list link;
+
+ int lx, ly;
+
+ struct wl_listener request_configure;
+ struct wl_listener commit;
+ struct wl_listener map;
+ struct wl_listener unmap;
+ struct wl_listener destroy;
+};
+
+struct sway_wl_shell_view {
+ struct sway_view view;
+
+ struct wl_listener commit;
+ struct wl_listener request_move;
+ struct wl_listener request_resize;
+ struct wl_listener request_maximize;
+ struct wl_listener destroy;
+
+ int pending_width, pending_height;
+};
+
+struct sway_view_child;
+
+struct sway_view_child_impl {
+ void (*destroy)(struct sway_view_child *child);
+};
+
+/**
+ * A view child is a surface in the view tree, such as a subsurface or a popup.
+ */
+struct sway_view_child {
+ const struct sway_view_child_impl *impl;
+
+ struct sway_view *view;
+ struct wlr_surface *surface;
+
+ struct wl_listener surface_commit;
+ struct wl_listener surface_new_subsurface;
+ struct wl_listener surface_destroy;
+ struct wl_listener view_unmap;
+};
+
+struct sway_xdg_popup_v6 {
+ struct sway_view_child child;
+
+ struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
+
+ struct wl_listener new_popup;
+ struct wl_listener unmap;
+ struct wl_listener destroy;
+};
+
+const char *view_get_title(struct sway_view *view);
+
+const char *view_get_app_id(struct sway_view *view);
+
+const char *view_get_class(struct sway_view *view);
+
+const char *view_get_instance(struct sway_view *view);
+
+void view_configure(struct sway_view *view, double ox, double oy, int width,
+ int height);
+
+void view_set_activated(struct sway_view *view, bool activated);
+
+void view_close(struct sway_view *view);
+
+void view_damage(struct sway_view *view, bool whole);
+
+void view_for_each_surface(struct sway_view *view,
+ wlr_surface_iterator_func_t iterator, void *user_data);
+
+// view implementation
+
+void view_init(struct sway_view *view, enum sway_view_type type,
+ const struct sway_view_impl *impl);
+
+void view_destroy(struct sway_view *view);
+
+void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
+
+void view_unmap(struct sway_view *view);
+
+void view_update_position(struct sway_view *view, double ox, double oy);
+
+void view_update_size(struct sway_view *view, int width, int height);
+
+void view_child_init(struct sway_view_child *child,
+ const struct sway_view_child_impl *impl, struct sway_view *view,
+ struct wlr_surface *surface);
+
+void view_child_destroy(struct sway_view_child *child);
+
+#endif
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h
new file mode 100644
index 00000000..8d49fefb
--- /dev/null
+++ b/include/sway/tree/workspace.h
@@ -0,0 +1,26 @@
+#ifndef _SWAY_WORKSPACE_H
+#define _SWAY_WORKSPACE_H
+
+#include "sway/tree/container.h"
+
+extern char *prev_workspace_name;
+
+char *workspace_next_name(const char *output_name);
+
+bool workspace_switch(struct sway_container *workspace);
+
+struct sway_container *workspace_by_number(const char* name);
+
+struct sway_container *workspace_by_name(const char*);
+
+struct sway_container *workspace_output_next(struct sway_container *current);
+
+struct sway_container *workspace_next(struct sway_container *current);
+
+struct sway_container *workspace_output_prev(struct sway_container *current);
+
+struct sway_container *workspace_prev(struct sway_container *current);
+
+bool workspace_is_visible(struct sway_container *ws);
+
+#endif
diff --git a/include/sway/workspace.h b/include/sway/workspace.h
deleted file mode 100644
index c268fafa..00000000
--- a/include/sway/workspace.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#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
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h
index 50d36e76..0037190b 100644
--- a/include/swaybar/bar.h
+++ b/include/swaybar/bar.h
@@ -1,36 +1,71 @@
#ifndef _SWAYBAR_BAR_H
#define _SWAYBAR_BAR_H
+#include <wayland-client.h>
+#include "pool-buffer.h"
-#include "client/registry.h"
-#include "client/window.h"
-#include "list.h"
+struct swaybar_config;
+struct swaybar_output;
+struct swaybar_workspace;
-struct bar {
- struct config *config;
+struct swaybar_pointer {
+ struct wl_pointer *pointer;
+ struct wl_cursor_theme *cursor_theme;
+ struct wl_cursor_image *cursor_image;
+ struct wl_surface *cursor_surface;
+ struct swaybar_output *current;
+ int x, y;
+};
+
+struct swaybar_hotspot {
+ struct wl_list link;
+ int x, y, width, height;
+ void (*callback)(struct swaybar_output *output,
+ int x, int y, uint32_t button, void *data);
+ void (*destroy)(void *data);
+ void *data;
+};
+
+struct swaybar {
+ struct wl_display *display;
+ struct wl_compositor *compositor;
+ struct zwlr_layer_shell_v1 *layer_shell;
+ struct wl_shm *shm;
+ struct wl_seat *seat;
+
+ struct swaybar_config *config;
+ struct swaybar_output *focused_output;
+ struct swaybar_pointer pointer;
struct status_line *status;
- list_t *outputs;
- struct output *focused_output;
int ipc_event_socketfd;
int ipc_socketfd;
- int status_read_fd;
- int status_write_fd;
- pid_t status_command_pid;
+
+ struct wl_list outputs;
};
-struct output {
- struct window *window;
- struct registry *registry;
- list_t *workspaces;
-#ifdef ENABLE_TRAY
- list_t *items;
-#endif
+struct swaybar_output {
+ struct wl_list link;
+ struct swaybar *bar;
+ struct wl_output *output;
+ struct wl_surface *surface;
+ struct zwlr_layer_surface_v1 *layer_surface;
+ uint32_t wl_name;
+
+ struct wl_list workspaces;
+ struct wl_list hotspots;
+
char *name;
- int idx;
+ size_t index;
bool focused;
+
+ uint32_t width, height;
+ int32_t scale;
+ struct pool_buffer buffers[2];
+ struct pool_buffer *current_buffer;
};
-struct workspace {
+struct swaybar_workspace {
+ struct wl_list link;
int num;
char *name;
bool focused;
@@ -38,35 +73,10 @@ struct workspace {
bool urgent;
};
-/** Global bar state */
-extern struct bar swaybar;
-
-/** True if sway needs to render */
-extern bool dirty;
-
-/**
- * Setup bar.
- */
-void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id);
-
-/**
- * Create new output struct from name.
- */
-struct output *new_output(const char *name);
+void bar_setup(struct swaybar *bar,
+ const char *socket_path,
+ const char *bar_id);
+void bar_run(struct swaybar *bar);
+void bar_teardown(struct swaybar *bar);
-/**
- * Bar mainloop.
- */
-void bar_run(struct bar *bar);
-
-/**
- * free workspace list.
- */
-void free_workspaces(list_t *workspaces);
-
-/**
- * Teardown bar.
- */
-void bar_teardown(struct bar *bar);
-
-#endif /* _SWAYBAR_BAR_H */
+#endif
diff --git a/include/swaybar/config.h b/include/swaybar/config.h
index 651f0ee3..7f321df8 100644
--- a/include/swaybar/config.h
+++ b/include/swaybar/config.h
@@ -1,49 +1,36 @@
#ifndef _SWAYBAR_CONFIG_H
#define _SWAYBAR_CONFIG_H
-
-#include <stdint.h>
#include <stdbool.h>
-
-#include "list.h"
+#include <stdint.h>
+#include <wayland-client.h>
#include "util.h"
-/**
- * Colors for a box with background, border and text colors.
- */
struct box_colors {
uint32_t border;
uint32_t background;
uint32_t text;
};
-/**
- * Swaybar config.
- */
-struct config {
+struct config_output {
+ struct wl_list link;
+ char *name;
+ size_t index;
+};
+
+struct swaybar_config {
char *status_command;
bool pango_markup;
- uint32_t position;
+ uint32_t position; // zwlr_layer_surface_v1_anchor
char *font;
char *sep_symbol;
char *mode;
+ bool mode_pango_markup;
bool strip_workspace_numbers;
bool binding_mode_indicator;
bool wrap_scroll;
bool workspace_buttons;
+ struct wl_list outputs;
bool all_outputs;
- list_t *outputs;
-
-#ifdef ENABLE_TRAY
- // Tray
- char *tray_output;
- char *icon_theme;
-
- uint32_t tray_padding;
- uint32_t activate_button;
- uint32_t context_button;
- uint32_t secondary_button;
-#endif
-
int height;
struct {
@@ -63,24 +50,8 @@ struct config {
} colors;
};
-/**
- * Parse position top|bottom|left|right.
- */
+struct swaybar_config *init_config();
+void free_config(struct swaybar_config *config);
uint32_t parse_position(const char *position);
-/**
- * Parse font.
- */
-char *parse_font(const char *font);
-
-/**
- * Initialize default sway config.
- */
-struct config *init_config();
-
-/**
- * Free config struct.
- */
-void free_config(struct config *config);
-
-#endif /* _SWAYBAR_CONFIG_H */
+#endif
diff --git a/include/swaybar/event_loop.h b/include/swaybar/event_loop.h
index a0cde07f..99f6ed36 100644
--- a/include/swaybar/event_loop.h
+++ b/include/swaybar/event_loop.h
@@ -1,6 +1,5 @@
#ifndef _SWAYBAR_EVENT_LOOP_H
#define _SWAYBAR_EVENT_LOOP_H
-
#include <stdbool.h>
#include <time.h>
@@ -23,4 +22,5 @@ bool remove_timer(timer_t timer);
void event_loop_poll();
void init_event_loop();
-#endif /*_SWAYBAR_EVENT_LOOP_H */
+
+#endif
diff --git a/include/swaybar/ipc.h b/include/swaybar/ipc.h
index c11931d0..a1696bcf 100644
--- a/include/swaybar/ipc.h
+++ b/include/swaybar/ipc.h
@@ -1,23 +1,11 @@
#ifndef _SWAYBAR_IPC_H
#define _SWAYBAR_IPC_H
+#include <stdbool.h>
+#include "swaybar/bar.h"
-#include "bar.h"
-
-/**
- * Initialize ipc connection to sway and get sway state, outputs, bar_config.
- */
-void ipc_bar_init(struct bar *bar, const char *bar_id);
-
-/**
- * Handle ipc event from sway.
- */
-bool handle_ipc_event(struct bar *bar);
-
-
-/**
- * Send workspace command to sway
- */
-void ipc_send_workspace_command(const char *workspace_name);
-
-#endif /* _SWAYBAR_IPC_H */
+void ipc_initialize(struct swaybar *bar, const char *bar_id);
+bool handle_ipc_readable(struct swaybar *bar);
+void ipc_get_workspaces(struct swaybar *bar);
+void ipc_send_workspace_command(struct swaybar *bar, const char *ws);
+#endif
diff --git a/include/swaybar/render.h b/include/swaybar/render.h
index 114f43f4..071e2298 100644
--- a/include/swaybar/render.h
+++ b/include/swaybar/render.h
@@ -1,22 +1,10 @@
#ifndef _SWAYBAR_RENDER_H
#define _SWAYBAR_RENDER_H
-#include "config.h"
-#include "bar.h"
+struct swaybar;
+struct swaybar_output;
+struct swaybar_config;
-/**
- * Render swaybar.
- */
-void render(struct output *output, struct config *config, struct status_line *line);
+void render_frame(struct swaybar *bar, struct swaybar_output *output);
-/**
- * Set window height and modify internal spacing accordingly.
- */
-void set_window_height(struct window *window, int height);
-
-/**
- * Compute the size of a workspace name
- */
-void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height);
-
-#endif /* _SWAYBAR_RENDER_H */
+#endif
diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h
index 0664ddee..3538f49c 100644
--- a/include/swaybar/status_line.h
+++ b/include/swaybar/status_line.h
@@ -1,25 +1,44 @@
#ifndef _SWAYBAR_STATUS_LINE_H
#define _SWAYBAR_STATUS_LINE_H
-
#include <stdint.h>
+#include <stdio.h>
#include <stdbool.h>
-
-#include "list.h"
#include "bar.h"
-typedef enum {UNDEF, TEXT, I3BAR} command_protocol;
+enum status_protocol {
+ PROTOCOL_UNDEF,
+ PROTOCOL_ERROR,
+ PROTOCOL_TEXT,
+ PROTOCOL_I3BAR,
+};
+
+struct text_protocol_state {
+ char *buffer;
+ size_t buffer_size;
+};
-struct status_line {
- list_t *block_line;
- const char *text_line;
- command_protocol protocol;
+enum json_node_type {
+ JSON_NODE_UNKNOWN,
+ JSON_NODE_ARRAY,
+ JSON_NODE_STRING,
+};
+
+struct i3bar_protocol_state {
bool click_events;
+ char *buffer;
+ size_t buffer_size;
+ size_t buffer_index;
+ const char *current_node;
+ bool escape;
+ size_t depth;
+ enum json_node_type nodes[16];
};
-struct status_block {
+struct i3bar_block {
+ struct wl_list link;
char *full_text, *short_text, *align;
bool urgent;
- uint32_t color;
+ uint32_t *color;
int min_width;
char *name, *instance;
bool separator;
@@ -32,30 +51,27 @@ struct status_block {
int border_bottom;
int border_left;
int border_right;
-
- // Set during rendering
- int x;
- int width;
};
-/**
- * Initialize status line struct.
- */
-struct status_line *init_status_line();
+struct status_line {
+ pid_t pid;
+ int read_fd, write_fd;
+ FILE *read, *write;
-/**
- * handle status line activity.
- */
-bool handle_status_line(struct bar *bar);
+ enum status_protocol protocol;
+ const char *text;
+ struct wl_list blocks; // i3bar_block::link
-/**
- * Handle mouse clicks.
- */
-bool status_line_mouse_event(struct bar *bar, int x, int y, uint32_t button);
+ struct text_protocol_state text_state;
+ struct i3bar_protocol_state i3bar_state;
+};
-/**
- * Free status line struct.
- */
-void free_status_line(struct status_line *line);
+struct status_line *status_line_init(char *cmd);
+void status_error(struct status_line *status, const char *text);
+bool status_handle_readable(struct status_line *status);
+void status_line_free(struct status_line *status);
+bool i3bar_handle_readable(struct status_line *status);
+void i3bar_block_send_click(struct status_line *status,
+ struct i3bar_block *block, int x, int y, uint32_t button);
-#endif /* _SWAYBAR_STATUS_LINE_H */
+#endif
diff --git a/include/swaylock/seat.h b/include/swaylock/seat.h
new file mode 100644
index 00000000..44bc37d5
--- /dev/null
+++ b/include/swaylock/seat.h
@@ -0,0 +1,38 @@
+#ifndef _SWAYLOCK_SEAT_H
+#define _SWAYLOCK_SEAT_H
+#include <xkbcommon/xkbcommon.h>
+
+enum mod_bit {
+ MOD_SHIFT = 1<<0,
+ MOD_CAPS = 1<<1,
+ MOD_CTRL = 1<<2,
+ MOD_ALT = 1<<3,
+ MOD_MOD2 = 1<<4,
+ MOD_MOD3 = 1<<5,
+ MOD_LOGO = 1<<6,
+ MOD_MOD5 = 1<<7,
+};
+
+enum mask {
+ MASK_SHIFT,
+ MASK_CAPS,
+ MASK_CTRL,
+ MASK_ALT,
+ MASK_MOD2,
+ MASK_MOD3,
+ MASK_LOGO,
+ MASK_MOD5,
+ MASK_LAST
+};
+
+struct swaylock_xkb {
+ uint32_t modifiers;
+ struct xkb_state *state;
+ struct xkb_context *context;
+ struct xkb_keymap *keymap;
+ xkb_mod_mask_t masks[MASK_LAST];
+};
+
+extern const struct wl_seat_listener seat_listener;
+
+#endif
diff --git a/include/swaylock/swaylock.h b/include/swaylock/swaylock.h
index eeed094e..173e8b12 100644
--- a/include/swaylock/swaylock.h
+++ b/include/swaylock/swaylock.h
@@ -1,66 +1,64 @@
#ifndef _SWAYLOCK_H
#define _SWAYLOCK_H
-
-#include "client/cairo.h"
-
-enum scaling_mode {
- SCALING_MODE_STRETCH,
- SCALING_MODE_FILL,
- SCALING_MODE_FIT,
- SCALING_MODE_CENTER,
- SCALING_MODE_TILE,
-};
+#include <stdbool.h>
+#include <stdint.h>
+#include <wayland-client.h>
+#include "background-image.h"
+#include "cairo.h"
+#include "pool-buffer.h"
+#include "swaylock/seat.h"
+#include "wlr-layer-shell-unstable-v1-client-protocol.h"
enum auth_state {
- AUTH_STATE_IDLE,
- AUTH_STATE_INPUT,
- AUTH_STATE_BACKSPACE,
- AUTH_STATE_VALIDATING,
- AUTH_STATE_INVALID,
+ AUTH_STATE_IDLE,
+ AUTH_STATE_INPUT,
+ AUTH_STATE_BACKSPACE,
+ AUTH_STATE_VALIDATING,
+ AUTH_STATE_INVALID,
};
-enum line_source {
- LINE_SOURCE_DEFAULT,
- LINE_SOURCE_RING,
- LINE_SOURCE_INSIDE,
-};
-
-struct render_data {
- list_t *surfaces;
- // Output specific images
- cairo_surface_t **images;
- // OR one image for all outputs:
- cairo_surface_t *image;
- int num_images;
- int color_set;
+struct swaylock_args {
uint32_t color;
- enum scaling_mode scaling_mode;
- enum auth_state auth_state;
+ enum background_mode mode;
+ bool show_indicator;
};
-struct lock_colors {
- uint32_t inner_ring;
- uint32_t outer_ring;
+struct swaylock_password {
+ size_t size;
+ size_t len;
+ char *buffer;
};
-struct lock_config {
- char *font;
-
- struct {
- uint32_t text;
- uint32_t line;
- uint32_t separator;
- uint32_t input_cursor;
- uint32_t backspace_cursor;
- struct lock_colors normal;
- struct lock_colors validating;
- struct lock_colors invalid;
- } colors;
+struct swaylock_state {
+ struct wl_display *display;
+ struct wl_compositor *compositor;
+ struct zwlr_layer_shell_v1 *layer_shell;
+ struct zwlr_input_inhibit_manager_v1 *input_inhibit_manager;
+ struct wl_shm *shm;
+ struct wl_list surfaces;
+ struct swaylock_args args;
+ struct swaylock_password password;
+ struct swaylock_xkb xkb;
+ enum auth_state auth_state;
+ bool run_display;
+};
- int radius;
- int thickness;
+struct swaylock_surface {
+ cairo_surface_t *image;
+ struct swaylock_state *state;
+ struct wl_output *output;
+ struct wl_surface *surface;
+ struct zwlr_layer_surface_v1 *layer_surface;
+ struct pool_buffer buffers[2];
+ struct pool_buffer *current_buffer;
+ uint32_t width, height;
+ int32_t scale;
+ struct wl_list link;
};
-void render(struct render_data* render_data, struct lock_config *config);
+void swaylock_handle_key(struct swaylock_state *state,
+ xkb_keysym_t keysym, uint32_t codepoint);
+void render_frame(struct swaylock_surface *surface);
+void render_frames(struct swaylock_state *state);
#endif
diff --git a/include/unicode.h b/include/unicode.h
new file mode 100644
index 00000000..e2ee9588
--- /dev/null
+++ b/include/unicode.h
@@ -0,0 +1,33 @@
+#ifndef _SWAY_UNICODE_H
+#define _SWAY_UNICODE_H
+#include <stddef.h>
+#include <stdint.h>
+
+// Technically UTF-8 supports up to 6 byte codepoints, but Unicode itself
+// doesn't really bother with more than 4.
+#define UTF8_MAX_SIZE 4
+
+#define UTF8_INVALID 0x80
+
+/**
+ * Grabs the next UTF-8 character and advances the string pointer
+ */
+uint32_t utf8_decode(const char **str);
+
+/**
+ * Encodes a character as UTF-8 and returns the length of that character.
+ */
+size_t utf8_encode(char *str, uint32_t ch);
+
+/**
+ * Returns the size of the next UTF-8 character
+ */
+int utf8_size(const char *str);
+
+/**
+ * Returns the size of a UTF-8 character
+ */
+size_t utf8_chsize(uint32_t ch);
+
+#endif
+