Skip to content

Commit

Permalink
Fix multiple "fake" focused output instances in list of outputs
Browse files Browse the repository at this point in the history
There should be only one. New "fake" output instance was inserted into
list of outputs every time physical output was connected. This can be
reproduced by having "output_mode = focused" and disconecting and
re-connecting physical output a few times.
  • Loading branch information
francma committed Nov 20, 2022
1 parent 30ea1ec commit 29e2536
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,7 @@ handle_global(void *data, struct wl_registry *registry, uint32_t name, const cha
app->wl_compositor = wl_registry_bind(registry, name, &wl_compositor_interface, 1);
}
else if (strcmp(interface, "wl_output") == 0) {
if (app->wob_config.output_mode == WOB_OUTPUT_MODE_FOCUSED) {
struct wob_output *output = calloc(1, sizeof(struct wob_output));
output->wl_output = NULL;
output->app = app;
output->wl_name = 0;
output->xdg_output = NULL;
output->name = strdup("focused");

wl_list_insert(&output->app->wob_outputs, &output->link);
}
else {
if (app->wob_config.output_mode != WOB_OUTPUT_MODE_FOCUSED) {
struct wob_output *output = calloc(1, sizeof(struct wob_output));
output->wl_output = wl_registry_bind(registry, name, &wl_output_interface, 1);
output->app = app;
Expand Down Expand Up @@ -369,7 +359,18 @@ wob_connect(struct wob *app)
exit(EXIT_FAILURE);
}

struct wob_dimensions dimensions = app->wob_config.dimensions;
if (app->wob_config.output_mode == WOB_OUTPUT_MODE_FOCUSED) {
struct wob_output *output = calloc(1, sizeof(struct wob_output));
output->wl_output = NULL;
output->app = app;
output->wl_name = 0;
output->xdg_output = NULL;
output->name = strdup("focused");

wl_list_insert(&app->wob_outputs, &output->link);
}

struct wob_dimensions dimensions = app->wob_config.dimensions;
struct wl_shm_pool *pool = wl_shm_create_pool(app->wl_shm, app->shmid, dimensions.height * dimensions.width * 4);
if (pool == NULL) {
wob_log_error("wl_shm_create_pool failed");
Expand Down

0 comments on commit 29e2536

Please sign in to comment.