mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 09:21:28 +00:00
desktop/output: Do not use commit listener to arrange
The reasoning for using a commit handler is to ensure that all paths for
output changes are correctly handled. With the centralized modeset
infrastructure in place, we can move the logic there. This allows us to
be smarter and avoid extraneous arranges, output manager updates and
transaction commits.
The side-effect is a minor duplication for the special-case
request_state, but the shared path will be relied upon further in future
commits to justify this duplication.
(cherry picked from commit b83e5aaa54
)
This commit is contained in:
parent
307ab531c0
commit
2f1db190c6
|
@ -149,4 +149,6 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener,
|
|||
|
||||
struct sway_output_non_desktop *output_non_desktop_create(struct wlr_output *wlr_output);
|
||||
|
||||
void update_output_manager_config(struct sway_server *server);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,9 +12,12 @@
|
|||
#include <wlr/types/wlr_output_swapchain_manager.h>
|
||||
#include <xf86drm.h>
|
||||
#include "sway/config.h"
|
||||
#include "sway/desktop/transaction.h"
|
||||
#include "sway/input/cursor.h"
|
||||
#include "sway/layers.h"
|
||||
#include "sway/output.h"
|
||||
#include "sway/server.h"
|
||||
#include "sway/tree/arrange.h"
|
||||
#include "sway/tree/root.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
@ -980,8 +983,13 @@ bool apply_output_configs(struct matched_output_config *configs,
|
|||
sway_log(SWAY_DEBUG, "Finalizing config for %s",
|
||||
cfg->output->wlr_output->name);
|
||||
finalize_output_config(cfg->config, cfg->output);
|
||||
arrange_layers(cfg->output);
|
||||
}
|
||||
|
||||
arrange_root();
|
||||
update_output_manager_config(&server);
|
||||
transaction_commit_dirty();
|
||||
|
||||
out:
|
||||
wlr_output_swapchain_manager_finish(&swapchain_mgr);
|
||||
for (size_t idx = 0; idx < configs_len; idx++) {
|
||||
|
|
|
@ -374,7 +374,7 @@ static void handle_frame(struct wl_listener *listener, void *user_data) {
|
|||
wlr_scene_output_for_each_buffer(output->scene_output, send_frame_done_iterator, &data);
|
||||
}
|
||||
|
||||
static void update_output_manager_config(struct sway_server *server) {
|
||||
void update_output_manager_config(struct sway_server *server) {
|
||||
struct wlr_output_configuration_v1 *config =
|
||||
wlr_output_configuration_v1_create();
|
||||
|
||||
|
@ -405,9 +405,6 @@ static int timer_modeset_handle(void *data) {
|
|||
server->delayed_modeset = NULL;
|
||||
|
||||
apply_all_output_configs();
|
||||
transaction_commit_dirty();
|
||||
update_output_manager_config(server);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -463,17 +460,6 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (event->state->committed & (
|
||||
WLR_OUTPUT_STATE_MODE |
|
||||
WLR_OUTPUT_STATE_TRANSFORM |
|
||||
WLR_OUTPUT_STATE_SCALE)) {
|
||||
arrange_layers(output);
|
||||
arrange_output(output);
|
||||
transaction_commit_dirty();
|
||||
|
||||
update_output_manager_config(output->server);
|
||||
}
|
||||
|
||||
// Next time the output is enabled, try to re-apply the gamma LUT
|
||||
if ((event->state->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) {
|
||||
output->gamma_lut_changed = true;
|
||||
|
@ -496,7 +482,20 @@ static void handle_request_state(struct wl_listener *listener, void *data) {
|
|||
struct sway_output *output =
|
||||
wl_container_of(listener, output, request_state);
|
||||
const struct wlr_output_event_request_state *event = data;
|
||||
|
||||
uint32_t committed = event->state->committed;
|
||||
wlr_output_commit_state(output->wlr_output, event->state);
|
||||
|
||||
if (committed & (
|
||||
WLR_OUTPUT_STATE_MODE |
|
||||
WLR_OUTPUT_STATE_TRANSFORM |
|
||||
WLR_OUTPUT_STATE_SCALE)) {
|
||||
arrange_layers(output);
|
||||
arrange_output(output);
|
||||
transaction_commit_dirty();
|
||||
|
||||
update_output_manager_config(output->server);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int last_headless_num = 0;
|
||||
|
|
Loading…
Reference in a new issue