mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
Zonai master (#1)
* simplify tearing implementation --------- Co-authored-by: Andrew J. Hesford <ajh@sideband.org>
This commit is contained in:
parent
fc69b80234
commit
8b7e953a25
6 changed files with 40 additions and 46 deletions
|
|
@ -133,10 +133,10 @@ this is for compatibility with Openbox.
|
||||||
Allow tearing to reduce input lag. Default is no.
|
Allow tearing to reduce input lag. Default is no.
|
||||||
This open requires setting the environment variable WLR_DRM_NO_ATOMIC=1.
|
This open requires setting the environment variable WLR_DRM_NO_ATOMIC=1.
|
||||||
|
|
||||||
*yes* allow tearing if an open window requests it.
|
*yes* allow tearing if the active window requests it.
|
||||||
|
|
||||||
*fullscreen* allow tearing if an open window requests it, or if any
|
*fullscreen* allow tearing if the active window requests it or is in
|
||||||
window is in fullscreen mode.
|
fullscreen mode.
|
||||||
|
|
||||||
*always* allow tearing regardless of window status.
|
*always* allow tearing regardless of window status.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ enum adaptive_sync_mode {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum tearing_mode {
|
enum tearing_mode {
|
||||||
LAB_TEARING_DISABLED,
|
LAB_TEARING_DISABLED = 0,
|
||||||
LAB_TEARING_ENABLED,
|
LAB_TEARING_ENABLED,
|
||||||
LAB_TEARING_FULLSCREEN,
|
LAB_TEARING_FULLSCREEN,
|
||||||
LAB_TEARING_ALWAYS,
|
LAB_TEARING_ALWAYS,
|
||||||
|
|
|
||||||
|
|
@ -361,7 +361,6 @@ struct output {
|
||||||
|
|
||||||
bool leased;
|
bool leased;
|
||||||
bool gamma_lut_changed;
|
bool gamma_lut_changed;
|
||||||
bool tearing;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef LAB_NR_LAYERS
|
#undef LAB_NR_LAYERS
|
||||||
|
|
@ -484,7 +483,6 @@ void output_add_virtual(struct server *server, const char *output_name);
|
||||||
void output_remove_virtual(struct server *server, const char *output_name);
|
void output_remove_virtual(struct server *server, const char *output_name);
|
||||||
void output_enable_adaptive_sync(struct wlr_output *output, bool enabled);
|
void output_enable_adaptive_sync(struct wlr_output *output, bool enabled);
|
||||||
void new_tearing_hint(struct wl_listener *listener, void *data);
|
void new_tearing_hint(struct wl_listener *listener, void *data);
|
||||||
void set_tearing(struct output *output);
|
|
||||||
|
|
||||||
void server_init(struct server *server);
|
void server_init(struct server *server);
|
||||||
void server_start(struct server *server);
|
void server_start(struct server *server);
|
||||||
|
|
|
||||||
44
src/output.c
44
src/output.c
|
|
@ -27,6 +27,40 @@
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "xwayland.h"
|
#include "xwayland.h"
|
||||||
|
|
||||||
|
static bool
|
||||||
|
get_tearing_preference(struct output *output)
|
||||||
|
{
|
||||||
|
struct server *server = output->server;
|
||||||
|
|
||||||
|
/* Never allow tearing when disabled */
|
||||||
|
if (rc.allow_tearing == LAB_TEARING_DISABLED) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allows allow tearing when forced */
|
||||||
|
if (rc.allow_tearing == LAB_TEARING_ALWAYS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tearing is only allowed for the output with the active view */
|
||||||
|
if (!server->active_view || server->active_view->output != output) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the active view requests tearing, allow it */
|
||||||
|
if (server->active_view->tearing_hint) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the active view is fullscreen, allow tearing if configured */
|
||||||
|
if (rc.allow_tearing == LAB_TEARING_FULLSCREEN &&
|
||||||
|
server->active_view->fullscreen) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
output_frame_notify(struct wl_listener *listener, void *data)
|
output_frame_notify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
|
|
@ -68,8 +102,8 @@ output_frame_notify(struct wl_listener *listener, void *data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
output->wlr_output->pending.tearing_page_flip = output->tearing;
|
output->wlr_output->pending.tearing_page_flip =
|
||||||
|
get_tearing_preference(output);
|
||||||
lab_wlr_scene_output_commit(output->scene_output);
|
lab_wlr_scene_output_commit(output->scene_output);
|
||||||
|
|
||||||
struct timespec now = { 0 };
|
struct timespec now = { 0 };
|
||||||
|
|
@ -275,12 +309,6 @@ new_output_notify(struct wl_listener *listener, void *data)
|
||||||
|
|
||||||
wl_list_init(&output->regions);
|
wl_list_init(&output->regions);
|
||||||
|
|
||||||
if (rc.allow_tearing == LAB_TEARING_ALWAYS) {
|
|
||||||
output->tearing = true;
|
|
||||||
} else {
|
|
||||||
output->tearing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create layer-trees (background, bottom, top and overlay) and
|
* Create layer-trees (background, bottom, top and overlay) and
|
||||||
* a layer-popup-tree.
|
* a layer-popup-tree.
|
||||||
|
|
|
||||||
|
|
@ -48,33 +48,3 @@ new_tearing_hint(struct wl_listener *listener, void *data)
|
||||||
controller->destroy.notify = tearing_controller_destroy;
|
controller->destroy.notify = tearing_controller_destroy;
|
||||||
wl_signal_add(&tearing_control->events.destroy, &controller->destroy);
|
wl_signal_add(&tearing_control->events.destroy, &controller->destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
set_tearing(struct output *output)
|
|
||||||
{
|
|
||||||
if (rc.allow_tearing == LAB_TEARING_DISABLED) {
|
|
||||||
output->tearing = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc.allow_tearing == LAB_TEARING_ALWAYS) {
|
|
||||||
output->tearing = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct server *server = output->server;
|
|
||||||
struct view *view;
|
|
||||||
bool on_fullscreen = rc.allow_tearing == LAB_TEARING_FULLSCREEN;
|
|
||||||
|
|
||||||
wl_list_for_each(view, &server->views, link) {
|
|
||||||
if (view->output != output) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view->tearing_hint || (on_fullscreen && view->fullscreen)) {
|
|
||||||
output->tearing = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output->tearing = false;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,6 @@ view_set_activated(struct view *view, bool activated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_adaptive_sync_fullscreen(view);
|
set_adaptive_sync_fullscreen(view);
|
||||||
set_tearing(view->output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1200,7 +1199,6 @@ view_set_fullscreen(struct view *view, bool fullscreen)
|
||||||
view_apply_special_geometry(view);
|
view_apply_special_geometry(view);
|
||||||
}
|
}
|
||||||
set_adaptive_sync_fullscreen(view);
|
set_adaptive_sync_fullscreen(view);
|
||||||
set_tearing(view->output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue