fix fix number 2 finally works

This commit is contained in:
vaxerski 2022-07-13 18:16:43 +02:00
parent d775852c71
commit 91d903a409
9 changed files with 27 additions and 7 deletions

View File

@ -190,6 +190,7 @@ void CCompositor::initAllSignals() {
addWLSignal(&m_sWLRVirtPtrMgr->events.new_virtual_pointer, &Events::listen_newVirtPtr, m_sWLRVirtPtrMgr, "VirtPtrMgr");
addWLSignal(&m_sWLRRenderer->events.destroy, &Events::listen_RendererDestroy, m_sWLRRenderer, "WLRRenderer");
addWLSignal(&m_sWLRIdleInhibitMgr->events.new_inhibitor, &Events::listen_newIdleInhibitor, m_sWLRIdleInhibitMgr, "WLRIdleInhibitMgr");
addWLSignal(&m_sWLRSession->events.active, &Events::listen_sessionActive, m_sWLRSession, "Session");
}
void CCompositor::cleanup() {
@ -1343,3 +1344,10 @@ void CCompositor::updateWorkspaceWindowDecos(const int& id) {
w->updateWindowDecos();
}
}
void CCompositor::scheduleFrameForMonitor(SMonitor* pMonitor) {
if (!m_sWLRSession->active || !m_bSessionActive)
return;
wlr_output_schedule_frame(pMonitor->output);
}

View File

@ -91,6 +91,7 @@ public:
SSeat m_sSeat;
bool m_bReadyToProcess = false;
bool m_bSessionActive = true;
// ------------------------------------------------- //
@ -144,6 +145,7 @@ public:
void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
void moveUnmanagedX11ToWindows(CWindow*);
CWindow* getX11Parent(CWindow*);
void scheduleFrameForMonitor(SMonitor*);
private:
void initAllSignals();

View File

@ -278,7 +278,7 @@ std::string getRequestFromThread(std::string rq) {
// this might be a race condition
// tested with 2 instances of `watch -n 0.1 hyprctl splash` and seems to not crash so I'll take that as a yes
if (!*PNOVFR)
wlr_output_schedule_frame(g_pCompositor->m_vMonitors.front()->output);
g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_vMonitors.front().get());
while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) {
std::this_thread::sleep_for(std::chrono::milliseconds(5));

View File

@ -119,4 +119,7 @@ namespace Events {
LISTENER(swipeBegin);
LISTENER(swipeEnd);
LISTENER(swipeUpdate);
// session
LISTENER(sessionActive);
};

View File

@ -157,4 +157,10 @@ void Events::listener_InhibitDeactivate(wl_listener* listener, void* data) {
void Events::listener_RendererDestroy(wl_listener* listener, void* data) {
Debug::log(LOG, "!!Renderer destroyed!!");
}
void Events::listener_sessionActive(wl_listener* listener, void* data) {
Debug::log(LOG, "Session got activated!");
g_pCompositor->m_bSessionActive = true;
}

View File

@ -166,7 +166,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
void Events::listener_monitorFrame(void* owner, void* data) {
SMonitor* const PMONITOR = (SMonitor*)owner;
if (!g_pCompositor->m_sWLRSession->active) {
if (!g_pCompositor->m_sWLRSession->active || !g_pCompositor->m_bSessionActive) {
Debug::log(WARN, "Attempted to render frame on inactive session!");
return; // cannot draw on session inactive (different tty)
}
@ -191,7 +191,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
PMONITOR->framesToSkip -= 1;
if (!PMONITOR->noFrameSchedule)
wlr_output_schedule_frame(PMONITOR->output);
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
else {
Debug::log(LOG, "NoFrameSchedule hit for %s.", PMONITOR->szName.c_str());
}
@ -241,7 +241,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
wlr_output_rollback(PMONITOR->output);
if (*PDAMAGEBLINK || *PNOVFR)
wlr_output_schedule_frame(PMONITOR->output);
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
return;
}
@ -331,7 +331,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
wlr_output_commit(PMONITOR->output);
if (*PDAMAGEBLINK || *PNOVFR)
wlr_output_schedule_frame(PMONITOR->output);
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
if (*PDEBUGOVERLAY == 1) {
const float µs = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - startRender).count() / 1000.f;

View File

@ -195,7 +195,7 @@ void CAnimationManager::tick() {
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
// manually schedule a frame
wlr_output_schedule_frame(PMONITOR->output);
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
}
}

View File

@ -140,6 +140,7 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
if (PSESSION) {
const int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
wlr_session_change_vt(PSESSION, TTY);
g_pCompositor->m_bSessionActive = false;
for (auto& m : g_pCompositor->m_vMonitors) {
m->noFrameSchedule = true;

View File

@ -599,7 +599,7 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
// schedule frame events
if (!wl_list_empty(&pSurface->current.frame_callback_list)) {
wlr_output_schedule_frame(g_pCompositor->getMonitorFromVector(Vector2D(x, y))->output);
g_pCompositor->scheduleFrameForMonitor(g_pCompositor->getMonitorFromVector(Vector2D(x, y)));
}
if (!pixman_region32_not_empty(&damageBox)) {