mirror of
https://github.com/swaywm/sway.git
synced 2026-04-18 06:46:56 -04:00
fix: don't mess with output timings when tearing is enabled
This commit is contained in:
parent
c810995119
commit
77b965dc33
2 changed files with 21 additions and 23 deletions
|
|
@ -73,7 +73,7 @@ struct sway_output {
|
|||
int max_render_time; // In milliseconds
|
||||
struct wl_event_source *repaint_timer;
|
||||
bool gamma_lut_changed;
|
||||
bool allow_tearing, enable_tearing;
|
||||
bool allow_tearing;
|
||||
};
|
||||
|
||||
struct sway_output_non_desktop {
|
||||
|
|
|
|||
|
|
@ -232,6 +232,23 @@ static void output_configure_scene(struct sway_output *output,
|
|||
}
|
||||
}
|
||||
|
||||
static bool output_can_tear(struct sway_output *output) {
|
||||
struct sway_workspace *workspace = output->current.active_workspace;
|
||||
if (!workspace) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct sway_container *fullscreen_con = root->fullscreen_global;
|
||||
if (!fullscreen_con) {
|
||||
fullscreen_con = workspace->current.fullscreen;
|
||||
}
|
||||
if (fullscreen_con && fullscreen_con->view) {
|
||||
return (output->allow_tearing && view_can_tear(fullscreen_con->view));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int output_repaint_timer_handler(void *data) {
|
||||
struct sway_output *output = data;
|
||||
|
||||
|
|
@ -276,7 +293,7 @@ static int output_repaint_timer_handler(void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
if (output->enable_tearing) {
|
||||
if (output_can_tear(output)) {
|
||||
pending.tearing_page_flip = true;
|
||||
|
||||
if (!wlr_output_test_state(output->wlr_output, &pending)) {
|
||||
|
|
@ -294,23 +311,6 @@ static int output_repaint_timer_handler(void *data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool output_can_tear(struct sway_output *output) {
|
||||
struct sway_workspace *workspace = output->current.active_workspace;
|
||||
if (!workspace) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct sway_container *fullscreen_con = root->fullscreen_global;
|
||||
if (!fullscreen_con) {
|
||||
fullscreen_con = workspace->current.fullscreen;
|
||||
}
|
||||
if (fullscreen_con && fullscreen_con->view) {
|
||||
return (output->allow_tearing && view_can_tear(fullscreen_con->view));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void handle_frame(struct wl_listener *listener, void *user_data) {
|
||||
struct sway_output *output =
|
||||
wl_container_of(listener, output, frame);
|
||||
|
|
@ -358,11 +358,9 @@ static void handle_frame(struct wl_listener *listener, void *user_data) {
|
|||
|
||||
int delay = msec_until_refresh - output->max_render_time;
|
||||
|
||||
output->enable_tearing = output_can_tear(output);
|
||||
|
||||
// If the delay is less than 1 millisecond (which is the least we can wait)
|
||||
// or if the output is allowed to tear, then just render right away.
|
||||
if (delay < 1 || output->enable_tearing) {
|
||||
// then just render right away.
|
||||
if (delay < 1) {
|
||||
output_repaint_timer_handler(output);
|
||||
} else {
|
||||
output->wlr_output->frame_pending = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue