diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-08-02 09:28:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-02 09:28:13 -0400 |
commit | ea14ef40955a94e21a5198d2469e54fe1e6056e5 (patch) | |
tree | 1a28ee032b762f471917c1f175ba02500f9ef794 /include/swaynag | |
parent | Revert "Fix popups" (diff) | |
parent | Merge branch 'master' into nagbar (diff) | |
download | sway-ea14ef40955a94e21a5198d2469e54fe1e6056e5.tar.gz sway-ea14ef40955a94e21a5198d2469e54fe1e6056e5.tar.zst sway-ea14ef40955a94e21a5198d2469e54fe1e6056e5.zip |
Merge pull request #2366 from RedSoxFan/nagbar
Implement swaynag
Diffstat (limited to 'include/swaynag')
-rw-r--r-- | include/swaynag/config.h | 13 | ||||
-rw-r--r-- | include/swaynag/render.h | 7 | ||||
-rw-r--r-- | include/swaynag/swaynag.h | 100 | ||||
-rw-r--r-- | include/swaynag/types.h | 39 |
4 files changed, 159 insertions, 0 deletions
diff --git a/include/swaynag/config.h b/include/swaynag/config.h new file mode 100644 index 00000000..0d8889de --- /dev/null +++ b/include/swaynag/config.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef _SWAYNAG_CONFIG_H | ||
2 | #define _SWAYNAG_CONFIG_H | ||
3 | #include "swaynag/swaynag.h" | ||
4 | #include "list.h" | ||
5 | |||
6 | int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, | ||
7 | list_t *types, struct swaynag_type *type, char **config, bool *debug); | ||
8 | |||
9 | char *swaynag_get_config_path(void); | ||
10 | |||
11 | int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types); | ||
12 | |||
13 | #endif | ||
diff --git a/include/swaynag/render.h b/include/swaynag/render.h new file mode 100644 index 00000000..d09e5929 --- /dev/null +++ b/include/swaynag/render.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _SWAYNAG_RENDER_H | ||
2 | #define _SWAYNAG_RENDER_H | ||
3 | #include "swaynag/swaynag.h" | ||
4 | |||
5 | void render_frame(struct swaynag *swaynag); | ||
6 | |||
7 | #endif | ||
diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h new file mode 100644 index 00000000..1bf8b640 --- /dev/null +++ b/include/swaynag/swaynag.h | |||
@@ -0,0 +1,100 @@ | |||
1 | #ifndef _SWAYNAG_SWAYNAG_H | ||
2 | #define _SWAYNAG_SWAYNAG_H | ||
3 | #include <stdint.h> | ||
4 | #include <strings.h> | ||
5 | #include "list.h" | ||
6 | #include "pool-buffer.h" | ||
7 | #include "swaynag/types.h" | ||
8 | #include "xdg-output-unstable-v1-client-protocol.h" | ||
9 | |||
10 | #define SWAYNAG_MAX_HEIGHT 500 | ||
11 | |||
12 | struct swaynag; | ||
13 | |||
14 | enum swaynag_action_type { | ||
15 | SWAYNAG_ACTION_DISMISS, | ||
16 | SWAYNAG_ACTION_EXPAND, | ||
17 | SWAYNAG_ACTION_COMMAND, | ||
18 | }; | ||
19 | |||
20 | struct swaynag_pointer { | ||
21 | struct wl_pointer *pointer; | ||
22 | uint32_t serial; | ||
23 | struct wl_cursor_theme *cursor_theme; | ||
24 | struct wl_cursor_image *cursor_image; | ||
25 | struct wl_surface *cursor_surface; | ||
26 | int x; | ||
27 | int y; | ||
28 | }; | ||
29 | |||
30 | struct swaynag_output { | ||
31 | char *name; | ||
32 | struct wl_output *wl_output; | ||
33 | uint32_t wl_name; | ||
34 | uint32_t scale; | ||
35 | struct swaynag *swaynag; | ||
36 | struct wl_list link; | ||
37 | }; | ||
38 | |||
39 | struct swaynag_button { | ||
40 | char *text; | ||
41 | enum swaynag_action_type type; | ||
42 | char *action; | ||
43 | int x; | ||
44 | int y; | ||
45 | int width; | ||
46 | int height; | ||
47 | }; | ||
48 | |||
49 | struct swaynag_details { | ||
50 | bool visible; | ||
51 | char *message; | ||
52 | |||
53 | int x; | ||
54 | int y; | ||
55 | int width; | ||
56 | int height; | ||
57 | |||
58 | int offset; | ||
59 | int visible_lines; | ||
60 | int total_lines; | ||
61 | struct swaynag_button button_details; | ||
62 | struct swaynag_button button_up; | ||
63 | struct swaynag_button button_down; | ||
64 | }; | ||
65 | |||
66 | struct swaynag { | ||
67 | bool run_display; | ||
68 | int querying_outputs; | ||
69 | |||
70 | struct wl_display *display; | ||
71 | struct wl_compositor *compositor; | ||
72 | struct wl_seat *seat; | ||
73 | struct wl_shm *shm; | ||
74 | struct swaynag_pointer pointer; | ||
75 | struct zxdg_output_manager_v1 *xdg_output_manager; | ||
76 | struct wl_list outputs; // swaynag_output::link | ||
77 | struct swaynag_output *output; | ||
78 | struct zwlr_layer_shell_v1 *layer_shell; | ||
79 | struct zwlr_layer_surface_v1 *layer_surface; | ||
80 | struct wl_surface *surface; | ||
81 | |||
82 | uint32_t width; | ||
83 | uint32_t height; | ||
84 | int32_t scale; | ||
85 | struct pool_buffer buffers[2]; | ||
86 | struct pool_buffer *current_buffer; | ||
87 | |||
88 | struct swaynag_type *type; | ||
89 | char *message; | ||
90 | list_t *buttons; | ||
91 | struct swaynag_details details; | ||
92 | }; | ||
93 | |||
94 | void swaynag_setup(struct swaynag *swaynag); | ||
95 | |||
96 | void swaynag_run(struct swaynag *swaynag); | ||
97 | |||
98 | void swaynag_destroy(struct swaynag *swaynag); | ||
99 | |||
100 | #endif | ||
diff --git a/include/swaynag/types.h b/include/swaynag/types.h new file mode 100644 index 00000000..2183ce22 --- /dev/null +++ b/include/swaynag/types.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef _SWAYNAG_TYPES_H | ||
2 | #define _SWAYNAG_TYPES_H | ||
3 | |||
4 | struct swaynag_type { | ||
5 | char *name; | ||
6 | |||
7 | char *font; | ||
8 | char *output; | ||
9 | uint32_t anchors; | ||
10 | |||
11 | uint32_t button_background; | ||
12 | uint32_t background; | ||
13 | uint32_t text; | ||
14 | uint32_t border; | ||
15 | uint32_t border_bottom; | ||
16 | |||
17 | uint32_t bar_border_thickness; | ||
18 | uint32_t message_padding; | ||
19 | uint32_t details_border_thickness; | ||
20 | uint32_t button_border_thickness; | ||
21 | uint32_t button_gap; | ||
22 | uint32_t button_gap_close; | ||
23 | uint32_t button_margin_right; | ||
24 | uint32_t button_padding; | ||
25 | }; | ||
26 | |||
27 | void swaynag_types_add_default(list_t *types); | ||
28 | |||
29 | struct swaynag_type *swaynag_type_get(list_t *types, char *name); | ||
30 | |||
31 | struct swaynag_type *swaynag_type_clone(struct swaynag_type *type); | ||
32 | |||
33 | void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src); | ||
34 | |||
35 | void swaynag_type_free(struct swaynag_type *type); | ||
36 | |||
37 | void swaynag_types_free(list_t *types); | ||
38 | |||
39 | #endif | ||