diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/background-image.h | 20 | ||||
-rw-r--r-- | include/sway/commands.h | 1 | ||||
-rw-r--r-- | include/sway/input/input-manager.h | 5 | ||||
-rw-r--r-- | include/sway/input/seat.h | 8 | ||||
-rw-r--r-- | include/sway/tree/container.h | 2 | ||||
-rw-r--r-- | include/sway/tree/view.h | 11 | ||||
-rw-r--r-- | include/swaylock/seat.h | 38 | ||||
-rw-r--r-- | include/swaylock/swaylock.h | 98 | ||||
-rw-r--r-- | include/unicode.h | 33 |
9 files changed, 158 insertions, 58 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/sway/commands.h b/include/sway/commands.h index 66f097ea..edb5a213 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -123,6 +123,7 @@ 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; diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 8e39a4a7..89a3ac71 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -1,6 +1,7 @@ #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" @@ -23,7 +24,11 @@ struct sway_input_manager { 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); diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 137fcd22..d1cfbe4c 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -32,6 +32,9 @@ struct sway_seat { // 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; @@ -64,6 +67,9 @@ void seat_set_focus_warp(struct sway_seat *seat, 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); /** @@ -85,4 +91,6 @@ 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/tree/container.h b/include/sway/tree/container.h index 277165ea..3a3a9429 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -83,6 +83,8 @@ struct sway_container { list_t *marks; // list of char* + float alpha; + struct { struct wl_signal destroy; // Raised after the tree updates, but before arrange_windows diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 4b84205e..f32ccc5a 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -59,11 +59,9 @@ struct sway_wl_shell_surface { }; enum sway_view_type { - SWAY_WL_SHELL_VIEW, - SWAY_XDG_SHELL_V6_VIEW, - SWAY_XWAYLAND_VIEW, - // Keep last - SWAY_VIEW_TYPES, + SWAY_VIEW_WL_SHELL, + SWAY_VIEW_XDG_SHELL_V6, + SWAY_VIEW_XWAYLAND, }; enum sway_view_prop { @@ -101,9 +99,6 @@ struct sway_view { struct sway_xwayland_surface *sway_xwayland_surface; struct sway_wl_shell_surface *sway_wl_shell_surface; }; - - // only used for unmanaged views (shell specific) - struct wl_list unmanaged_view_link; // sway_root::unmanaged_views }; struct sway_view *view_create(enum sway_view_type type, 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 + |