diff options
author | 2021-12-13 18:33:32 +0100 | |
---|---|---|
committer | 2021-12-13 20:17:20 -0600 | |
commit | 57a7b3998ea62616223000eb6369c999b4cd1a94 (patch) | |
tree | b008d40847ea177b20120d53c1d923638906e52f | |
parent | Add support for linux-dmabuf surface hints (diff) | |
download | sway-57a7b3998ea62616223000eb6369c999b4cd1a94.tar.gz sway-57a7b3998ea62616223000eb6369c999b4cd1a94.tar.zst sway-57a7b3998ea62616223000eb6369c999b4cd1a94.zip |
swaynag: remove xdg-output logic
We can just get the output name from wl_output directly, now that
wl_output version 4 exists.
-rw-r--r-- | include/swaynag/swaynag.h | 3 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | swaybar/bar.c | 1 | ||||
-rw-r--r-- | swaynag/swaynag.c | 59 |
4 files changed, 20 insertions, 45 deletions
diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h index 9e39e716..baa6ee8b 100644 --- a/include/swaynag/swaynag.h +++ b/include/swaynag/swaynag.h | |||
@@ -5,7 +5,6 @@ | |||
5 | #include "list.h" | 5 | #include "list.h" |
6 | #include "pool-buffer.h" | 6 | #include "pool-buffer.h" |
7 | #include "swaynag/types.h" | 7 | #include "swaynag/types.h" |
8 | #include "xdg-output-unstable-v1-client-protocol.h" | ||
9 | 8 | ||
10 | #define SWAYNAG_MAX_HEIGHT 500 | 9 | #define SWAYNAG_MAX_HEIGHT 500 |
11 | 10 | ||
@@ -75,13 +74,11 @@ struct swaynag_details { | |||
75 | 74 | ||
76 | struct swaynag { | 75 | struct swaynag { |
77 | bool run_display; | 76 | bool run_display; |
78 | int querying_outputs; | ||
79 | 77 | ||
80 | struct wl_display *display; | 78 | struct wl_display *display; |
81 | struct wl_compositor *compositor; | 79 | struct wl_compositor *compositor; |
82 | struct wl_seat *seat; | 80 | struct wl_seat *seat; |
83 | struct wl_shm *shm; | 81 | struct wl_shm *shm; |
84 | struct zxdg_output_manager_v1 *xdg_output_manager; | ||
85 | struct wl_list outputs; // swaynag_output::link | 82 | struct wl_list outputs; // swaynag_output::link |
86 | struct wl_list seats; // swaynag_seat::link | 83 | struct wl_list seats; // swaynag_seat::link |
87 | struct swaynag_output *output; | 84 | struct swaynag_output *output; |
diff --git a/meson.build b/meson.build index 72bce0ee..be1af04a 100644 --- a/meson.build +++ b/meson.build | |||
@@ -37,7 +37,7 @@ endif | |||
37 | 37 | ||
38 | jsonc = dependency('json-c', version: '>=0.13') | 38 | jsonc = dependency('json-c', version: '>=0.13') |
39 | pcre = dependency('libpcre') | 39 | pcre = dependency('libpcre') |
40 | wayland_server = dependency('wayland-server') | 40 | wayland_server = dependency('wayland-server', version: '>=1.20.0') |
41 | wayland_client = dependency('wayland-client') | 41 | wayland_client = dependency('wayland-client') |
42 | wayland_cursor = dependency('wayland-cursor') | 42 | wayland_cursor = dependency('wayland-cursor') |
43 | wayland_egl = dependency('wayland-egl') | 43 | wayland_egl = dependency('wayland-egl') |
diff --git a/swaybar/bar.c b/swaybar/bar.c index 18b87e6d..6ffdc9b4 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -54,7 +54,6 @@ static void swaybar_output_free(struct swaybar_output *output) { | |||
54 | if (output->input_region != NULL) { | 54 | if (output->input_region != NULL) { |
55 | wl_region_destroy(output->input_region); | 55 | wl_region_destroy(output->input_region); |
56 | } | 56 | } |
57 | zxdg_output_v1_destroy(output->xdg_output); | ||
58 | wl_output_destroy(output->output); | 57 | wl_output_destroy(output->output); |
59 | destroy_buffer(&output->buffers[0]); | 58 | destroy_buffer(&output->buffers[0]); |
60 | destroy_buffer(&output->buffers[1]); | 59 | destroy_buffer(&output->buffers[1]); |
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 6d4a7a58..9b57d578 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c | |||
@@ -307,33 +307,25 @@ static void output_scale(void *data, struct wl_output *output, | |||
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | static const struct wl_output_listener output_listener = { | 310 | static void output_name(void *data, struct wl_output *output, |
311 | .geometry = nop, | 311 | const char *name) { |
312 | .mode = nop, | ||
313 | .done = nop, | ||
314 | .scale = output_scale, | ||
315 | }; | ||
316 | |||
317 | static void xdg_output_handle_name(void *data, | ||
318 | struct zxdg_output_v1 *xdg_output, const char *name) { | ||
319 | struct swaynag_output *swaynag_output = data; | 312 | struct swaynag_output *swaynag_output = data; |
320 | char *outname = swaynag_output->swaynag->type->output; | 313 | swaynag_output->name = strdup(name); |
321 | sway_log(SWAY_DEBUG, "Checking against output %s for %s", name, outname); | 314 | |
322 | if (!swaynag_output->swaynag->output && outname && name | 315 | const char *outname = swaynag_output->swaynag->type->output; |
323 | && strcmp(outname, name) == 0) { | 316 | if (!swaynag_output->swaynag->output && outname && |
317 | strcmp(outname, name) == 0) { | ||
324 | sway_log(SWAY_DEBUG, "Using output %s", name); | 318 | sway_log(SWAY_DEBUG, "Using output %s", name); |
325 | swaynag_output->swaynag->output = swaynag_output; | 319 | swaynag_output->swaynag->output = swaynag_output; |
326 | } | 320 | } |
327 | swaynag_output->name = strdup(name); | ||
328 | zxdg_output_v1_destroy(xdg_output); | ||
329 | swaynag_output->swaynag->querying_outputs--; | ||
330 | } | 321 | } |
331 | 322 | ||
332 | static const struct zxdg_output_v1_listener xdg_output_listener = { | 323 | static const struct wl_output_listener output_listener = { |
333 | .logical_position = nop, | 324 | .geometry = nop, |
334 | .logical_size = nop, | 325 | .mode = nop, |
335 | .done = nop, | 326 | .done = nop, |
336 | .name = xdg_output_handle_name, | 327 | .scale = output_scale, |
328 | .name = output_name, | ||
337 | .description = nop, | 329 | .description = nop, |
338 | }; | 330 | }; |
339 | 331 | ||
@@ -361,33 +353,21 @@ static void handle_global(void *data, struct wl_registry *registry, | |||
361 | } else if (strcmp(interface, wl_shm_interface.name) == 0) { | 353 | } else if (strcmp(interface, wl_shm_interface.name) == 0) { |
362 | swaynag->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); | 354 | swaynag->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); |
363 | } else if (strcmp(interface, wl_output_interface.name) == 0) { | 355 | } else if (strcmp(interface, wl_output_interface.name) == 0) { |
364 | if (!swaynag->output && swaynag->xdg_output_manager) { | 356 | if (!swaynag->output) { |
365 | swaynag->querying_outputs++; | ||
366 | struct swaynag_output *output = | 357 | struct swaynag_output *output = |
367 | calloc(1, sizeof(struct swaynag_output)); | 358 | calloc(1, sizeof(struct swaynag_output)); |
368 | output->wl_output = wl_registry_bind(registry, name, | 359 | output->wl_output = wl_registry_bind(registry, name, |
369 | &wl_output_interface, 3); | 360 | &wl_output_interface, 4); |
370 | output->wl_name = name; | 361 | output->wl_name = name; |
371 | output->scale = 1; | 362 | output->scale = 1; |
372 | output->swaynag = swaynag; | 363 | output->swaynag = swaynag; |
373 | wl_list_insert(&swaynag->outputs, &output->link); | 364 | wl_list_insert(&swaynag->outputs, &output->link); |
374 | wl_output_add_listener(output->wl_output, | 365 | wl_output_add_listener(output->wl_output, |
375 | &output_listener, output); | 366 | &output_listener, output); |
376 | |||
377 | struct zxdg_output_v1 *xdg_output; | ||
378 | xdg_output = zxdg_output_manager_v1_get_xdg_output( | ||
379 | swaynag->xdg_output_manager, output->wl_output); | ||
380 | zxdg_output_v1_add_listener(xdg_output, | ||
381 | &xdg_output_listener, output); | ||
382 | } | 367 | } |
383 | } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { | 368 | } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { |
384 | swaynag->layer_shell = wl_registry_bind( | 369 | swaynag->layer_shell = wl_registry_bind( |
385 | registry, name, &zwlr_layer_shell_v1_interface, 1); | 370 | registry, name, &zwlr_layer_shell_v1_interface, 1); |
386 | } else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0 | ||
387 | && version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) { | ||
388 | swaynag->xdg_output_manager = wl_registry_bind(registry, name, | ||
389 | &zxdg_output_manager_v1_interface, | ||
390 | ZXDG_OUTPUT_V1_NAME_SINCE_VERSION); | ||
391 | } | 371 | } |
392 | } | 372 | } |
393 | 373 | ||
@@ -453,12 +433,11 @@ void swaynag_setup(struct swaynag *swaynag) { | |||
453 | 433 | ||
454 | assert(swaynag->compositor && swaynag->layer_shell && swaynag->shm); | 434 | assert(swaynag->compositor && swaynag->layer_shell && swaynag->shm); |
455 | 435 | ||
456 | while (swaynag->querying_outputs > 0) { | 436 | // Second roundtrip to get wl_output properties |
457 | if (wl_display_roundtrip(swaynag->display) < 0) { | 437 | if (wl_display_roundtrip(swaynag->display) < 0) { |
458 | sway_log(SWAY_ERROR, "Error during outputs init."); | 438 | sway_log(SWAY_ERROR, "Error during outputs init."); |
459 | swaynag_destroy(swaynag); | 439 | swaynag_destroy(swaynag); |
460 | exit(EXIT_FAILURE); | 440 | exit(EXIT_FAILURE); |
461 | } | ||
462 | } | 441 | } |
463 | 442 | ||
464 | if (!swaynag->output && swaynag->type->output) { | 443 | if (!swaynag->output && swaynag->type->output) { |