summaryrefslogtreecommitdiffstats
path: root/swaynag/swaynag.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaynag/swaynag.c')
-rw-r--r--swaynag/swaynag.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index 06185f20..674c24b5 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -1,4 +1,4 @@
1#define _XOPEN_SOURCE 500 1#define _POSIX_C_SOURCE 200809L
2#include <stdlib.h> 2#include <stdlib.h>
3#include <assert.h> 3#include <assert.h>
4#include <sys/stat.h> 4#include <sys/stat.h>
@@ -49,14 +49,17 @@ static void swaynag_button_execute(struct swaynag *swaynag,
49 if (fork() == 0) { 49 if (fork() == 0) {
50 // Child of the child. Will be reparented to the init process 50 // Child of the child. Will be reparented to the init process
51 char *terminal = getenv("TERMINAL"); 51 char *terminal = getenv("TERMINAL");
52 if (terminal && strlen(terminal)) { 52 if (button->terminal && terminal && strlen(terminal)) {
53 wlr_log(WLR_DEBUG, "Found $TERMINAL: %s", terminal); 53 wlr_log(WLR_DEBUG, "Found $TERMINAL: %s", terminal);
54 if (!terminal_execute(terminal, button->action)) { 54 if (!terminal_execute(terminal, button->action)) {
55 swaynag_destroy(swaynag); 55 swaynag_destroy(swaynag);
56 exit(EXIT_FAILURE); 56 exit(EXIT_FAILURE);
57 } 57 }
58 } else { 58 } else {
59 wlr_log(WLR_DEBUG, "$TERMINAL not found. Running directly"); 59 if (button->terminal) {
60 wlr_log(WLR_DEBUG,
61 "$TERMINAL not found. Running directly");
62 }
60 execl("/bin/sh", "/bin/sh", "-c", button->action, NULL); 63 execl("/bin/sh", "/bin/sh", "-c", button->action, NULL);
61 } 64 }
62 } 65 }
@@ -126,6 +129,8 @@ static void update_cursor(struct swaynag *swaynag) {
126 pointer->cursor_surface, 129 pointer->cursor_surface,
127 pointer->cursor_image->hotspot_x / swaynag->scale, 130 pointer->cursor_image->hotspot_x / swaynag->scale,
128 pointer->cursor_image->hotspot_y / swaynag->scale); 131 pointer->cursor_image->hotspot_y / swaynag->scale);
132 wl_surface_damage_buffer(pointer->cursor_surface, 0, 0,
133 INT32_MAX, INT32_MAX);
129 wl_surface_commit(pointer->cursor_surface); 134 wl_surface_commit(pointer->cursor_surface);
130} 135}
131 136
@@ -290,7 +295,7 @@ static void handle_global(void *data, struct wl_registry *registry,
290 struct swaynag *swaynag = data; 295 struct swaynag *swaynag = data;
291 if (strcmp(interface, wl_compositor_interface.name) == 0) { 296 if (strcmp(interface, wl_compositor_interface.name) == 0) {
292 swaynag->compositor = wl_registry_bind(registry, name, 297 swaynag->compositor = wl_registry_bind(registry, name,
293 &wl_compositor_interface, 3); 298 &wl_compositor_interface, 4);
294 } else if (strcmp(interface, wl_seat_interface.name) == 0) { 299 } else if (strcmp(interface, wl_seat_interface.name) == 0) {
295 swaynag->seat = wl_registry_bind(registry, name, &wl_seat_interface, 1); 300 swaynag->seat = wl_registry_bind(registry, name, &wl_seat_interface, 1);
296 wl_seat_add_listener(swaynag->seat, &seat_listener, swaynag); 301 wl_seat_add_listener(swaynag->seat, &seat_listener, swaynag);
@@ -404,15 +409,13 @@ void swaynag_destroy(struct swaynag *swaynag) {
404 swaynag->run_display = false; 409 swaynag->run_display = false;
405 410
406 free(swaynag->message); 411 free(swaynag->message);
407 while (swaynag->buttons->length) { 412 for (int i = 0; i < swaynag->buttons->length; ++i) {
408 struct swaynag_button *button = swaynag->buttons->items[0]; 413 struct swaynag_button *button = swaynag->buttons->items[i];
409 list_del(swaynag->buttons, 0);
410 free(button->text); 414 free(button->text);
411 free(button->action); 415 free(button->action);
412 free(button); 416 free(button);
413 } 417 }
414 list_free(swaynag->buttons); 418 list_free(swaynag->buttons);
415 free(swaynag->details.button_details);
416 free(swaynag->details.message); 419 free(swaynag->details.message);
417 free(swaynag->details.button_up.text); 420 free(swaynag->details.button_up.text);
418 free(swaynag->details.button_down.text); 421 free(swaynag->details.button_down.text);