tearing: cleanup vars and avoid rendering before drm is ready
This commit is contained in:
parent
e2b72b2975
commit
a2a29a60e5
6 changed files with 37 additions and 33 deletions
|
|
@ -40,7 +40,7 @@ void CMonitor::onConnect(bool noRule) {
|
|||
hyprListener_monitorCommit.initCallback(&output->events.commit, &Events::listener_monitorCommit, this);
|
||||
hyprListener_monitorBind.initCallback(&output->events.bind, &Events::listener_monitorBind, this);
|
||||
|
||||
canTear = wlr_backend_is_drm(output->backend); // tearing only works on drm
|
||||
tearingState.canTear = wlr_backend_is_drm(output->backend); // tearing only works on drm
|
||||
|
||||
if (m_bEnabled) {
|
||||
wlr_output_enable(output, 1);
|
||||
|
|
|
|||
|
|
@ -82,12 +82,16 @@ class CMonitor {
|
|||
CRegion lastFrameDamage; // stores last frame damage
|
||||
|
||||
// for tearing
|
||||
CWindow* solitaryClient = nullptr;
|
||||
bool canTear = false;
|
||||
bool nextRenderTorn = false;
|
||||
bool ignoreNextFlipEvent = false;
|
||||
bool renderingFromVblankEvent = false;
|
||||
bool activelyTearing = false;
|
||||
CWindow* solitaryClient = nullptr;
|
||||
|
||||
struct {
|
||||
bool canTear = false;
|
||||
bool nextRenderTorn = false;
|
||||
bool activelyTearing = false;
|
||||
|
||||
bool busy = false;
|
||||
bool frameScheduledWhileBusy = false;
|
||||
} tearingState;
|
||||
|
||||
// for the special workspace. 0 means not open.
|
||||
int specialWorkspaceID = 0;
|
||||
|
|
|
|||
|
|
@ -249,14 +249,19 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
|
|||
if (pNode->pWindowOwner) {
|
||||
// tearing: if solitary, redraw it. This still might be a single surface window
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pNode->pWindowOwner->m_iMonitorID);
|
||||
if (PMONITOR->solitaryClient == pNode->pWindowOwner && pNode->pWindowOwner->canBeTorn() && PMONITOR->canTear) {
|
||||
if (PMONITOR->solitaryClient == pNode->pWindowOwner && pNode->pWindowOwner->canBeTorn() && PMONITOR->tearingState.canTear) {
|
||||
|
||||
CRegion damageBox;
|
||||
wlr_surface_get_effective_damage(pNode->pSurface->wlr(), damageBox.pixman());
|
||||
|
||||
if (!damageBox.empty()) {
|
||||
PMONITOR->nextRenderTorn = true;
|
||||
g_pHyprRenderer->renderMonitor(PMONITOR);
|
||||
|
||||
if (PMONITOR->tearingState.busy) {
|
||||
PMONITOR->tearingState.frameScheduledWhileBusy = true;
|
||||
} else {
|
||||
PMONITOR->tearingState.nextRenderTorn = true;
|
||||
g_pHyprRenderer->renderMonitor(PMONITOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue