aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-04 20:16:35 -0400
committerLibravatar GitHub <noreply@github.com>2018-04-04 20:16:35 -0400
commitf2153f3f28c8aa2e6738610abf09b2e2396d891a (patch)
tree4702abb406a59fb8588cbd2019741e99d40bcbfe /include
parentMerge pull request #1731 from acrisci/ipc-window-events (diff)
parentAddress review feedback from @emersion (diff)
downloadsway-f2153f3f28c8aa2e6738610abf09b2e2396d891a.tar.gz
sway-f2153f3f28c8aa2e6738610abf09b2e2396d891a.tar.zst
sway-f2153f3f28c8aa2e6738610abf09b2e2396d891a.zip
Merge pull request #1705 from swaywm/swaylock-layers
Port swaylock to layer shell
Diffstat (limited to 'include')
-rw-r--r--include/background-image.h20
-rw-r--r--include/sway/input/input-manager.h5
-rw-r--r--include/sway/input/seat.h8
-rw-r--r--include/swaylock/seat.h38
-rw-r--r--include/swaylock/swaylock.h98
-rw-r--r--include/unicode.h33
6 files changed, 152 insertions, 50 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 @@
1#ifndef _SWAY_BACKGROUND_IMAGE_H
2#define _SWAY_BACKGROUND_IMAGE_H
3#include "cairo.h"
4
5enum background_mode {
6 BACKGROUND_MODE_STRETCH,
7 BACKGROUND_MODE_FILL,
8 BACKGROUND_MODE_FIT,
9 BACKGROUND_MODE_CENTER,
10 BACKGROUND_MODE_TILE,
11 BACKGROUND_MODE_SOLID_COLOR,
12 BACKGROUND_MODE_INVALID,
13};
14
15enum background_mode parse_background_mode(const char *mode);
16cairo_surface_t *load_background_image(const char *path);
17void render_background_image(cairo_t *cairo, cairo_surface_t *image,
18 enum background_mode mode, int buffer_width, int buffer_height);
19
20#endif
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 @@
1#ifndef _SWAY_INPUT_INPUT_MANAGER_H 1#ifndef _SWAY_INPUT_INPUT_MANAGER_H
2#define _SWAY_INPUT_INPUT_MANAGER_H 2#define _SWAY_INPUT_INPUT_MANAGER_H
3#include <libinput.h> 3#include <libinput.h>
4#include <wlr/types/wlr_input_inhibitor.h>
4#include "sway/server.h" 5#include "sway/server.h"
5#include "sway/config.h" 6#include "sway/config.h"
6#include "list.h" 7#include "list.h"
@@ -23,7 +24,11 @@ struct sway_input_manager {
23 struct wl_list devices; 24 struct wl_list devices;
24 struct wl_list seats; 25 struct wl_list seats;
25 26
27 struct wlr_input_inhibit_manager *inhibit;
28
26 struct wl_listener new_input; 29 struct wl_listener new_input;
30 struct wl_listener inhibit_activate;
31 struct wl_listener inhibit_deactivate;
27}; 32};
28 33
29struct sway_input_manager *input_manager_create(struct sway_server *server); 34struct 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 {
32 // If the focused layer is set, views cannot receive keyboard focus 32 // If the focused layer is set, views cannot receive keyboard focus
33 struct wlr_layer_surface *focused_layer; 33 struct wlr_layer_surface *focused_layer;
34 34
35 // If exclusive_client is set, no other clients will receive input events
36 struct wl_client *exclusive_client;
37
35 struct wl_listener focus_destroy; 38 struct wl_listener focus_destroy;
36 struct wl_listener new_container; 39 struct wl_listener new_container;
37 40
@@ -64,6 +67,9 @@ void seat_set_focus_warp(struct sway_seat *seat,
64void seat_set_focus_layer(struct sway_seat *seat, 67void seat_set_focus_layer(struct sway_seat *seat,
65 struct wlr_layer_surface *layer); 68 struct wlr_layer_surface *layer);
66 69
70void seat_set_exclusive_client(struct sway_seat *seat,
71 struct wl_client *client);
72
67struct sway_container *seat_get_focus(struct sway_seat *seat); 73struct sway_container *seat_get_focus(struct sway_seat *seat);
68 74
69/** 75/**
@@ -85,4 +91,6 @@ void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
85 91
86struct seat_config *seat_get_config(struct sway_seat *seat); 92struct seat_config *seat_get_config(struct sway_seat *seat);
87 93
94bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
95
88#endif 96#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 @@
1#ifndef _SWAYLOCK_SEAT_H
2#define _SWAYLOCK_SEAT_H
3#include <xkbcommon/xkbcommon.h>
4
5enum mod_bit {
6 MOD_SHIFT = 1<<0,
7 MOD_CAPS = 1<<1,
8 MOD_CTRL = 1<<2,
9 MOD_ALT = 1<<3,
10 MOD_MOD2 = 1<<4,
11 MOD_MOD3 = 1<<5,
12 MOD_LOGO = 1<<6,
13 MOD_MOD5 = 1<<7,
14};
15
16enum mask {
17 MASK_SHIFT,
18 MASK_CAPS,
19 MASK_CTRL,
20 MASK_ALT,
21 MASK_MOD2,
22 MASK_MOD3,
23 MASK_LOGO,
24 MASK_MOD5,
25 MASK_LAST
26};
27
28struct swaylock_xkb {
29 uint32_t modifiers;
30 struct xkb_state *state;
31 struct xkb_context *context;
32 struct xkb_keymap *keymap;
33 xkb_mod_mask_t masks[MASK_LAST];
34};
35
36extern const struct wl_seat_listener seat_listener;
37
38#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 @@
1#ifndef _SWAYLOCK_H 1#ifndef _SWAYLOCK_H
2#define _SWAYLOCK_H 2#define _SWAYLOCK_H
3 3#include <stdbool.h>
4#include "client/cairo.h" 4#include <stdint.h>
5 5#include <wayland-client.h>
6enum scaling_mode { 6#include "background-image.h"
7 SCALING_MODE_STRETCH, 7#include "cairo.h"
8 SCALING_MODE_FILL, 8#include "pool-buffer.h"
9 SCALING_MODE_FIT, 9#include "swaylock/seat.h"
10 SCALING_MODE_CENTER, 10#include "wlr-layer-shell-unstable-v1-client-protocol.h"
11 SCALING_MODE_TILE,
12};
13 11
14enum auth_state { 12enum auth_state {
15 AUTH_STATE_IDLE, 13 AUTH_STATE_IDLE,
16 AUTH_STATE_INPUT, 14 AUTH_STATE_INPUT,
17 AUTH_STATE_BACKSPACE, 15 AUTH_STATE_BACKSPACE,
18 AUTH_STATE_VALIDATING, 16 AUTH_STATE_VALIDATING,
19 AUTH_STATE_INVALID, 17 AUTH_STATE_INVALID,
20}; 18};
21 19
22enum line_source { 20struct swaylock_args {
23 LINE_SOURCE_DEFAULT,
24 LINE_SOURCE_RING,
25 LINE_SOURCE_INSIDE,
26};
27
28struct render_data {
29 list_t *surfaces;
30 // Output specific images
31 cairo_surface_t **images;
32 // OR one image for all outputs:
33 cairo_surface_t *image;
34 int num_images;
35 int color_set;
36 uint32_t color; 21 uint32_t color;
37 enum scaling_mode scaling_mode; 22 enum background_mode mode;
38 enum auth_state auth_state; 23 bool show_indicator;
39}; 24};
40 25
41struct lock_colors { 26struct swaylock_password {
42 uint32_t inner_ring; 27 size_t size;
43 uint32_t outer_ring; 28 size_t len;
29 char *buffer;
44}; 30};
45 31
46struct lock_config { 32struct swaylock_state {
47 char *font; 33 struct wl_display *display;
48 34 struct wl_compositor *compositor;
49 struct { 35 struct zwlr_layer_shell_v1 *layer_shell;
50 uint32_t text; 36 struct zwlr_input_inhibit_manager_v1 *input_inhibit_manager;
51 uint32_t line; 37 struct wl_shm *shm;
52 uint32_t separator; 38 struct wl_list surfaces;
53 uint32_t input_cursor; 39 struct swaylock_args args;
54 uint32_t backspace_cursor; 40 struct swaylock_password password;
55 struct lock_colors normal; 41 struct swaylock_xkb xkb;
56 struct lock_colors validating; 42 enum auth_state auth_state;
57 struct lock_colors invalid; 43 bool run_display;
58 } colors; 44};
59 45
60 int radius; 46struct swaylock_surface {
61 int thickness; 47 cairo_surface_t *image;
48 struct swaylock_state *state;
49 struct wl_output *output;
50 struct wl_surface *surface;
51 struct zwlr_layer_surface_v1 *layer_surface;
52 struct pool_buffer buffers[2];
53 struct pool_buffer *current_buffer;
54 uint32_t width, height;
55 int32_t scale;
56 struct wl_list link;
62}; 57};
63 58
64void render(struct render_data* render_data, struct lock_config *config); 59void swaylock_handle_key(struct swaylock_state *state,
60 xkb_keysym_t keysym, uint32_t codepoint);
61void render_frame(struct swaylock_surface *surface);
62void render_frames(struct swaylock_state *state);
65 63
66#endif 64#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 @@
1#ifndef _SWAY_UNICODE_H
2#define _SWAY_UNICODE_H
3#include <stddef.h>
4#include <stdint.h>
5
6// Technically UTF-8 supports up to 6 byte codepoints, but Unicode itself
7// doesn't really bother with more than 4.
8#define UTF8_MAX_SIZE 4
9
10#define UTF8_INVALID 0x80
11
12/**
13 * Grabs the next UTF-8 character and advances the string pointer
14 */
15uint32_t utf8_decode(const char **str);
16
17/**
18 * Encodes a character as UTF-8 and returns the length of that character.
19 */
20size_t utf8_encode(char *str, uint32_t ch);
21
22/**
23 * Returns the size of the next UTF-8 character
24 */
25int utf8_size(const char *str);
26
27/**
28 * Returns the size of a UTF-8 character
29 */
30size_t utf8_chsize(uint32_t ch);
31
32#endif
33