Compare commits

...

25 Commits

Author SHA1 Message Date
Vaxry
882f7ad7d2 version: bump to 0.47.2 2025-02-02 00:47:17 +00:00
Vaxry
3822673c05 desktop: move popups to UPs and fix missing subsurface resource
fixes #9283
2025-02-02 00:47:17 +00:00
Vaxry
bdbfa93371 popup: take xdg geometry into account in input calcs
fixes #9023
2025-02-02 00:47:17 +00:00
Vaxry
f827690983 desktop: move popup and subsurface ctors to factories
makes sure m_pSelf is set before we do anything like possibly adding children

fixes #9275

supersedes #9276
2025-02-02 00:47:17 +00:00
Maximilian Seidler
ff8b5b70fa animation: don't immediately disconnect active vars during tick (#9272) 2025-02-02 00:47:17 +00:00
nyx
3236566939 xwayland: correct pointer coordinate mismatch in X11 windows (#9259)
refactor(xwayland): add back comments
2025-02-02 00:47:17 +00:00
Mihai Fufezan
dd64757602 configWatcher: watch both symlinks and canonical paths (#9219) 2025-02-02 00:47:16 +00:00
Brayden Zee
047ea02820 desktop: fix segfault when destroying a partially create layer surface (#9247) 2025-02-02 00:45:37 +00:00
nyx
c8eec1916d xwayland: prevent invalid window configurations for X11 apps (#9253)
* fix(xwayland): prevent invalid window configurations for X11 apps

* refact(xwayland): remove unneeded line
2025-02-02 00:45:37 +00:00
Ikalco
c062fd2985 monitor: preferred mode now tries first 3 modes if preferred fails before erroring (#9246) 2025-02-02 00:45:37 +00:00
nyx
f04d94aa13 xwayland: handle window coords correctly (#9238) 2025-02-02 00:45:37 +00:00
Vaxry
75dff7205f version: bump to 0.47.1 2025-01-29 23:19:39 +00:00
Vaxry
48817b97f5 subsurface: fix invalid parent typo
fixes #9224
2025-01-29 23:19:20 +00:00
Vaxry
664da71d10 popup: stop refocusing at unmap
fixes #9018
2025-01-29 23:19:20 +00:00
Vaxry
a285722bc8 monitor: round refresh rates in sorting modes
fixes #9209
2025-01-29 23:19:20 +00:00
vaxerski
bdee557d15 config/hyprctl: fix keyword not updating autoreload
ref #9139
2025-01-29 23:19:20 +00:00
vaxerski
901271fa8b pass/rect: fix bounding / opaque regions
fixes #9212
2025-01-29 23:19:20 +00:00
nyx
fa61042288 renderer: calculate UV using both pixel and monitor dimensions (#9210) 2025-01-29 23:19:20 +00:00
Vaxry
778508e39e presentation: log a fixme when there is a feedback leak
ref #8087
2025-01-29 23:19:20 +00:00
Tom Englund
762bbf5857 configmgr: properly free glob memory
globfree is only freeing internally allocated resources, so also call
free the on glob_t memory we allocated.
2025-01-29 23:19:20 +00:00
Tom Englund
c68653d7c4 ikeyboard: free xkbSymState in clearManuallyAllocd
asan reported a leak on xkbSymState on destruction, because it wasnt
beeing unrefed, was only being unrefed on calls to updateXKBTranslationState.
2025-01-29 23:19:20 +00:00
DDoSolitary
56540f5bd8 xwayland: respect window size set by configure requests (#9190) 2025-01-29 23:19:20 +00:00
Jan Beich
017f322532 deps: add libinotify-kqueue on BSDs after 8dd2cd41fb (#9197)
src/config/ConfigWatcher.cpp:2:10: fatal error: 'sys/inotify.h' file not found
    2 | #include <sys/inotify.h>
      |          ^~~~~~~~~~~~~~~
2025-01-29 23:19:20 +00:00
DDoSolitary
a7d7df5c4b xwayland: send synthetic configure events (#9193) 2025-01-29 23:19:20 +00:00
Vaxry
0d06f287d0 core: fix clang-format 2025-01-29 23:19:20 +00:00
27 changed files with 214 additions and 124 deletions

View File

@@ -104,7 +104,7 @@ find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION})
pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=0.4.5)
pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=0.3.2)
pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=0.1.7)
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=0.4.0)
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=0.5.0)
pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=0.1.1)
add_compile_definitions(AQUAMARINE_VERSION="${aquamarine_dep_VERSION}")
@@ -197,6 +197,12 @@ if(NOT HAS_TIMERFD AND epoll_FOUND)
target_link_libraries(Hyprland PkgConfig::epoll)
endif()
check_include_file("sys/inotify.h" HAS_INOTIFY)
pkg_check_modules(inotify IMPORTED_TARGET libinotify)
if(NOT HAS_INOTIFY AND inotify_FOUND)
target_link_libraries(Hyprland PkgConfig::inotify)
endif()
if(LEGACY_RENDERER)
message(STATUS "Using the legacy GLES2 renderer!")
add_compile_definitions(LEGACY_RENDERER)

View File

@@ -1 +1 @@
0.47.0
0.47.2

View File

@@ -58,6 +58,7 @@ endif
backtrace_dep = cpp_compiler.find_library('execinfo', required: false)
epoll_dep = dependency('epoll-shim', required: false) # timerfd on BSDs
inotify_dep = dependency('libinotify', required: false) # inotify on BSDs
re2 = dependency('re2', required: true)

View File

@@ -912,12 +912,16 @@ std::optional<std::string> CConfigManager::resetHLConfig() {
return RET;
}
void CConfigManager::updateWatcher() {
static const auto PDISABLEAUTORELOAD = CConfigValue<Hyprlang::INT>("misc:disable_autoreload");
g_pConfigWatcher->setWatchList(*PDISABLEAUTORELOAD ? std::vector<std::string>{} : m_configPaths);
}
void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
static const auto PENABLEEXPLICIT = CConfigValue<Hyprlang::INT>("render:explicit_sync");
static const auto PDISABLEAUTORELOAD = CConfigValue<Hyprlang::INT>("misc:disable_autoreload");
static int prevEnabledExplicit = *PENABLEEXPLICIT;
g_pConfigWatcher->setWatchList(*PDISABLEAUTORELOAD ? std::vector<std::string>{} : m_configPaths);
updateWatcher();
for (auto const& w : g_pCompositor->m_vWindows) {
w->uncacheWindowDecos();
@@ -2690,8 +2694,14 @@ std::optional<std::string> CConfigManager::handleSource(const std::string& comma
Debug::log(ERR, "source= path garbage");
return "source= path " + rawpath + " bogus!";
}
std::unique_ptr<glob_t, void (*)(glob_t*)> glob_buf{new glob_t, [](glob_t* g) { globfree(g); }};
memset(glob_buf.get(), 0, sizeof(glob_t));
std::unique_ptr<glob_t, void (*)(glob_t*)> glob_buf{static_cast<glob_t*>(calloc(1, sizeof(glob_t))), // allocate and zero-initialize
[](glob_t* g) {
if (g) {
globfree(g); // free internal resources allocated by glob()
free(g); // free the memory for the glob_t structure
}
}};
if (auto r = glob(absolutePath(rawpath, configCurrentPath).c_str(), GLOB_TILDE, nullptr, glob_buf.get()); r != 0) {
std::string err = std::format("source= globbing error: {}", r == GLOB_NOMATCH ? "found no match" : GLOB_ABORTED ? "read error" : "out of memory");

View File

@@ -190,6 +190,7 @@ class CConfigManager {
void ensureVRR(PHLMONITOR pMonitor = nullptr);
bool shouldUseSoftwareCursors();
void updateWatcher();
std::string parseKeyword(const std::string&, const std::string&);

View File

@@ -4,6 +4,7 @@
#include <ranges>
#include <fcntl.h>
#include <unistd.h>
#include <filesystem>
CConfigWatcher::CConfigWatcher() : m_inotifyFd(inotify_init()) {
if (m_inotifyFd < 0) {
@@ -46,9 +47,19 @@ void CConfigWatcher::setWatchList(const std::vector<std::string>& paths) {
// add new paths
for (const auto& path : paths) {
m_watches.emplace_back(SInotifyWatch{
.wd = inotify_add_watch(m_inotifyFd, path.c_str(), IN_MODIFY),
.wd = inotify_add_watch(m_inotifyFd, path.c_str(), IN_MODIFY | IN_DONT_FOLLOW),
.file = path,
});
std::error_code ec, ec2;
const auto CANONICAL = std::filesystem::canonical(path, ec);
const auto IS_SYMLINK = std::filesystem::is_symlink(path, ec2);
if (!ec && !ec2 && IS_SYMLINK) {
m_watches.emplace_back(SInotifyWatch{
.wd = inotify_add_watch(m_inotifyFd, CANONICAL.c_str(), IN_MODIFY),
.file = path,
});
}
}
}

View File

@@ -1100,6 +1100,9 @@ static std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in)
}
}
if (COMMAND.contains("misc:disable_autoreload"))
g_pConfigManager->updateWatcher();
// decorations will probably need a repaint
if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source" ||
COMMAND.starts_with("windowrule")) {

View File

@@ -31,10 +31,9 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
pLS->szNamespace = resource->layerNamespace;
pLS->layer = resource->current.layer;
pLS->popupHead = makeUnique<CPopup>(pLS);
pLS->popupHead->m_pSelf = pLS->popupHead;
pLS->monitor = pMonitor;
pLS->layer = resource->current.layer;
pLS->popupHead = CPopup::create(pLS);
pLS->monitor = pMonitor;
pMonitor->m_aLayerSurfaceLayers[resource->current.layer].emplace_back(pLS);
pLS->forceBlur = g_pConfigManager->shouldBlurLS(pLS->szNamespace);
@@ -98,7 +97,8 @@ void CLayerSurface::onDestroy() {
onUnmap();
} else {
Debug::log(LOG, "Removing LayerSurface that wasn't mapped.");
alpha->setValueAndWarp(0.f);
if (alpha)
alpha->setValueAndWarp(0.f);
fadingOut = true;
g_pCompositor->addToFadingOutSafe(self.lock());
}

View File

@@ -12,23 +12,37 @@
#include "../render/OpenGL.hpp"
#include <ranges>
CPopup::CPopup(PHLWINDOW pOwner) : m_pWindowOwner(pOwner) {
initAllSignals();
UP<CPopup> CPopup::create(PHLWINDOW pOwner) {
auto popup = UP<CPopup>(new CPopup());
popup->m_pWindowOwner = pOwner;
popup->m_pSelf = popup;
popup->initAllSignals();
return popup;
}
CPopup::CPopup(PHLLS pOwner) : m_pLayerOwner(pOwner) {
initAllSignals();
UP<CPopup> CPopup::create(PHLLS pOwner) {
auto popup = UP<CPopup>(new CPopup());
popup->m_pLayerOwner = pOwner;
popup->m_pSelf = popup;
popup->initAllSignals();
return popup;
}
CPopup::CPopup(SP<CXDGPopupResource> popup, WP<CPopup> pOwner) :
m_pWindowOwner(pOwner->m_pWindowOwner), m_pLayerOwner(pOwner->m_pLayerOwner), m_pParent(pOwner), m_pResource(popup) {
m_pWLSurface = CWLSurface::create();
m_pWLSurface->assign(popup->surface->surface.lock(), this);
UP<CPopup> CPopup::create(SP<CXDGPopupResource> resource, WP<CPopup> pOwner) {
auto popup = UP<CPopup>(new CPopup());
popup->m_pResource = resource;
popup->m_pWindowOwner = pOwner->m_pWindowOwner;
popup->m_pLayerOwner = pOwner->m_pLayerOwner;
popup->m_pParent = pOwner;
popup->m_pSelf = popup;
popup->m_pWLSurface = CWLSurface::create();
popup->m_pWLSurface->assign(resource->surface->surface.lock(), popup.get());
m_vLastSize = popup->surface->current.geometry.size();
reposition();
popup->m_vLastSize = resource->surface->current.geometry.size();
popup->reposition();
initAllSignals();
popup->initAllSignals();
return popup;
}
CPopup::~CPopup() {
@@ -59,7 +73,7 @@ void CPopup::initAllSignals() {
}
void CPopup::onNewPopup(SP<CXDGPopupResource> popup) {
const auto& POPUP = m_vChildren.emplace_back(makeShared<CPopup>(popup, m_pSelf));
const auto& POPUP = m_vChildren.emplace_back(CPopup::create(popup, m_pSelf));
POPUP->m_pSelf = POPUP;
Debug::log(LOG, "New popup at {:x}", (uintptr_t)POPUP);
}
@@ -91,8 +105,7 @@ void CPopup::onMap() {
g_pInputManager->simulateMouseMovement();
m_pSubsurfaceHead = makeUnique<CSubsurface>(m_pSelf);
m_pSubsurfaceHead->m_pSelf = m_pSubsurfaceHead;
m_pSubsurfaceHead = CSubsurface::create(m_pSelf);
//unconstrain();
sendScale();
@@ -138,10 +151,11 @@ void CPopup::onUnmap() {
},
nullptr);
const bool WASLASTFOCUS = g_pSeatManager->state.keyboardFocus == m_pWLSurface->resource() || g_pSeatManager->state.pointerFocus == m_pWLSurface->resource();
// TODO: probably refocus, but without a motion event?
// const bool WASLASTFOCUS = g_pSeatManager->state.keyboardFocus == m_pWLSurface->resource() || g_pSeatManager->state.pointerFocus == m_pWLSurface->resource();
if (WASLASTFOCUS)
g_pInputManager->simulateMouseMovement();
// if (WASLASTFOCUS)
// g_pInputManager->simulateMouseMovement();
}
void CPopup::onCommit(bool ignoreSiblings) {
@@ -268,7 +282,8 @@ void CPopup::recheckTree() {
}
void CPopup::recheckChildrenRecursive() {
auto cpy = m_vChildren;
std::vector<WP<CPopup>> cpy;
std::ranges::for_each(m_vChildren, [&cpy](const auto& el) { cpy.emplace_back(el); });
for (auto const& c : cpy) {
c->onCommit(true);
c->recheckChildrenRecursive();
@@ -325,22 +340,24 @@ void CPopup::breadthfirst(std::function<void(WP<CPopup>, void*)> fn, void* data)
WP<CPopup> CPopup::at(const Vector2D& globalCoords, bool allowsInput) {
std::vector<WP<CPopup>> popups;
breadthfirst([](WP<CPopup> popup, void* data) { ((std::vector<WP<CPopup>>*)data)->push_back(popup); }, &popups);
breadthfirst([&popups](WP<CPopup> popup, void* data) { popups.push_back(popup); }, &popups);
for (auto const& p : popups | std::views::reverse) {
if (!p->m_pResource || !p->m_bMapped)
continue;
if (!allowsInput) {
const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{};
const Vector2D size = p->m_pResource ? p->m_pResource->geometry.size() : p->size();
const Vector2D offset =
p->m_pResource && p->m_pResource->surface ? (p->size() - p->m_pResource->geometry.size()) / 2.F - p->m_pResource->surface->current.geometry.pos() : Vector2D{};
const Vector2D size = p->m_pResource ? p->m_pResource->geometry.size() : p->size();
const auto BOX = CBox{p->coordsGlobal() + offset, size};
if (BOX.containsPoint(globalCoords))
return p;
} else {
const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{};
const auto REGION =
const Vector2D offset =
p->m_pResource && p->m_pResource->surface ? (p->size() - p->m_pResource->geometry.size()) / 2.F - p->m_pResource->surface->current.geometry.pos() : Vector2D{};
const auto REGION =
CRegion{p->m_pWLSurface->resource()->current.input}.intersect(CBox{{}, p->m_pWLSurface->resource()->current.size}).translate(p->coordsGlobal() + offset);
if (REGION.containsPoint(globalCoords))
return p;

View File

@@ -10,11 +10,11 @@ class CXDGPopupResource;
class CPopup {
public:
// dummy head nodes
CPopup(PHLWINDOW pOwner);
CPopup(PHLLS pOwner);
static UP<CPopup> create(PHLWINDOW pOwner);
static UP<CPopup> create(PHLLS pOwner);
// real nodes
CPopup(SP<CXDGPopupResource> popup, WP<CPopup> pOwner);
static UP<CPopup> create(SP<CXDGPopupResource> popup, WP<CPopup> pOwner);
~CPopup();
@@ -45,6 +45,8 @@ class CPopup {
bool m_bMapped = false;
private:
CPopup() = default;
// T1 owners, each popup has to have one of these
PHLWINDOWREF m_pWindowOwner;
PHLLSREF m_pLayerOwner;
@@ -62,7 +64,7 @@ class CPopup {
bool m_bInert = false;
//
std::vector<SP<CPopup>> m_vChildren;
std::vector<UP<CPopup>> m_vChildren;
UP<CSubsurface> m_pSubsurfaceHead;
struct {

View File

@@ -7,28 +7,47 @@
#include "../render/Renderer.hpp"
#include "../managers/input/InputManager.hpp"
CSubsurface::CSubsurface(PHLWINDOW pOwner) : m_pWindowParent(pOwner) {
initSignals();
initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
UP<CSubsurface> CSubsurface::create(PHLWINDOW pOwner) {
auto subsurface = UP<CSubsurface>(new CSubsurface());
subsurface->m_pWindowParent = pOwner;
subsurface->m_pSelf = subsurface;
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
return subsurface;
}
CSubsurface::CSubsurface(WP<CPopup> pOwner) : m_pPopupParent(pOwner) {
initSignals();
initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
UP<CSubsurface> CSubsurface::create(WP<CPopup> pOwner) {
auto subsurface = UP<CSubsurface>(new CSubsurface());
subsurface->m_pPopupParent = pOwner;
subsurface->m_pSelf = subsurface;
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
return subsurface;
}
CSubsurface::CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner) : m_pSubsurface(pSubsurface), m_pWindowParent(pOwner) {
m_pWLSurface = CWLSurface::create();
m_pWLSurface->assign(pSubsurface->surface.lock(), this);
initSignals();
initExistingSubsurfaces(pSubsurface->surface.lock());
UP<CSubsurface> CSubsurface::create(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner) {
auto subsurface = UP<CSubsurface>(new CSubsurface());
subsurface->m_pWindowParent = pOwner;
subsurface->m_pSubsurface = pSubsurface;
subsurface->m_pSelf = subsurface;
subsurface->m_pWLSurface = CWLSurface::create();
subsurface->m_pWLSurface->assign(pSubsurface->surface.lock(), subsurface.get());
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pSubsurface->surface.lock());
return subsurface;
}
CSubsurface::CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, WP<CPopup> pOwner) : m_pSubsurface(pSubsurface), m_pPopupParent(pOwner) {
m_pWLSurface = CWLSurface::create();
m_pWLSurface->assign(pSubsurface->surface.lock(), this);
initSignals();
initExistingSubsurfaces(pSubsurface->surface.lock());
UP<CSubsurface> CSubsurface::create(SP<CWLSubsurfaceResource> pSubsurface, WP<CPopup> pOwner) {
auto subsurface = UP<CSubsurface>(new CSubsurface());
subsurface->m_pPopupParent = pOwner;
subsurface->m_pSubsurface = pSubsurface;
subsurface->m_pSelf = subsurface;
subsurface->m_pWLSurface = CWLSurface::create();
subsurface->m_pWLSurface->assign(pSubsurface->surface.lock(), subsurface.get());
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pSubsurface->surface.lock());
return subsurface;
}
CSubsurface::~CSubsurface() {
@@ -135,15 +154,15 @@ void CSubsurface::onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface) {
WP<CSubsurface> PSUBSURFACE;
if (!m_pWindowParent.expired())
PSUBSURFACE = m_vChildren.emplace_back(makeUnique<CSubsurface>(pSubsurface, m_pWindowParent.lock()));
PSUBSURFACE = m_vChildren.emplace_back(CSubsurface::create(pSubsurface, m_pWindowParent.lock()));
else if (m_pPopupParent)
PSUBSURFACE = m_vChildren.emplace_back(makeUnique<CSubsurface>(pSubsurface, m_pPopupParent));
PSUBSURFACE = m_vChildren.emplace_back(CSubsurface::create(pSubsurface, m_pPopupParent));
PSUBSURFACE->m_pSelf = PSUBSURFACE;
ASSERT(PSUBSURFACE);
PSUBSURFACE->m_pParent = PSUBSURFACE;
PSUBSURFACE->m_pParent = m_pSelf;
}
void CSubsurface::onMap() {

View File

@@ -10,12 +10,12 @@ class CWLSubsurfaceResource;
class CSubsurface {
public:
// root dummy nodes
CSubsurface(PHLWINDOW pOwner);
CSubsurface(WP<CPopup> pOwner);
static UP<CSubsurface> create(PHLWINDOW pOwner);
static UP<CSubsurface> create(WP<CPopup> pOwner);
// real nodes
CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner);
CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, WP<CPopup> pOwner);
static UP<CSubsurface> create(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner);
static UP<CSubsurface> create(SP<CWLSubsurfaceResource> pSubsurface, WP<CPopup> pOwner);
~CSubsurface();
@@ -37,6 +37,8 @@ class CSubsurface {
WP<CSubsurface> m_pSelf;
private:
CSubsurface() = default;
struct {
CHyprSignalListener destroySubsurface;
CHyprSignalListener commitSubsurface;

View File

@@ -571,10 +571,8 @@ void CWindow::onMap() {
if (m_bIsX11)
return;
m_pSubsurfaceHead = makeUnique<CSubsurface>(m_pSelf.lock());
m_pSubsurfaceHead->m_pSelf = m_pSubsurfaceHead;
m_pPopupHead = makeUnique<CPopup>(m_pSelf.lock());
m_pPopupHead->m_pSelf = m_pPopupHead;
m_pSubsurfaceHead = CSubsurface::create(m_pSelf.lock());
m_pPopupHead = CPopup::create(m_pSelf.lock());
}
void CWindow::onBorderAngleAnimEnd(WP<CBaseAnimatedVariable> pav) {
@@ -1697,18 +1695,18 @@ Vector2D CWindow::requestedMaxSize() {
void CWindow::sendWindowSize(Vector2D size, bool force, std::optional<Vector2D> overridePos) {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
const auto PMONITOR = m_pMonitor.lock();
const auto PMONITOR = m_pMonitor.lock();
size = size.clamp(Vector2D{0, 0}, Vector2D{std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()});
size = size.clamp(Vector2D{1, 1}, Vector2D{std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()});
// calculate pos
// TODO: this should be decoupled from setWindowSize IMO
Vector2D windowPos = overridePos.value_or(m_vRealPosition->goal());
if (m_bIsX11) {
if (const auto XWAYLANDPOS = g_pXWaylandManager->waylandToXWaylandCoords(windowPos); XWAYLANDPOS != Vector2D{})
windowPos = XWAYLANDPOS;
if (m_bIsX11 && PMONITOR) {
windowPos = g_pXWaylandManager->waylandToXWaylandCoords(windowPos);
if (*PXWLFORCESCALEZERO)
size *= PMONITOR->scale;
}
if (!force && m_vPendingReportedSize == size && (windowPos == m_vReportedPosition || !m_bIsX11))
@@ -1716,13 +1714,10 @@ void CWindow::sendWindowSize(Vector2D size, bool force, std::optional<Vector2D>
m_vReportedPosition = windowPos;
m_vPendingReportedSize = size;
m_fX11SurfaceScaledBy = 1.0f;
m_fX11SurfaceScaledBy = 1.0f;
if (*PXWLFORCESCALEZERO && m_bIsX11 && PMONITOR) {
size *= PMONITOR->scale;
if (*PXWLFORCESCALEZERO && m_bIsX11 && PMONITOR)
m_fX11SurfaceScaledBy = PMONITOR->scale;
}
if (m_bIsX11 && m_pXWaylandSurface)
m_pXWaylandSurface->configure({windowPos, size});

View File

@@ -44,6 +44,10 @@ void IKeyboard::clearManuallyAllocd() {
if (xkbKeymapFD >= 0)
close(xkbKeymapFD);
if (xkbSymState)
xkb_state_unref(xkbSymState);
xkbSymState = nullptr;
xkbKeymap = nullptr;
xkbState = nullptr;
xkbStaticState = nullptr;

View File

@@ -434,7 +434,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
// accumulate requested modes in reverse order (cause inesrting at front is inefficient)
std::vector<SP<Aquamarine::SOutputMode>> requestedModes;
std::string requestedStr = "preferred";
std::string requestedStr = "unknown";
// use sortFunc, add best 3 to requestedModes in reverse, since we test in reverse
auto addBest3Modes = [&](auto const& sortFunc) {
@@ -445,20 +445,31 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
requestedModes.insert(requestedModes.end(), sortedModes.rbegin(), sortedModes.rend());
};
// last fallback is preferred mode, btw this covers resolution == Vector2D()
// last fallback is always preferred mode
if (!output->preferredMode())
Debug::log(ERR, "Monitor {} has NO PREFERRED MODE", output->name);
else
requestedModes.push_back(output->preferredMode());
if (RULE->resolution == Vector2D(-1, -1)) {
if (RULE->resolution == Vector2D()) {
requestedStr = "preferred";
// fallback to first 3 modes if preferred fails/doesn't exist
requestedModes = output->modes;
if (requestedModes.size() > 3)
requestedModes.erase(requestedModes.begin() + 3, requestedModes.end());
std::ranges::reverse(requestedModes.begin(), requestedModes.end());
if (output->preferredMode())
requestedModes.push_back(output->preferredMode());
} else if (RULE->resolution == Vector2D(-1, -1)) {
requestedStr = "highrr";
// sort prioritizing refresh rate 1st and resolution 2nd, then add best 3
addBest3Modes([](auto const& a, auto const& b) {
if (a->refreshRate > b->refreshRate)
if (std::round(a->refreshRate) > std::round(b->refreshRate))
return true;
else if (DELTALESSTHAN((float)a->refreshRate, (float)b->refreshRate, 1000) && a->pixelSize.x > b->pixelSize.x && a->pixelSize.y > b->pixelSize.y)
else if (DELTALESSTHAN((float)a->refreshRate, (float)b->refreshRate, 1.F) && a->pixelSize.x > b->pixelSize.x && a->pixelSize.y > b->pixelSize.y)
return true;
return false;
});
@@ -469,7 +480,8 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
addBest3Modes([](auto const& a, auto const& b) {
if (a->pixelSize.x > b->pixelSize.x && a->pixelSize.y > b->pixelSize.y)
return true;
else if (DELTALESSTHAN(a->pixelSize.x, b->pixelSize.x, 1) && DELTALESSTHAN(a->pixelSize.y, b->pixelSize.y, 1) && a->refreshRate > b->refreshRate)
else if (DELTALESSTHAN(a->pixelSize.x, b->pixelSize.x, 1) && DELTALESSTHAN(a->pixelSize.y, b->pixelSize.y, 1) &&
std::round(a->refreshRate) > std::round(b->refreshRate))
return true;
return false;
});

View File

@@ -33,7 +33,7 @@ struct SMonitorRule {
Vector2D resolution = Vector2D(1280, 720);
Vector2D offset = Vector2D(0, 0);
float scale = 1;
float refreshRate = 60;
float refreshRate = 60; // Hz
bool disabled = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
std::string mirrorOf = "";
@@ -92,7 +92,7 @@ class CMonitor {
CDamageRing damage;
SP<Aquamarine::IOutput> output;
float refreshRate = 60;
float refreshRate = 60; // Hz
int forceFullFrames = 0;
bool scheduledRecalc = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;

View File

@@ -43,7 +43,7 @@ CHyprAnimationManager::CHyprAnimationManager() {
template <Animable VarType>
static void updateVariable(CAnimatedVariable<VarType>& av, const float POINTY, bool warp = false) {
if (warp || av.value() == av.goal()) {
av.warp();
av.warp(true, false);
return;
}
@@ -53,7 +53,7 @@ static void updateVariable(CAnimatedVariable<VarType>& av, const float POINTY, b
static void updateColorVariable(CAnimatedVariable<CHyprColor>& av, const float POINTY, bool warp) {
if (warp || av.value() == av.goal()) {
av.warp();
av.warp(true, false);
return;
}

View File

@@ -82,29 +82,9 @@ CBox CHyprXWaylandManager::getGeometryForWindow(PHLWINDOW pWindow) {
CBox box;
if (pWindow->m_bIsX11) {
const auto SIZEHINTS = pWindow->m_pXWaylandSurface->sizeHints.get();
if (SIZEHINTS && !pWindow->isX11OverrideRedirect()) {
// WM_SIZE_HINTS' x,y,w,h is deprecated it seems.
// Source: https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#wm_normal_hints_property
box.x = pWindow->m_pXWaylandSurface->geometry.x;
box.y = pWindow->m_pXWaylandSurface->geometry.y;
constexpr int ICCCM_USSize = 0x2;
constexpr int ICCCM_PSize = 0x8;
if ((SIZEHINTS->flags & ICCCM_USSize) || (SIZEHINTS->flags & ICCCM_PSize)) {
box.w = SIZEHINTS->base_width;
box.h = SIZEHINTS->base_height;
} else {
box.w = pWindow->m_pXWaylandSurface->geometry.w;
box.h = pWindow->m_pXWaylandSurface->geometry.h;
}
} else
box = pWindow->m_pXWaylandSurface->geometry;
} else if (pWindow->m_pXDGSurface)
if (pWindow->m_bIsX11)
box = pWindow->m_pXWaylandSurface->geometry;
else if (pWindow->m_pXDGSurface)
box = pWindow->m_pXDGSurface->current.geometry;
return box;

View File

@@ -32,6 +32,7 @@ executable(
xcb_xfixes_dep,
backtrace_dep,
epoll_dep,
inotify_dep,
gio_dep,
tracy,

View File

@@ -130,6 +130,11 @@ void CPresentationProtocol::onPresented(PHLMONITOR pMonitor, timespec* when, uin
}
}
if (m_vFeedbacks.size() > 10000 /* arbitrary number I chose as fitting */) {
LOGM(ERR, "FIXME: presentation has a feedback leak, and has grown to {} pending entries!!! Dropping!!!!!", m_vFeedbacks.size());
m_vFeedbacks = {m_vFeedbacks.begin() + 9000, m_vFeedbacks.end()};
}
std::erase_if(m_vFeedbacks, [](const auto& other) { return !other->surface || other->done; });
std::erase_if(m_vQueue, [pMonitor](const auto& other) { return !other->surface || other->pMonitor == pMonitor || !other->pMonitor || other->done; });
}

View File

@@ -308,9 +308,7 @@ void CWLSurfaceResource::breadthfirst(std::function<void(SP<CWLSurfaceResource>,
std::pair<SP<CWLSurfaceResource>, Vector2D> CWLSurfaceResource::at(const Vector2D& localCoords, bool allowsInput) {
std::vector<std::pair<SP<CWLSurfaceResource>, Vector2D>> surfs;
breadthfirst([](SP<CWLSurfaceResource> surf, const Vector2D& offset,
void* data) { ((std::vector<std::pair<SP<CWLSurfaceResource>, Vector2D>>*)data)->emplace_back(std::make_pair<>(surf, offset)); },
&surfs);
breadthfirst([&surfs](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { surfs.emplace_back(std::make_pair<>(surf, offset)); }, &surfs);
for (auto const& [surf, pos] : surfs | std::views::reverse) {
if (!allowsInput) {

View File

@@ -2147,14 +2147,20 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP<CTexture> tex, const CBox& box, f
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
// stencil done. Render everything.
CBox MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
// render our great blurred FB
// calculate the uv for it
const auto LASTTL = m_RenderData.primarySurfaceUVTopLeft;
const auto LASTBR = m_RenderData.primarySurfaceUVBottomRight;
m_RenderData.primarySurfaceUVTopLeft = box.pos() / MONITORBOX.size();
m_RenderData.primarySurfaceUVBottomRight = (box.pos() + box.size()) / MONITORBOX.size();
CBox transformedBox = box;
transformedBox.transform(wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x,
m_RenderData.pMonitor->vecTransformedSize.y);
CBox monitorSpaceBox = {transformedBox.pos().x / m_RenderData.pMonitor->vecPixelSize.x * m_RenderData.pMonitor->vecTransformedSize.x,
transformedBox.pos().y / m_RenderData.pMonitor->vecPixelSize.y * m_RenderData.pMonitor->vecTransformedSize.y,
transformedBox.width / m_RenderData.pMonitor->vecPixelSize.x * m_RenderData.pMonitor->vecTransformedSize.x,
transformedBox.height / m_RenderData.pMonitor->vecPixelSize.y * m_RenderData.pMonitor->vecTransformedSize.y};
m_RenderData.primarySurfaceUVTopLeft = monitorSpaceBox.pos() / m_RenderData.pMonitor->vecTransformedSize;
m_RenderData.primarySurfaceUVBottomRight = (monitorSpaceBox.pos() + monitorSpaceBox.size()) / m_RenderData.pMonitor->vecTransformedSize;
static auto PBLURIGNOREOPACITY = CConfigValue<Hyprlang::INT>("decoration:blur:ignore_opacity");
setMonitorTransformEnabled(true);

View File

@@ -337,7 +337,8 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(PHLMONITOR pMonitor, PHLWOR
// then render windows over fullscreen.
for (auto const& w : g_pCompositor->m_vWindows) {
if (w->m_pWorkspace != pWorkspaceWindow->m_pWorkspace || !w->m_bIsFloating || (!w->m_bCreatedOverFullscreen && !w->m_bPinned) || (!w->m_bIsMapped && !w->m_bFadingOut) || w->isFullscreen())
if (w->m_pWorkspace != pWorkspaceWindow->m_pWorkspace || !w->m_bIsFloating || (!w->m_bCreatedOverFullscreen && !w->m_bPinned) || (!w->m_bIsMapped && !w->m_bFadingOut) ||
w->isFullscreen())
continue;
if (w->m_pMonitor == pWorkspace->m_pMonitor && pWorkspace->m_bIsSpecialWorkspace != w->onSpecialWorkspace())

View File

@@ -13,7 +13,7 @@ class IPassElement {
virtual const char* passName() = 0;
virtual void discard();
virtual bool undiscardable();
virtual std::optional<CBox> boundingBox();
virtual CRegion opaqueRegion();
virtual std::optional<CBox> boundingBox(); // in monitor-local logical coordinates
virtual CRegion opaqueRegion(); // in monitor-local logical coordinates
virtual bool disableSimplification();
};

View File

@@ -24,7 +24,7 @@ bool CRectPassElement::needsPrecomputeBlur() {
}
std::optional<CBox> CRectPassElement::boundingBox() {
return data.box;
return data.box.copy().scale(1.F / g_pHyprOpenGL->m_RenderData.pMonitor->scale).round();
}
CRegion CRectPassElement::opaqueRegion() {

View File

@@ -169,6 +169,22 @@ void CXWaylandSurface::configure(const CBox& box) {
uint32_t values[] = {box.x, box.y, box.width, box.height, 0};
xcb_configure_window(g_pXWayland->pWM->connection, xID, mask, values);
if (geometry.width == box.width && geometry.height == box.height) {
// ICCCM requires a synthetic event when window size is not changed
xcb_configure_notify_event_t e;
e.response_type = XCB_CONFIGURE_NOTIFY;
e.event = xID;
e.window = xID;
e.x = box.x;
e.y = box.y;
e.width = box.width;
e.height = box.height;
e.border_width = 0;
e.above_sibling = XCB_NONE;
e.override_redirect = overrideRedirect;
xcb_send_event(g_pXWayland->pWM->connection, false, xID, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char*)&e);
}
g_pXWayland->pWM->updateClientList();
xcb_flush(g_pXWayland->pWM->connection);

View File

@@ -102,8 +102,8 @@ void CXWM::handleMapRequest(xcb_map_request_event_t* e) {
const bool HAS_HINTS = XSURF->sizeHints && Vector2D{XSURF->sizeHints->base_width, XSURF->sizeHints->base_height} > Vector2D{5, 5};
const auto DESIREDSIZE = HAS_HINTS ? Vector2D{XSURF->sizeHints->base_width, XSURF->sizeHints->base_height} : Vector2D{800, 800};
// if it's too small, or its base size is set, configure it.
if ((SMALL || HAS_HINTS) && !XSURF->overrideRedirect) // default to 800 x 800
// if it's too small, configure it.
if (SMALL && !XSURF->overrideRedirect) // default to 800 x 800
XSURF->configure({XSURF->geometry.pos(), DESIREDSIZE});
Debug::log(LOG, "[xwm] Mapping window {} in X (geometry {}x{} at {}x{}))", e->window, XSURF->geometry.width, XSURF->geometry.height, XSURF->geometry.x, XSURF->geometry.y);