renderer: Tearing implementation (#3441)

This commit is contained in:
Vaxry 2023-09-28 21:48:33 +01:00 committed by GitHub
parent 1e513e25d5
commit 88b63a00b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 231 additions and 61 deletions

View file

@ -40,6 +40,8 @@ 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
if (m_bEnabled) {
wlr_output_enable(output, 1);
wlr_output_commit(output);

View file

@ -81,6 +81,13 @@ 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;
// for the special workspace. 0 means not open.
int specialWorkspaceID = 0;

View file

@ -245,6 +245,15 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
if (pNode->pSurface && pNode->pSurface->exists())
g_pHyprRenderer->damageSurface(pNode->pSurface->wlr(), lx, ly, SCALE);
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) {
PMONITOR->nextRenderTorn = true;
g_pHyprRenderer->renderMonitor(PMONITOR);
}
}
}
void Events::listener_destroySubsurface(void* owner, void* data) {

View file

@ -180,7 +180,7 @@ struct SConstraint {
Vector2D getLogicConstraintSize();
bool operator==(const SConstraint& b) const {
return constraint == b.constraint;
return constraint == b.constraint;
}
};
@ -393,3 +393,14 @@ struct SSwitchDevice {
return pWlrDevice == other.pWlrDevice;
}
};
struct STearingController {
wlr_tearing_control_v1* pWlrHint = nullptr;
DYNLISTENER(set);
DYNLISTENER(destroy);
bool operator==(const STearingController& other) {
return pWlrHint == other.pWlrHint;
}
};