diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2023-08-16 17:45:01 -0400 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2024-01-18 18:36:54 +0300 |
commit | 09e11dabb203513c038b723e50de2fd836e7edb3 (patch) | |
tree | b8c6f417f87563f4ceb3eaff4fd88b41acdac367 | |
parent | scene_graph: Arrange scene graph on transaction apply (diff) | |
download | sway-09e11dabb203513c038b723e50de2fd836e7edb3.tar.gz sway-09e11dabb203513c038b723e50de2fd836e7edb3.tar.zst sway-09e11dabb203513c038b723e50de2fd836e7edb3.zip |
scene_graph: Port opacity and filter modes
-rw-r--r-- | sway/commands/opacity.c | 2 | ||||
-rw-r--r-- | sway/config/output.c | 1 | ||||
-rw-r--r-- | sway/desktop/output.c | 43 |
3 files changed, 46 insertions, 0 deletions
diff --git a/sway/commands/opacity.c b/sway/commands/opacity.c index 1c44a646..610cecc6 100644 --- a/sway/commands/opacity.c +++ b/sway/commands/opacity.c | |||
@@ -37,5 +37,7 @@ struct cmd_results *cmd_opacity(int argc, char **argv) { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | con->alpha = val; | 39 | con->alpha = val; |
40 | container_update(con); | ||
41 | |||
40 | return cmd_results_new(CMD_SUCCESS, NULL); | 42 | return cmd_results_new(CMD_SUCCESS, NULL); |
41 | } | 43 | } |
diff --git a/sway/config/output.c b/sway/config/output.c index 66baf194..1a5215fe 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -554,6 +554,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { | |||
554 | if (scale_filter_old != output->scale_filter) { | 554 | if (scale_filter_old != output->scale_filter) { |
555 | sway_log(SWAY_DEBUG, "Set %s scale_filter to %s", oc->name, | 555 | sway_log(SWAY_DEBUG, "Set %s scale_filter to %s", oc->name, |
556 | sway_output_scale_filter_to_string(output->scale_filter)); | 556 | sway_output_scale_filter_to_string(output->scale_filter)); |
557 | wlr_damage_ring_add_whole(&output->scene_output->damage_ring); | ||
557 | } | 558 | } |
558 | } | 559 | } |
559 | 560 | ||
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index aea2a8d7..9c4baafd 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -182,6 +182,47 @@ static void send_frame_done_iterator(struct wlr_scene_buffer *buffer, | |||
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output) { | ||
186 | switch (output->scale_filter) { | ||
187 | case SCALE_FILTER_LINEAR: | ||
188 | return WLR_SCALE_FILTER_BILINEAR; | ||
189 | case SCALE_FILTER_NEAREST: | ||
190 | return WLR_SCALE_FILTER_NEAREST; | ||
191 | default: | ||
192 | abort(); // unreachable | ||
193 | } | ||
194 | } | ||
195 | |||
196 | static void output_configure_scene(struct sway_output *output, | ||
197 | struct wlr_scene_node *node, float opacity) { | ||
198 | if (!node->enabled) { | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | struct sway_container *con = | ||
203 | scene_descriptor_try_get(node, SWAY_SCENE_DESC_CONTAINER); | ||
204 | if (con) { | ||
205 | opacity = con->alpha; | ||
206 | } | ||
207 | |||
208 | if (node->type == WLR_SCENE_NODE_BUFFER) { | ||
209 | struct wlr_scene_buffer *buffer = wlr_scene_buffer_from_node(node); | ||
210 | |||
211 | // hack: don't call the scene setter because that will damage all outputs | ||
212 | // We don't want to damage outputs that aren't our current output that | ||
213 | // we're configuring | ||
214 | buffer->filter_mode = get_scale_filter(output); | ||
215 | |||
216 | wlr_scene_buffer_set_opacity(buffer, opacity); | ||
217 | } else if (node->type == WLR_SCENE_NODE_TREE) { | ||
218 | struct wlr_scene_tree *tree = wlr_scene_tree_from_node(node); | ||
219 | struct wlr_scene_node *node; | ||
220 | wl_list_for_each(node, &tree->children, link) { | ||
221 | output_configure_scene(output, node, opacity); | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
185 | static int output_repaint_timer_handler(void *data) { | 226 | static int output_repaint_timer_handler(void *data) { |
186 | struct sway_output *output = data; | 227 | struct sway_output *output = data; |
187 | 228 | ||
@@ -191,6 +232,8 @@ static int output_repaint_timer_handler(void *data) { | |||
191 | 232 | ||
192 | output->wlr_output->frame_pending = false; | 233 | output->wlr_output->frame_pending = false; |
193 | 234 | ||
235 | output_configure_scene(output, &root->root_scene->tree.node, 1.0f); | ||
236 | |||
194 | if (output->gamma_lut_changed) { | 237 | if (output->gamma_lut_changed) { |
195 | struct wlr_output_state pending; | 238 | struct wlr_output_state pending; |
196 | wlr_output_state_init(&pending); | 239 | wlr_output_state_init(&pending); |