mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
Update output containers on output layout change
This commit is contained in:
parent
d293c42942
commit
a4619e98c4
|
@ -13,15 +13,7 @@ struct sway_output {
|
|||
struct sway_server *server;
|
||||
struct timespec last_frame;
|
||||
|
||||
struct {
|
||||
struct wl_signal scale;
|
||||
struct wl_signal transform;
|
||||
} events;
|
||||
|
||||
struct wl_listener frame;
|
||||
struct wl_listener resolution;
|
||||
struct wl_listener scale;
|
||||
struct wl_listener transform;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -113,13 +113,10 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
|
|||
if (oc && oc->scale > 0) {
|
||||
sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale);
|
||||
wlr_output_set_scale(wlr_output, oc->scale);
|
||||
wl_signal_emit(&output->sway_output->events.scale, output->sway_output);
|
||||
}
|
||||
if (oc && oc->transform >= 0) {
|
||||
sway_log(L_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
|
||||
wlr_output_transform(wlr_output, oc->transform);
|
||||
wl_signal_emit(&output->sway_output->events.transform,
|
||||
output->sway_output);
|
||||
wlr_output_set_transform(wlr_output, oc->transform);
|
||||
}
|
||||
|
||||
// Find position for it
|
||||
|
|
|
@ -91,32 +91,6 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
soutput->last_frame = now;
|
||||
}
|
||||
|
||||
static void output_update_size(struct sway_output *output) {
|
||||
struct wlr_box *output_layout_box = wlr_output_layout_get_box(
|
||||
root_container.sway_root->output_layout, output->wlr_output);
|
||||
output->swayc->x = output_layout_box->x;
|
||||
output->swayc->y = output_layout_box->y;
|
||||
output->swayc->width = output_layout_box->width;
|
||||
output->swayc->height = output_layout_box->height;
|
||||
|
||||
arrange_windows(output->swayc, -1, -1);
|
||||
}
|
||||
|
||||
static void output_resolution_notify(struct wl_listener *listener, void *data) {
|
||||
struct sway_output *output = wl_container_of(listener, output, resolution);
|
||||
output_update_size(output);
|
||||
}
|
||||
|
||||
static void output_scale_notify(struct wl_listener *listener, void *data) {
|
||||
struct sway_output *output = wl_container_of(listener, output, scale);
|
||||
output_update_size(output);
|
||||
}
|
||||
|
||||
static void output_transform_notify(struct wl_listener *listener, void *data) {
|
||||
struct sway_output *output = wl_container_of(listener, output, transform);
|
||||
output_update_size(output);
|
||||
}
|
||||
|
||||
void output_add_notify(struct wl_listener *listener, void *data) {
|
||||
struct sway_server *server = wl_container_of(listener, server, output_add);
|
||||
struct wlr_output *wlr_output = data;
|
||||
|
@ -129,8 +103,11 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
output->wlr_output = wlr_output;
|
||||
output->server = server;
|
||||
|
||||
wl_signal_init(&output->events.scale);
|
||||
wl_signal_init(&output->events.transform);
|
||||
if (!wl_list_empty(&wlr_output->modes)) {
|
||||
struct wlr_output_mode *mode =
|
||||
wl_container_of(wlr_output->modes.prev, mode, link);
|
||||
wlr_output_set_mode(wlr_output, mode);
|
||||
}
|
||||
|
||||
output->swayc = new_output(output);
|
||||
if (!output->swayc) {
|
||||
|
@ -138,22 +115,8 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!wl_list_empty(&wlr_output->modes)) {
|
||||
struct wlr_output_mode *mode = NULL;
|
||||
mode = wl_container_of((&wlr_output->modes)->prev, mode, link);
|
||||
wlr_output_set_mode(wlr_output, mode);
|
||||
}
|
||||
|
||||
output->frame.notify = output_frame_notify;
|
||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||
output->resolution.notify = output_resolution_notify;
|
||||
wl_signal_add(&wlr_output->events.resolution, &output->resolution);
|
||||
output->scale.notify = output_scale_notify;
|
||||
wl_signal_add(&output->events.scale, &output->scale);
|
||||
output->transform.notify = output_transform_notify;
|
||||
wl_signal_add(&output->events.transform, &output->transform);
|
||||
|
||||
arrange_windows(output->swayc, -1, -1);
|
||||
}
|
||||
|
||||
void output_remove_notify(struct wl_listener *listener, void *data) {
|
||||
|
|
|
@ -16,10 +16,24 @@
|
|||
swayc_t root_container;
|
||||
|
||||
static void output_layout_change_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_box *box = wlr_output_layout_get_box(
|
||||
struct wlr_box *layout_box = wlr_output_layout_get_box(
|
||||
root_container.sway_root->output_layout, NULL);
|
||||
root_container.width = box->width;
|
||||
root_container.height = box->height;
|
||||
root_container.width = layout_box->width;
|
||||
root_container.height = layout_box->height;
|
||||
|
||||
for (int i = 0 ; i < root_container.children->length; ++i) {
|
||||
swayc_t *output_container = root_container.children->items[i];
|
||||
struct sway_output *output = output_container->sway_output;
|
||||
|
||||
struct wlr_box *output_box = wlr_output_layout_get_box(
|
||||
root_container.sway_root->output_layout, output->wlr_output);
|
||||
output_container->x = output_box->x;
|
||||
output_container->y = output_box->y;
|
||||
output_container->width = output_box->width;
|
||||
output_container->height = output_box->height;
|
||||
}
|
||||
|
||||
arrange_windows(&root_container, -1, -1);
|
||||
}
|
||||
|
||||
void init_layout(void) {
|
||||
|
|
Loading…
Reference in a new issue