layout/algo: fix swar on removing a target (#13427)
ref https://github.com/hyprwm/Hyprland/discussions/13422
This commit is contained in:
parent
b90c61c04f
commit
f12904e641
2 changed files with 56 additions and 2 deletions
54
hyprtester/src/tests/main/layout.cpp
Normal file
54
hyprtester/src/tests/main/layout.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include "../shared.hpp"
|
||||||
|
#include "../../shared.hpp"
|
||||||
|
#include "../../hyprctlCompat.hpp"
|
||||||
|
#include "tests.hpp"
|
||||||
|
|
||||||
|
static int ret = 0;
|
||||||
|
|
||||||
|
static void swar() {
|
||||||
|
OK(getFromSocket("/keyword layout:single_window_aspect_ratio 1 1"));
|
||||||
|
|
||||||
|
Tests::spawnKitty();
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(str, "at: 442,22");
|
||||||
|
EXPECT_CONTAINS(str, "size: 1036,1036");
|
||||||
|
}
|
||||||
|
|
||||||
|
Tests::spawnKitty();
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch killwindow activewindow"));
|
||||||
|
|
||||||
|
Tests::waitUntilWindowsN(1);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(str, "at: 442,22");
|
||||||
|
EXPECT_CONTAINS(str, "size: 1036,1036");
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||||
|
Tests::killAllWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool test() {
|
||||||
|
NLog::log("{}Testing layout generic", Colors::GREEN);
|
||||||
|
|
||||||
|
// setup
|
||||||
|
OK(getFromSocket("/dispatch workspace 10"));
|
||||||
|
|
||||||
|
// test
|
||||||
|
NLog::log("{}Testing `single_window_aspect_ratio`", Colors::GREEN);
|
||||||
|
swar();
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
NLog::log("Cleaning up", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("/dispatch workspace 1"));
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
|
||||||
|
return !ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_TEST_FN(test);
|
||||||
|
|
@ -42,16 +42,16 @@ void CAlgorithm::removeTarget(SP<ITarget> target) {
|
||||||
const bool IS_FLOATING = std::ranges::contains(m_floatingTargets, target);
|
const bool IS_FLOATING = std::ranges::contains(m_floatingTargets, target);
|
||||||
|
|
||||||
if (IS_FLOATING) {
|
if (IS_FLOATING) {
|
||||||
m_floating->removeTarget(target);
|
|
||||||
std::erase(m_floatingTargets, target);
|
std::erase(m_floatingTargets, target);
|
||||||
|
m_floating->removeTarget(target);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool IS_TILED = std::ranges::contains(m_tiledTargets, target);
|
const bool IS_TILED = std::ranges::contains(m_tiledTargets, target);
|
||||||
|
|
||||||
if (IS_TILED) {
|
if (IS_TILED) {
|
||||||
m_tiled->removeTarget(target);
|
|
||||||
std::erase(m_tiledTargets, target);
|
std::erase(m_tiledTargets, target);
|
||||||
|
m_tiled->removeTarget(target);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue