From 09e11dabb203513c038b723e50de2fd836e7edb3 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Wed, 16 Aug 2023 17:45:01 -0400 Subject: scene_graph: Port opacity and filter modes --- sway/commands/opacity.c | 2 ++ sway/config/output.c | 1 + sway/desktop/output.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) 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) { } con->alpha = val; + container_update(con); + return cmd_results_new(CMD_SUCCESS, NULL); } 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) { if (scale_filter_old != output->scale_filter) { sway_log(SWAY_DEBUG, "Set %s scale_filter to %s", oc->name, sway_output_scale_filter_to_string(output->scale_filter)); + wlr_damage_ring_add_whole(&output->scene_output->damage_ring); } } 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, } } +static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output) { + switch (output->scale_filter) { + case SCALE_FILTER_LINEAR: + return WLR_SCALE_FILTER_BILINEAR; + case SCALE_FILTER_NEAREST: + return WLR_SCALE_FILTER_NEAREST; + default: + abort(); // unreachable + } +} + +static void output_configure_scene(struct sway_output *output, + struct wlr_scene_node *node, float opacity) { + if (!node->enabled) { + return; + } + + struct sway_container *con = + scene_descriptor_try_get(node, SWAY_SCENE_DESC_CONTAINER); + if (con) { + opacity = con->alpha; + } + + if (node->type == WLR_SCENE_NODE_BUFFER) { + struct wlr_scene_buffer *buffer = wlr_scene_buffer_from_node(node); + + // hack: don't call the scene setter because that will damage all outputs + // We don't want to damage outputs that aren't our current output that + // we're configuring + buffer->filter_mode = get_scale_filter(output); + + wlr_scene_buffer_set_opacity(buffer, opacity); + } else if (node->type == WLR_SCENE_NODE_TREE) { + struct wlr_scene_tree *tree = wlr_scene_tree_from_node(node); + struct wlr_scene_node *node; + wl_list_for_each(node, &tree->children, link) { + output_configure_scene(output, node, opacity); + } + } +} + static int output_repaint_timer_handler(void *data) { struct sway_output *output = data; @@ -191,6 +232,8 @@ static int output_repaint_timer_handler(void *data) { output->wlr_output->frame_pending = false; + output_configure_scene(output, &root->root_scene->tree.node, 1.0f); + if (output->gamma_lut_changed) { struct wlr_output_state pending; wlr_output_state_init(&pending); -- cgit v1.2.3