diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-27 11:19:42 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-08-01 22:47:54 -0400 |
commit | a4f7bf23b21d0d838a8a19261d5fd69719003a03 (patch) | |
tree | e46a226d8c3ded2d93e1933323263b6756199a68 | |
parent | Support a detailed message in swaynagbar (diff) | |
download | sway-a4f7bf23b21d0d838a8a19261d5fd69719003a03.tar.gz sway-a4f7bf23b21d0d838a8a19261d5fd69719003a03.tar.zst sway-a4f7bf23b21d0d838a8a19261d5fd69719003a03.zip |
Address first round review for swaynag
-rw-r--r-- | include/swaynag/nagbar.h (renamed from include/swaynagbar/nagbar.h) | 0 | ||||
-rw-r--r-- | include/swaynag/render.h (renamed from include/swaynagbar/render.h) | 0 | ||||
-rw-r--r-- | meson.build | 4 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 8 | ||||
-rw-r--r-- | swaynag/main.c (renamed from swaynagbar/main.c) | 20 | ||||
-rw-r--r-- | swaynag/meson.build (renamed from swaynagbar/meson.build) | 2 | ||||
-rw-r--r-- | swaynag/nagbar.c (renamed from swaynagbar/nagbar.c) | 8 | ||||
-rw-r--r-- | swaynag/render.c (renamed from swaynagbar/render.c) | 6 | ||||
-rw-r--r-- | swaynag/swaynag.1.scd (renamed from swaynagbar/swaynagbar.1.scd) | 11 |
9 files changed, 29 insertions, 30 deletions
diff --git a/include/swaynagbar/nagbar.h b/include/swaynag/nagbar.h index 8b55e4fa..8b55e4fa 100644 --- a/include/swaynagbar/nagbar.h +++ b/include/swaynag/nagbar.h | |||
diff --git a/include/swaynagbar/render.h b/include/swaynag/render.h index d9429f7f..d9429f7f 100644 --- a/include/swaynagbar/render.h +++ b/include/swaynag/render.h | |||
diff --git a/meson.build b/meson.build index 26d36e06..c6501c39 100644 --- a/meson.build +++ b/meson.build | |||
@@ -82,7 +82,7 @@ if scdoc.found() | |||
82 | 'swaylock/swaylock.1.scd', | 82 | 'swaylock/swaylock.1.scd', |
83 | 'swaymsg/swaymsg.1.scd', | 83 | 'swaymsg/swaymsg.1.scd', |
84 | 'swayidle/swayidle.1.scd', | 84 | 'swayidle/swayidle.1.scd', |
85 | 'swaynagbar/swaynagbar.1.scd', | 85 | 'swaynag/swaynag.1.scd', |
86 | ] | 86 | ] |
87 | foreach filename : man_files | 87 | foreach filename : man_files |
88 | topic = filename.split('.')[-3].split('/')[-1] | 88 | topic = filename.split('.')[-3].split('/')[-1] |
@@ -131,7 +131,7 @@ subdir('swaybg') | |||
131 | subdir('swaybar') | 131 | subdir('swaybar') |
132 | subdir('swaylock') | 132 | subdir('swaylock') |
133 | subdir('swayidle') | 133 | subdir('swayidle') |
134 | subdir('swaynagbar') | 134 | subdir('swaynag') |
135 | 135 | ||
136 | config = configuration_data() | 136 | config = configuration_data() |
137 | config.set('sysconfdir', join_paths(prefix, sysconfdir)) | 137 | config.set('sysconfdir', join_paths(prefix, sysconfdir)) |
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 71a0163c..a2935883 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -214,9 +214,6 @@ void arrange_layers(struct sway_output *output) { | |||
214 | wl_list_for_each(seat, &input_manager->seats, link) { | 214 | wl_list_for_each(seat, &input_manager->seats, link) { |
215 | seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL); | 215 | seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL); |
216 | } | 216 | } |
217 | |||
218 | arrange_windows(output->swayc); | ||
219 | transaction_commit_dirty(); | ||
220 | } | 217 | } |
221 | 218 | ||
222 | static void handle_output_destroy(struct wl_listener *listener, void *data) { | 219 | static void handle_output_destroy(struct wl_listener *listener, void *data) { |
@@ -250,6 +247,9 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { | |||
250 | output_damage_surface(output, layer->geo.x, layer->geo.y, | 247 | output_damage_surface(output, layer->geo.x, layer->geo.y, |
251 | layer_surface->surface, false); | 248 | layer_surface->surface, false); |
252 | } | 249 | } |
250 | |||
251 | arrange_windows(output->swayc); | ||
252 | transaction_commit_dirty(); | ||
253 | } | 253 | } |
254 | 254 | ||
255 | static void unmap(struct sway_layer_surface *sway_layer) { | 255 | static void unmap(struct sway_layer_surface *sway_layer) { |
@@ -287,6 +287,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
287 | struct sway_output *output = sway_layer->layer_surface->output->data; | 287 | struct sway_output *output = sway_layer->layer_surface->output->data; |
288 | if (output != NULL && output->swayc != NULL) { | 288 | if (output != NULL && output->swayc != NULL) { |
289 | arrange_layers(output); | 289 | arrange_layers(output); |
290 | arrange_windows(output->swayc); | ||
291 | transaction_commit_dirty(); | ||
290 | } | 292 | } |
291 | wl_list_remove(&sway_layer->output_destroy.link); | 293 | wl_list_remove(&sway_layer->output_destroy.link); |
292 | sway_layer->layer_surface->output = NULL; | 294 | sway_layer->layer_surface->output = NULL; |
diff --git a/swaynagbar/main.c b/swaynag/main.c index 389118c6..60560c72 100644 --- a/swaynagbar/main.c +++ b/swaynag/main.c | |||
@@ -4,7 +4,7 @@ | |||
4 | #include "log.h" | 4 | #include "log.h" |
5 | #include "list.h" | 5 | #include "list.h" |
6 | #include "readline.h" | 6 | #include "readline.h" |
7 | #include "swaynagbar/nagbar.h" | 7 | #include "swaynag/nagbar.h" |
8 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | 8 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" |
9 | 9 | ||
10 | static struct sway_nagbar nagbar; | 10 | static struct sway_nagbar nagbar; |
@@ -71,7 +71,7 @@ int main(int argc, char **argv) { | |||
71 | | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; | 71 | | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; |
72 | nagbar.type = NAGBAR_ERROR; | 72 | nagbar.type = NAGBAR_ERROR; |
73 | set_nagbar_colors(); | 73 | set_nagbar_colors(); |
74 | nagbar.font = strdup("pango:monospace 8"); | 74 | nagbar.font = strdup("pango:monospace 10"); |
75 | nagbar.buttons = create_list(); | 75 | nagbar.buttons = create_list(); |
76 | 76 | ||
77 | struct sway_nagbar_button *button_close = | 77 | struct sway_nagbar_button *button_close = |
@@ -91,7 +91,7 @@ int main(int argc, char **argv) { | |||
91 | {"edge", required_argument, NULL, 'e'}, | 91 | {"edge", required_argument, NULL, 'e'}, |
92 | {"font", required_argument, NULL, 'f'}, | 92 | {"font", required_argument, NULL, 'f'}, |
93 | {"help", no_argument, NULL, 'h'}, | 93 | {"help", no_argument, NULL, 'h'}, |
94 | {"detailed-message", required_argument, NULL, 'l'}, | 94 | {"detailed-message", no_argument, NULL, 'l'}, |
95 | {"detailed-button", required_argument, NULL, 'L'}, | 95 | {"detailed-button", required_argument, NULL, 'L'}, |
96 | {"message", required_argument, NULL, 'm'}, | 96 | {"message", required_argument, NULL, 'm'}, |
97 | {"output", required_argument, NULL, 'o'}, | 97 | {"output", required_argument, NULL, 'o'}, |
@@ -102,7 +102,7 @@ int main(int argc, char **argv) { | |||
102 | }; | 102 | }; |
103 | 103 | ||
104 | const char *usage = | 104 | const char *usage = |
105 | "Usage: swaynagbar [options...]\n" | 105 | "Usage: swaynag [options...]\n" |
106 | "\n" | 106 | "\n" |
107 | " -b, --button <text> <action> Create a button with text that " | 107 | " -b, --button <text> <action> Create a button with text that " |
108 | "executes action when pressed. Multiple buttons can be defined.\n" | 108 | "executes action when pressed. Multiple buttons can be defined.\n" |
@@ -110,7 +110,7 @@ int main(int argc, char **argv) { | |||
110 | " -e, --edge top|bottom Set the edge to use.\n" | 110 | " -e, --edge top|bottom Set the edge to use.\n" |
111 | " -f, --font <font> Set the font to use.\n" | 111 | " -f, --font <font> Set the font to use.\n" |
112 | " -h, --help Show help message and quit.\n" | 112 | " -h, --help Show help message and quit.\n" |
113 | " -l, --detailed-message <msg> Set a detailed message.\n" | 113 | " -l, --detailed-message Read a detailed message from stdin.\n" |
114 | " -L, --detailed-button <text> Set the text of the detail button.\n" | 114 | " -L, --detailed-button <text> Set the text of the detail button.\n" |
115 | " -m, --message <msg> Set the message text.\n" | 115 | " -m, --message <msg> Set the message text.\n" |
116 | " -o, --output <output> Set the output to use.\n" | 116 | " -o, --output <output> Set the output to use.\n" |
@@ -119,7 +119,7 @@ int main(int argc, char **argv) { | |||
119 | " -v, --version Show the version number and quit.\n"; | 119 | " -v, --version Show the version number and quit.\n"; |
120 | 120 | ||
121 | while (1) { | 121 | while (1) { |
122 | int c = getopt_long(argc, argv, "b:de:f:hl:L:m:o:s:t:v", opts, NULL); | 122 | int c = getopt_long(argc, argv, "b:de:f:hlL:m:o:s:t:v", opts, NULL); |
123 | if (c == -1) { | 123 | if (c == -1) { |
124 | break; | 124 | break; |
125 | } | 125 | } |
@@ -162,11 +162,7 @@ int main(int argc, char **argv) { | |||
162 | break; | 162 | break; |
163 | case 'l': // Detailed Message | 163 | case 'l': // Detailed Message |
164 | free(nagbar.details.message); | 164 | free(nagbar.details.message); |
165 | if (strcmp(optarg, "-") == 0) { | 165 | nagbar.details.message = read_from_stdin(); |
166 | nagbar.details.message = read_from_stdin(); | ||
167 | } else { | ||
168 | nagbar.details.message = strdup(optarg); | ||
169 | } | ||
170 | nagbar.details.button_up.text = strdup("▲"); | 166 | nagbar.details.button_up.text = strdup("▲"); |
171 | nagbar.details.button_down.text = strdup("▼"); | 167 | nagbar.details.button_down.text = strdup("▼"); |
172 | break; | 168 | break; |
@@ -199,7 +195,7 @@ int main(int argc, char **argv) { | |||
199 | set_nagbar_colors(); | 195 | set_nagbar_colors(); |
200 | break; | 196 | break; |
201 | case 'v': // Version | 197 | case 'v': // Version |
202 | fprintf(stdout, "sway version " SWAY_VERSION "\n"); | 198 | fprintf(stdout, "swaynag version " SWAY_VERSION "\n"); |
203 | exit_code = EXIT_SUCCESS; | 199 | exit_code = EXIT_SUCCESS; |
204 | goto cleanup; | 200 | goto cleanup; |
205 | default: // Help or unknown flag | 201 | default: // Help or unknown flag |
diff --git a/swaynagbar/meson.build b/swaynag/meson.build index 254462f2..6492e4dc 100644 --- a/swaynagbar/meson.build +++ b/swaynag/meson.build | |||
@@ -1,5 +1,5 @@ | |||
1 | executable( | 1 | executable( |
2 | 'swaynagbar', [ | 2 | 'swaynag', [ |
3 | 'main.c', | 3 | 'main.c', |
4 | 'nagbar.c', | 4 | 'nagbar.c', |
5 | 'render.c', | 5 | 'render.c', |
diff --git a/swaynagbar/nagbar.c b/swaynag/nagbar.c index 9e8bbb4b..6647e8c2 100644 --- a/swaynagbar/nagbar.c +++ b/swaynag/nagbar.c | |||
@@ -6,8 +6,8 @@ | |||
6 | #include <wayland-cursor.h> | 6 | #include <wayland-cursor.h> |
7 | #include "log.h" | 7 | #include "log.h" |
8 | #include "list.h" | 8 | #include "list.h" |
9 | #include "swaynagbar/nagbar.h" | 9 | #include "swaynag/nagbar.h" |
10 | #include "swaynagbar/render.h" | 10 | #include "swaynag/render.h" |
11 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | 11 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" |
12 | 12 | ||
13 | static void nop() { | 13 | static void nop() { |
@@ -15,7 +15,7 @@ static void nop() { | |||
15 | } | 15 | } |
16 | 16 | ||
17 | static bool terminal_execute(char *terminal, char *command) { | 17 | static bool terminal_execute(char *terminal, char *command) { |
18 | char fname[] = "/tmp/swaynagbarXXXXXX"; | 18 | char fname[] = "/tmp/swaynagXXXXXX"; |
19 | FILE *tmp= fdopen(mkstemp(fname), "w"); | 19 | FILE *tmp= fdopen(mkstemp(fname), "w"); |
20 | if (!tmp) { | 20 | if (!tmp) { |
21 | wlr_log(WLR_ERROR, "Failed to create temp script"); | 21 | wlr_log(WLR_ERROR, "Failed to create temp script"); |
@@ -352,7 +352,7 @@ void nagbar_setup(struct sway_nagbar *nagbar) { | |||
352 | assert(nagbar->surface); | 352 | assert(nagbar->surface); |
353 | nagbar->layer_surface = zwlr_layer_shell_v1_get_layer_surface( | 353 | nagbar->layer_surface = zwlr_layer_shell_v1_get_layer_surface( |
354 | nagbar->layer_shell, nagbar->surface, nagbar->output.wl_output, | 354 | nagbar->layer_shell, nagbar->surface, nagbar->output.wl_output, |
355 | ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "nagbar"); | 355 | ZWLR_LAYER_SHELL_V1_LAYER_TOP, "swaynag"); |
356 | assert(nagbar->layer_surface); | 356 | assert(nagbar->layer_surface); |
357 | zwlr_layer_surface_v1_add_listener(nagbar->layer_surface, | 357 | zwlr_layer_surface_v1_add_listener(nagbar->layer_surface, |
358 | &layer_surface_listener, nagbar); | 358 | &layer_surface_listener, nagbar); |
diff --git a/swaynagbar/render.c b/swaynag/render.c index 7bc2961e..150ae3f2 100644 --- a/swaynagbar/render.c +++ b/swaynag/render.c | |||
@@ -3,7 +3,7 @@ | |||
3 | #include "log.h" | 3 | #include "log.h" |
4 | #include "pango.h" | 4 | #include "pango.h" |
5 | #include "pool-buffer.h" | 5 | #include "pool-buffer.h" |
6 | #include "swaynagbar/nagbar.h" | 6 | #include "swaynag/nagbar.h" |
7 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | 7 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" |
8 | 8 | ||
9 | static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { | 9 | static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { |
@@ -274,7 +274,7 @@ void render_frame(struct sway_nagbar *nagbar) { | |||
274 | nagbar->height * nagbar->scale); | 274 | nagbar->height * nagbar->scale); |
275 | if (!nagbar->current_buffer) { | 275 | if (!nagbar->current_buffer) { |
276 | wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame."); | 276 | wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame."); |
277 | return; | 277 | goto cleanup; |
278 | } | 278 | } |
279 | 279 | ||
280 | cairo_t *shm = nagbar->current_buffer->cairo; | 280 | cairo_t *shm = nagbar->current_buffer->cairo; |
@@ -293,6 +293,8 @@ void render_frame(struct sway_nagbar *nagbar) { | |||
293 | wl_surface_commit(nagbar->surface); | 293 | wl_surface_commit(nagbar->surface); |
294 | wl_display_roundtrip(nagbar->display); | 294 | wl_display_roundtrip(nagbar->display); |
295 | } | 295 | } |
296 | |||
297 | cleanup: | ||
296 | cairo_surface_destroy(recorder); | 298 | cairo_surface_destroy(recorder); |
297 | cairo_destroy(cairo); | 299 | cairo_destroy(cairo); |
298 | } | 300 | } |
diff --git a/swaynagbar/swaynagbar.1.scd b/swaynag/swaynag.1.scd index 2a34ae68..879aaf2e 100644 --- a/swaynagbar/swaynagbar.1.scd +++ b/swaynag/swaynag.1.scd | |||
@@ -2,11 +2,11 @@ swaynagbar(1) | |||
2 | 2 | ||
3 | # NAME | 3 | # NAME |
4 | 4 | ||
5 | swaynagbar - Show a warning or error message with buttons | 5 | swaynag - Show a warning or error message with buttons |
6 | 6 | ||
7 | # SYNOPSIS | 7 | # SYNOPSIS |
8 | 8 | ||
9 | _swaynagbar_ [options...] | 9 | _swaynag_ [options...] |
10 | 10 | ||
11 | # OPTIONS | 11 | # OPTIONS |
12 | *-b, --button* <text> <action> | 12 | *-b, --button* <text> <action> |
@@ -25,10 +25,9 @@ _swaynagbar_ [options...] | |||
25 | *-h, --help* | 25 | *-h, --help* |
26 | Show help message and quit. | 26 | Show help message and quit. |
27 | 27 | ||
28 | *-l, --detailed-message <msg>* | 28 | *-l, --detailed-message* |
29 | Set the detailed message. A button to toggle details will be added. Details | 29 | Read a detailed message from stdin. A button to toggle details will be |
30 | are shown in a scrollable multi-line text area. If _msg_ is _-_, then the | 30 | added. Details are shown in a scrollable multi-line text area. |
31 | detailed message will be read from stdin. | ||
32 | 31 | ||
33 | *-L, --detailed-button <text>* | 32 | *-L, --detailed-button <text>* |
34 | Set the text for the button that toggles details. This has no effect if | 33 | Set the text for the button that toggles details. This has no effect if |