diff options
author | 2018-05-19 23:33:36 +1000 | |
---|---|---|
committer | 2018-05-19 23:33:36 +1000 | |
commit | 9fd28aea8cc78fc19bbde3ca9c25e3e7a5465f96 (patch) | |
tree | 602dfad3130297a3fb46c8d0f1c8b13aa3b76c37 /sway/tree/container.c | |
parent | Merge pull request #1982 from RyanDwyer/show-marks (diff) | |
download | sway-9fd28aea8cc78fc19bbde3ca9c25e3e7a5465f96.tar.gz sway-9fd28aea8cc78fc19bbde3ca9c25e3e7a5465f96.tar.zst sway-9fd28aea8cc78fc19bbde3ca9c25e3e7a5465f96.zip |
Rebuild textures if needed when moving a container
When moving a container to an output which has a different scale than
the previous, rebuild the title and marks textures at the new scale.
Fixes #1999.
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index e47338e7..feaf7647 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -73,6 +73,44 @@ static void container_close_notify(struct sway_container *container) { | |||
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | static void container_update_textures_recursive(struct sway_container *con) { | ||
77 | container_update_title_textures(con); | ||
78 | |||
79 | if (con->type == C_VIEW) { | ||
80 | view_update_marks_textures(con->sway_view); | ||
81 | } else { | ||
82 | for (int i = 0; i < con->children->length; ++i) { | ||
83 | struct sway_container *child = con->children->items[i]; | ||
84 | container_update_textures_recursive(child); | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | static void handle_reparent(struct wl_listener *listener, | ||
90 | void *data) { | ||
91 | struct sway_container *container = | ||
92 | wl_container_of(listener, container, reparent); | ||
93 | struct sway_container *old_parent = data; | ||
94 | |||
95 | struct sway_container *old_output = old_parent; | ||
96 | if (old_output != NULL && old_output->type != C_OUTPUT) { | ||
97 | old_output = container_parent(old_output, C_OUTPUT); | ||
98 | } | ||
99 | |||
100 | struct sway_container *new_output = container->parent; | ||
101 | if (new_output != NULL && new_output->type != C_OUTPUT) { | ||
102 | new_output = container_parent(new_output, C_OUTPUT); | ||
103 | } | ||
104 | |||
105 | if (old_output && new_output) { | ||
106 | float old_scale = old_output->sway_output->wlr_output->scale; | ||
107 | float new_scale = new_output->sway_output->wlr_output->scale; | ||
108 | if (old_scale != new_scale) { | ||
109 | container_update_textures_recursive(container); | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | |||
76 | struct sway_container *container_create(enum sway_container_type type) { | 114 | struct sway_container *container_create(enum sway_container_type type) { |
77 | // next id starts at 1 because 0 is assigned to root_container in layout.c | 115 | // next id starts at 1 because 0 is assigned to root_container in layout.c |
78 | static size_t next_id = 1; | 116 | static size_t next_id = 1; |
@@ -92,6 +130,9 @@ struct sway_container *container_create(enum sway_container_type type) { | |||
92 | wl_signal_init(&c->events.destroy); | 130 | wl_signal_init(&c->events.destroy); |
93 | wl_signal_init(&c->events.reparent); | 131 | wl_signal_init(&c->events.reparent); |
94 | 132 | ||
133 | wl_signal_add(&c->events.reparent, &c->reparent); | ||
134 | c->reparent.notify = handle_reparent; | ||
135 | |||
95 | return c; | 136 | return c; |
96 | } | 137 | } |
97 | 138 | ||