mirror of
https://github.com/swaywm/sway.git
synced 2024-12-27 15:36:29 +01:00
swaynag: remove xdg-output logic
We can just get the output name from wl_output directly, now that wl_output version 4 exists.
This commit is contained in:
parent
4732325f59
commit
57a7b3998e
4 changed files with 22 additions and 47 deletions
|
@ -5,7 +5,6 @@
|
|||
#include "list.h"
|
||||
#include "pool-buffer.h"
|
||||
#include "swaynag/types.h"
|
||||
#include "xdg-output-unstable-v1-client-protocol.h"
|
||||
|
||||
#define SWAYNAG_MAX_HEIGHT 500
|
||||
|
||||
|
@ -75,13 +74,11 @@ struct swaynag_details {
|
|||
|
||||
struct swaynag {
|
||||
bool run_display;
|
||||
int querying_outputs;
|
||||
|
||||
struct wl_display *display;
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_seat *seat;
|
||||
struct wl_shm *shm;
|
||||
struct zxdg_output_manager_v1 *xdg_output_manager;
|
||||
struct wl_list outputs; // swaynag_output::link
|
||||
struct wl_list seats; // swaynag_seat::link
|
||||
struct swaynag_output *output;
|
||||
|
|
|
@ -37,7 +37,7 @@ endif
|
|||
|
||||
jsonc = dependency('json-c', version: '>=0.13')
|
||||
pcre = dependency('libpcre')
|
||||
wayland_server = dependency('wayland-server')
|
||||
wayland_server = dependency('wayland-server', version: '>=1.20.0')
|
||||
wayland_client = dependency('wayland-client')
|
||||
wayland_cursor = dependency('wayland-cursor')
|
||||
wayland_egl = dependency('wayland-egl')
|
||||
|
|
|
@ -54,7 +54,6 @@ static void swaybar_output_free(struct swaybar_output *output) {
|
|||
if (output->input_region != NULL) {
|
||||
wl_region_destroy(output->input_region);
|
||||
}
|
||||
zxdg_output_v1_destroy(output->xdg_output);
|
||||
wl_output_destroy(output->output);
|
||||
destroy_buffer(&output->buffers[0]);
|
||||
destroy_buffer(&output->buffers[1]);
|
||||
|
|
|
@ -307,33 +307,25 @@ static void output_scale(void *data, struct wl_output *output,
|
|||
}
|
||||
}
|
||||
|
||||
static void output_name(void *data, struct wl_output *output,
|
||||
const char *name) {
|
||||
struct swaynag_output *swaynag_output = data;
|
||||
swaynag_output->name = strdup(name);
|
||||
|
||||
const char *outname = swaynag_output->swaynag->type->output;
|
||||
if (!swaynag_output->swaynag->output && outname &&
|
||||
strcmp(outname, name) == 0) {
|
||||
sway_log(SWAY_DEBUG, "Using output %s", name);
|
||||
swaynag_output->swaynag->output = swaynag_output;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_output_listener output_listener = {
|
||||
.geometry = nop,
|
||||
.mode = nop,
|
||||
.done = nop,
|
||||
.scale = output_scale,
|
||||
};
|
||||
|
||||
static void xdg_output_handle_name(void *data,
|
||||
struct zxdg_output_v1 *xdg_output, const char *name) {
|
||||
struct swaynag_output *swaynag_output = data;
|
||||
char *outname = swaynag_output->swaynag->type->output;
|
||||
sway_log(SWAY_DEBUG, "Checking against output %s for %s", name, outname);
|
||||
if (!swaynag_output->swaynag->output && outname && name
|
||||
&& strcmp(outname, name) == 0) {
|
||||
sway_log(SWAY_DEBUG, "Using output %s", name);
|
||||
swaynag_output->swaynag->output = swaynag_output;
|
||||
}
|
||||
swaynag_output->name = strdup(name);
|
||||
zxdg_output_v1_destroy(xdg_output);
|
||||
swaynag_output->swaynag->querying_outputs--;
|
||||
}
|
||||
|
||||
static const struct zxdg_output_v1_listener xdg_output_listener = {
|
||||
.logical_position = nop,
|
||||
.logical_size = nop,
|
||||
.done = nop,
|
||||
.name = xdg_output_handle_name,
|
||||
.name = output_name,
|
||||
.description = nop,
|
||||
};
|
||||
|
||||
|
@ -361,33 +353,21 @@ static void handle_global(void *data, struct wl_registry *registry,
|
|||
} else if (strcmp(interface, wl_shm_interface.name) == 0) {
|
||||
swaynag->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
|
||||
} else if (strcmp(interface, wl_output_interface.name) == 0) {
|
||||
if (!swaynag->output && swaynag->xdg_output_manager) {
|
||||
swaynag->querying_outputs++;
|
||||
if (!swaynag->output) {
|
||||
struct swaynag_output *output =
|
||||
calloc(1, sizeof(struct swaynag_output));
|
||||
output->wl_output = wl_registry_bind(registry, name,
|
||||
&wl_output_interface, 3);
|
||||
&wl_output_interface, 4);
|
||||
output->wl_name = name;
|
||||
output->scale = 1;
|
||||
output->swaynag = swaynag;
|
||||
wl_list_insert(&swaynag->outputs, &output->link);
|
||||
wl_output_add_listener(output->wl_output,
|
||||
&output_listener, output);
|
||||
|
||||
struct zxdg_output_v1 *xdg_output;
|
||||
xdg_output = zxdg_output_manager_v1_get_xdg_output(
|
||||
swaynag->xdg_output_manager, output->wl_output);
|
||||
zxdg_output_v1_add_listener(xdg_output,
|
||||
&xdg_output_listener, output);
|
||||
}
|
||||
} else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
|
||||
swaynag->layer_shell = wl_registry_bind(
|
||||
registry, name, &zwlr_layer_shell_v1_interface, 1);
|
||||
} else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0
|
||||
&& version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) {
|
||||
swaynag->xdg_output_manager = wl_registry_bind(registry, name,
|
||||
&zxdg_output_manager_v1_interface,
|
||||
ZXDG_OUTPUT_V1_NAME_SINCE_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,13 +433,12 @@ void swaynag_setup(struct swaynag *swaynag) {
|
|||
|
||||
assert(swaynag->compositor && swaynag->layer_shell && swaynag->shm);
|
||||
|
||||
while (swaynag->querying_outputs > 0) {
|
||||
// Second roundtrip to get wl_output properties
|
||||
if (wl_display_roundtrip(swaynag->display) < 0) {
|
||||
sway_log(SWAY_ERROR, "Error during outputs init.");
|
||||
swaynag_destroy(swaynag);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!swaynag->output && swaynag->type->output) {
|
||||
sway_log(SWAY_ERROR, "Output '%s' not found", swaynag->type->output);
|
||||
|
|
Loading…
Reference in a new issue