mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-22 07:02:28 +00:00
fix layout hotplugging issue in output-layout.c
This commit is contained in:
parent
f25511ee3d
commit
fa3d4ecc84
@ -42,6 +42,10 @@ static void handle_output_frame(struct output_state *output,
|
|||||||
struct sample_state *sample = state->data;
|
struct sample_state *sample = state->data;
|
||||||
struct wlr_output *wlr_output = output->output;
|
struct wlr_output *wlr_output = output->output;
|
||||||
|
|
||||||
|
if (sample->main_output == NULL) {
|
||||||
|
sample->main_output = wlr_output;
|
||||||
|
}
|
||||||
|
|
||||||
wlr_output_make_current(wlr_output);
|
wlr_output_make_current(wlr_output);
|
||||||
wlr_renderer_begin(sample->renderer, wlr_output);
|
wlr_renderer_begin(sample->renderer, wlr_output);
|
||||||
|
|
||||||
@ -124,15 +128,6 @@ static void handle_output_frame(struct output_state *output,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_main_output(struct sample_state *sample,
|
|
||||||
struct wlr_output *output) {
|
|
||||||
sample->main_output = output;
|
|
||||||
struct wlr_output_layout_output *l_output;
|
|
||||||
l_output = wlr_output_layout_get(sample->layout, output);
|
|
||||||
sample->x_offs = l_output->x + 200;
|
|
||||||
sample->y_offs = l_output->y + 200;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_output_add(struct output_state *ostate) {
|
static void handle_output_add(struct output_state *ostate) {
|
||||||
struct sample_state *sample = ostate->compositor->data;
|
struct sample_state *sample = ostate->compositor->data;
|
||||||
wl_list_insert(&sample->outputs, &ostate->link);
|
wl_list_insert(&sample->outputs, &ostate->link);
|
||||||
@ -147,8 +142,16 @@ static void handle_output_add(struct output_state *ostate) {
|
|||||||
} else {
|
} else {
|
||||||
wlr_output_layout_add_auto(sample->layout, ostate->output);
|
wlr_output_layout_add_auto(sample->layout, ostate->output);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set_main_output(sample, ostate->output);
|
static void handle_output_remove(struct output_state *ostate) {
|
||||||
|
struct sample_state *sample = ostate->compositor->data;
|
||||||
|
|
||||||
|
if (sample->main_output == ostate->output) {
|
||||||
|
sample->main_output = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_output_layout_remove(sample->layout, ostate->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_velocities(struct compositor_state *state,
|
static void update_velocities(struct compositor_state *state,
|
||||||
@ -195,6 +198,7 @@ int main(int argc, char *argv[]) {
|
|||||||
struct compositor_state compositor = { 0 };
|
struct compositor_state compositor = { 0 };
|
||||||
compositor.data = &state;
|
compositor.data = &state;
|
||||||
compositor.output_add_cb = handle_output_add;
|
compositor.output_add_cb = handle_output_add;
|
||||||
|
compositor.output_remove_cb = handle_output_remove;
|
||||||
compositor.output_frame_cb = handle_output_frame;
|
compositor.output_frame_cb = handle_output_frame;
|
||||||
compositor.keyboard_key_cb = handle_keyboard_key;
|
compositor.keyboard_key_cb = handle_keyboard_key;
|
||||||
compositor_init(&compositor);
|
compositor_init(&compositor);
|
||||||
|
@ -29,6 +29,7 @@ struct wlr_output_layout *wlr_output_layout_init() {
|
|||||||
|
|
||||||
static void wlr_output_layout_output_destroy(
|
static void wlr_output_layout_output_destroy(
|
||||||
struct wlr_output_layout_output *l_output) {
|
struct wlr_output_layout_output *l_output) {
|
||||||
|
wl_list_remove(&l_output->state->resolution.link);
|
||||||
wl_list_remove(&l_output->link);
|
wl_list_remove(&l_output->link);
|
||||||
free(l_output->state->_box);
|
free(l_output->state->_box);
|
||||||
free(l_output->state);
|
free(l_output->state);
|
||||||
|
Loading…
Reference in New Issue
Block a user