aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag/swaynag.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaynag/swaynag.c')
-rw-r--r--swaynag/swaynag.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index d9bec368..6d4a7a58 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -30,8 +30,8 @@ static bool terminal_execute(char *terminal, char *command) {
30 chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR); 30 chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR);
31 char *cmd = malloc(sizeof(char) * (strlen(terminal) + strlen(" -e ") + strlen(fname) + 1)); 31 char *cmd = malloc(sizeof(char) * (strlen(terminal) + strlen(" -e ") + strlen(fname) + 1));
32 sprintf(cmd, "%s -e %s", terminal, fname); 32 sprintf(cmd, "%s -e %s", terminal, fname);
33 execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); 33 execlp("sh", "sh", "-c", cmd, NULL);
34 sway_log_errno(SWAY_ERROR, "Failed to run command, execl() returned."); 34 sway_log_errno(SWAY_ERROR, "Failed to run command, execlp() returned.");
35 free(cmd); 35 free(cmd);
36 return false; 36 return false;
37} 37}
@@ -69,8 +69,8 @@ static void swaynag_button_execute(struct swaynag *swaynag,
69 sway_log(SWAY_DEBUG, 69 sway_log(SWAY_DEBUG,
70 "$TERMINAL not found. Running directly"); 70 "$TERMINAL not found. Running directly");
71 } 71 }
72 execl("/bin/sh", "/bin/sh", "-c", button->action, NULL); 72 execlp("sh", "sh", "-c", button->action, NULL);
73 sway_log_errno(SWAY_DEBUG, "execl failed"); 73 sway_log_errno(SWAY_DEBUG, "execlp failed");
74 _exit(EXIT_FAILURE); 74 _exit(EXIT_FAILURE);
75 } 75 }
76 } 76 }
@@ -103,7 +103,7 @@ static void layer_surface_closed(void *data,
103 swaynag_destroy(swaynag); 103 swaynag_destroy(swaynag);
104} 104}
105 105
106static struct zwlr_layer_surface_v1_listener layer_surface_listener = { 106static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
107 .configure = layer_surface_configure, 107 .configure = layer_surface_configure,
108 .closed = layer_surface_closed, 108 .closed = layer_surface_closed,
109}; 109};
@@ -124,7 +124,7 @@ static void surface_enter(void *data, struct wl_surface *surface,
124 }; 124 };
125} 125}
126 126
127static struct wl_surface_listener surface_listener = { 127static const struct wl_surface_listener surface_listener = {
128 .enter = surface_enter, 128 .enter = surface_enter,
129 .leave = nop, 129 .leave = nop,
130}; 130};
@@ -178,6 +178,8 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
178 wl_fixed_t surface_x, wl_fixed_t surface_y) { 178 wl_fixed_t surface_x, wl_fixed_t surface_y) {
179 struct swaynag_seat *seat = data; 179 struct swaynag_seat *seat = data;
180 struct swaynag_pointer *pointer = &seat->pointer; 180 struct swaynag_pointer *pointer = &seat->pointer;
181 pointer->x = wl_fixed_to_int(surface_x);
182 pointer->y = wl_fixed_to_int(surface_y);
181 pointer->serial = serial; 183 pointer->serial = serial;
182 update_cursor(seat); 184 update_cursor(seat);
183} 185}
@@ -198,8 +200,8 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
198 return; 200 return;
199 } 201 }
200 202
201 double x = seat->pointer.x * swaynag->scale; 203 double x = seat->pointer.x;
202 double y = seat->pointer.y * swaynag->scale; 204 double y = seat->pointer.y;
203 for (int i = 0; i < swaynag->buttons->length; i++) { 205 for (int i = 0; i < swaynag->buttons->length; i++) {
204 struct swaynag_button *nagbutton = swaynag->buttons->items[i]; 206 struct swaynag_button *nagbutton = swaynag->buttons->items[i];
205 if (x >= nagbutton->x 207 if (x >= nagbutton->x
@@ -263,7 +265,7 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
263 render_frame(swaynag); 265 render_frame(swaynag);
264} 266}
265 267
266static struct wl_pointer_listener pointer_listener = { 268static const struct wl_pointer_listener pointer_listener = {
267 .enter = wl_pointer_enter, 269 .enter = wl_pointer_enter,
268 .leave = nop, 270 .leave = nop,
269 .motion = wl_pointer_motion, 271 .motion = wl_pointer_motion,
@@ -289,7 +291,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
289 } 291 }
290} 292}
291 293
292const struct wl_seat_listener seat_listener = { 294static const struct wl_seat_listener seat_listener = {
293 .capabilities = seat_handle_capabilities, 295 .capabilities = seat_handle_capabilities,
294 .name = nop, 296 .name = nop,
295}; 297};
@@ -305,7 +307,7 @@ static void output_scale(void *data, struct wl_output *output,
305 } 307 }
306} 308}
307 309
308static struct wl_output_listener output_listener = { 310static const struct wl_output_listener output_listener = {
309 .geometry = nop, 311 .geometry = nop,
310 .mode = nop, 312 .mode = nop,
311 .done = nop, 313 .done = nop,
@@ -327,7 +329,7 @@ static void xdg_output_handle_name(void *data,
327 swaynag_output->swaynag->querying_outputs--; 329 swaynag_output->swaynag->querying_outputs--;
328} 330}
329 331
330static struct zxdg_output_v1_listener xdg_output_listener = { 332static const struct zxdg_output_v1_listener xdg_output_listener = {
331 .logical_position = nop, 333 .logical_position = nop,
332 .logical_size = nop, 334 .logical_size = nop,
333 .done = nop, 335 .done = nop,
@@ -474,7 +476,8 @@ void swaynag_setup(struct swaynag *swaynag) {
474 swaynag->layer_surface = zwlr_layer_shell_v1_get_layer_surface( 476 swaynag->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
475 swaynag->layer_shell, swaynag->surface, 477 swaynag->layer_shell, swaynag->surface,
476 swaynag->output ? swaynag->output->wl_output : NULL, 478 swaynag->output ? swaynag->output->wl_output : NULL,
477 ZWLR_LAYER_SHELL_V1_LAYER_TOP, "swaynag"); 479 swaynag->type->layer,
480 "swaynag");
478 assert(swaynag->layer_surface); 481 assert(swaynag->layer_surface);
479 zwlr_layer_surface_v1_add_listener(swaynag->layer_surface, 482 zwlr_layer_surface_v1_add_listener(swaynag->layer_surface,
480 &layer_surface_listener, swaynag); 483 &layer_surface_listener, swaynag);