| 1 |
#include "../shared.hpp" |
| 2 |
#include "../../shared.hpp" |
| 3 |
#include "../../hyprctlCompat.hpp" |
| 4 |
#include "tests.hpp" |
| 5 |
|
| 6 |
#include <hyprutils/utils/ScopeGuard.hpp> |
| 7 |
|
| 8 |
using namespace Hyprutils::Utils; |
| 9 |
|
| 10 |
// get the block from hyprctl clients where a class is located |
| 11 |
static std::string getClientBlock(const std::string& clients, const std::string& cls) { |
| 12 |
|
| 13 |
// lambda for finding the next block with `Window * ->` |
| 14 |
const auto findNextBlockHeader = [&](const std::string& s, size_t pos) -> size_t { |
| 15 |
const auto NPOS = std::string::npos; |
| 16 |
while (pos != NPOS) { |
| 17 |
pos = s.find("Window ", pos); |
| 18 |
if (pos == NPOS) |
| 19 |
return NPOS; |
| 20 |
size_t lineEnd = s.find('\n', pos); |
| 21 |
size_t arrowPos = s.find(" ->", pos); |
| 22 |
if (arrowPos != NPOS && arrowPos < lineEnd) |
| 23 |
return pos; |
| 24 |
pos = (lineEnd != NPOS) ? lineEnd + 1 : NPOS; |
| 25 |
} |
| 26 |
return NPOS; |
| 27 |
}; |
| 28 |
|
| 29 |
const std::string CLASS_TARGET = "class: " + cls + "\n"; |
| 30 |
|
| 31 |
// block by block till you find the class within a block |
| 32 |
size_t blockStart = findNextBlockHeader(clients, 0); |
| 33 |
while (blockStart != std::string::npos) { |
| 34 |
size_t blockEnd = findNextBlockHeader(clients, blockStart + 1); |
| 35 |
std::string block = clients.substr(blockStart, blockEnd == std::string::npos ? std::string::npos : blockEnd - blockStart); |
| 36 |
|
| 37 |
if (block.contains(CLASS_TARGET)) |
| 38 |
return block; |
| 39 |
|
| 40 |
blockStart = blockEnd; |
| 41 |
} |
| 42 |
|
| 43 |
return ""; |
| 44 |
} |
| 45 |
|
| 46 |
// Taken from layers tests |
| 47 |
static bool spawnLayer(const std::string& namespace_, const std::vector<std::string>& args = {}) { |
| 48 |
NLog::log("{}Spawning kitty layer {}", Colors::YELLOW, namespace_); |
| 49 |
if (!Tests::spawnLayerKitty(namespace_, args)) { |
| 50 |
NLog::log("{}Error: {} layer did not spawn", Colors::RED, namespace_); |
| 51 |
return false; |
| 52 |
} |
| 53 |
return true; |
| 54 |
} |
| 55 |
|
| 56 |
// Taken from layers tests |
| 57 |
static std::string getLayerLine(const std::string& layers, const std::string& target) { |
| 58 |
|
| 59 |
auto pos = layers.find("namespace: " + target); |
| 60 |
if (pos == std::string::npos) |
| 61 |
return ""; |
| 62 |
|
| 63 |
auto start = layers.rfind('\n', pos); |
| 64 |
start = (start == std::string::npos) ? 0 : start + 1; |
| 65 |
|
| 66 |
auto end = layers.find('\n', pos); |
| 67 |
|
| 68 |
return layers.substr(start, end - start); |
| 69 |
} |
| 70 |
|
| 71 |
TEST_CASE(scrollFocusCycling) { |
| 72 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 73 |
|
| 74 |
for (auto const& win : {"a", "b", "c", "d"}) { |
| 75 |
SPAWN_KITTY(win); |
| 76 |
} |
| 77 |
|
| 78 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:a' })")); |
| 79 |
|
| 80 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 81 |
|
| 82 |
{ |
| 83 |
auto str = getFromSocket("/activewindow"); |
| 84 |
ASSERT_CONTAINS(str, "class: b"); |
| 85 |
} |
| 86 |
|
| 87 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 88 |
|
| 89 |
{ |
| 90 |
auto str = getFromSocket("/activewindow"); |
| 91 |
ASSERT_CONTAINS(str, "class: c"); |
| 92 |
} |
| 93 |
|
| 94 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 95 |
|
| 96 |
{ |
| 97 |
auto str = getFromSocket("/activewindow"); |
| 98 |
ASSERT_CONTAINS(str, "class: d"); |
| 99 |
} |
| 100 |
|
| 101 |
OK(getFromSocket("/dispatch hl.dsp.window.move({ direction = 'left' })")); |
| 102 |
|
| 103 |
{ |
| 104 |
auto str = getFromSocket("/activewindow"); |
| 105 |
ASSERT_CONTAINS(str, "class: d"); |
| 106 |
} |
| 107 |
|
| 108 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'up' })")); |
| 109 |
|
| 110 |
{ |
| 111 |
auto str = getFromSocket("/activewindow"); |
| 112 |
ASSERT_CONTAINS(str, "class: c"); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
TEST_CASE(scrollFocusWrapping) { |
| 117 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 118 |
|
| 119 |
for (auto const& win : {"a", "b", "c", "d"}) { |
| 120 |
SPAWN_KITTY(win); |
| 121 |
} |
| 122 |
|
| 123 |
// set wrap_focus to true |
| 124 |
OK(getFromSocket("/eval hl.config({ scrolling = { wrap_focus = true } })")); |
| 125 |
|
| 126 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:a' })")); |
| 127 |
|
| 128 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 129 |
|
| 130 |
{ |
| 131 |
auto str = getFromSocket("/activewindow"); |
| 132 |
ASSERT_CONTAINS(str, "class: d"); |
| 133 |
} |
| 134 |
|
| 135 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 136 |
|
| 137 |
{ |
| 138 |
auto str = getFromSocket("/activewindow"); |
| 139 |
ASSERT_CONTAINS(str, "class: a"); |
| 140 |
} |
| 141 |
|
| 142 |
// set wrap_focus to false |
| 143 |
OK(getFromSocket("/eval hl.config({ scrolling = { wrap_focus = false } })")); |
| 144 |
|
| 145 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:a' })")); |
| 146 |
|
| 147 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 148 |
|
| 149 |
{ |
| 150 |
auto str = getFromSocket("/activewindow"); |
| 151 |
ASSERT_CONTAINS(str, "class: a"); |
| 152 |
} |
| 153 |
|
| 154 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:d' })")); |
| 155 |
|
| 156 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 157 |
|
| 158 |
{ |
| 159 |
auto str = getFromSocket("/activewindow"); |
| 160 |
ASSERT_CONTAINS(str, "class: d"); |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
TEST_CASE(scrollSwapcolWrapping) { |
| 165 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 166 |
|
| 167 |
for (auto const& win : {"a", "b", "c", "d"}) { |
| 168 |
SPAWN_KITTY(win); |
| 169 |
} |
| 170 |
|
| 171 |
// set wrap_swapcol to true |
| 172 |
OK(getFromSocket("/eval hl.config({ scrolling = { wrap_swapcol = true } })")); |
| 173 |
|
| 174 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:a' })")); |
| 175 |
|
| 176 |
OK(getFromSocket("/dispatch hl.dsp.layout('swapcol l')")); |
| 177 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 178 |
|
| 179 |
{ |
| 180 |
auto str = getFromSocket("/activewindow"); |
| 181 |
ASSERT_CONTAINS(str, "class: c"); |
| 182 |
} |
| 183 |
|
| 184 |
// clean up |
| 185 |
NLog::yellow("Killing all windows"); |
| 186 |
Tests::killAllWindows(); |
| 187 |
|
| 188 |
for (auto const& win : {"a", "b", "c", "d"}) { |
| 189 |
SPAWN_KITTY(win); |
| 190 |
} |
| 191 |
|
| 192 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:d' })")); |
| 193 |
OK(getFromSocket("/dispatch hl.dsp.layout('swapcol r')")); |
| 194 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 195 |
|
| 196 |
{ |
| 197 |
auto str = getFromSocket("/activewindow"); |
| 198 |
ASSERT_CONTAINS(str, "class: b"); |
| 199 |
} |
| 200 |
|
| 201 |
// clean up |
| 202 |
NLog::yellow("Killing all windows"); |
| 203 |
Tests::killAllWindows(); |
| 204 |
|
| 205 |
for (auto const& win : {"a", "b", "c", "d"}) { |
| 206 |
SPAWN_KITTY(win); |
| 207 |
} |
| 208 |
|
| 209 |
// set wrap_swapcol to false |
| 210 |
OK(getFromSocket("/eval hl.config({ scrolling = { wrap_swapcol = false } })")); |
| 211 |
|
| 212 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:a' })")); |
| 213 |
|
| 214 |
OK(getFromSocket("/dispatch hl.dsp.layout('swapcol l')")); |
| 215 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 216 |
|
| 217 |
{ |
| 218 |
auto str = getFromSocket("/activewindow"); |
| 219 |
ASSERT_CONTAINS(str, "class: b"); |
| 220 |
} |
| 221 |
|
| 222 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:d' })")); |
| 223 |
|
| 224 |
OK(getFromSocket("/dispatch hl.dsp.layout('swapcol r')")); |
| 225 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 226 |
|
| 227 |
{ |
| 228 |
auto str = getFromSocket("/activewindow"); |
| 229 |
ASSERT_CONTAINS(str, "class: c"); |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
TEST_CASE(scrollWindowRule) { |
| 234 |
OK(getFromSocket("/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 235 |
|
| 236 |
NLog::green("Testing Scrolling Width"); |
| 237 |
|
| 238 |
// inject a new rule. |
| 239 |
OK(getFromSocket("/eval hl.window_rule({ name = 'scrolling-width', match = { class = 'kitty_scroll' } })")); |
| 240 |
OK(getFromSocket("/eval hl.window_rule({ name = 'scrolling-width', scrolling_width = 0.1 })")); |
| 241 |
|
| 242 |
SPAWN_KITTY("kitty_scroll"); |
| 243 |
SPAWN_KITTY("kitty_scroll"); |
| 244 |
|
| 245 |
ASSERT(Tests::windowCount(), 2); |
| 246 |
|
| 247 |
// not the greatest test, but as long as res and gaps don't change, we good. |
| 248 |
// if this test breaks, it's likely you broke equal sizing |
| 249 |
ASSERT_CONTAINS(getFromSocket("/activewindow"), "size: 179,1036"); |
| 250 |
} |
| 251 |
|
| 252 |
/* |
| 253 |
Fullscreen Tests |
| 254 |
|
| 255 |
Tests with `Shared test among all default handled FS` comment are duplicated among all layouts to test each layout individually |
| 256 |
|
| 257 |
Scroll has layout handled fullscreen so it will have scrolling-specific FS tests in addition to shared Default Handled Tests |
| 258 |
|
| 259 |
*/ |
| 260 |
|
| 261 |
TEST_CASE(scroll_LAYOUT_HANDLED_fullscreen) { |
| 262 |
OK(getFromSocket("/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 263 |
|
| 264 |
NLog::green("Testing Scrolling FS"); |
| 265 |
|
| 266 |
SPAWN_KITTY("kitty_scroll_A"); |
| 267 |
SPAWN_KITTY("kitty_scroll_B"); |
| 268 |
SPAWN_KITTY("kitty_scroll_C"); |
| 269 |
|
| 270 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = \"class:kitty_scroll_B\" })")); |
| 271 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen()")); |
| 272 |
|
| 273 |
{ |
| 274 |
auto str = getFromSocket("/activewindow"); |
| 275 |
ASSERT_CONTAINS(str, "size: 1920,1080"); |
| 276 |
ASSERT_CONTAINS(str, "class: kitty_scroll_B"); |
| 277 |
} |
| 278 |
|
| 279 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 280 |
|
| 281 |
{ |
| 282 |
auto str = getFromSocket("/activewindow"); |
| 283 |
ASSERT_CONTAINS(str, "class: kitty_scroll_A"); |
| 284 |
} |
| 285 |
|
| 286 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 287 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 288 |
|
| 289 |
{ |
| 290 |
auto str = getFromSocket("/activewindow"); |
| 291 |
ASSERT_CONTAINS(str, "class: kitty_scroll_C"); |
| 292 |
} |
| 293 |
|
| 294 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 295 |
|
| 296 |
{ |
| 297 |
auto str = getFromSocket("/activewindow"); |
| 298 |
ASSERT_CONTAINS(str, "size: 1920,1080"); |
| 299 |
ASSERT_CONTAINS(str, "class: kitty_scroll_B"); |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
TEST_CASE(scroll_LAYOUT_HANDLED_maximized) { |
| 304 |
OK(getFromSocket("/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 305 |
|
| 306 |
NLog::green("Testing Scrolling Maximize"); |
| 307 |
|
| 308 |
SPAWN_KITTY("kitty_scroll_A"); |
| 309 |
SPAWN_KITTY("kitty_scroll_B"); |
| 310 |
SPAWN_KITTY("kitty_scroll_C"); |
| 311 |
|
| 312 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = \"class:kitty_scroll_B\" })")); |
| 313 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({mode = 'maximized'})")); |
| 314 |
|
| 315 |
{ |
| 316 |
auto str = getFromSocket("/activewindow"); |
| 317 |
ASSERT_CONTAINS(str, "size: 1866,1036"); |
| 318 |
ASSERT_CONTAINS(str, "class: kitty_scroll_B"); |
| 319 |
ASSERT_CONTAINS(str, "fullscreen: 1"); |
| 320 |
} |
| 321 |
|
| 322 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 323 |
|
| 324 |
{ |
| 325 |
auto str = getFromSocket("/activewindow"); |
| 326 |
ASSERT_CONTAINS(str, "class: kitty_scroll_A"); |
| 327 |
} |
| 328 |
|
| 329 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 330 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 331 |
|
| 332 |
{ |
| 333 |
auto str = getFromSocket("/activewindow"); |
| 334 |
ASSERT_CONTAINS(str, "class: kitty_scroll_C"); |
| 335 |
} |
| 336 |
|
| 337 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 338 |
|
| 339 |
{ |
| 340 |
auto str = getFromSocket("/activewindow"); |
| 341 |
ASSERT_CONTAINS(str, "size: 1866,1036"); |
| 342 |
ASSERT_CONTAINS(str, "class: kitty_scroll_B"); |
| 343 |
ASSERT_CONTAINS(str, "fullscreen: 1"); |
| 344 |
} |
| 345 |
} |
| 346 |
|
| 347 |
TEST_CASE(scroll_LAYOUT_HANDLED_fullscreenRetainsGeometryWhileScrolling) { |
| 348 |
OK(getFromSocket("/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 349 |
|
| 350 |
SPAWN_KITTY("kitty_scroll_A"); |
| 351 |
SPAWN_KITTY("kitty_scroll_B"); |
| 352 |
SPAWN_KITTY("kitty_scroll_C"); |
| 353 |
|
| 354 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_scroll_B' })")); |
| 355 |
|
| 356 |
const auto REGULAR_SIZE = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 357 |
|
| 358 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 0, action = 'set' })")); |
| 359 |
|
| 360 |
const auto FULLSCREEN_POS = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 361 |
|
| 362 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_scroll_A' })")); |
| 363 |
|
| 364 |
{ |
| 365 |
const auto WINDOW = getClientBlock(getFromSocket("/clients"), "kitty_scroll_B"); |
| 366 |
ASSERT_CONTAINS(WINDOW, "fullscreen: 2"); |
| 367 |
ASSERT_CONTAINS(WINDOW, "fullscreenClient: 0"); |
| 368 |
ASSERT_CONTAINS(WINDOW, "fullscreenHandler: scrolling"); |
| 369 |
ASSERT_CONTAINS(WINDOW, "size: 1920,1080"); |
| 370 |
ASSERT_NOT(Tests::getAttribute(WINDOW, "at"), FULLSCREEN_POS); |
| 371 |
} |
| 372 |
|
| 373 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 0, client = 0, action = 'set', window = 'class:kitty_scroll_B' })")); |
| 374 |
|
| 375 |
{ |
| 376 |
const auto WINDOW = getClientBlock(getFromSocket("/clients"), "kitty_scroll_B"); |
| 377 |
ASSERT_CONTAINS(WINDOW, "fullscreen: 0"); |
| 378 |
ASSERT(Tests::getAttribute(WINDOW, "size"), REGULAR_SIZE); |
| 379 |
} |
| 380 |
|
| 381 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_scroll_B' })")); |
| 382 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 1, client = 0, action = 'set' })")); |
| 383 |
|
| 384 |
const auto MAXIMIZED_POS = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 385 |
const auto MAXIMIZED_SIZE = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 386 |
|
| 387 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_scroll_C' })")); |
| 388 |
|
| 389 |
{ |
| 390 |
const auto WINDOW = getClientBlock(getFromSocket("/clients"), "kitty_scroll_B"); |
| 391 |
ASSERT_CONTAINS(WINDOW, "fullscreen: 1"); |
| 392 |
ASSERT_CONTAINS(WINDOW, "fullscreenClient: 0"); |
| 393 |
ASSERT_CONTAINS(WINDOW, "fullscreenHandler: scrolling"); |
| 394 |
ASSERT(Tests::getAttribute(WINDOW, "size"), MAXIMIZED_SIZE); |
| 395 |
ASSERT_NOT(Tests::getAttribute(WINDOW, "at"), MAXIMIZED_POS); |
| 396 |
} |
| 397 |
|
| 398 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_scroll_B' })")); |
| 399 |
OK(getFromSocket("/dispatch hl.dsp.layout('consume')")); |
| 400 |
|
| 401 |
{ |
| 402 |
const auto WINDOW = getClientBlock(getFromSocket("/clients"), "kitty_scroll_B"); |
| 403 |
ASSERT_CONTAINS(WINDOW, "fullscreen: 0"); |
| 404 |
ASSERT_CONTAINS(WINDOW, "fullscreenClient: 0"); |
| 405 |
} |
| 406 |
} |
| 407 |
|
| 408 |
TEST_CASE(scroll_LAYOUT_HANDLED_floatingWindowHiding) { |
| 409 |
|
| 410 |
/* |
| 411 |
|
| 412 |
Scrolling layout allows floating FS windows to 'layer over' tiled FS window. |
| 413 |
|
| 414 |
If a floating window was open before a tiled window was FSed, hide it |
| 415 |
If a floating window was opened after a tiled window was FSed, show it |
| 416 |
|
| 417 |
If a floating window was FSed ontop of the tiled window, hide all floating windows that were visible over the tiled FS window |
| 418 |
If this floating window is unFSed, all floating windows that were ontop of the tiled FS window as well as the floating window that was just FS-unFSed must still show ontop of the tiled FS window |
| 419 |
If we scroll onto another tiled FS window, hide them all. Scrolling back onto the prev tiled FS window doesn't cause them to reappear |
| 420 |
|
| 421 |
|
| 422 |
Considerations for the test: |
| 423 |
allowedOverFullscreen is used for floating windows' visibility. It's not always set for tiled ones, and don't implact their visibility. |
| 424 |
|
| 425 |
`visible` and `hidden` are not reliable since they are inconsistent. After they are fixed, they should be added to tested fields |
| 426 |
|
| 427 |
acceptInput works since hidden windows don't accept input. |
| 428 |
|
| 429 |
|
| 430 |
*/ |
| 431 |
|
| 432 |
OK(getFromSocket("/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 433 |
|
| 434 |
// Spawn a window, float it |
| 435 |
Tests::spawnKitty("under"); |
| 436 |
OK(getFromSocket("/dispatch hl.dsp.window.float({action = 'enable', window = 'class:under'})")); |
| 437 |
|
| 438 |
// FS 2 tiled windows - one fullscreen and one maximised |
| 439 |
Tests::spawnKitty("tiledOne"); |
| 440 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({mode = 'fullscreen'})")); |
| 441 |
|
| 442 |
// under should be hidden by now |
| 443 |
{ |
| 444 |
auto clients = getFromSocket("/clients"); |
| 445 |
auto under = getClientBlock(clients, "under"); |
| 446 |
ASSERT_CONTAINS(under, "class: under"); |
| 447 |
ASSERT_CONTAINS(under, "floating: 1"); |
| 448 |
|
| 449 |
ASSERT_CONTAINS(under, "allowedOverFullscreen: 0"); |
| 450 |
ASSERT_CONTAINS(under, "acceptsInput: 0"); |
| 451 |
|
| 452 |
ASSERT_CONTAINS(under, "fullscreen: 0"); |
| 453 |
ASSERT_CONTAINS(under, "fullscreenClient: 0"); |
| 454 |
} |
| 455 |
|
| 456 |
Tests::spawnKitty("tiledTwo"); |
| 457 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({mode = 'maximized'})")); |
| 458 |
|
| 459 |
// move view to tiledOne |
| 460 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:tiledOne' })")); |
| 461 |
|
| 462 |
// Check that tiledOne is visible - focus move is also tested here |
| 463 |
{ |
| 464 |
auto clients = getFromSocket("/clients"); |
| 465 |
auto tiledOne = getClientBlock(clients, "tiledOne"); |
| 466 |
ASSERT_CONTAINS(tiledOne, "class: tiledOne"); |
| 467 |
ASSERT_CONTAINS(tiledOne, "floating: 0"); |
| 468 |
|
| 469 |
ASSERT_CONTAINS(tiledOne, "acceptsInput: 1"); |
| 470 |
|
| 471 |
ASSERT_CONTAINS(tiledOne, "fullscreen: 2"); |
| 472 |
ASSERT_CONTAINS(tiledOne, "fullscreenClient: 2"); |
| 473 |
} |
| 474 |
|
| 475 |
// Check that under is still hidden |
| 476 |
{ |
| 477 |
auto clients = getFromSocket("/clients"); |
| 478 |
auto under = getClientBlock(clients, "under"); |
| 479 |
ASSERT_CONTAINS(under, "class: under"); |
| 480 |
ASSERT_CONTAINS(under, "floating: 1"); |
| 481 |
|
| 482 |
ASSERT_CONTAINS(under, "allowedOverFullscreen: 0"); |
| 483 |
ASSERT_CONTAINS(under, "acceptsInput: 0"); |
| 484 |
|
| 485 |
ASSERT_CONTAINS(under, "fullscreen: 0"); |
| 486 |
ASSERT_CONTAINS(under, "fullscreenClient: 0"); |
| 487 |
} |
| 488 |
|
| 489 |
// Window rule for spawing kittens as floating as we need it from now on |
| 490 |
OK(getFromSocket("/eval hl.window_rule({ name = 'kittens float with certain size', match = {class = 'floating.*',}, float = true, size = {950, 500},})")); |
| 491 |
|
| 492 |
// Spawn 2 floating windows |
| 493 |
Tests::spawnKitty("floatingOne"); |
| 494 |
Tests::spawnKitty("floatingTwo"); |
| 495 |
|
| 496 |
// Check that both are visible |
| 497 |
{ |
| 498 |
auto clients = getFromSocket("/clients"); |
| 499 |
auto floatingOne = getClientBlock(clients, "floatingOne"); |
| 500 |
ASSERT_CONTAINS(floatingOne, "class: floatingOne"); |
| 501 |
ASSERT_CONTAINS(floatingOne, "floating: 1"); |
| 502 |
|
| 503 |
ASSERT_CONTAINS(floatingOne, "allowedOverFullscreen: 1"); |
| 504 |
ASSERT_CONTAINS(floatingOne, "acceptsInput: 1"); |
| 505 |
|
| 506 |
ASSERT_CONTAINS(floatingOne, "fullscreen: 0"); |
| 507 |
ASSERT_CONTAINS(floatingOne, "fullscreenClient: 0"); |
| 508 |
} |
| 509 |
{ |
| 510 |
auto clients = getFromSocket("/clients"); |
| 511 |
auto floatingTwo = getClientBlock(clients, "floatingTwo"); |
| 512 |
ASSERT_CONTAINS(floatingTwo, "class: floatingTwo"); |
| 513 |
ASSERT_CONTAINS(floatingTwo, "floating: 1"); |
| 514 |
|
| 515 |
ASSERT_CONTAINS(floatingTwo, "allowedOverFullscreen: 1"); |
| 516 |
ASSERT_CONTAINS(floatingTwo, "acceptsInput: 1"); |
| 517 |
|
| 518 |
ASSERT_CONTAINS(floatingTwo, "fullscreen: 0"); |
| 519 |
ASSERT_CONTAINS(floatingTwo, "fullscreenClient: 0"); |
| 520 |
} |
| 521 |
|
| 522 |
// FS one floating window |
| 523 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:floatingOne' })")); |
| 524 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({mode = 'maximized'})")); |
| 525 |
|
| 526 |
// floatingTwo should now be hidden, as well as all others save for floatingOne |
| 527 |
|
| 528 |
// floatingOne - visible |
| 529 |
{ |
| 530 |
auto clients = getFromSocket("/clients"); |
| 531 |
auto floatingOne = getClientBlock(clients, "floatingOne"); |
| 532 |
ASSERT_CONTAINS(floatingOne, "class: floatingOne"); |
| 533 |
ASSERT_CONTAINS(floatingOne, "floating: 1"); |
| 534 |
|
| 535 |
// The window itself is FS so allowedOverFullscreen = 0 |
| 536 |
ASSERT_CONTAINS(floatingOne, "allowedOverFullscreen: 0"); |
| 537 |
ASSERT_CONTAINS(floatingOne, "acceptsInput: 1"); |
| 538 |
|
| 539 |
ASSERT_CONTAINS(floatingOne, "fullscreen: 1"); |
| 540 |
ASSERT_CONTAINS(floatingOne, "fullscreenClient: 1"); |
| 541 |
} |
| 542 |
|
| 543 |
// floatingTwo - hidden |
| 544 |
{ |
| 545 |
auto clients = getFromSocket("/clients"); |
| 546 |
auto floatingTwo = getClientBlock(clients, "floatingTwo"); |
| 547 |
ASSERT_CONTAINS(floatingTwo, "class: floatingTwo"); |
| 548 |
ASSERT_CONTAINS(floatingTwo, "floating: 1"); |
| 549 |
|
| 550 |
ASSERT_CONTAINS(floatingTwo, "allowedOverFullscreen: 0"); |
| 551 |
ASSERT_CONTAINS(floatingTwo, "acceptsInput: 0"); |
| 552 |
|
| 553 |
ASSERT_CONTAINS(floatingTwo, "fullscreen: 0"); |
| 554 |
ASSERT_CONTAINS(floatingTwo, "fullscreenClient: 0"); |
| 555 |
} |
| 556 |
// tiledOne - hidden |
| 557 |
{ |
| 558 |
auto clients = getFromSocket("/clients"); |
| 559 |
auto tiledOne = getClientBlock(clients, "tiledOne"); |
| 560 |
ASSERT_CONTAINS(tiledOne, "class: tiledOne"); |
| 561 |
ASSERT_CONTAINS(tiledOne, "floating: 0"); |
| 562 |
|
| 563 |
ASSERT_CONTAINS(tiledOne, "acceptsInput: 0"); |
| 564 |
|
| 565 |
ASSERT_CONTAINS(tiledOne, "fullscreen: 2"); |
| 566 |
ASSERT_CONTAINS(tiledOne, "fullscreenClient: 2"); |
| 567 |
} |
| 568 |
// tiledTwo - hidden |
| 569 |
{ |
| 570 |
auto clients = getFromSocket("/clients"); |
| 571 |
auto tiledTwo = getClientBlock(clients, "tiledTwo"); |
| 572 |
ASSERT_CONTAINS(tiledTwo, "class: tiledTwo"); |
| 573 |
ASSERT_CONTAINS(tiledTwo, "floating: 0"); |
| 574 |
|
| 575 |
ASSERT_CONTAINS(tiledTwo, "acceptsInput: 0"); |
| 576 |
|
| 577 |
ASSERT_CONTAINS(tiledTwo, "fullscreen: 1"); |
| 578 |
ASSERT_CONTAINS(tiledTwo, "fullscreenClient: 1"); |
| 579 |
} |
| 580 |
// under - hidden |
| 581 |
{ |
| 582 |
auto clients = getFromSocket("/clients"); |
| 583 |
auto under = getClientBlock(clients, "under"); |
| 584 |
ASSERT_CONTAINS(under, "class: under"); |
| 585 |
ASSERT_CONTAINS(under, "floating: 1"); |
| 586 |
|
| 587 |
ASSERT_CONTAINS(under, "allowedOverFullscreen: 0"); |
| 588 |
ASSERT_CONTAINS(under, "acceptsInput: 0"); |
| 589 |
|
| 590 |
ASSERT_CONTAINS(under, "fullscreen: 0"); |
| 591 |
ASSERT_CONTAINS(under, "fullscreenClient: 0"); |
| 592 |
} |
| 593 |
|
| 594 |
// Spawn a floating window - this should be ontop of floatingOne |
| 595 |
Tests::spawnKitty("floatingThree"); |
| 596 |
|
| 597 |
// floatingThree - visible and allowedOverFullscreen (spawned while floatingOne FS is active) |
| 598 |
{ |
| 599 |
auto clients = getFromSocket("/clients"); |
| 600 |
auto floatingThree = getClientBlock(clients, "floatingThree"); |
| 601 |
ASSERT_CONTAINS(floatingThree, "class: floatingThree"); |
| 602 |
ASSERT_CONTAINS(floatingThree, "floating: 1"); |
| 603 |
|
| 604 |
ASSERT_CONTAINS(floatingThree, "allowedOverFullscreen: 1"); |
| 605 |
ASSERT_CONTAINS(floatingThree, "acceptsInput: 1"); |
| 606 |
|
| 607 |
ASSERT_CONTAINS(floatingThree, "fullscreen: 0"); |
| 608 |
ASSERT_CONTAINS(floatingThree, "fullscreenClient: 0"); |
| 609 |
} |
| 610 |
|
| 611 |
// unFs floatingOne - floatingOne,Two,Three should be ontop of tiledOne and tiledTwo should still be hidden |
| 612 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:floatingOne' })")); |
| 613 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 0, client = 0, action = 'set', window = 'activewindow' })")); |
| 614 |
|
| 615 |
// floatingOne - visible (unFSed) |
| 616 |
{ |
| 617 |
auto clients = getFromSocket("/clients"); |
| 618 |
auto floatingOne = getClientBlock(clients, "floatingOne"); |
| 619 |
ASSERT_CONTAINS(floatingOne, "class: floatingOne"); |
| 620 |
ASSERT_CONTAINS(floatingOne, "floating: 1"); |
| 621 |
|
| 622 |
ASSERT_CONTAINS(floatingOne, "allowedOverFullscreen: 1"); |
| 623 |
ASSERT_CONTAINS(floatingOne, "acceptsInput: 1"); |
| 624 |
|
| 625 |
ASSERT_CONTAINS(floatingOne, "fullscreen: 0"); |
| 626 |
ASSERT_CONTAINS(floatingOne, "fullscreenClient: 0"); |
| 627 |
} |
| 628 |
// floatingTwo - visible |
| 629 |
{ |
| 630 |
auto clients = getFromSocket("/clients"); |
| 631 |
auto floatingTwo = getClientBlock(clients, "floatingTwo"); |
| 632 |
ASSERT_CONTAINS(floatingTwo, "class: floatingTwo"); |
| 633 |
ASSERT_CONTAINS(floatingTwo, "floating: 1"); |
| 634 |
|
| 635 |
ASSERT_CONTAINS(floatingTwo, "allowedOverFullscreen: 1"); |
| 636 |
ASSERT_CONTAINS(floatingTwo, "acceptsInput: 1"); |
| 637 |
|
| 638 |
ASSERT_CONTAINS(floatingTwo, "fullscreen: 0"); |
| 639 |
ASSERT_CONTAINS(floatingTwo, "fullscreenClient: 0"); |
| 640 |
} |
| 641 |
// floatingThree - visible |
| 642 |
{ |
| 643 |
auto clients = getFromSocket("/clients"); |
| 644 |
auto floatingThree = getClientBlock(clients, "floatingThree"); |
| 645 |
ASSERT_CONTAINS(floatingThree, "class: floatingThree"); |
| 646 |
ASSERT_CONTAINS(floatingThree, "floating: 1"); |
| 647 |
|
| 648 |
ASSERT_CONTAINS(floatingThree, "allowedOverFullscreen: 1"); |
| 649 |
ASSERT_CONTAINS(floatingThree, "acceptsInput: 1"); |
| 650 |
|
| 651 |
ASSERT_CONTAINS(floatingThree, "fullscreen: 0"); |
| 652 |
ASSERT_CONTAINS(floatingThree, "fullscreenClient: 0"); |
| 653 |
} |
| 654 |
// tiledOne - Visisble |
| 655 |
{ |
| 656 |
auto clients = getFromSocket("/clients"); |
| 657 |
auto tiledOne = getClientBlock(clients, "tiledOne"); |
| 658 |
ASSERT_CONTAINS(tiledOne, "class: tiledOne"); |
| 659 |
ASSERT_CONTAINS(tiledOne, "floating: 0"); |
| 660 |
|
| 661 |
ASSERT_CONTAINS(tiledOne, "acceptsInput: 1"); |
| 662 |
|
| 663 |
ASSERT_CONTAINS(tiledOne, "fullscreen: 2"); |
| 664 |
ASSERT_CONTAINS(tiledOne, "fullscreenClient: 2"); |
| 665 |
} |
| 666 |
// tiledTwo - still hidden |
| 667 |
{ |
| 668 |
auto clients = getFromSocket("/clients"); |
| 669 |
auto tiledTwo = getClientBlock(clients, "tiledTwo"); |
| 670 |
ASSERT_CONTAINS(tiledTwo, "class: tiledTwo"); |
| 671 |
ASSERT_CONTAINS(tiledTwo, "floating: 0"); |
| 672 |
|
| 673 |
ASSERT_CONTAINS(tiledTwo, "acceptsInput: 0"); |
| 674 |
|
| 675 |
ASSERT_CONTAINS(tiledTwo, "fullscreen: 1"); |
| 676 |
ASSERT_CONTAINS(tiledTwo, "fullscreenClient: 1"); |
| 677 |
} |
| 678 |
// under - still hidden |
| 679 |
{ |
| 680 |
auto clients = getFromSocket("/clients"); |
| 681 |
auto under = getClientBlock(clients, "under"); |
| 682 |
ASSERT_CONTAINS(under, "class: under"); |
| 683 |
ASSERT_CONTAINS(under, "floating: 1"); |
| 684 |
|
| 685 |
ASSERT_CONTAINS(under, "allowedOverFullscreen: 0"); |
| 686 |
ASSERT_CONTAINS(under, "acceptsInput: 0"); |
| 687 |
|
| 688 |
ASSERT_CONTAINS(under, "fullscreen: 0"); |
| 689 |
ASSERT_CONTAINS(under, "fullscreenClient: 0"); |
| 690 |
} |
| 691 |
|
| 692 |
// Scroll onto tiledTwo - all but tiledTwo should be hidden |
| 693 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:tiledTwo' })")); |
| 694 |
|
| 695 |
// tiledTwo - now visible |
| 696 |
{ |
| 697 |
auto clients = getFromSocket("/clients"); |
| 698 |
auto tiledTwo = getClientBlock(clients, "tiledTwo"); |
| 699 |
ASSERT_CONTAINS(tiledTwo, "class: tiledTwo"); |
| 700 |
ASSERT_CONTAINS(tiledTwo, "floating: 0"); |
| 701 |
|
| 702 |
ASSERT_CONTAINS(tiledTwo, "acceptsInput: 1"); |
| 703 |
|
| 704 |
ASSERT_CONTAINS(tiledTwo, "fullscreen: 1"); |
| 705 |
ASSERT_CONTAINS(tiledTwo, "fullscreenClient: 1"); |
| 706 |
} |
| 707 |
// floatingOne - hidden |
| 708 |
{ |
| 709 |
auto clients = getFromSocket("/clients"); |
| 710 |
auto floatingOne = getClientBlock(clients, "floatingOne"); |
| 711 |
ASSERT_CONTAINS(floatingOne, "class: floatingOne"); |
| 712 |
ASSERT_CONTAINS(floatingOne, "floating: 1"); |
| 713 |
|
| 714 |
ASSERT_CONTAINS(floatingOne, "allowedOverFullscreen: 0"); |
| 715 |
ASSERT_CONTAINS(floatingOne, "acceptsInput: 0"); |
| 716 |
|
| 717 |
ASSERT_CONTAINS(floatingOne, "fullscreen: 0"); |
| 718 |
ASSERT_CONTAINS(floatingOne, "fullscreenClient: 0"); |
| 719 |
} |
| 720 |
// floatingTwo - hidden |
| 721 |
{ |
| 722 |
auto clients = getFromSocket("/clients"); |
| 723 |
auto floatingTwo = getClientBlock(clients, "floatingTwo"); |
| 724 |
ASSERT_CONTAINS(floatingTwo, "class: floatingTwo"); |
| 725 |
ASSERT_CONTAINS(floatingTwo, "floating: 1"); |
| 726 |
|
| 727 |
ASSERT_CONTAINS(floatingTwo, "allowedOverFullscreen: 0"); |
| 728 |
ASSERT_CONTAINS(floatingTwo, "acceptsInput: 0"); |
| 729 |
|
| 730 |
ASSERT_CONTAINS(floatingTwo, "fullscreen: 0"); |
| 731 |
ASSERT_CONTAINS(floatingTwo, "fullscreenClient: 0"); |
| 732 |
} |
| 733 |
// floatingThree - hidden |
| 734 |
{ |
| 735 |
auto clients = getFromSocket("/clients"); |
| 736 |
auto floatingThree = getClientBlock(clients, "floatingThree"); |
| 737 |
ASSERT_CONTAINS(floatingThree, "class: floatingThree"); |
| 738 |
ASSERT_CONTAINS(floatingThree, "floating: 1"); |
| 739 |
|
| 740 |
ASSERT_CONTAINS(floatingThree, "allowedOverFullscreen: 0"); |
| 741 |
ASSERT_CONTAINS(floatingThree, "acceptsInput: 0"); |
| 742 |
|
| 743 |
ASSERT_CONTAINS(floatingThree, "fullscreen: 0"); |
| 744 |
ASSERT_CONTAINS(floatingThree, "fullscreenClient: 0"); |
| 745 |
} |
| 746 |
// tiledOne - hidden |
| 747 |
{ |
| 748 |
auto clients = getFromSocket("/clients"); |
| 749 |
auto tiledOne = getClientBlock(clients, "tiledOne"); |
| 750 |
ASSERT_CONTAINS(tiledOne, "class: tiledOne"); |
| 751 |
ASSERT_CONTAINS(tiledOne, "floating: 0"); |
| 752 |
|
| 753 |
ASSERT_CONTAINS(tiledOne, "acceptsInput: 0"); |
| 754 |
|
| 755 |
ASSERT_CONTAINS(tiledOne, "fullscreen: 2"); |
| 756 |
ASSERT_CONTAINS(tiledOne, "fullscreenClient: 2"); |
| 757 |
} |
| 758 |
// under - hidden |
| 759 |
{ |
| 760 |
auto clients = getFromSocket("/clients"); |
| 761 |
auto under = getClientBlock(clients, "under"); |
| 762 |
ASSERT_CONTAINS(under, "class: under"); |
| 763 |
ASSERT_CONTAINS(under, "floating: 1"); |
| 764 |
|
| 765 |
ASSERT_CONTAINS(under, "allowedOverFullscreen: 0"); |
| 766 |
ASSERT_CONTAINS(under, "acceptsInput: 0"); |
| 767 |
|
| 768 |
ASSERT_CONTAINS(under, "fullscreen: 0"); |
| 769 |
ASSERT_CONTAINS(under, "fullscreenClient: 0"); |
| 770 |
} |
| 771 |
|
| 772 |
// Scroll onto tiledOne - all but tiledOne should be hidden, floatings do not reappear |
| 773 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:tiledOne' })")); |
| 774 |
|
| 775 |
// tiledOne - visible |
| 776 |
{ |
| 777 |
auto clients = getFromSocket("/clients"); |
| 778 |
auto tiledOne = getClientBlock(clients, "tiledOne"); |
| 779 |
ASSERT_CONTAINS(tiledOne, "class: tiledOne"); |
| 780 |
ASSERT_CONTAINS(tiledOne, "floating: 0"); |
| 781 |
|
| 782 |
ASSERT_CONTAINS(tiledOne, "acceptsInput: 1"); |
| 783 |
|
| 784 |
ASSERT_CONTAINS(tiledOne, "fullscreen: 2"); |
| 785 |
ASSERT_CONTAINS(tiledOne, "fullscreenClient: 2"); |
| 786 |
} |
| 787 |
// floatingOne - hidden (scrolling back does not cause reappearance) |
| 788 |
{ |
| 789 |
auto clients = getFromSocket("/clients"); |
| 790 |
auto floatingOne = getClientBlock(clients, "floatingOne"); |
| 791 |
ASSERT_CONTAINS(floatingOne, "class: floatingOne"); |
| 792 |
ASSERT_CONTAINS(floatingOne, "floating: 1"); |
| 793 |
|
| 794 |
ASSERT_CONTAINS(floatingOne, "allowedOverFullscreen: 0"); |
| 795 |
ASSERT_CONTAINS(floatingOne, "acceptsInput: 0"); |
| 796 |
|
| 797 |
ASSERT_CONTAINS(floatingOne, "fullscreen: 0"); |
| 798 |
ASSERT_CONTAINS(floatingOne, "fullscreenClient: 0"); |
| 799 |
} |
| 800 |
// floatingTwo - hidden |
| 801 |
{ |
| 802 |
auto clients = getFromSocket("/clients"); |
| 803 |
auto floatingTwo = getClientBlock(clients, "floatingTwo"); |
| 804 |
ASSERT_CONTAINS(floatingTwo, "class: floatingTwo"); |
| 805 |
ASSERT_CONTAINS(floatingTwo, "floating: 1"); |
| 806 |
|
| 807 |
ASSERT_CONTAINS(floatingTwo, "allowedOverFullscreen: 0"); |
| 808 |
ASSERT_CONTAINS(floatingTwo, "acceptsInput: 0"); |
| 809 |
|
| 810 |
ASSERT_CONTAINS(floatingTwo, "fullscreen: 0"); |
| 811 |
ASSERT_CONTAINS(floatingTwo, "fullscreenClient: 0"); |
| 812 |
} |
| 813 |
// floatingThree - hidden |
| 814 |
{ |
| 815 |
auto clients = getFromSocket("/clients"); |
| 816 |
auto floatingThree = getClientBlock(clients, "floatingThree"); |
| 817 |
ASSERT_CONTAINS(floatingThree, "class: floatingThree"); |
| 818 |
ASSERT_CONTAINS(floatingThree, "floating: 1"); |
| 819 |
|
| 820 |
ASSERT_CONTAINS(floatingThree, "allowedOverFullscreen: 0"); |
| 821 |
ASSERT_CONTAINS(floatingThree, "acceptsInput: 0"); |
| 822 |
|
| 823 |
ASSERT_CONTAINS(floatingThree, "fullscreen: 0"); |
| 824 |
ASSERT_CONTAINS(floatingThree, "fullscreenClient: 0"); |
| 825 |
} |
| 826 |
// tiledTwo - hidden |
| 827 |
{ |
| 828 |
auto clients = getFromSocket("/clients"); |
| 829 |
auto tiledTwo = getClientBlock(clients, "tiledTwo"); |
| 830 |
ASSERT_CONTAINS(tiledTwo, "class: tiledTwo"); |
| 831 |
ASSERT_CONTAINS(tiledTwo, "floating: 0"); |
| 832 |
|
| 833 |
ASSERT_CONTAINS(tiledTwo, "acceptsInput: 0"); |
| 834 |
|
| 835 |
ASSERT_CONTAINS(tiledTwo, "fullscreen: 1"); |
| 836 |
ASSERT_CONTAINS(tiledTwo, "fullscreenClient: 1"); |
| 837 |
} |
| 838 |
// under - hidden |
| 839 |
{ |
| 840 |
auto clients = getFromSocket("/clients"); |
| 841 |
auto under = getClientBlock(clients, "under"); |
| 842 |
ASSERT_CONTAINS(under, "class: under"); |
| 843 |
ASSERT_CONTAINS(under, "floating: 1"); |
| 844 |
|
| 845 |
ASSERT_CONTAINS(under, "allowedOverFullscreen: 0"); |
| 846 |
ASSERT_CONTAINS(under, "acceptsInput: 0"); |
| 847 |
|
| 848 |
ASSERT_CONTAINS(under, "fullscreen: 0"); |
| 849 |
ASSERT_CONTAINS(under, "fullscreenClient: 0"); |
| 850 |
} |
| 851 |
} |
| 852 |
|
| 853 |
TEST_CASE(scroll_LAYOUT_HANDLED_layerVisibilityOnFs) { |
| 854 |
|
| 855 |
OK(getFromSocket("/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 856 |
|
| 857 |
// For default handled fullscreen |
| 858 |
|
| 859 |
static constexpr const char* LAYER_NAMESPACE = "bar-like-layer"; |
| 860 |
|
| 861 |
ASSERT(spawnLayer(LAYER_NAMESPACE, {"--edge=top", "--layer=top", "--lines=48px", "--focus-policy=not-allowed"}), true); |
| 862 |
|
| 863 |
Tests::spawnKitty("cat"); |
| 864 |
|
| 865 |
{ |
| 866 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 867 |
EXPECT_CONTAINS(str, "a: 1") |
| 868 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 869 |
} |
| 870 |
|
| 871 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'set', window = 'class:cat', layout_aware = false })")); |
| 872 |
|
| 873 |
{ |
| 874 |
|
| 875 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 876 |
EXPECT_CONTAINS(str, "a: 1") |
| 877 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 1"); |
| 878 |
} |
| 879 |
|
| 880 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'unset', window = 'class:cat', layout_aware = false })")); |
| 881 |
|
| 882 |
{ |
| 883 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 884 |
EXPECT_CONTAINS(str, "a: 1") |
| 885 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 886 |
} |
| 887 |
|
| 888 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'class:cat', layout_aware = false })")); |
| 889 |
|
| 890 |
{ |
| 891 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 892 |
EXPECT_CONTAINS(str, "a: 0") |
| 893 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 2"); |
| 894 |
} |
| 895 |
|
| 896 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'unset', window = 'class:cat', layout_aware = false })")); |
| 897 |
|
| 898 |
{ |
| 899 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 900 |
EXPECT_CONTAINS(str, "a: 1") |
| 901 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 902 |
} |
| 903 |
|
| 904 |
// Now we test Layout Handled FS |
| 905 |
|
| 906 |
// same as above but with layout_aware = false |
| 907 |
|
| 908 |
{ |
| 909 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 910 |
EXPECT_CONTAINS(str, "a: 1") |
| 911 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 912 |
} |
| 913 |
|
| 914 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'set', window = 'class:cat' })")); |
| 915 |
|
| 916 |
{ |
| 917 |
|
| 918 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 919 |
EXPECT_CONTAINS(str, "a: 1") |
| 920 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 1"); |
| 921 |
} |
| 922 |
|
| 923 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'unset', window = 'class:cat' })")); |
| 924 |
|
| 925 |
{ |
| 926 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 927 |
EXPECT_CONTAINS(str, "a: 1") |
| 928 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 929 |
} |
| 930 |
|
| 931 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'class:cat' })")); |
| 932 |
|
| 933 |
{ |
| 934 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 935 |
EXPECT_CONTAINS(str, "a: 0") |
| 936 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 2"); |
| 937 |
} |
| 938 |
|
| 939 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'unset', window = 'class:cat' })")); |
| 940 |
|
| 941 |
{ |
| 942 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 943 |
EXPECT_CONTAINS(str, "a: 1") |
| 944 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 945 |
} |
| 946 |
|
| 947 |
// Scrolling onto FS windows |
| 948 |
|
| 949 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'class:cat' })")); |
| 950 |
|
| 951 |
{ |
| 952 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 953 |
EXPECT_CONTAINS(str, "a: 0") |
| 954 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 2"); |
| 955 |
} |
| 956 |
|
| 957 |
Tests::spawnKitty("cat2"); |
| 958 |
|
| 959 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'set', window = 'class:cat2' })")); |
| 960 |
|
| 961 |
{ |
| 962 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 963 |
EXPECT_CONTAINS(str, "a: 1") |
| 964 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 1"); |
| 965 |
} |
| 966 |
|
| 967 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 968 |
|
| 969 |
{ |
| 970 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 971 |
EXPECT_CONTAINS(str, "a: 0") |
| 972 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 2"); |
| 973 |
} |
| 974 |
|
| 975 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')")); |
| 976 |
{ |
| 977 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 978 |
EXPECT_CONTAINS(str, "a: 1") |
| 979 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 1"); |
| 980 |
} |
| 981 |
|
| 982 |
// floating windows layered ontop of tiled windows |
| 983 |
|
| 984 |
// window rule for spawning floating kittens |
| 985 |
OK(getFromSocket("/eval hl.window_rule({ name = 'kittens float with certain size', match = {class = 'floating.*',}, float = true, size = {950, 500},})")); |
| 986 |
|
| 987 |
Tests::spawnKitty("floating_cat"); |
| 988 |
|
| 989 |
// still ontop of maximised widnow |
| 990 |
|
| 991 |
{ |
| 992 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 993 |
EXPECT_CONTAINS(str, "a: 1") |
| 994 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 995 |
} |
| 996 |
|
| 997 |
// maximise the floating kitty |
| 998 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'set', window = 'class:floating_cat' })")); |
| 999 |
|
| 1000 |
{ |
| 1001 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 1002 |
EXPECT_CONTAINS(str, "a: 1") |
| 1003 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 1"); |
| 1004 |
} |
| 1005 |
|
| 1006 |
// fullscreen the floating kitty |
| 1007 |
|
| 1008 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'class:floating_cat' })")); |
| 1009 |
|
| 1010 |
{ |
| 1011 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 1012 |
EXPECT_CONTAINS(str, "a: 0") |
| 1013 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 2"); |
| 1014 |
} |
| 1015 |
|
| 1016 |
// dispel the FS of floating kitty |
| 1017 |
|
| 1018 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'unset', window = 'class:floating_cat' })")); |
| 1019 |
|
| 1020 |
{ |
| 1021 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 1022 |
EXPECT_CONTAINS(str, "a: 1") |
| 1023 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 1024 |
} |
| 1025 |
|
| 1026 |
// move to the fullscreen window on the left, maximise and fullscreen the kitty window ontop of that too - the old floating kitten is now hidden so we can't use that |
| 1027 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cat' })")); |
| 1028 |
|
| 1029 |
Tests::spawnKitty("floating_cat2"); |
| 1030 |
|
| 1031 |
{ |
| 1032 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 1033 |
EXPECT_CONTAINS(str, "a: 0") |
| 1034 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 1035 |
} |
| 1036 |
|
| 1037 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'class:floating_cat2' })")); |
| 1038 |
|
| 1039 |
{ |
| 1040 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 1041 |
EXPECT_CONTAINS(str, "a: 0") |
| 1042 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 2"); |
| 1043 |
} |
| 1044 |
|
| 1045 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'set', window = 'class:floating_cat2' })")); |
| 1046 |
|
| 1047 |
{ |
| 1048 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 1049 |
EXPECT_CONTAINS(str, "a: 1") |
| 1050 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 1"); |
| 1051 |
} |
| 1052 |
|
| 1053 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'unset', window = 'class:floating_cat2' })")); |
| 1054 |
|
| 1055 |
// the fullscreen tiled window is now in effect |
| 1056 |
|
| 1057 |
{ |
| 1058 |
auto str = getLayerLine(getFromSocket("/layers"), LAYER_NAMESPACE); |
| 1059 |
EXPECT_CONTAINS(str, "a: 0") |
| 1060 |
EXPECT_CONTAINS(getFromSocket("/activewindow"), "fullscreen: 0"); |
| 1061 |
} |
| 1062 |
} |
| 1063 |
|
| 1064 |
TEST_CASE(scroll_LAYOUT_HANDLED_focusInDirectionFocusFollowFocusTrue) { |
| 1065 |
|
| 1066 |
/* |
| 1067 |
Scrolling quasi-equivalent of `defaultHandledFsfocusInDirection` |
| 1068 |
*/ |
| 1069 |
|
| 1070 |
// if movefocus_cycles_fullscreen = false, all focus({direction}) is disallowed from moving focus from FS window |
| 1071 |
|
| 1072 |
// if movefocus_cycles_fullscreen = true, standard behaviour of the config option won't be followed but focus will move in the firection specified as if window was not FS |
| 1073 |
// if on_focus_under_fullscreen = 0 focus({direction}) is disallowed from moving focus from FS window |
| 1074 |
// if on_focus_under_fullscreen = 1/2, standard behaviour of the config option won't be followed but focus will move in the firection specified as if window was not FS |
| 1075 |
|
| 1076 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1077 |
|
| 1078 |
/* |
| 1079 |
This test serves as a test for all layouts that use deafult FS behaviour |
| 1080 |
*/ |
| 1081 |
|
| 1082 |
Tests::spawnKitty("normal1"); |
| 1083 |
Tests::spawnKitty("fs"); |
| 1084 |
Tests::spawnKitty("normal2"); |
| 1085 |
|
| 1086 |
// if movefocus_cycles_fullscreen = false, all focus({direction}) is disallowed from moving focus from FS window |
| 1087 |
OK(getFromSocket("r/eval hl.config({ binds = { movefocus_cycles_fullscreen = false } })")); |
| 1088 |
|
| 1089 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:fs' })")); |
| 1090 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'class:fs' })")); |
| 1091 |
|
| 1092 |
// on_focus_under_fullscreen = 0 |
| 1093 |
OK(getFromSocket("r/eval hl.config({ misc = { on_focus_under_fullscreen = 0 } })")); |
| 1094 |
|
| 1095 |
{ |
| 1096 |
auto str = getFromSocket("/activewindow"); |
| 1097 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1098 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1099 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1100 |
} |
| 1101 |
|
| 1102 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 1103 |
{ |
| 1104 |
auto str = getFromSocket("/activewindow"); |
| 1105 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1106 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1107 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1108 |
} |
| 1109 |
|
| 1110 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 1111 |
{ |
| 1112 |
auto str = getFromSocket("/activewindow"); |
| 1113 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1114 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1115 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1116 |
} |
| 1117 |
|
| 1118 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'up' })")); |
| 1119 |
{ |
| 1120 |
auto str = getFromSocket("/activewindow"); |
| 1121 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1122 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1123 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1124 |
} |
| 1125 |
|
| 1126 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'down' })")); |
| 1127 |
{ |
| 1128 |
auto str = getFromSocket("/activewindow"); |
| 1129 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1130 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1131 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1132 |
} |
| 1133 |
|
| 1134 |
// on_focus_under_fullscreen = 1 |
| 1135 |
OK(getFromSocket("r/eval hl.config({ misc = { on_focus_under_fullscreen = 1 } })")); |
| 1136 |
|
| 1137 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 1138 |
{ |
| 1139 |
auto str = getFromSocket("/activewindow"); |
| 1140 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1141 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1142 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1143 |
} |
| 1144 |
|
| 1145 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 1146 |
{ |
| 1147 |
auto str = getFromSocket("/activewindow"); |
| 1148 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1149 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1150 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1151 |
} |
| 1152 |
|
| 1153 |
// on_focus_under_fullscreen = 2 |
| 1154 |
OK(getFromSocket("r/eval hl.config({ misc = { on_focus_under_fullscreen = 2 } })")); |
| 1155 |
|
| 1156 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 1157 |
{ |
| 1158 |
auto str = getFromSocket("/activewindow"); |
| 1159 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1160 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1161 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1162 |
} |
| 1163 |
|
| 1164 |
// if movefocus_cycles_fullscreen = true, standard behaviour of the config option won't be followed but focus will move in the firection specified as if window was not FS |
| 1165 |
|
| 1166 |
OK(getFromSocket("r/eval hl.config({ binds = { movefocus_cycles_fullscreen = true } })")); |
| 1167 |
|
| 1168 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:fs' })")); |
| 1169 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'class:fs' })")); |
| 1170 |
|
| 1171 |
// on_focus_under_fullscreen = 0 |
| 1172 |
OK(getFromSocket("r/eval hl.config({ misc = { on_focus_under_fullscreen = 0 } })")); |
| 1173 |
|
| 1174 |
{ |
| 1175 |
auto str = getFromSocket("/activewindow"); |
| 1176 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1177 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1178 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1179 |
} |
| 1180 |
|
| 1181 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 1182 |
{ |
| 1183 |
auto str = getFromSocket("/activewindow"); |
| 1184 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1185 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1186 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1187 |
} |
| 1188 |
|
| 1189 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 1190 |
{ |
| 1191 |
auto str = getFromSocket("/activewindow"); |
| 1192 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1193 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1194 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1195 |
} |
| 1196 |
|
| 1197 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'up' })")); |
| 1198 |
{ |
| 1199 |
auto str = getFromSocket("/activewindow"); |
| 1200 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1201 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1202 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1203 |
} |
| 1204 |
|
| 1205 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'down' })")); |
| 1206 |
{ |
| 1207 |
auto str = getFromSocket("/activewindow"); |
| 1208 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1209 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1210 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1211 |
} |
| 1212 |
|
| 1213 |
// on_focus_under_fullscreen = 1 - Won't cycle, but will simply switch to that window (viewport moves if follow_focus = true) |
| 1214 |
OK(getFromSocket("r/eval hl.config({ misc = { on_focus_under_fullscreen = 1 } })")); |
| 1215 |
|
| 1216 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 1217 |
{ |
| 1218 |
auto str = getFromSocket("/activewindow"); |
| 1219 |
EXPECT_CONTAINS(str, "class: normal1"); |
| 1220 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1221 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1222 |
EXPECT_CONTAINS(Tests::getAttribute(getFromSocket("/activewindow"), "at"), "22,22"); |
| 1223 |
} |
| 1224 |
|
| 1225 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 1226 |
{ |
| 1227 |
auto str = getFromSocket("/activewindow"); |
| 1228 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1229 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1230 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1231 |
EXPECT_CONTAINS(Tests::getAttribute(getFromSocket("/activewindow"), "at"), "0,0"); |
| 1232 |
} |
| 1233 |
|
| 1234 |
// on_focus_under_fullscreen = 2 - Won't dispel FS, but will simply switch to that window (viewport moves if follow_focus = true) |
| 1235 |
OK(getFromSocket("r/eval hl.config({ misc = { on_focus_under_fullscreen = 2 } })")); |
| 1236 |
|
| 1237 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 1238 |
{ |
| 1239 |
auto str = getFromSocket("/activewindow"); |
| 1240 |
EXPECT_CONTAINS(str, "class: normal1"); |
| 1241 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1242 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1243 |
EXPECT_CONTAINS(Tests::getAttribute(getFromSocket("/activewindow"), "at"), "22,22"); |
| 1244 |
} |
| 1245 |
|
| 1246 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 1247 |
{ |
| 1248 |
auto str = getFromSocket("/activewindow"); |
| 1249 |
EXPECT_CONTAINS(str, "class: fs"); |
| 1250 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1251 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1252 |
EXPECT_CONTAINS(Tests::getAttribute(getFromSocket("/activewindow"), "at"), "0,0"); |
| 1253 |
} |
| 1254 |
} |
| 1255 |
|
| 1256 |
TEST_CASE(scroll_LAYOUT_HANDLED_respectFocusFitMethodOnUnFs) { |
| 1257 |
|
| 1258 |
OK(getFromSocket("/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1259 |
|
| 1260 |
Tests::spawnKitty("kitty_A"); |
| 1261 |
Tests::spawnKitty("kitty_B"); |
| 1262 |
|
| 1263 |
// Fullscreen |
| 1264 |
|
| 1265 |
// focus_fit_method = 0 |
| 1266 |
|
| 1267 |
OK(getFromSocket("/eval hl.config({ scrolling = { focus_fit_method = 0 } })")); |
| 1268 |
|
| 1269 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'activewindow', layout_aware = true })")); |
| 1270 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'unset', window = 'activewindow', layout_aware = true })")); |
| 1271 |
{ |
| 1272 |
auto str = getFromSocket("/activewindow"); |
| 1273 |
EXPECT_CONTAINS(str, "class: kitty_B"); |
| 1274 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1275 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1276 |
EXPECT_CONTAINS(str, "at: 497,22") |
| 1277 |
} |
| 1278 |
|
| 1279 |
// focus_fit_method = 1 |
| 1280 |
OK(getFromSocket("/eval hl.config({ scrolling = { focus_fit_method = 1 } })")); |
| 1281 |
|
| 1282 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'activewindow', layout_aware = true })")); |
| 1283 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'unset', window = 'activewindow', layout_aware = true })")); |
| 1284 |
{ |
| 1285 |
auto str = getFromSocket("/activewindow"); |
| 1286 |
EXPECT_CONTAINS(str, "class: kitty_B"); |
| 1287 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1288 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1289 |
EXPECT_CONTAINS(str, "at: 27,22"); |
| 1290 |
} |
| 1291 |
|
| 1292 |
// Maximised |
| 1293 |
|
| 1294 |
// focus_fit_method = 0 |
| 1295 |
|
| 1296 |
OK(getFromSocket("/eval hl.config({ scrolling = { focus_fit_method = 0 } })")); |
| 1297 |
|
| 1298 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'set', window = 'activewindow', layout_aware = true })")); |
| 1299 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'unset', window = 'activewindow', layout_aware = true })")); |
| 1300 |
{ |
| 1301 |
auto str = getFromSocket("/activewindow"); |
| 1302 |
EXPECT_CONTAINS(str, "class: kitty_B"); |
| 1303 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1304 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1305 |
EXPECT_CONTAINS(str, "at: 497,22") |
| 1306 |
} |
| 1307 |
|
| 1308 |
// focus_fit_method = 1 |
| 1309 |
OK(getFromSocket("/eval hl.config({ scrolling = { focus_fit_method = 1 } })")); |
| 1310 |
|
| 1311 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'set', window = 'activewindow', layout_aware = true })")); |
| 1312 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'unset', window = 'activewindow', layout_aware = true })")); |
| 1313 |
{ |
| 1314 |
auto str = getFromSocket("/activewindow"); |
| 1315 |
EXPECT_CONTAINS(str, "class: kitty_B"); |
| 1316 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1317 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1318 |
EXPECT_CONTAINS(str, "at: 27,22"); |
| 1319 |
} |
| 1320 |
} |
| 1321 |
|
| 1322 |
TEST_CASE(scroll_DEFAULT_HANDLED_fullscreenMaximiseDispatchers) { |
| 1323 |
|
| 1324 |
// Shared test among all default handled FS |
| 1325 |
|
| 1326 |
OK(getFromSocket("/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1327 |
|
| 1328 |
Tests::spawnKitty("kitty_A"); |
| 1329 |
Tests::spawnKitty("kitty_B"); |
| 1330 |
|
| 1331 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_A' })")); |
| 1332 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set' })")); |
| 1333 |
|
| 1334 |
{ |
| 1335 |
auto str = getFromSocket("/activewindow"); |
| 1336 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1337 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1338 |
} |
| 1339 |
|
| 1340 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'unset' })")); |
| 1341 |
|
| 1342 |
{ |
| 1343 |
auto str = getFromSocket("/activewindow"); |
| 1344 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1345 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1346 |
} |
| 1347 |
|
| 1348 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'toggle' })")); |
| 1349 |
|
| 1350 |
{ |
| 1351 |
auto str = getFromSocket("/activewindow"); |
| 1352 |
EXPECT_CONTAINS(str, "fullscreen: 1"); |
| 1353 |
EXPECT_CONTAINS(str, "fullscreenClient: 1"); |
| 1354 |
} |
| 1355 |
|
| 1356 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'toggle' })")); |
| 1357 |
|
| 1358 |
{ |
| 1359 |
auto str = getFromSocket("/activewindow"); |
| 1360 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1361 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1362 |
} |
| 1363 |
|
| 1364 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'set' })")); |
| 1365 |
|
| 1366 |
{ |
| 1367 |
auto str = getFromSocket("/activewindow"); |
| 1368 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1369 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1370 |
} |
| 1371 |
|
| 1372 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'set' })")); |
| 1373 |
|
| 1374 |
{ |
| 1375 |
auto str = getFromSocket("/activewindow"); |
| 1376 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1377 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1378 |
} |
| 1379 |
|
| 1380 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'toggle' })")); |
| 1381 |
|
| 1382 |
{ |
| 1383 |
auto str = getFromSocket("/activewindow"); |
| 1384 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1385 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1386 |
} |
| 1387 |
|
| 1388 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'toggle' })")); |
| 1389 |
|
| 1390 |
{ |
| 1391 |
auto str = getFromSocket("/activewindow"); |
| 1392 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1393 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1394 |
} |
| 1395 |
} |
| 1396 |
|
| 1397 |
TEST_CASE(scroll_DEFAULT_HANDLED_testFsFocusUnderFSWindow) { |
| 1398 |
|
| 1399 |
// Shared test among all default handled FS |
| 1400 |
|
| 1401 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1402 |
|
| 1403 |
for (auto const& win : {"one", "two", "three"}) |
| 1404 |
if (!Tests::spawnKitty(win)) { |
| 1405 |
FAIL_TEST("Could not spawn kitty with win class `{}`", win); |
| 1406 |
} |
| 1407 |
|
| 1408 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:one' })")); |
| 1409 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', layout_aware = false, })")); |
| 1410 |
|
| 1411 |
{ |
| 1412 |
auto str = getFromSocket("/activewindow"); |
| 1413 |
EXPECT_CONTAINS(str, "at: 22,22"); |
| 1414 |
EXPECT_CONTAINS(str, "size: 1876,1036"); |
| 1415 |
EXPECT_CONTAINS(str, "class: one"); |
| 1416 |
} |
| 1417 |
|
| 1418 |
OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 1 } })")); |
| 1419 |
|
| 1420 |
Tests::spawnKitty("four"); |
| 1421 |
|
| 1422 |
{ |
| 1423 |
auto str = getFromSocket("/activewindow"); |
| 1424 |
EXPECT_CONTAINS(str, "at: 22,22"); |
| 1425 |
EXPECT_CONTAINS(str, "size: 1876,1036"); |
| 1426 |
EXPECT_CONTAINS(str, "class: four"); |
| 1427 |
EXPECT_CONTAINS(str, "fullscreen: 1"); |
| 1428 |
} |
| 1429 |
|
| 1430 |
OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 0 } })")); |
| 1431 |
|
| 1432 |
Tests::spawnKitty("ignored"); |
| 1433 |
|
| 1434 |
{ |
| 1435 |
auto str = getFromSocket("/activewindow"); |
| 1436 |
EXPECT_CONTAINS(str, "at: 22,22"); |
| 1437 |
EXPECT_CONTAINS(str, "size: 1876,1036"); |
| 1438 |
EXPECT_CONTAINS(str, "class: four"); |
| 1439 |
EXPECT_CONTAINS(str, "fullscreen: 1"); |
| 1440 |
} |
| 1441 |
|
| 1442 |
OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 2 } })")); |
| 1443 |
|
| 1444 |
Tests::spawnKitty("erstarrwashere"); |
| 1445 |
|
| 1446 |
{ |
| 1447 |
auto str = getFromSocket("/activewindow"); |
| 1448 |
EXPECT_CONTAINS(str, "class: erstarrwashere"); |
| 1449 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1450 |
} |
| 1451 |
} |
| 1452 |
|
| 1453 |
TEST_CASE(scroll_DEFAULT_HANDLED_newWindowTakesOverFullscreen) { |
| 1454 |
|
| 1455 |
// Shared test among all default handled FS |
| 1456 |
|
| 1457 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1458 |
|
| 1459 |
OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 0 } })")); |
| 1460 |
|
| 1461 |
Tests::spawnKitty("kitty_A"); |
| 1462 |
|
| 1463 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', layout_aware = false, })")); |
| 1464 |
|
| 1465 |
{ |
| 1466 |
auto str = getFromSocket("/activewindow"); |
| 1467 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1468 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1469 |
EXPECT_CONTAINS(str, "kitty_A"); |
| 1470 |
} |
| 1471 |
|
| 1472 |
Tests::spawnKitty("kitty_B"); |
| 1473 |
|
| 1474 |
{ |
| 1475 |
auto str = getFromSocket("/activewindow"); |
| 1476 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1477 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1478 |
EXPECT_CONTAINS(str, "kitty_A"); |
| 1479 |
} |
| 1480 |
|
| 1481 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_B' })")); |
| 1482 |
|
| 1483 |
{ |
| 1484 |
// should be ignored as per focus_under_fullscreen 0 |
| 1485 |
auto str = getFromSocket("/activewindow"); |
| 1486 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1487 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1488 |
EXPECT_CONTAINS(str, "kitty_A"); |
| 1489 |
} |
| 1490 |
|
| 1491 |
OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 1 } })")); |
| 1492 |
|
| 1493 |
Tests::spawnKitty("kitty_C"); |
| 1494 |
|
| 1495 |
{ |
| 1496 |
auto str = getFromSocket("/activewindow"); |
| 1497 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1498 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1499 |
EXPECT_CONTAINS(str, "kitty_C"); |
| 1500 |
} |
| 1501 |
|
| 1502 |
OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 2 } })")); |
| 1503 |
|
| 1504 |
Tests::spawnKitty("kitty_D"); |
| 1505 |
|
| 1506 |
{ |
| 1507 |
auto str = getFromSocket("/activewindow"); |
| 1508 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1509 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1510 |
EXPECT_CONTAINS(str, "kitty_D"); |
| 1511 |
} |
| 1512 |
|
| 1513 |
OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 0 } })")); |
| 1514 |
|
| 1515 |
Tests::killAllWindows(); |
| 1516 |
} |
| 1517 |
|
| 1518 |
TEST_CASE(scroll_DEFAULT_HANDLED_exitWindowRetainsFullscreen) { |
| 1519 |
|
| 1520 |
// Shared test among all default handled FS |
| 1521 |
|
| 1522 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1523 |
|
| 1524 |
OK(getFromSocket("/eval hl.config({ misc = { exit_window_retains_fullscreen = false } })")); |
| 1525 |
|
| 1526 |
Tests::spawnKitty("kitty_A"); |
| 1527 |
Tests::spawnKitty("kitty_B"); |
| 1528 |
|
| 1529 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', layout_aware = false, })")); |
| 1530 |
|
| 1531 |
{ |
| 1532 |
auto str = getFromSocket("/activewindow"); |
| 1533 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1534 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1535 |
} |
| 1536 |
|
| 1537 |
OK(getFromSocket("/dispatch hl.dsp.window.kill({ window = 'activewindow' })")); |
| 1538 |
Tests::waitUntilWindowsN(1); |
| 1539 |
|
| 1540 |
{ |
| 1541 |
auto str = getFromSocket("/activewindow"); |
| 1542 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1543 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1544 |
} |
| 1545 |
|
| 1546 |
Tests::spawnKitty("kitty_B"); |
| 1547 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', layout_aware = false, })")); |
| 1548 |
OK(getFromSocket("/eval hl.config({ misc = { exit_window_retains_fullscreen = true } })")); |
| 1549 |
|
| 1550 |
OK(getFromSocket("/dispatch hl.dsp.window.kill({ window = 'activewindow' })")); |
| 1551 |
Tests::waitUntilWindowsN(1); |
| 1552 |
|
| 1553 |
{ |
| 1554 |
auto str = getFromSocket("/activewindow"); |
| 1555 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1556 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1557 |
} |
| 1558 |
|
| 1559 |
Tests::killAllWindows(); |
| 1560 |
} |
| 1561 |
|
| 1562 |
TEST_CASE(scroll_DEFAULT_HANDLED_FullscreenPinnedWindows) { |
| 1563 |
|
| 1564 |
// Shared test among all default handled FS |
| 1565 |
|
| 1566 |
/* |
| 1567 |
|
| 1568 |
allow_pin_fullscreen -> Allow internal FSing a pinned window at all? |
| 1569 |
|
| 1570 |
if true: FSed pinned window doesn't behave as pinned while it is FS but continues to behave as pinned when it's unFS |
| 1571 |
if false: doesn't allow FSing it at all (client can be set if de-syncing internal and client) |
| 1572 |
|
| 1573 |
*/ |
| 1574 |
|
| 1575 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1576 |
|
| 1577 |
Tests::spawnKitty("cake"); |
| 1578 |
|
| 1579 |
OK(getFromSocket("/dispatch hl.dsp.window.float({action = 'enable', window = 'class:cake'})")); |
| 1580 |
|
| 1581 |
// resize to expected floating value: 200 x 200 |
| 1582 |
OK(getFromSocket("/dispatch hl.dsp.window.resize({x = 200, y = 200, relative = false, window = 'class:cake'})")); |
| 1583 |
|
| 1584 |
// Workspace we are testing on: 1 |
| 1585 |
OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '1' })")); |
| 1586 |
|
| 1587 |
// Pin the window |
| 1588 |
OK(getFromSocket("r/dispatch hl.dsp.window.pin({ window = 'class:cake' })")); |
| 1589 |
|
| 1590 |
// set to false, try to FS; expect the cake to be a lie |
| 1591 |
OK(getFromSocket("r/eval hl.config({ binds = { allow_pin_fullscreen = false } })")); |
| 1592 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:cake'})")); |
| 1593 |
|
| 1594 |
// Try with fullscreen |
| 1595 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', layout_aware = false })")); |
| 1596 |
{ |
| 1597 |
auto str = getFromSocket("/activewindow"); |
| 1598 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1599 |
EXPECT_CONTAINS(str, "pinned: 1"); |
| 1600 |
EXPECT_CONTAINS(str, "pinFullscreened: 0"); |
| 1601 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1602 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1603 |
EXPECT_CONTAINS(str, "size: 200,200"); |
| 1604 |
} |
| 1605 |
|
| 1606 |
// Try with maximised |
| 1607 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', layout_aware = false })")); |
| 1608 |
{ |
| 1609 |
auto str = getFromSocket("/activewindow"); |
| 1610 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1611 |
EXPECT_CONTAINS(str, "pinned: 1"); |
| 1612 |
EXPECT_CONTAINS(str, "pinFullscreened: 0"); |
| 1613 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1614 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1615 |
EXPECT_CONTAINS(str, "size: 200,200"); |
| 1616 |
} |
| 1617 |
|
| 1618 |
// Move to another workspace, expect it to follow |
| 1619 |
OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '2' })")); |
| 1620 |
{ |
| 1621 |
auto str = getFromSocket("/clients"); |
| 1622 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1623 |
EXPECT_CONTAINS(str, "pinned: 1"); |
| 1624 |
EXPECT_CONTAINS(str, "pinFullscreened: 0"); |
| 1625 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1626 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1627 |
EXPECT_CONTAINS(str, "size: 200,200"); |
| 1628 |
EXPECT_CONTAINS(str, "workspace: 2"); |
| 1629 |
} |
| 1630 |
|
| 1631 |
// Move back to primary testing workspace, assumed it'll follow since the last test passed |
| 1632 |
OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '1' })")); |
| 1633 |
|
| 1634 |
// While syncing FS state, is not supposed to set either mode. If internal and client are decoupled, client is expected to go through |
| 1635 |
// Try with fullscreen |
| 1636 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'set', layout_aware = false, window = 'activewindow' })")); |
| 1637 |
{ |
| 1638 |
auto str = getFromSocket("/clients"); |
| 1639 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1640 |
EXPECT_CONTAINS(str, "pinned: 1"); |
| 1641 |
EXPECT_CONTAINS(str, "pinFullscreened: 0"); |
| 1642 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1643 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1644 |
EXPECT_CONTAINS(str, "size: 200,200"); |
| 1645 |
EXPECT_CONTAINS(str, "workspace: 1"); |
| 1646 |
} |
| 1647 |
|
| 1648 |
// Try with maximised |
| 1649 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 1, client = 1, action = 'set', layout_aware = false, window = 'activewindow' })")); |
| 1650 |
{ |
| 1651 |
auto str = getFromSocket("/clients"); |
| 1652 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1653 |
EXPECT_CONTAINS(str, "pinned: 1"); |
| 1654 |
EXPECT_CONTAINS(str, "pinFullscreened: 0"); |
| 1655 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1656 |
EXPECT_CONTAINS(str, "fullscreenClient: 1"); |
| 1657 |
EXPECT_CONTAINS(str, "size: 200,200"); |
| 1658 |
EXPECT_CONTAINS(str, "workspace: 1"); |
| 1659 |
} |
| 1660 |
|
| 1661 |
// re-set its FS values for the next test |
| 1662 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 0, client = 0, action = 'set', layout_aware = false, window = 'activewindow' })")); |
| 1663 |
|
| 1664 |
// set to true, try to FS; expect the cake to be real |
| 1665 |
OK(getFromSocket("r/eval hl.config({ binds = { allow_pin_fullscreen = true } })")); |
| 1666 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:cake'})")); |
| 1667 |
|
| 1668 |
// Try with fullscreen |
| 1669 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', layout_aware = false })")); |
| 1670 |
{ |
| 1671 |
auto str = getFromSocket("/activewindow"); |
| 1672 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1673 |
EXPECT_CONTAINS(str, "pinned: 0"); |
| 1674 |
EXPECT_CONTAINS(str, "pinFullscreened: 1"); |
| 1675 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1676 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1677 |
EXPECT_CONTAINS(str, "at: 0,0"); |
| 1678 |
EXPECT_CONTAINS(str, "size: 1920,1080"); |
| 1679 |
} |
| 1680 |
|
| 1681 |
// Try with maximised |
| 1682 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', layout_aware = false })")); |
| 1683 |
{ |
| 1684 |
auto str = getFromSocket("/activewindow"); |
| 1685 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1686 |
EXPECT_CONTAINS(str, "pinned: 0"); |
| 1687 |
EXPECT_CONTAINS(str, "pinFullscreened: 1"); |
| 1688 |
EXPECT_CONTAINS(str, "fullscreen: 1"); |
| 1689 |
EXPECT_CONTAINS(str, "fullscreenClient: 1"); |
| 1690 |
EXPECT_CONTAINS(str, "at: 2,2"); |
| 1691 |
EXPECT_CONTAINS(str, "size: 1916,1076"); |
| 1692 |
} |
| 1693 |
|
| 1694 |
// unFs it, move to another workspace - expect it to follow |
| 1695 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 0, client = 0, action = 'set', layout_aware = false, window = 'activewindow' })")); |
| 1696 |
OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '2' })")); |
| 1697 |
{ |
| 1698 |
auto str = getFromSocket("/clients"); |
| 1699 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1700 |
// After the FSed pinned window is unFSed, expect its pinned value to come back |
| 1701 |
EXPECT_CONTAINS(str, "pinned: 1"); |
| 1702 |
EXPECT_CONTAINS(str, "pinFullscreened: 0"); |
| 1703 |
EXPECT_CONTAINS(str, "fullscreen: 0"); |
| 1704 |
EXPECT_CONTAINS(str, "fullscreenClient: 0"); |
| 1705 |
EXPECT_CONTAINS(str, "size: 200,200"); |
| 1706 |
EXPECT_CONTAINS(str, "workspace: 2"); |
| 1707 |
} |
| 1708 |
|
| 1709 |
// set the variable to false, unpin it and expect it to be FS-able |
| 1710 |
OK(getFromSocket("r/eval hl.config({ binds = { allow_pin_fullscreen = false } })")); |
| 1711 |
OK(getFromSocket("r/dispatch hl.dsp.window.pin({ window = 'class:cake' })")); |
| 1712 |
|
| 1713 |
// Try with fullscreen |
| 1714 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', layout_aware = false })")); |
| 1715 |
{ |
| 1716 |
auto str = getFromSocket("/activewindow"); |
| 1717 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1718 |
EXPECT_CONTAINS(str, "pinned: 0"); |
| 1719 |
EXPECT_CONTAINS(str, "pinFullscreened: 0"); |
| 1720 |
EXPECT_CONTAINS(str, "fullscreen: 2"); |
| 1721 |
EXPECT_CONTAINS(str, "fullscreenClient: 2"); |
| 1722 |
EXPECT_CONTAINS(str, "at: 0,0"); |
| 1723 |
EXPECT_CONTAINS(str, "size: 1920,1080"); |
| 1724 |
} |
| 1725 |
|
| 1726 |
// Try with maximised |
| 1727 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', layout_aware = false })")); |
| 1728 |
{ |
| 1729 |
auto str = getFromSocket("/activewindow"); |
| 1730 |
EXPECT_CONTAINS(str, "class: cake"); |
| 1731 |
EXPECT_CONTAINS(str, "pinned: 0"); |
| 1732 |
EXPECT_CONTAINS(str, "pinFullscreened: 0"); |
| 1733 |
EXPECT_CONTAINS(str, "fullscreen: 1"); |
| 1734 |
EXPECT_CONTAINS(str, "fullscreenClient: 1"); |
| 1735 |
EXPECT_CONTAINS(str, "at: 2,2"); |
| 1736 |
EXPECT_CONTAINS(str, "size: 1916,1076"); |
| 1737 |
} |
| 1738 |
} |
| 1739 |
|
| 1740 |
TEST_CASE(scroll_DEFAULT_HANDLED_FullscreenNonInterference) { |
| 1741 |
|
| 1742 |
// Shared test among all default handled FS |
| 1743 |
|
| 1744 |
/* |
| 1745 |
|
| 1746 |
When a tiled/floating window is default handled FSed, it must not cause the windows under it to have moved/resized after it is unFSed |
| 1747 |
|
| 1748 |
also tests if floating pos/size is properly restored after fS-unfs |
| 1749 |
|
| 1750 |
*/ |
| 1751 |
|
| 1752 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1753 |
|
| 1754 |
Tests::spawnKitty("red"); |
| 1755 |
Tests::spawnKitty("crimson"); |
| 1756 |
Tests::spawnKitty("blue"); |
| 1757 |
Tests::spawnKitty("cyan"); |
| 1758 |
Tests::spawnKitty("azure"); |
| 1759 |
Tests::spawnKitty("green"); |
| 1760 |
|
| 1761 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })")); |
| 1762 |
|
| 1763 |
// Testing tiled first |
| 1764 |
{ |
| 1765 |
|
| 1766 |
// save all pos/size inc red |
| 1767 |
|
| 1768 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })")); |
| 1769 |
auto redPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1770 |
auto redSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1771 |
|
| 1772 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:crimson' })")); |
| 1773 |
auto crimsonPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1774 |
auto crimsonSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1775 |
|
| 1776 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:blue' })")); |
| 1777 |
auto bluePos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1778 |
auto blueSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1779 |
|
| 1780 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cyan' })")); |
| 1781 |
auto cyanPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1782 |
auto cyanSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1783 |
|
| 1784 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:azure' })")); |
| 1785 |
auto azurePos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1786 |
auto azureSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1787 |
|
| 1788 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:green' })")); |
| 1789 |
auto greenPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1790 |
auto greenSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1791 |
|
| 1792 |
// FS and unFS red, then check all positions are unchanged |
| 1793 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })")); |
| 1794 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', layout_aware = false, })")); |
| 1795 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', layout_aware = false, })")); |
| 1796 |
|
| 1797 |
// red |
| 1798 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })")); |
| 1799 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), redPos); |
| 1800 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), redSize); |
| 1801 |
|
| 1802 |
// crimson |
| 1803 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:crimson' })")); |
| 1804 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), crimsonPos); |
| 1805 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), crimsonSize); |
| 1806 |
|
| 1807 |
// blue |
| 1808 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:blue' })")); |
| 1809 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), bluePos); |
| 1810 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), blueSize); |
| 1811 |
|
| 1812 |
// cyan |
| 1813 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cyan' })")); |
| 1814 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), cyanPos); |
| 1815 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), cyanSize); |
| 1816 |
|
| 1817 |
// azure |
| 1818 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:azure' })")); |
| 1819 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), azurePos); |
| 1820 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), azureSize); |
| 1821 |
|
| 1822 |
// green |
| 1823 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:green' })")); |
| 1824 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), greenPos); |
| 1825 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), greenSize); |
| 1826 |
} |
| 1827 |
|
| 1828 |
// test floating |
| 1829 |
|
| 1830 |
{ |
| 1831 |
|
| 1832 |
// float red |
| 1833 |
OK(getFromSocket("/dispatch hl.dsp.window.float({ action = 'set', window = 'class:red' })")); |
| 1834 |
|
| 1835 |
// save all pos/size (red's size will be its floating size) |
| 1836 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })")); |
| 1837 |
auto redPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1838 |
auto redSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1839 |
|
| 1840 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:crimson' })")); |
| 1841 |
auto crimsonPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1842 |
auto crimsonSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1843 |
|
| 1844 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:blue' })")); |
| 1845 |
auto bluePos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1846 |
auto blueSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1847 |
|
| 1848 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cyan' })")); |
| 1849 |
auto cyanPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1850 |
auto cyanSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1851 |
|
| 1852 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:azure' })")); |
| 1853 |
auto azurePos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1854 |
auto azureSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1855 |
|
| 1856 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:green' })")); |
| 1857 |
auto greenPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1858 |
auto greenSize = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 1859 |
|
| 1860 |
// FS and unFS red, then check all positions are unchanged |
| 1861 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })")); |
| 1862 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', layout_aware = false, })")); |
| 1863 |
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', layout_aware = false, })")); |
| 1864 |
|
| 1865 |
// red |
| 1866 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })")); |
| 1867 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), redPos); |
| 1868 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), redSize); |
| 1869 |
|
| 1870 |
// crimson |
| 1871 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:crimson' })")); |
| 1872 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), crimsonPos); |
| 1873 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), crimsonSize); |
| 1874 |
|
| 1875 |
// blue |
| 1876 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:blue' })")); |
| 1877 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), bluePos); |
| 1878 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), blueSize); |
| 1879 |
|
| 1880 |
// cyan |
| 1881 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cyan' })")); |
| 1882 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), cyanPos); |
| 1883 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), cyanSize); |
| 1884 |
|
| 1885 |
// azure |
| 1886 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:azure' })")); |
| 1887 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), azurePos); |
| 1888 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), azureSize); |
| 1889 |
|
| 1890 |
// green |
| 1891 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:green' })")); |
| 1892 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), greenPos); |
| 1893 |
EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), greenSize); |
| 1894 |
} |
| 1895 |
} |
| 1896 |
|
| 1897 |
/* Scroll viewport tests */ |
| 1898 |
|
| 1899 |
TEST_CASE(testScrollingViewBehaviourDispatchFocusWindowFollowFocusFalse) { |
| 1900 |
|
| 1901 |
/* |
| 1902 |
focuswindow DOES NOT move the scrolling view when follow_focus = false |
| 1903 |
--------------------------------------------------------------------------------- |
| 1904 |
*/ |
| 1905 |
|
| 1906 |
NLog::green("Testing scrolling view behaviour: focuswindow dispatch SHOULD NOT move scrolling view when follow_focus = false"); |
| 1907 |
|
| 1908 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1909 |
|
| 1910 |
// ensure variables are correctly set for the test |
| 1911 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 1912 |
|
| 1913 |
SPAWN_KITTY("a"); |
| 1914 |
|
| 1915 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 1916 |
|
| 1917 |
SPAWN_KITTY("b"); |
| 1918 |
|
| 1919 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 1920 |
|
| 1921 |
// if the view does not move, we expect the x coordinate of the window of class "a" to be negative, as it would be to the left of the viewport |
| 1922 |
const std::string posA = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1923 |
const int posAx = std::stoi(posA.substr(0, posA.find(','))); |
| 1924 |
|
| 1925 |
if (posAx >= 0) |
| 1926 |
FAIL_TEST("Expected the x coordinate of window of class \"a\" to be < 0, got {}.", posAx); |
| 1927 |
} |
| 1928 |
|
| 1929 |
TEST_CASE(testScrollingViewBehaviourDispatchFocusWindowFollowFocustrue) { |
| 1930 |
|
| 1931 |
/* |
| 1932 |
focuswindow DOES move the view when follow_focus = true |
| 1933 |
-------------------------------------------------------------------- |
| 1934 |
*/ |
| 1935 |
|
| 1936 |
NLog::green("Testing scrolling view behaviour: focuswindow dispatch SHOULD move scrolling view when follow_focus = true"); |
| 1937 |
|
| 1938 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1939 |
|
| 1940 |
SPAWN_KITTY("a"); |
| 1941 |
|
| 1942 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 1943 |
|
| 1944 |
SPAWN_KITTY("b"); |
| 1945 |
|
| 1946 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 1947 |
|
| 1948 |
// If the view does not move, we expect the x coordinate of the window of class "a" to be negative, as it would be to the left of the viewport. |
| 1949 |
// If it is not, the view moved, which is what we expect to happen. |
| 1950 |
const std::string posA = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1951 |
const int posAx = std::stoi(posA.substr(0, posA.find(','))); |
| 1952 |
|
| 1953 |
if (posAx < 0) |
| 1954 |
FAIL_TEST("Expected the x coordinate of window of class \"a\" to be >= 0, got {}.", posAx); |
| 1955 |
} |
| 1956 |
|
| 1957 |
TEST_CASE(testScrollingViewBehaviourFocusFallback) { |
| 1958 |
|
| 1959 |
/* |
| 1960 |
Focus fallback from killing a floating window onto a tiled window must NOT move scrolling view, regardless of follow_focus |
| 1961 |
-------------------------------------------------------------------------------------------------------------------------- |
| 1962 |
*/ |
| 1963 |
|
| 1964 |
NLog::green("Testing scrolling view behaviour: focus fallback from floating window to a tiled window should not move scrolling view"); |
| 1965 |
|
| 1966 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 1967 |
|
| 1968 |
// ensure variables are correctly set for the test |
| 1969 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 1970 |
|
| 1971 |
SPAWN_KITTY("a"); |
| 1972 |
|
| 1973 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 1974 |
|
| 1975 |
SPAWN_KITTY("b"); |
| 1976 |
SPAWN_KITTY("c"); |
| 1977 |
|
| 1978 |
// make it (window of class:c) float - the view now mush have shifted to fit window class:b |
| 1979 |
OK(getFromSocket("/dispatch hl.dsp.window.float({action = 'enable', window = 'class:c'})")); |
| 1980 |
|
| 1981 |
// establish focus history |
| 1982 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:c'})")); |
| 1983 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 1984 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:c'})")); |
| 1985 |
|
| 1986 |
// kill the floating window |
| 1987 |
// Expect the focus to fall back to the left tiled window |
| 1988 |
OK(getFromSocket("/dispatch hl.dsp.window.kill({window = 'class:c'})")); |
| 1989 |
Tests::waitUntilWindowsN(2); |
| 1990 |
|
| 1991 |
// The focus now must have fallen back to tiled window of class "a". |
| 1992 |
|
| 1993 |
// If the view did not move, we expect currently focused window's (class:a) to have "at: " x coordinat value <0 (must be left of the viewport) |
| 1994 |
|
| 1995 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 1996 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 1997 |
|
| 1998 |
if (std::stoi(currentWindowPosX) >= 0) |
| 1999 |
FAIL_TEST("Expected the x coordinate of window of class \"a\" to be < 0, got {}.", currentWindowPosX); |
| 2000 |
} |
| 2001 |
|
| 2002 |
TEST_CASE(testScrollingViewBehaviourFocusFallbackWithGroups) { |
| 2003 |
|
| 2004 |
// same idea as testScrollingViewBehaviourFocusFallback, but with window of class "a" being grouped. |
| 2005 |
|
| 2006 |
NLog::green("Testing scrolling view behaviour: focus fallback from floating window to a grouped tiled should not move scrolling view"); |
| 2007 |
|
| 2008 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2009 |
|
| 2010 |
// ensure variables are correctly set for the test |
| 2011 |
|
| 2012 |
// to correctly set up windows for the test |
| 2013 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2014 |
// only one tiled window will be grouped for the test |
| 2015 |
OK(getFromSocket("/eval hl.config({group = {auto_group = false}})")); |
| 2016 |
|
| 2017 |
SPAWN_KITTY("a"); |
| 2018 |
|
| 2019 |
// make it a grouped. There need not be any other windows in the group for this test |
| 2020 |
OK(getFromSocket("/dispatch hl.dsp.group.toggle({window = 'class:a'})")); |
| 2021 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2022 |
|
| 2023 |
SPAWN_KITTY("b"); |
| 2024 |
SPAWN_KITTY("c"); |
| 2025 |
|
| 2026 |
// make it float - the view now mush have shifted to fit window class:b |
| 2027 |
OK(getFromSocket("/dispatch hl.dsp.window.float({action = 'enable', window = 'class:c'})")); |
| 2028 |
|
| 2029 |
// establish focus history |
| 2030 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:c'})")); |
| 2031 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 2032 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:c'})")); |
| 2033 |
|
| 2034 |
// kill the floating window |
| 2035 |
OK(getFromSocket("/dispatch hl.dsp.window.kill({window = 'class:c'})")); |
| 2036 |
Tests::waitUntilWindowsN(2); |
| 2037 |
|
| 2038 |
// The focus now must have fallen back to tiled window of class "a". |
| 2039 |
|
| 2040 |
// If the view did not move, we expect currently focused window's (class:a) to have "at: " x coordinat value <0 (must be left of the viewport) |
| 2041 |
|
| 2042 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2043 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2044 |
|
| 2045 |
if (std::stoi(currentWindowPosX) >= 0) |
| 2046 |
FAIL_TEST("Expected the x coordinate of window of class \"a\" to be < 0, got {}.", currentWindowPosX); |
| 2047 |
} |
| 2048 |
|
| 2049 |
TEST_CASE(testScrollingViewBehaviourWorkspaceChange) { |
| 2050 |
|
| 2051 |
/* |
| 2052 |
When you change to a scrolling workspace, the focused window in that workspace must not be pulled into view, regardless of follow_focus |
| 2053 |
--------------------------------------------------------------------------------------------------------------------------------------- |
| 2054 |
*/ |
| 2055 |
|
| 2056 |
NLog::green("Testing scrolling view behaviour: changing to a scrolling workspace should not move scrolling view"); |
| 2057 |
|
| 2058 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2059 |
|
| 2060 |
// ensure variables are correctly set for the test - this is to avoid unwanted view shifts when setting up the windows |
| 2061 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2062 |
|
| 2063 |
// switch to workspace 1 for this test |
| 2064 |
OK(getFromSocket("/dispatch hl.dsp.focus({workspace = '1'})")); |
| 2065 |
|
| 2066 |
SPAWN_KITTY("a"); |
| 2067 |
|
| 2068 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2069 |
|
| 2070 |
SPAWN_KITTY("b"); |
| 2071 |
|
| 2072 |
// does not move view when follow_focus = 0 |
| 2073 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 2074 |
|
| 2075 |
// change to workspace 2, then back to workspace 1 again |
| 2076 |
OK(getFromSocket("/dispatch hl.dsp.focus({workspace = '2'})")); |
| 2077 |
OK(getFromSocket("/dispatch hl.dsp.focus({workspace = '1'})")); |
| 2078 |
|
| 2079 |
// If the scrolling view did not move, the x value for `at:` of the currently focused window, class:a, must be <0 (must be left of the viewport) |
| 2080 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2081 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2082 |
|
| 2083 |
if (std::stoi(currentWindowPosX) > 0) |
| 2084 |
FAIL_TEST("window of class 'a' does not have negative x coordinates for its position: {}", currentWindowPosX); |
| 2085 |
} |
| 2086 |
|
| 2087 |
TEST_CASE(testScrollingViewBehaviourSpecialWorkspaceChange) { |
| 2088 |
|
| 2089 |
/* |
| 2090 |
When you change to a special scrolling workspace from a normal workspace, the focused window in that workspace must not be pulled into view, regardless of follow_focus |
| 2091 |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 2092 |
*/ |
| 2093 |
|
| 2094 |
NLog::green("Testing scrolling view behaviour: changing to a special scrolling workspace from a normal workspace should not move scrolling view"); |
| 2095 |
|
| 2096 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2097 |
|
| 2098 |
// ensure variables are correctly set for the test - this is to avoid unwanted view shifts when setting up the windows |
| 2099 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2100 |
|
| 2101 |
// We'll test in this special workspace |
| 2102 |
OK(getFromSocket("/dispatch hl.dsp.workspace.toggle_special('name:scroll_S')")); |
| 2103 |
|
| 2104 |
SPAWN_KITTY("a"); |
| 2105 |
|
| 2106 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2107 |
|
| 2108 |
SPAWN_KITTY("b"); |
| 2109 |
|
| 2110 |
// does not move view when follow_focus = 0 |
| 2111 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 2112 |
|
| 2113 |
// change to workspace 2, then back to special "scroll_S" workspace again |
| 2114 |
OK(getFromSocket("/dispatch hl.dsp.focus({workspace = '2'})")); |
| 2115 |
OK(getFromSocket("/dispatch hl.dsp.workspace.toggle_special('name:scroll_S')")); |
| 2116 |
|
| 2117 |
// Reestablish focus since it is finnicky in hyprtester - Harmless and does not move view when follow_focus = 0 |
| 2118 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 2119 |
|
| 2120 |
// If the scrolling view did not move, the x value for `at:` of the currently focused windows, class:c, must be <0 (must be left of the viewport) |
| 2121 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2122 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2123 |
|
| 2124 |
if (std::stoi(currentWindowPosX) > 0) |
| 2125 |
FAIL_TEST("window of class 'a' does not have negative x coordinates for its position: {}", currentWindowPosX); |
| 2126 |
} |
| 2127 |
|
| 2128 |
TEST_CASE(testScrollingViewBehaviourSpecialToSpecialWorkspaceChange) { |
| 2129 |
|
| 2130 |
/* |
| 2131 |
We also test switching between 2 special workspaces |
| 2132 |
This follows the same idea and dependencies as the test testScrollingViewBehaviourSpecialWorkspaceChange() |
| 2133 |
*/ |
| 2134 |
|
| 2135 |
NLog::green("Testing scrolling view behaviour: changing to a special scrolling workspace from another special workspace should not move scrolling view"); |
| 2136 |
|
| 2137 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2138 |
|
| 2139 |
// ensure variables are correctly set for the test - this is to avoid unwanted view shifts when setting up the windows |
| 2140 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2141 |
|
| 2142 |
// We'll test in this special workspace |
| 2143 |
OK(getFromSocket("/dispatch hl.dsp.workspace.toggle_special('name:scroll_S')")); |
| 2144 |
|
| 2145 |
SPAWN_KITTY("a"); |
| 2146 |
|
| 2147 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2148 |
|
| 2149 |
SPAWN_KITTY("b"); |
| 2150 |
|
| 2151 |
// does not move view when follow_focus = 0 |
| 2152 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 2153 |
|
| 2154 |
// change to special workspace "scroll_F", then back to special "scroll_S" workspace again |
| 2155 |
OK(getFromSocket("/dispatch hl.dsp.workspace.toggle_special('name:scroll_F')")); |
| 2156 |
OK(getFromSocket("/dispatch hl.dsp.workspace.toggle_special('name:scroll_S')")); |
| 2157 |
|
| 2158 |
// Reestablish focus since it is finnicky in hyprtester - Harmless and does not move view when follow_focus = 0 |
| 2159 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 2160 |
|
| 2161 |
// If the scrolling view did not move, the x value for `at:` of the currently focused windows, class:c, must be <0 (must be left of the viewport) |
| 2162 |
|
| 2163 |
const std::string currentWindowPosSPECIAL = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2164 |
const std::string currentWindowPosSPECIALX = currentWindowPosSPECIAL.substr(0, currentWindowPosSPECIAL.find(',')); |
| 2165 |
|
| 2166 |
if (std::stoi(currentWindowPosSPECIALX) > 0) |
| 2167 |
FAIL_TEST("window of class 'a' does not have negative x coordinates for its position: {}", currentWindowPosSPECIALX); |
| 2168 |
} |
| 2169 |
|
| 2170 |
TEST_CASE(testScrollingViewBehaviourCloseWindowInGroup) { |
| 2171 |
|
| 2172 |
/* |
| 2173 |
When you change close a window inside a group (NOT destroying the group!), it should not cause scrolling view to shift to pull that group into view, regardless of follow_focus |
| 2174 |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 2175 |
*/ |
| 2176 |
|
| 2177 |
NLog::green("Testing scrolling view behaviour: closing a window in a group (> 1 window in group) should not move scrolling view"); |
| 2178 |
|
| 2179 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2180 |
|
| 2181 |
// ensure variables are correctly set for the test |
| 2182 |
|
| 2183 |
// this is to avoid unwanted view shifts when setting up the windows |
| 2184 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2185 |
// We need 2 windows to be grouped, the third one not. |
| 2186 |
OK(getFromSocket("/eval hl.config({group = {auto_group = false}})")); |
| 2187 |
|
| 2188 |
SPAWN_KITTY("a"); |
| 2189 |
|
| 2190 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2191 |
OK(getFromSocket("/dispatch hl.dsp.group.toggle({window = 'class:a'})")); |
| 2192 |
|
| 2193 |
SPAWN_KITTY("b"); |
| 2194 |
|
| 2195 |
OK(getFromSocket("/dispatch hl.dsp.window.move({ into_group = 'left' })")); |
| 2196 |
|
| 2197 |
SPAWN_KITTY("c"); |
| 2198 |
|
| 2199 |
// switch focus to group. This will not move view when follow_focus = 0 |
| 2200 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:b'})")); |
| 2201 |
|
| 2202 |
// kill window class:b. we expect that this should cause not difference in the position of the group |
| 2203 |
OK(getFromSocket("/dispatch hl.dsp.window.kill({window = 'class:b'})")); |
| 2204 |
Tests::waitUntilWindowsN(2); |
| 2205 |
|
| 2206 |
// If the scrolling view did not move, the x value for `at:` of the currently focused windows, class:a, must be <0 (must be left of the viewport) |
| 2207 |
|
| 2208 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2209 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2210 |
|
| 2211 |
if (std::stoi(currentWindowPosX) > 0) |
| 2212 |
FAIL_TEST("window of class 'a' does not have negative x coordinates for its position: {}", currentWindowPosX); |
| 2213 |
} |
| 2214 |
|
| 2215 |
TEST_CASE(testScrollingViewBehaviourMoveWindowIntoGroupFollowFocusFalse) { |
| 2216 |
|
| 2217 |
/* |
| 2218 |
when a window is moved inside a group, scrolling view should not move to fit that group when follow_focus = false |
| 2219 |
----------------------------------------------------------------------------------------------------------------- |
| 2220 |
*/ |
| 2221 |
|
| 2222 |
NLog::green("Testing scrolling view behaviour: moving a window into a group SHOULD NOT move scrolling view if follow_focus = 0"); |
| 2223 |
|
| 2224 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2225 |
|
| 2226 |
// ensure variables are correctly set for the test |
| 2227 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2228 |
OK(getFromSocket("/eval hl.config({group = {auto_group = false}})")); |
| 2229 |
|
| 2230 |
SPAWN_KITTY("a"); |
| 2231 |
|
| 2232 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2233 |
OK(getFromSocket("/dispatch hl.dsp.group.toggle({window = 'class:a'})")); |
| 2234 |
|
| 2235 |
SPAWN_KITTY("b"); |
| 2236 |
SPAWN_KITTY("c"); |
| 2237 |
|
| 2238 |
// focus class:b |
| 2239 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:b'})")); |
| 2240 |
|
| 2241 |
// move it into the group where class:a is |
| 2242 |
OK(getFromSocket("/dispatch hl.dsp.window.move({ into_group = 'left' })")); |
| 2243 |
|
| 2244 |
// the focus now should still be on class:b window. If the view did not move, its x coordinate for its `at:` value should be <0 |
| 2245 |
|
| 2246 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2247 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2248 |
|
| 2249 |
if (std::stoi(currentWindowPosX) > 0) |
| 2250 |
FAIL_TEST("window of class 'b' does not have negative x coordinates for its position: {}", currentWindowPosX); |
| 2251 |
} |
| 2252 |
|
| 2253 |
TEST_CASE(testScrollingViewBehaviourMoveWindowInGroupFollowFocusTrue) { |
| 2254 |
|
| 2255 |
/* |
| 2256 |
when a window is moved inside a group, scrolling view should move to fit that group when follow_focus = true |
| 2257 |
------------------------------------------------------------------------------------------------------------ |
| 2258 |
*/ |
| 2259 |
|
| 2260 |
NLog::green("Testing scrolling view behaviour: moving a window in a group SHOULD move scrolling view if follow_focus = true"); |
| 2261 |
|
| 2262 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2263 |
|
| 2264 |
// ensure variables are correctly set for the test |
| 2265 |
OK(getFromSocket("/eval hl.config({group = {auto_group = false}})")); |
| 2266 |
|
| 2267 |
SPAWN_KITTY("a"); |
| 2268 |
|
| 2269 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2270 |
OK(getFromSocket("/dispatch hl.dsp.group.toggle({window = 'class:a'})")); |
| 2271 |
|
| 2272 |
SPAWN_KITTY("b"); |
| 2273 |
SPAWN_KITTY("c"); |
| 2274 |
|
| 2275 |
// focus class:b |
| 2276 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:b'})")); |
| 2277 |
|
| 2278 |
// move it into the group where class:a is |
| 2279 |
OK(getFromSocket("/dispatch hl.dsp.window.move({ into_group = 'left' })")); |
| 2280 |
|
| 2281 |
// the focus now should still be on class:b window. If the scrolling view did move, its x coordinate for its `at:` value should be >= 0 |
| 2282 |
|
| 2283 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2284 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2285 |
|
| 2286 |
if (std::stoi(currentWindowPosX) < 0) |
| 2287 |
FAIL_TEST("window of class 'b' does not have x coordinates >= 0 for its position: {}", currentWindowPosX); |
| 2288 |
} |
| 2289 |
|
| 2290 |
TEST_CASE(testScrollingViewBehaviourNewLayer) { |
| 2291 |
|
| 2292 |
/* |
| 2293 |
Starting a program on a different layer shouldn't cause scrolling view to move to fit the window that was focused when this program was started, regardless of follow_focus |
| 2294 |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 2295 |
*/ |
| 2296 |
|
| 2297 |
NLog::green("Testing scrolling view behaviour: new program occupying another layer shouldn't move scrolling view"); |
| 2298 |
|
| 2299 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2300 |
|
| 2301 |
// ensure variables are correctly set for the test - this is to avoid unwanted view shifts when setting up the windows |
| 2302 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2303 |
|
| 2304 |
SPAWN_KITTY("a"); |
| 2305 |
|
| 2306 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2307 |
|
| 2308 |
SPAWN_KITTY("b"); |
| 2309 |
|
| 2310 |
// focus class:a - this does not move scrolling view when follow_focus = 0 |
| 2311 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); |
| 2312 |
|
| 2313 |
NLog::yellow("Spawning kitty layer"); |
| 2314 |
SPAWN_LAYER_KITTY("myLayer"); |
| 2315 |
|
| 2316 |
// If the scrolling view did not move, class:a window's x coordinate for its `at:` value should be <0 |
| 2317 |
|
| 2318 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2319 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2320 |
|
| 2321 |
if (std::stoi(currentWindowPosX) > 0) |
| 2322 |
FAIL_TEST("window of class 'a' does not have negative x coordinates for its position: {}", currentWindowPosX); |
| 2323 |
} |
| 2324 |
|
| 2325 |
TEST_CASE(testScrollingViewBehaviourMoveFocusFollowFocusFalse) { |
| 2326 |
|
| 2327 |
/* |
| 2328 |
dispatching movefocus when follow_focus = false should not cause scrolling view to move |
| 2329 |
--------------------------------------------------------------------------------------- |
| 2330 |
*/ |
| 2331 |
|
| 2332 |
NLog::green("Testing scrolling view behaviour: movefocus does not cause scrolling view to move if follow_focus = false"); |
| 2333 |
|
| 2334 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2335 |
|
| 2336 |
// ensure variables are correctly set for the test |
| 2337 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2338 |
|
| 2339 |
SPAWN_KITTY("a"); |
| 2340 |
|
| 2341 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2342 |
|
| 2343 |
SPAWN_KITTY("b"); |
| 2344 |
|
| 2345 |
// we expect that after dispatching this, scrolling view must not have moved |
| 2346 |
OK(getFromSocket("/dispatch hl.dsp.focus({direction = 'left'})")); |
| 2347 |
|
| 2348 |
// If the scrolling view did not move, class:a window's x coordinate for its `at:` value should be < 0. |
| 2349 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2350 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2351 |
|
| 2352 |
if (std::stoi(currentWindowPosX) > 0) |
| 2353 |
FAIL_TEST("window of class 'a' does not have negative x coordinates for its position: {}", currentWindowPosX); |
| 2354 |
} |
| 2355 |
|
| 2356 |
TEST_CASE(testScrollingViewBehaviourMoveFocusFollowFocusTrue) { |
| 2357 |
|
| 2358 |
/* |
| 2359 |
dispatching movefocus when follow_focus = true should cause scrolling view to move |
| 2360 |
---------------------------------------------------------------------------------- |
| 2361 |
*/ |
| 2362 |
|
| 2363 |
NLog::green("Testing scrolling view behaviour: movefocus does cause scrolling view to move if follow_focus = true"); |
| 2364 |
|
| 2365 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2366 |
|
| 2367 |
SPAWN_KITTY("a"); |
| 2368 |
|
| 2369 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2370 |
|
| 2371 |
SPAWN_KITTY("b"); |
| 2372 |
|
| 2373 |
// we expect that after dispatching this, scrolling view must have moved since follow_focus = true |
| 2374 |
OK(getFromSocket("/dispatch hl.dsp.focus({direction = 'left'})")); |
| 2375 |
|
| 2376 |
// If the scrolling view moved, class:a window's x coordinate for its `at:` value should be >= 0 |
| 2377 |
|
| 2378 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2379 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2380 |
|
| 2381 |
if (std::stoi(currentWindowPosX) < 0) |
| 2382 |
FAIL_TEST("window of class 'a' does not have x coordinates >= 0 for its position: {}", currentWindowPosX); |
| 2383 |
} |
| 2384 |
|
| 2385 |
TEST_CASE(testScrollingViewBehaviourMoveFocusInGroupFollowFocusFalse) { |
| 2386 |
|
| 2387 |
/* |
| 2388 |
When movefocus is dispatched within groups to move focus from one group member to another, scrolling view must not move if follow_focus = false |
| 2389 |
----------------------------------------------------------------------------------------------------------------------------------------------- |
| 2390 |
*/ |
| 2391 |
|
| 2392 |
NLog::green("Testing scrolling view behaviour: movefocus within groups does not cause scrolling view to move if follow_focus = false"); |
| 2393 |
|
| 2394 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2395 |
|
| 2396 |
// ensure variables are correctly set for the test |
| 2397 |
|
| 2398 |
// necessary to make sure movefocus first cycles through tabs in a group |
| 2399 |
OK(getFromSocket("/eval hl.config({ binds = {movefocus_cycles_groupfirst = true}})")); |
| 2400 |
OK(getFromSocket("/eval hl.config({group = {auto_group = false}})")); |
| 2401 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2402 |
|
| 2403 |
SPAWN_KITTY("a"); |
| 2404 |
|
| 2405 |
OK(getFromSocket("/dispatch hl.dsp.group.toggle({window = 'class:a'})")); |
| 2406 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2407 |
|
| 2408 |
SPAWN_KITTY("b"); |
| 2409 |
SPAWN_KITTY("c"); |
| 2410 |
|
| 2411 |
// focus class:b. This does not cause scrolling view to move when follow_focus = false |
| 2412 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:b'})")); |
| 2413 |
|
| 2414 |
// move it into the group where class:a is. This does not cause scrolling view to move when follow_focus = false |
| 2415 |
OK(getFromSocket("/dispatch hl.dsp.window.move({ into_group = 'left' })")); |
| 2416 |
|
| 2417 |
// we move from one window of a group to another (from class:b to class:a) via movefocus |
| 2418 |
OK(getFromSocket("/dispatch hl.dsp.focus({direction = 'left'})")); |
| 2419 |
|
| 2420 |
// the focus now should still be on class:a window. If the scrolling view did not move, its x coordinate for its `at:` value should be < 0 |
| 2421 |
|
| 2422 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2423 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2424 |
|
| 2425 |
if (std::stoi(currentWindowPosX) > 0) |
| 2426 |
FAIL_TEST("window of class 'a' does not have negative x coordinates for its position: {}", currentWindowPosX); |
| 2427 |
} |
| 2428 |
|
| 2429 |
TEST_CASE(testScrollingViewBehaviourMoveFocusInGroupFollowFocusTrue) { |
| 2430 |
|
| 2431 |
/* |
| 2432 |
When movefocus is dispatched within groups to move focus from one group member to another, scrolling view must move if follow_focus = true |
| 2433 |
------------------------------------------------------------------------------------------------------------------------------------------ |
| 2434 |
*/ |
| 2435 |
|
| 2436 |
NLog::green("Testing scrolling view behaviour: movefocus within groups does causes scrolling view to move if follow_focus = true"); |
| 2437 |
|
| 2438 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2439 |
|
| 2440 |
// ensure variables are correctly set for the test |
| 2441 |
|
| 2442 |
// necessary to make sure movefocus first cycles through tabs in a group |
| 2443 |
OK(getFromSocket("/eval hl.config({ binds = {movefocus_cycles_groupfirst = true}})")); |
| 2444 |
OK(getFromSocket("/eval hl.config({group = {auto_group = false}})")); |
| 2445 |
|
| 2446 |
SPAWN_KITTY("a"); |
| 2447 |
|
| 2448 |
OK(getFromSocket("/dispatch hl.dsp.group.toggle({window = 'class:a'})")); |
| 2449 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2450 |
|
| 2451 |
SPAWN_KITTY("b"); |
| 2452 |
SPAWN_KITTY("c"); |
| 2453 |
|
| 2454 |
// focus class:b. This does not cause scrolling view to move when follow_focus = false |
| 2455 |
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:b'})")); |
| 2456 |
|
| 2457 |
// move it into the group where class:a is. This does not cause scrolling view to move when follow_focus = false |
| 2458 |
OK(getFromSocket("/dispatch hl.dsp.window.move({ into_group = 'left' })")); |
| 2459 |
|
| 2460 |
// we move from one window of a group to another (from class:b to class:a) via movefocus |
| 2461 |
OK(getFromSocket("/dispatch hl.dsp.focus({direction = 'left'})")); |
| 2462 |
|
| 2463 |
// the focus now should still be on class:a window. If the scrolling view moved, its x coordinate for its `at:` value should be >= 0 |
| 2464 |
|
| 2465 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2466 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2467 |
|
| 2468 |
if (std::stoi(currentWindowPosX) < 0) |
| 2469 |
FAIL_TEST("window of class 'a' does not have x coordinates >= 0 for its position: {}", currentWindowPosX); |
| 2470 |
} |
| 2471 |
|
| 2472 |
TEST_CASE(testScrollingViewBehaviourScheduledPropRefresh) { |
| 2473 |
|
| 2474 |
/* |
| 2475 |
Test that hl.exec_scheduled_prop_refresh_immediately() should immediately execute prop refresh. This is tested via inhibiting scrollin during helper functs dispatch; if it works, the viewport |
| 2476 |
should not move when a new workspace rule is created. If it doesn't, dispatch will miss because the refresh will be executed as another event |
| 2477 |
-------------------------------------------------------------------------------------------------------------------------------------- |
| 2478 |
*/ |
| 2479 |
|
| 2480 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2481 |
|
| 2482 |
// ensure variables are correctly set for the test |
| 2483 |
|
| 2484 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2485 |
|
| 2486 |
SPAWN_KITTY("a"); |
| 2487 |
|
| 2488 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2489 |
|
| 2490 |
SPAWN_KITTY("b"); |
| 2491 |
|
| 2492 |
// since follow_focus = false, viewport does not move |
| 2493 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:a' })")); |
| 2494 |
|
| 2495 |
// setting a workspace rule queues a doLater() call in the Event Loop Manager |
| 2496 |
OK(getFromSocket("/eval hl.dispatch(hl.dsp.layout('inhibit_scroll true')); hl.workspace_rule({workspace = hl.get_active_workspace().id,gaps_in = 0}); " |
| 2497 |
"hl.exec_scheduled_prop_refresh_immediately(); hl.dispatch(hl.dsp.layout('inhibit_scroll false'));")); |
| 2498 |
|
| 2499 |
// Check that the workspace rule is set |
| 2500 |
ASSERT_CONTAINS(getFromSocket("/workspacerules"), "gapsIn: 0 0 0 0"); |
| 2501 |
|
| 2502 |
// The viewport must not have moved: left corner cords of window should be < 0 |
| 2503 |
const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2504 |
const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); |
| 2505 |
|
| 2506 |
if (std::stoi(currentWindowPosX) > 0) |
| 2507 |
FAIL_TEST("window of class 'a' does not have negative x coordinates for its position: {}", currentWindowPosX); |
| 2508 |
} |
| 2509 |
|
| 2510 |
TEST_CASE(testScrollInhibitor) { |
| 2511 |
|
| 2512 |
/* |
| 2513 |
scroll inhibitor prevent the scrolling view from moving |
| 2514 |
--------------------------------------------------------------------------------- |
| 2515 |
*/ |
| 2516 |
|
| 2517 |
// set current layout to scrolling |
| 2518 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2519 |
|
| 2520 |
NLog::green("Testing inhibit_scroll"); |
| 2521 |
|
| 2522 |
SPAWN_KITTY("a"); |
| 2523 |
|
| 2524 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2525 |
|
| 2526 |
SPAWN_KITTY("b"); |
| 2527 |
// Currently, we are focused on window class:b |
| 2528 |
|
| 2529 |
// enable scroll inhibitor |
| 2530 |
OK(getFromSocket("/dispatch hl.dsp.layout('inhibit_scroll 1')")); |
| 2531 |
|
| 2532 |
// dispatching `layoutmsg focus l` will move scrolling view regardless of follow_focus if inhibitor is not working |
| 2533 |
OK(getFromSocket("/dispatch hl.dsp.layout('focus l')")); |
| 2534 |
|
| 2535 |
// the focus must have moved regardless of the state of the inhibitor (it only prevents the scrolling view from moving). We are now focused on window class:a |
| 2536 |
|
| 2537 |
// if the view does not move, we expect the x coordinate of the window of class "a" to be negative, as it would be to the left of the viewport |
| 2538 |
const std::string posA = Tests::getAttribute(getFromSocket("/activewindow"), "at"); |
| 2539 |
const int posAx = std::stoi(posA.substr(0, posA.find(','))); |
| 2540 |
|
| 2541 |
if (posAx >= 0) |
| 2542 |
FAIL_TEST("Expected the x coordinate of window of class \"a\" to be < 0, got {}.", posAx); |
| 2543 |
} |
| 2544 |
|
| 2545 |
TEST_CASE(layoutmsg_fit_into_view) { |
| 2546 |
|
| 2547 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2548 |
|
| 2549 |
// ensure variables are correctly set for the test |
| 2550 |
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})")); |
| 2551 |
|
| 2552 |
if (!Tests::spawnKitty("a")) { |
| 2553 |
FAIL_TEST("Could not spawn kitty with win class `a`"); |
| 2554 |
return; |
| 2555 |
} |
| 2556 |
|
| 2557 |
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); |
| 2558 |
|
| 2559 |
if (!Tests::spawnKitty("b")) { |
| 2560 |
FAIL_TEST("Could not spawn kitty with win class `b`"); |
| 2561 |
return; |
| 2562 |
} |
| 2563 |
|
| 2564 |
// class:a column is now off screen to the left |
| 2565 |
|
| 2566 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:a' })")); |
| 2567 |
|
| 2568 |
// fit class:a window into view |
| 2569 |
|
| 2570 |
OK(getFromSocket("/dispatch hl.dsp.layout('fit_into_view')")); |
| 2571 |
|
| 2572 |
// If it worked, class:a window must now have at: ~= 0,0 -- 0,0 + gaps, border = 22,22. |
| 2573 |
|
| 2574 |
ASSERT_CONTAINS(Tests::getAttribute(getFromSocket("/activewindow"), "at"), "22,22"); |
| 2575 |
} |
| 2576 |
|
| 2577 |
TEST_CASE(layoutRuleExpand) { |
| 2578 |
// set current layout to scrolling |
| 2579 |
OK(getFromSocket( |
| 2580 |
"r/eval hl.config({ general = { layout = 'scrolling', gaps_in = 0, border_size = 0, gaps_out = 0 }, scrolling = {column_width = 0.5, fullscreen_on_one_column = true} })")); |
| 2581 |
|
| 2582 |
SPAWN_KITTY("a"); |
| 2583 |
|
| 2584 |
const std::string sizeSingle = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 2585 |
const int sizeSingleX = std::stoi(sizeSingle.substr(0, sizeSingle.find(','))); |
| 2586 |
|
| 2587 |
for (auto const& win : {"b", "c"}) { |
| 2588 |
SPAWN_KITTY(win); |
| 2589 |
} |
| 2590 |
|
| 2591 |
OK(getFromSocket("dispatch hl.dsp.window.resize({x = 100, y = 500, window = 'class:a'})")); |
| 2592 |
OK(getFromSocket("dispatch hl.dsp.window.resize({x = 100, y = 500, window = 'class:c'})")); |
| 2593 |
|
| 2594 |
OK(getFromSocket("dispatch hl.dsp.focus({window = 'class:b'})")); |
| 2595 |
|
| 2596 |
// const std::string sizeBefore = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 2597 |
// const int sizeBeforeX = std::stoi(sizeBefore.substr(0, sizeBefore.find(','))); |
| 2598 |
|
| 2599 |
OK(getFromSocket("/dispatch hl.dsp.layout('fit expand')")); |
| 2600 |
|
| 2601 |
const std::string sizeAfter = Tests::getAttribute(getFromSocket("/activewindow"), "size"); |
| 2602 |
const int sizeAfterX = std::stoi(sizeAfter.substr(0, sizeAfter.find(','))); |
| 2603 |
|
| 2604 |
if (sizeAfterX < sizeSingleX - 200) |
| 2605 |
FAIL_TEST("Expected the width of window of class \"b\" to take up all remaining space {}, got {}.", sizeSingleX - 200, sizeAfterX); |
| 2606 |
} |
| 2607 |
TEST_CASE(scrollTapeOnClickOutOfWindow) { |
| 2608 |
/* |
| 2609 |
* Do not move tape on click in the direction, but out of the window |
| 2610 |
*/ |
| 2611 |
|
| 2612 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2613 |
OK(getFromSocket("r/eval hl.config({ general = { gaps_out = 100 } })")); |
| 2614 |
OK(getFromSocket("r/eval hl.config({ scrolling = { follow_min_visible = 1.0, column_width = 0.6 } })")); |
| 2615 |
OK(getFromSocket("r/eval hl.config({ input = { follow_mouse = 1 } })")); |
| 2616 |
|
| 2617 |
SPAWN_KITTY("A"); // A should be at x negative |
| 2618 |
SPAWN_KITTY("B"); |
| 2619 |
|
| 2620 |
OK(getFromSocket("/eval hl.plugin.test.window_soft_focus('A')")); // soft focus A |
| 2621 |
OK(getFromSocket("/dispatch hl.dsp.cursor.move({ x = 0, y = 20 })")); // move cursor to the gap zone |
| 2622 |
|
| 2623 |
OK(getFromSocket("/eval hl.plugin.test.click(272, 1)")); |
| 2624 |
OK(getFromSocket("/eval hl.plugin.test.click(272, 0)")); |
| 2625 |
|
| 2626 |
const auto active = getFromSocket("/activewindow"); |
| 2627 |
ASSERT_CONTAINS(active, "class: A"); |
| 2628 |
|
| 2629 |
const auto posA = Tests::getAttribute(active, "at"); |
| 2630 |
const auto posAx = std::stoi(posA.substr(0, posA.find(','))); |
| 2631 |
|
| 2632 |
if (posAx >= 0) |
| 2633 |
FAIL_TEST("Expected the x coordinate of window of class \"A\" to be < 0, got {}.", posAx); |
| 2634 |
} |
| 2635 |
|
| 2636 |
TEST_CASE(properFocusBehvaior) { |
| 2637 |
// test that focus history does not fuck with proper workspace preference |
| 2638 |
|
| 2639 |
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); |
| 2640 |
|
| 2641 |
if (getFromSocket("/monitors all").contains("HEADLESS-3")) |
| 2642 |
OK(getFromSocket("/output remove HEADLESS-3")); |
| 2643 |
|
| 2644 |
OK(getFromSocket("/output create headless HEADLESS-3")); |
| 2645 |
CScopeGuard x([&] { |
| 2646 |
if (getFromSocket("/monitors all").contains("HEADLESS-3")) |
| 2647 |
OK(getFromSocket("/output remove HEADLESS-3")); |
| 2648 |
}); |
| 2649 |
|
| 2650 |
auto test = [&] { |
| 2651 |
OK(getFromSocket("/dispatch hl.dsp.focus({ monitor = 'HEADLESS-2' })")); |
| 2652 |
|
| 2653 |
SPAWN_KITTY("a"); |
| 2654 |
Tests::waitUntilWindowsN(1); |
| 2655 |
|
| 2656 |
OK(getFromSocket("/dispatch hl.dsp.focus({ monitor = 'HEADLESS-3' })")); |
| 2657 |
|
| 2658 |
SPAWN_KITTY("b"); |
| 2659 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:b' })")); |
| 2660 |
SPAWN_KITTY("c"); |
| 2661 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:c' })")); |
| 2662 |
SPAWN_KITTY("d"); |
| 2663 |
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:d' })")); |
| 2664 |
|
| 2665 |
Tests::waitUntilWindowsN(4); |
| 2666 |
|
| 2667 |
{ |
| 2668 |
const auto str = getFromSocket("/activewindow"); |
| 2669 |
EXPECT_CONTAINS(str, "class: d"); |
| 2670 |
} |
| 2671 |
|
| 2672 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 2673 |
|
| 2674 |
{ |
| 2675 |
const auto str = getFromSocket("/activewindow"); |
| 2676 |
EXPECT_CONTAINS(str, "class: c"); |
| 2677 |
} |
| 2678 |
|
| 2679 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 2680 |
|
| 2681 |
{ |
| 2682 |
const auto str = getFromSocket("/activewindow"); |
| 2683 |
EXPECT_CONTAINS(str, "class: b"); |
| 2684 |
} |
| 2685 |
|
| 2686 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 2687 |
|
| 2688 |
{ |
| 2689 |
const auto str = getFromSocket("/activewindow"); |
| 2690 |
EXPECT_CONTAINS(str, "class: a"); |
| 2691 |
} |
| 2692 |
|
| 2693 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 2694 |
|
| 2695 |
{ |
| 2696 |
const auto str = getFromSocket("/activewindow"); |
| 2697 |
EXPECT_CONTAINS(str, "class: b"); |
| 2698 |
} |
| 2699 |
|
| 2700 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 2701 |
|
| 2702 |
{ |
| 2703 |
const auto str = getFromSocket("/activewindow"); |
| 2704 |
EXPECT_CONTAINS(str, "class: c"); |
| 2705 |
} |
| 2706 |
|
| 2707 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })")); |
| 2708 |
|
| 2709 |
{ |
| 2710 |
const auto str = getFromSocket("/activewindow"); |
| 2711 |
EXPECT_CONTAINS(str, "class: d"); |
| 2712 |
} |
| 2713 |
|
| 2714 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 2715 |
|
| 2716 |
{ |
| 2717 |
const auto str = getFromSocket("/activewindow"); |
| 2718 |
EXPECT_CONTAINS(str, "class: c"); |
| 2719 |
} |
| 2720 |
|
| 2721 |
// now we have a situation of: |
| 2722 |
// HEADLESS-2: a |
| 2723 |
// HEADLESS-3: b | c d | -> b is offscreen |
| 2724 |
|
| 2725 |
OK(getFromSocket("/dispatch hl.dsp.focus({ monitor = 'HEADLESS-2' })")); |
| 2726 |
|
| 2727 |
{ |
| 2728 |
const auto str = getFromSocket("/activewindow"); |
| 2729 |
EXPECT_CONTAINS(str, "class: a"); |
| 2730 |
} |
| 2731 |
|
| 2732 |
OK(getFromSocket("/dispatch hl.dsp.focus({ monitor = 'HEADLESS-3' })")); |
| 2733 |
|
| 2734 |
{ |
| 2735 |
const auto str = getFromSocket("/activewindow"); |
| 2736 |
EXPECT_CONTAINS(str, "class: c"); |
| 2737 |
} |
| 2738 |
|
| 2739 |
// now we have a history of a being more recent than b, but if we move left, we should still focus b. |
| 2740 |
|
| 2741 |
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'left' })")); |
| 2742 |
|
| 2743 |
{ |
| 2744 |
const auto str = getFromSocket("/activewindow"); |
| 2745 |
EXPECT_CONTAINS(str, "class: b"); |
| 2746 |
} |
| 2747 |
|
| 2748 |
Tests::killAllWindows(); |
| 2749 |
Tests::waitUntilWindowsN(0); |
| 2750 |
}; |
| 2751 |
|
| 2752 |
OK(getFromSocket("/eval hl.config({ binds = { focus_preferred_method = 0 } })")); // set history mode, default |
| 2753 |
test(); |
| 2754 |
|
| 2755 |
OK(getFromSocket("/eval hl.config({ binds = { focus_preferred_method = 1 } })")); // set length mode |
| 2756 |
test(); |
| 2757 |
} |