mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-12-22 21:39:47 +01:00
core: create surface on monitor connect
This commit is contained in:
parent
a7cffd0f77
commit
1f268e0a39
5 changed files with 43 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "Output.hpp"
|
#include "Output.hpp"
|
||||||
#include "../helpers/Log.hpp"
|
#include "../helpers/Log.hpp"
|
||||||
|
#include "hyprlock.hpp"
|
||||||
|
#include "../renderer/Renderer.hpp"
|
||||||
|
|
||||||
static void handleGeometry(void* data, wl_output* output, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char* make,
|
static void handleGeometry(void* data, wl_output* output, 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) {
|
const char* model, int32_t transform) {
|
||||||
|
@ -13,15 +15,23 @@ static void handleMode(void* data, wl_output* output, uint32_t flags, int32_t wi
|
||||||
const auto POUTPUT = (COutput*)data;
|
const auto POUTPUT = (COutput*)data;
|
||||||
|
|
||||||
// handle portrait mode and flipped cases
|
// handle portrait mode and flipped cases
|
||||||
if (POUTPUT->transform == WL_OUTPUT_TRANSFORM_270 || POUTPUT->transform == WL_OUTPUT_TRANSFORM_90 ||
|
if (POUTPUT->transform == WL_OUTPUT_TRANSFORM_270 || POUTPUT->transform == WL_OUTPUT_TRANSFORM_90 || POUTPUT->transform == WL_OUTPUT_TRANSFORM_FLIPPED_270 ||
|
||||||
POUTPUT->transform == WL_OUTPUT_TRANSFORM_FLIPPED_270 || POUTPUT->transform == WL_OUTPUT_TRANSFORM_FLIPPED_90)
|
POUTPUT->transform == WL_OUTPUT_TRANSFORM_FLIPPED_90)
|
||||||
POUTPUT->size = {height, width};
|
POUTPUT->size = {height, width};
|
||||||
else
|
else
|
||||||
POUTPUT->size = {width, height};
|
POUTPUT->size = {width, height};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleDone(void* data, wl_output* output) {
|
static void handleDone(void* data, wl_output* output) {
|
||||||
;
|
const auto POUTPUT = (COutput*)data;
|
||||||
|
Debug::log(LOG, "output {} done", POUTPUT->name);
|
||||||
|
if (g_pHyprlock->m_bLocked && !POUTPUT->sessionLockSurface) {
|
||||||
|
// if we are already locked, create a surface dynamically after a small timeout
|
||||||
|
// we also need to request a dma frame for screenshots
|
||||||
|
Debug::log(LOG, "Creating a surface dynamically for output as we are already locked");
|
||||||
|
POUTPUT->sessionLockSurface = std::make_unique<CSessionLockSurface>(POUTPUT);
|
||||||
|
g_pRenderer->asyncResourceGatherer->recheckDMAFramesFor(POUTPUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleScale(void* data, wl_output* output, int32_t factor) {
|
static void handleScale(void* data, wl_output* output, int32_t factor) {
|
||||||
|
|
|
@ -713,6 +713,7 @@ void CHyprlock::unlockSession() {
|
||||||
Debug::log(LOG, "Unlocked, exiting!");
|
Debug::log(LOG, "Unlocked, exiting!");
|
||||||
|
|
||||||
m_bTerminate = true;
|
m_bTerminate = true;
|
||||||
|
m_bLocked = false;
|
||||||
|
|
||||||
wl_display_roundtrip(m_sWaylandState.display);
|
wl_display_roundtrip(m_sWaylandState.display);
|
||||||
}
|
}
|
||||||
|
@ -723,6 +724,8 @@ void CHyprlock::onLockLocked() {
|
||||||
for (auto& o : m_vOutputs) {
|
for (auto& o : m_vOutputs) {
|
||||||
o->sessionLockSurface = std::make_unique<CSessionLockSurface>(o.get());
|
o->sessionLockSurface = std::make_unique<CSessionLockSurface>(o.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_bLocked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprlock::onLockFinished() {
|
void CHyprlock::onLockFinished() {
|
||||||
|
|
|
@ -72,6 +72,8 @@ class CHyprlock {
|
||||||
|
|
||||||
bool m_bTerminate = false;
|
bool m_bTerminate = false;
|
||||||
|
|
||||||
|
bool m_bLocked = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
std::chrono::system_clock::time_point m_tGraceEnds;
|
std::chrono::system_clock::time_point m_tGraceEnds;
|
||||||
Vector2D m_vLastEnterCoords = {};
|
Vector2D m_vLastEnterCoords = {};
|
||||||
|
|
|
@ -53,6 +53,30 @@ CAsyncResourceGatherer::CAsyncResourceGatherer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAsyncResourceGatherer::recheckDMAFramesFor(COutput* output) {
|
||||||
|
const auto CWIDGETS = g_pConfigManager->getWidgetConfigs();
|
||||||
|
|
||||||
|
bool shouldMake = false;
|
||||||
|
|
||||||
|
for (auto& c : CWIDGETS) {
|
||||||
|
if (c.type != "background")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (std::string{std::any_cast<Hyprlang::STRING>(c.values.at("path"))} != "screenshot")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (c.monitor.empty() || c.monitor == output->stringPort) {
|
||||||
|
shouldMake = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shouldMake)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dmas.emplace_back(std::make_unique<CDMAFrame>(output));
|
||||||
|
}
|
||||||
|
|
||||||
SPreloadedAsset* CAsyncResourceGatherer::getAssetByID(const std::string& id) {
|
SPreloadedAsset* CAsyncResourceGatherer::getAssetByID(const std::string& id) {
|
||||||
if (asyncLoopState.busy)
|
if (asyncLoopState.busy)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,7 @@ class CAsyncResourceGatherer {
|
||||||
void unloadAsset(SPreloadedAsset* asset);
|
void unloadAsset(SPreloadedAsset* asset);
|
||||||
void notify();
|
void notify();
|
||||||
void await();
|
void await();
|
||||||
|
void recheckDMAFramesFor(COutput* output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::thread initThread;
|
std::thread initThread;
|
||||||
|
|
Loading…
Reference in a new issue