layouts: fix crash on missed relayout updates (#13444)
This commit is contained in:
parent
93aacfc0dc
commit
2928d6af0a
5 changed files with 27 additions and 7 deletions
|
|
@ -33,6 +33,19 @@ static void swar() {
|
||||||
Tests::killAllWindows();
|
Tests::killAllWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't crash when focus after global geometry changes
|
||||||
|
static void testCrashOnGeomUpdate() {
|
||||||
|
Tests::spawnKitty();
|
||||||
|
Tests::spawnKitty();
|
||||||
|
Tests::spawnKitty();
|
||||||
|
|
||||||
|
// move the layout
|
||||||
|
OK(getFromSocket("/keyword monitor HEADLESS-2,1920x1080@60,1000x0,1"));
|
||||||
|
|
||||||
|
// shouldnt crash
|
||||||
|
OK(getFromSocket("/dispatch movefocus r"));
|
||||||
|
}
|
||||||
|
|
||||||
static bool test() {
|
static bool test() {
|
||||||
NLog::log("{}Testing layout generic", Colors::GREEN);
|
NLog::log("{}Testing layout generic", Colors::GREEN);
|
||||||
|
|
||||||
|
|
@ -43,6 +56,8 @@ static bool test() {
|
||||||
NLog::log("{}Testing `single_window_aspect_ratio`", Colors::GREEN);
|
NLog::log("{}Testing `single_window_aspect_ratio`", Colors::GREEN);
|
||||||
swar();
|
swar();
|
||||||
|
|
||||||
|
testCrashOnGeomUpdate();
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
NLog::log("Cleaning up", Colors::YELLOW);
|
NLog::log("Cleaning up", Colors::YELLOW);
|
||||||
OK(getFromSocket("/dispatch workspace 1"));
|
OK(getFromSocket("/dispatch workspace 1"));
|
||||||
|
|
|
||||||
|
|
@ -2772,6 +2772,7 @@ void CCompositor::arrangeMonitors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
PROTO::xdgOutput->updateAllOutputs();
|
PROTO::xdgOutput->updateAllOutputs();
|
||||||
|
Event::bus()->m_events.monitor.layoutChanged.emit();
|
||||||
|
|
||||||
#ifndef NO_XWAYLAND
|
#ifndef NO_XWAYLAND
|
||||||
const auto box = g_pCompositor->calculateX11WorkArea();
|
const auto box = g_pCompositor->calculateX11WorkArea();
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,7 @@
|
||||||
|
|
||||||
using namespace Layout;
|
using namespace Layout;
|
||||||
|
|
||||||
CLayoutManager::CLayoutManager() {
|
CLayoutManager::CLayoutManager() = default;
|
||||||
static auto P = Event::bus()->m_events.monitor.layoutChanged.listen([] {
|
|
||||||
for (const auto& ws : g_pCompositor->getWorkspaces()) {
|
|
||||||
ws->m_space->recheckWorkArea();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void CLayoutManager::newTarget(SP<ITarget> target, SP<CSpace> space) {
|
void CLayoutManager::newTarget(SP<ITarget> target, SP<CSpace> space) {
|
||||||
// on a new target: remember desired pos for float, if available
|
// on a new target: remember desired pos for float, if available
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../../debug/log/Logger.hpp"
|
#include "../../debug/log/Logger.hpp"
|
||||||
#include "../../desktop/Workspace.hpp"
|
#include "../../desktop/Workspace.hpp"
|
||||||
#include "../../config/ConfigManager.hpp"
|
#include "../../config/ConfigManager.hpp"
|
||||||
|
#include "../../event/EventBus.hpp"
|
||||||
|
|
||||||
using namespace Layout;
|
using namespace Layout;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,12 @@ SP<CSpace> CSpace::create(PHLWORKSPACE w) {
|
||||||
|
|
||||||
CSpace::CSpace(PHLWORKSPACE parent) : m_parent(parent) {
|
CSpace::CSpace(PHLWORKSPACE parent) : m_parent(parent) {
|
||||||
recheckWorkArea();
|
recheckWorkArea();
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE
|
||||||
|
m_geomUpdateCallback = Event::bus()->m_events.monitor.layoutChanged.listen([this] {
|
||||||
|
recheckWorkArea();
|
||||||
|
m_algorithm->recalculate();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSpace::add(SP<ITarget> t) {
|
void CSpace::add(SP<ITarget> t) {
|
||||||
|
|
|
||||||
|
|
@ -63,5 +63,8 @@ namespace Layout {
|
||||||
|
|
||||||
// work area is in global coords
|
// work area is in global coords
|
||||||
CBox m_workArea, m_floatingWorkArea;
|
CBox m_workArea, m_floatingWorkArea;
|
||||||
|
|
||||||
|
// for recalc
|
||||||
|
CHyprSignalListener m_geomUpdateCallback;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue