minor fixes for new drm stuff

This commit is contained in:
Vaxry 2024-06-24 23:22:27 +02:00
parent 2dbb77b16b
commit 2b7c89474b
3 changed files with 57 additions and 2 deletions

View file

@ -258,6 +258,7 @@ void CCompositor::initServer() {
m_bInitialized = true; m_bInitialized = true;
m_iDRMFD = m_pAqBackend->drmFD(); m_iDRMFD = m_pAqBackend->drmFD();
Debug::log(LOG, "Running on DRMFD: {}", m_iDRMFD);
initManagers(STAGE_BASICINIT); initManagers(STAGE_BASICINIT);
@ -2852,6 +2853,8 @@ void CCompositor::onNewMonitor(SP<Aquamarine::IOutput> output) {
if (std::string("HEADLESS-1") == output->name) if (std::string("HEADLESS-1") == output->name)
g_pCompositor->m_pUnsafeOutput = PNEWMONITOR.get(); g_pCompositor->m_pUnsafeOutput = PNEWMONITOR.get();
Debug::log(LOG, "New output with name {}", output->name);
PNEWMONITOR->szName = output->name; PNEWMONITOR->szName = output->name;
PNEWMONITOR->output = output; PNEWMONITOR->output = output;
PNEWMONITOR->self = PNEWMONITOR; PNEWMONITOR->self = PNEWMONITOR;

View file

@ -131,6 +131,49 @@ std::string CHyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor>
return result; return result;
} }
std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
CVarList vars(request, 0, ' ');
auto allMonitors = false;
if (vars.size() > 2)
return "too many args";
if (vars.size() == 2 && vars[1] == "all")
allMonitors = true;
std::string result = "";
if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
result += "[";
for (auto& m : allMonitors ? g_pCompositor->m_vRealMonitors : g_pCompositor->m_vMonitors) {
result += CHyprCtl::getMonitorData(m, format);
}
trimTrailingComma(result);
result += "]";
} else {
for (auto& m : allMonitors ? g_pCompositor->m_vRealMonitors : g_pCompositor->m_vMonitors) {
if (!m->output || m->ID == -1ull)
continue;
result += std::format(
"Monitor {} (ID {}):\n\t{}x{}@{:.5f} at {}x{}\n\tdescription: {}\n\tmake: {}\n\tmodel: {}\n\tserial: {}\n\tactive workspace: {} ({})\n\t"
"special workspace: {} ({})\n\treserved: {} {} {} {}\n\tscale: {:.2f}\n\ttransform: {}\n\tfocused: {}\n\t"
"dpmsStatus: {}\n\tvrr: {}\n\tactivelyTearing: {}\n\tdisabled: {}\n\tcurrentFormat: {}\n\tavailableModes: {}\n\n",
m->szName, m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, m->szShortDescription,
m->output->make, m->output->model, m->output->serial, m->activeWorkspaceID(),
(!m->activeWorkspace ? "" : m->activeWorkspace->m_szName), m->activeSpecialWorkspaceID(), (m->activeSpecialWorkspace ? m->activeSpecialWorkspace->m_szName : ""),
(int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform,
(m == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus, (int)(m->output->state ? m->output->state->state().adaptiveSync : false),
m->tearingState.activelyTearing, !m->m_bEnabled, formatToString(m->drmFormat), availableModesForOutput(m.get(), format));
}
}
return result;
}
static std::string getTagsData(PHLWINDOW w, eHyprCtlOutputFormat format) { static std::string getTagsData(PHLWINDOW w, eHyprCtlOutputFormat format) {
const auto tags = w->m_tags.getTags(); const auto tags = w->m_tags.getTags();

View file

@ -27,7 +27,7 @@ static int cursorTicker(void* data) {
CHyprRenderer::CHyprRenderer() { CHyprRenderer::CHyprRenderer() {
if (g_pCompositor->m_pAqBackend->hasSession()) { if (g_pCompositor->m_pAqBackend->hasSession()) {
for (auto& dev : g_pCompositor->m_pAqBackend->session->sessionDevices) { for (auto& dev : g_pCompositor->m_pAqBackend->session->sessionDevices) {
const auto DRMV = drmGetVersion(dev->fd); const auto DRMV = drmGetVersion(dev->fd);
if (!DRMV) if (!DRMV)
continue; continue;
std::string name = std::string{DRMV->name, DRMV->name_len}; std::string name = std::string{DRMV->name, DRMV->name_len};
@ -1249,7 +1249,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
// check the damage // check the damage
bool hasChanged = /*pMonitor->output->needs_frame ||*/ pMonitor->damage.hasChanged(); bool hasChanged = pMonitor->output->needsFrame || pMonitor->damage.hasChanged();
if (!hasChanged && *PDAMAGETRACKINGMODE != DAMAGE_TRACKING_NONE && pMonitor->forceFullFrames == 0 && damageBlinkCleanup == 0) if (!hasChanged && *PDAMAGETRACKINGMODE != DAMAGE_TRACKING_NONE && pMonitor->forceFullFrames == 0 && damageBlinkCleanup == 0)
return; return;
@ -2604,6 +2604,15 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode
int bufferAge = 0; int bufferAge = 0;
if (!buffer) { if (!buffer) {
Aquamarine::SSwapchainOptions opts = pMonitor->output->swapchain->currentOptions();
opts.length = 2;
opts.size = pMonitor->currentMode->pixelSize;
opts.format = pMonitor->drmFormat;
if (!pMonitor->output->swapchain->reconfigure(opts)) {
Debug::log(ERR, "Failed to reconfigure swapchain for {}", pMonitor->szName);
return false;
}
m_pCurrentBuffer = pMonitor->output->swapchain->next(&bufferAge); m_pCurrentBuffer = pMonitor->output->swapchain->next(&bufferAge);
if (!m_pCurrentBuffer) { if (!m_pCurrentBuffer) {
Debug::log(ERR, "Failed to acquire swapchain buffer for {}", pMonitor->szName); Debug::log(ERR, "Failed to acquire swapchain buffer for {}", pMonitor->szName);