mirror of
https://github.com/swaywm/sway.git
synced 2026-04-18 06:46:56 -04:00
fix: review comments
This commit is contained in:
parent
81e67e18bb
commit
a9ba469715
7 changed files with 34 additions and 38 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, can_tear;
|
||||
bool allow_tearing, enable_tearing;
|
||||
};
|
||||
|
||||
struct sway_output_non_desktop {
|
||||
|
|
|
|||
|
|
@ -4,22 +4,21 @@
|
|||
#include "util.h"
|
||||
|
||||
struct cmd_results *cmd_allow_tearing(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "allow_tearing", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
|
||||
struct sway_container *container = config->handler_context.container;
|
||||
if (!container || !container->view) {
|
||||
return cmd_results_new(CMD_INVALID,
|
||||
"Tearing can only be allowed on views");
|
||||
}
|
||||
struct sway_container *container = config->handler_context.container;
|
||||
if (!container || !container->view) {
|
||||
return cmd_results_new(CMD_INVALID, "Tearing can only be allowed on views");
|
||||
}
|
||||
|
||||
bool wants_tearing = parse_boolean(argv[0], true);
|
||||
bool wants_tearing = parse_boolean(argv[0], true);
|
||||
|
||||
struct sway_view *view = container->view;
|
||||
view->tearing_mode = wants_tearing ? TEARING_OVERRIDE_TRUE :
|
||||
TEARING_OVERRIDE_FALSE;
|
||||
struct sway_view *view = container->view;
|
||||
view->tearing_mode = wants_tearing ? TEARING_OVERRIDE_TRUE :
|
||||
TEARING_OVERRIDE_FALSE;
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,20 +3,20 @@
|
|||
#include "util.h"
|
||||
|
||||
struct cmd_results *output_cmd_allow_tearing(int argc, char **argv) {
|
||||
if (!config->handler_context.output_config) {
|
||||
if (!config->handler_context.output_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "Missing output config");
|
||||
}
|
||||
if (argc == 0) {
|
||||
return cmd_results_new(CMD_INVALID, "Missing allow_tearing argument");
|
||||
}
|
||||
|
||||
if (parse_boolean(argv[0], true)) {
|
||||
config->handler_context.output_config->allow_tearing = 1;
|
||||
} else {
|
||||
config->handler_context.output_config->allow_tearing = 0;
|
||||
}
|
||||
if (parse_boolean(argv[0], true)) {
|
||||
config->handler_context.output_config->allow_tearing = 1;
|
||||
} else {
|
||||
config->handler_context.output_config->allow_tearing = 0;
|
||||
}
|
||||
|
||||
config->handler_context.leftovers.argc = argc - 1;
|
||||
config->handler_context.leftovers.argv = argv + 1;
|
||||
return NULL;
|
||||
config->handler_context.leftovers.argc = argc - 1;
|
||||
config->handler_context.leftovers.argv = argv + 1;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,19 +299,14 @@ static int output_repaint_timer_handler(void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
if (output->can_tear) {
|
||||
if (output->enable_tearing) {
|
||||
pending.tearing_page_flip = true;
|
||||
|
||||
if (!wlr_output_test_state(output->wlr_output, &pending)) {
|
||||
sway_log(SWAY_ERROR, "Output test failed on '%s', retrying without tearing page-flip",
|
||||
sway_log(SWAY_DEBUG, "Output test failed on '%s', retrying without tearing page-flip",
|
||||
output->wlr_output->name);
|
||||
|
||||
pending.tearing_page_flip = false;
|
||||
|
||||
if (!wlr_output_test_state(output->wlr_output, &pending)) {
|
||||
wlr_output_state_finish(&pending);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -388,11 +383,11 @@ static void handle_frame(struct wl_listener *listener, void *user_data) {
|
|||
int delay = msec_until_refresh - output->max_render_time;
|
||||
|
||||
struct sway_view *fullscreen_view = output_get_fullscreen_view(output);
|
||||
output->can_tear = output_can_tear_fullscreen_view(output, fullscreen_view);
|
||||
output->enable_tearing = output_can_tear_fullscreen_view(output, fullscreen_view);
|
||||
|
||||
// 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->can_tear) {
|
||||
if (delay < 1 || output->enable_tearing) {
|
||||
output_repaint_timer_handler(output);
|
||||
} else {
|
||||
output->wlr_output->frame_pending = true;
|
||||
|
|
|
|||
|
|
@ -191,17 +191,19 @@ must be separated by one space. For example:
|
|||
HDR support features.
|
||||
|
||||
*output* <name> allow_tearing yes|no
|
||||
Allows or disallows screen tearing as a result of asynchronous page flips,
|
||||
and an immediate presentation mode from a client.
|
||||
Allows or disallows screen tearing as a result of immediate page flips,
|
||||
and an immediate presentation mode from a client. The default is that no
|
||||
screen tearing is allowed.
|
||||
|
||||
With asynchronous page flips, frames from the client are presented as soon
|
||||
With immediate page flips, frames from the client are presented as soon
|
||||
as possible instead of synchronizing with the monitor's vblank interval
|
||||
(VSync). This prevents stutter and reduces latency in games.
|
||||
(VSync).
|
||||
|
||||
To adjust whether tearing is allowed for specific applications, see
|
||||
*allow_tearing* in *sway*(5).
|
||||
*allow_tearing* in *sway*(5). Note that tearing will only be enabled
|
||||
when it's allowed for both the output and the application.
|
||||
|
||||
This setting only has effect on fullscreen windows.
|
||||
This setting only has effect when a window is fullscreen on the output.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ set|plus|minus|toggle <amount>
|
|||
further details.
|
||||
|
||||
*allow_tearing* yes|no
|
||||
Allows or disallows screen tearing as a result of asynchronous page flips
|
||||
Allows or disallows screen tearing as a result of immediate page flips
|
||||
for a fullscreen application.
|
||||
|
||||
When this option is not set, the tearing hints provided by the application
|
||||
|
|
|
|||
|
|
@ -1262,7 +1262,7 @@ bool view_is_transient_for(struct sway_view *child,
|
|||
}
|
||||
|
||||
bool view_can_tear(struct sway_view *view) {
|
||||
switch(view->tearing_mode) {
|
||||
switch (view->tearing_mode) {
|
||||
case TEARING_OVERRIDE_FALSE:
|
||||
return false;
|
||||
case TEARING_OVERRIDE_TRUE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue