2024-02-18 23:08:03 +00:00
|
|
|
#include "Output.hpp"
|
|
|
|
|
#include "../helpers/Log.hpp"
|
2024-02-26 17:58:50 +00:00
|
|
|
#include "hyprlock.hpp"
|
2024-02-18 23:08:03 +00:00
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
void COutput::create(WP<COutput> pSelf, SP<CCWlOutput> pWlOutput, uint32_t _name) {
|
|
|
|
|
m_ID = _name;
|
|
|
|
|
m_wlOutput = pWlOutput;
|
|
|
|
|
m_self = pSelf;
|
|
|
|
|
|
|
|
|
|
m_wlOutput->setDescription([this](CCWlOutput* r, const char* description) {
|
2024-12-29 18:36:08 +00:00
|
|
|
stringDesc = description ? std::string{description} : "";
|
2026-03-31 14:56:08 +00:00
|
|
|
Log::logger->log(Log::INFO, "output {} description {}", m_ID, stringDesc);
|
2024-12-29 18:36:08 +00:00
|
|
|
});
|
|
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
m_wlOutput->setName([this](CCWlOutput* r, const char* name) {
|
2024-12-29 18:36:08 +00:00
|
|
|
stringName = std::string{name} + stringName;
|
|
|
|
|
stringPort = std::string{name};
|
2026-03-31 14:56:08 +00:00
|
|
|
Log::logger->log(Log::INFO, "output {} name {}", name, name);
|
2024-12-29 18:36:08 +00:00
|
|
|
});
|
|
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
m_wlOutput->setScale([this](CCWlOutput* r, int32_t sc) { scale = sc; });
|
2024-12-29 18:36:08 +00:00
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
m_wlOutput->setDone([this](CCWlOutput* r) {
|
2025-02-16 06:29:52 +00:00
|
|
|
done = true;
|
2026-03-31 14:56:08 +00:00
|
|
|
Log::logger->log(Log::INFO, "output {} done", m_ID);
|
2025-03-05 08:35:43 +01:00
|
|
|
if (g_pHyprlock->m_lockAquired && !m_sessionLockSurface) {
|
2026-03-31 14:56:08 +00:00
|
|
|
Log::logger->log(Log::INFO, "output {} creating a new lock surface", m_ID);
|
2025-03-05 08:35:43 +01:00
|
|
|
createSessionLockSurface();
|
2024-12-29 18:36:08 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
m_wlOutput->setMode([this](CCWlOutput* r, uint32_t flags, int32_t width, int32_t height, int32_t refresh) {
|
2024-12-29 18:36:08 +00:00
|
|
|
// handle portrait mode and flipped cases
|
|
|
|
|
if (transform % 2 == 1)
|
|
|
|
|
size = {height, width};
|
|
|
|
|
else
|
|
|
|
|
size = {width, height};
|
|
|
|
|
});
|
|
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
m_wlOutput->setGeometry(
|
2025-01-03 22:57:16 +00:00
|
|
|
[this](CCWlOutput* r, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char* make, const char* model, int32_t transform_) {
|
|
|
|
|
transform = (wl_output_transform)transform_;
|
2024-12-29 18:36:08 +00:00
|
|
|
|
2026-03-31 14:56:08 +00:00
|
|
|
Log::logger->log(Log::INFO, "output {} make {} model {}", m_ID, make ? make : "", model ? model : "");
|
2024-12-29 18:36:08 +00:00
|
|
|
});
|
2024-03-24 00:06:54 +03:00
|
|
|
}
|
2025-03-05 08:35:43 +01:00
|
|
|
|
|
|
|
|
void COutput::createSessionLockSurface() {
|
2025-03-08 09:58:29 +00:00
|
|
|
if (!m_self.valid()) {
|
2026-03-31 14:56:08 +00:00
|
|
|
Log::logger->log(Log::ERR, "output {} dead??", m_ID);
|
2025-03-08 09:58:29 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_sessionLockSurface) {
|
2026-03-31 14:56:08 +00:00
|
|
|
Log::logger->log(Log::ERR, "output {} already has a session lock surface", m_ID);
|
2025-03-08 09:58:29 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-07 11:15:41 +02:00
|
|
|
if (size == Vector2D{0, 0}) {
|
2026-03-31 14:56:08 +00:00
|
|
|
Log::logger->log(Log::WARN, "output {} refusing to create a lock surface with size 0x0", m_ID);
|
2025-04-07 11:15:41 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
m_sessionLockSurface = makeUnique<CSessionLockSurface>(m_self.lock());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vector2D COutput::getViewport() const {
|
|
|
|
|
return (m_sessionLockSurface) ? m_sessionLockSurface->size : size;
|
|
|
|
|
}
|