aboutsummaryrefslogtreecommitdiffstats
path: root/include/swaynag
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-27 11:19:42 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-08-01 22:47:54 -0400
commita4f7bf23b21d0d838a8a19261d5fd69719003a03 (patch)
treee46a226d8c3ded2d93e1933323263b6756199a68 /include/swaynag
parentSupport a detailed message in swaynagbar (diff)
downloadsway-a4f7bf23b21d0d838a8a19261d5fd69719003a03.tar.gz
sway-a4f7bf23b21d0d838a8a19261d5fd69719003a03.tar.zst
sway-a4f7bf23b21d0d838a8a19261d5fd69719003a03.zip
Address first round review for swaynag
Diffstat (limited to 'include/swaynag')
-rw-r--r--include/swaynag/nagbar.h115
-rw-r--r--include/swaynag/render.h6
2 files changed, 121 insertions, 0 deletions
diff --git a/include/swaynag/nagbar.h b/include/swaynag/nagbar.h
new file mode 100644
index 00000000..8b55e4fa
--- /dev/null
+++ b/include/swaynag/nagbar.h
@@ -0,0 +1,115 @@
1#ifndef _SWAY_NAGBAR_NAGBAR_H
2#define _SWAY_NAGBAR_NAGNAR_H
3#include <stdint.h>
4#include "list.h"
5#include "pool-buffer.h"
6#include "xdg-output-unstable-v1-client-protocol.h"
7
8#define NAGBAR_BAR_BORDER_THICKNESS 2
9#define NAGBAR_MESSAGE_PADDING 8
10#define NAGBAR_DETAILS_BORDER_THICKNESS 3
11#define NAGBAR_BUTTON_BORDER_THICKNESS 3
12#define NAGBAR_BUTTON_GAP 20
13#define NAGBAR_BUTTON_GAP_CLOSE 15
14#define NAGBAR_BUTTON_MARGIN_RIGHT 2
15#define NAGBAR_BUTTON_PADDING 3
16
17#define NAGBAR_MAX_HEIGHT 500
18
19enum sway_nagbar_type {
20 NAGBAR_ERROR,
21 NAGBAR_WARNING,
22};
23
24enum sway_nagbar_action_type {
25 NAGBAR_ACTION_DISMISS,
26 NAGBAR_ACTION_EXPAND,
27 NAGBAR_ACTION_COMMAND,
28};
29
30struct sway_nagbar_colors {
31 uint32_t button_background;
32 uint32_t background;
33 uint32_t text;
34 uint32_t border;
35 uint32_t border_bottom;
36};
37
38struct sway_nagbar_pointer {
39 struct wl_pointer *pointer;
40 struct wl_cursor_theme *cursor_theme;
41 struct wl_cursor_image *cursor_image;
42 struct wl_surface *cursor_surface;
43 int x;
44 int y;
45};
46
47struct sway_nagbar_output {
48 char *name;
49 struct wl_output *wl_output;
50 uint32_t wl_name;
51};
52
53struct sway_nagbar_button {
54 char *text;
55 enum sway_nagbar_action_type type;
56 char *action;
57 int x;
58 int y;
59 int width;
60 int height;
61};
62
63struct sway_nagbar_details {
64 bool visible;
65 char *message;
66
67 int x;
68 int y;
69 int width;
70 int height;
71
72 int offset;
73 int visible_lines;
74 int total_lines;
75 struct sway_nagbar_button button_up;
76 struct sway_nagbar_button button_down;
77};
78
79struct sway_nagbar {
80 bool run_display;
81 int querying_outputs;
82
83 struct wl_display *display;
84 struct wl_compositor *compositor;
85 struct wl_seat *seat;
86 struct wl_shm *shm;
87 struct sway_nagbar_pointer pointer;
88 struct zxdg_output_manager_v1 *xdg_output_manager;
89 struct sway_nagbar_output output;
90 struct zwlr_layer_shell_v1 *layer_shell;
91 struct zwlr_layer_surface_v1 *layer_surface;
92 struct wl_surface *surface;
93
94 uint32_t width;
95 uint32_t height;
96 int32_t scale;
97 struct pool_buffer buffers[2];
98 struct pool_buffer *current_buffer;
99
100 enum sway_nagbar_type type;
101 struct sway_nagbar_colors colors;
102 uint32_t anchors;
103 char *message;
104 char *font;
105 list_t *buttons;
106 struct sway_nagbar_details details;
107};
108
109void nagbar_setup(struct sway_nagbar *nagbar);
110
111void nagbar_run(struct sway_nagbar *nagbar);
112
113void nagbar_destroy(struct sway_nagbar *nagbar);
114
115#endif
diff --git a/include/swaynag/render.h b/include/swaynag/render.h
new file mode 100644
index 00000000..d9429f7f
--- /dev/null
+++ b/include/swaynag/render.h
@@ -0,0 +1,6 @@
1#ifndef _SWAY_NAGBAR_RENDER_H
2#define _SWAY_NAGBAR_RENDER_H
3
4void render_frame(struct sway_nagbar *nagbar);
5
6#endif