mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-12-22 05:19:48 +01:00
core: add fractional_scaling option (#456)
* config: add fractional_scaling option 0 -> off 1 -> on 2 -> auto * core: default auto option for fractional_scaling * locksurface: fallback to integer scaling
This commit is contained in:
parent
8cffe0618c
commit
9393a3e94d
4 changed files with 29 additions and 20 deletions
|
@ -49,6 +49,7 @@ void CConfigManager::init() {
|
|||
m_config.addConfigValue("general:ignore_empty_input", Hyprlang::INT{0});
|
||||
m_config.addConfigValue("general:immediate_render", Hyprlang::INT{0});
|
||||
m_config.addConfigValue("general:pam_module", Hyprlang::STRING{"hyprlock"});
|
||||
m_config.addConfigValue("general:fractional_scaling", Hyprlang::INT{2});
|
||||
|
||||
m_config.addSpecialCategory("background", Hyprlang::SSpecialCategoryOptions{.key = nullptr, .anonymousKeyBased = true});
|
||||
m_config.addSpecialConfigValue("background", "monitor", Hyprlang::STRING{""});
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "../helpers/Log.hpp"
|
||||
#include "Egl.hpp"
|
||||
#include "../renderer/Renderer.hpp"
|
||||
#include "src/config/ConfigManager.hpp"
|
||||
|
||||
static void handleConfigure(void* data, ext_session_lock_surface_v1* surf, uint32_t serial, uint32_t width, uint32_t height) {
|
||||
const auto PSURF = (CSessionLockSurface*)data;
|
||||
|
@ -53,9 +54,13 @@ CSessionLockSurface::CSessionLockSurface(COutput* output) : output(output) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
const auto PFRACTIONALSCALING = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:fractional_scaling");
|
||||
const auto ENABLE_FSV1 = **PFRACTIONALSCALING == 1 ||
|
||||
/* auto */ (**PFRACTIONALSCALING == 2 && (g_pHyprlock->m_sCurrentDesktop == "Hyprland" || g_pHyprlock->m_sCurrentDesktop == "niri"));
|
||||
const auto PFRACTIONALMGR = g_pHyprlock->getFractionalMgr();
|
||||
const auto PVIEWPORTER = g_pHyprlock->getViewporter();
|
||||
if (PFRACTIONALMGR && PVIEWPORTER) {
|
||||
|
||||
if (ENABLE_FSV1 && PFRACTIONALMGR && PVIEWPORTER) {
|
||||
fractional = wp_fractional_scale_manager_v1_get_fractional_scale(PFRACTIONALMGR, surface);
|
||||
if (fractional) {
|
||||
wp_fractional_scale_v1_add_listener(fractional, &fsListener, this);
|
||||
|
@ -63,7 +68,7 @@ CSessionLockSurface::CSessionLockSurface(COutput* output) : output(output) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!PFRACTIONALMGR || !fractional)
|
||||
if (!PFRACTIONALMGR)
|
||||
Debug::log(LOG, "No fractional-scale support! Oops, won't be able to scale!");
|
||||
if (!PVIEWPORTER)
|
||||
Debug::log(LOG, "No viewporter support! Oops, won't be able to scale!");
|
||||
|
@ -81,7 +86,7 @@ CSessionLockSurface::CSessionLockSurface(COutput* output) : output(output) {
|
|||
void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) {
|
||||
Debug::log(LOG, "configure with serial {}", serial_);
|
||||
|
||||
const bool sameSerial = serial == serial_;
|
||||
const bool SAMESERIAL = serial == serial_;
|
||||
|
||||
serial = serial_;
|
||||
logicalSize = size_;
|
||||
|
@ -89,16 +94,17 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) {
|
|||
if (fractional) {
|
||||
size = (size_ * fractionalScale).floor();
|
||||
wp_viewport_set_destination(viewport, logicalSize.x, logicalSize.y);
|
||||
wl_surface_set_buffer_scale(surface, 1);
|
||||
} else {
|
||||
size = size_;
|
||||
size = size_ * output->scale;
|
||||
wl_surface_set_buffer_scale(surface, output->scale);
|
||||
}
|
||||
|
||||
if (!SAMESERIAL)
|
||||
ext_session_lock_surface_v1_ack_configure(lockSurface, serial);
|
||||
|
||||
Debug::log(LOG, "Configuring surface for logical {} and pixel {}", logicalSize, size);
|
||||
|
||||
if (!sameSerial)
|
||||
ext_session_lock_surface_v1_ack_configure(lockSurface, serial);
|
||||
|
||||
wl_surface_set_buffer_scale(surface, 1);
|
||||
wl_surface_damage_buffer(surface, 0, 0, 0xFFFF, 0xFFFF);
|
||||
|
||||
if (!eglWindow) {
|
||||
|
|
|
@ -43,6 +43,10 @@ CHyprlock::CHyprlock(const std::string& wlDisplay, const bool immediate, const b
|
|||
|
||||
const auto* const PNOFADEIN = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:no_fade_in");
|
||||
m_bNoFadeIn = noFadeIn || **PNOFADEIN;
|
||||
|
||||
const auto CURRENTDESKTOP = getenv("XDG_CURRENT_DESKTOP");
|
||||
const auto SZCURRENTD = std::string{CURRENTDESKTOP ? CURRENTDESKTOP : ""};
|
||||
m_sCurrentDesktop = SZCURRENTD;
|
||||
}
|
||||
|
||||
CHyprlock::~CHyprlock() {
|
||||
|
@ -380,15 +384,13 @@ void CHyprlock::run() {
|
|||
|
||||
g_pRenderer = std::make_unique<CRenderer>();
|
||||
|
||||
const auto CURRENTDESKTOP = getenv("XDG_CURRENT_DESKTOP");
|
||||
const auto SZCURRENTD = std::string{CURRENTDESKTOP ? CURRENTDESKTOP : ""};
|
||||
static auto* const PNOFADEOUT = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:no_fade_out");
|
||||
const bool NOFADEOUT = **PNOFADEOUT;
|
||||
|
||||
Debug::log(LOG, "Running on {}", SZCURRENTD);
|
||||
Debug::log(LOG, "Running on {}", m_sCurrentDesktop);
|
||||
|
||||
// Hyprland violates the protocol a bit to allow for this.
|
||||
if (SZCURRENTD != "Hyprland") {
|
||||
if (m_sCurrentDesktop != "Hyprland") {
|
||||
while (!g_pRenderer->asyncResourceGatherer->gathered) {
|
||||
wl_display_flush(m_sWaylandState.display);
|
||||
if (wl_display_prepare_read(m_sWaylandState.display) == 0) {
|
||||
|
@ -574,10 +576,8 @@ void CHyprlock::run() {
|
|||
|
||||
void CHyprlock::unlock() {
|
||||
static auto* const PNOFADEOUT = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:no_fade_out");
|
||||
const auto CURRENTDESKTOP = getenv("XDG_CURRENT_DESKTOP");
|
||||
const auto SZCURRENTD = std::string{CURRENTDESKTOP ? CURRENTDESKTOP : ""};
|
||||
|
||||
if (**PNOFADEOUT || SZCURRENTD != "Hyprland") {
|
||||
if (**PNOFADEOUT || m_sCurrentDesktop != "Hyprland") {
|
||||
releaseSessionLock();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,8 @@ class CHyprlock {
|
|||
|
||||
bool m_bNoFadeIn = false;
|
||||
|
||||
std::string m_sCurrentDesktop = "";
|
||||
|
||||
//
|
||||
std::chrono::system_clock::time_point m_tGraceEnds;
|
||||
std::chrono::system_clock::time_point m_tFadeEnds;
|
||||
|
|
Loading…
Reference in a new issue