Debian Codegraph @

hyprtester/src/tests/main/monocle.cpp

raw
1 #include "../shared.hpp"
2 #include "../../shared.hpp"
3 #include "../../hyprctlCompat.hpp"
4 #include <string>
5 #include <vector>
6 #include "tests.hpp"
7
8 TEST_CASE(monocleWorkspaceRule) {
9
10 OK(getFromSocket("/eval hl.config({ general = { layout = 'monocle' } })"));
11
12 // w[tv1]
13
14 // With monocle only having one tiled window in view at any time, this must
15
16 OK(getFromSocket("/eval hl.workspace_rule{ workspace = 'w[tv1]', gaps_out = 40}"));
17
18 // spawn 3 window, all should be compliant
19
20 Tests::spawnKitty("neutral_cat");
21 {
22 auto str = getFromSocket("/activewindow");
23 EXPECT_CONTAINS(str, "class: neutral_cat")
24 EXPECT_CONTAINS(str, "size: 1836,996")
25 EXPECT_CONTAINS(str, "at: 42,42")
26 }
27
28 Tests::spawnKitty("happy_cat");
29 {
30 auto str = getFromSocket("/activewindow");
31 EXPECT_CONTAINS(str, "class: happy_cat")
32 EXPECT_CONTAINS(str, "size: 1836,996")
33 EXPECT_CONTAINS(str, "at: 42,42")
34 }
35
36 Tests::spawnKitty("angry_cat");
37 {
38 auto str = getFromSocket("/activewindow");
39 EXPECT_CONTAINS(str, "class: angry_cat")
40 EXPECT_CONTAINS(str, "size: 1836,996")
41 EXPECT_CONTAINS(str, "at: 42,42")
42 }
43
44 // try closing a window, fallback window should be compliant
45
46 OK(getFromSocket("/dispatch hl.dsp.window.kill({ window = 'class:angry_cat' })"));
47 Tests::waitUntilWindowsN(2);
48
49 // focus fallback to happy_cat
50 {
51 auto str = getFromSocket("/activewindow");
52 EXPECT_CONTAINS(str, "class: happy_cat")
53 EXPECT_CONTAINS(str, "size: 1836,996")
54 EXPECT_CONTAINS(str, "at: 42,42")
55 }
56
57 // re-open a window after killing
58 Tests::spawnKitty("angry_cat");
59 {
60 auto str = getFromSocket("/activewindow");
61 EXPECT_CONTAINS(str, "class: angry_cat")
62 EXPECT_CONTAINS(str, "size: 1836,996")
63 EXPECT_CONTAINS(str, "at: 42,42")
64 }
65
66 OK(getFromSocket("/dispatch hl.dsp.window.kill({ window = 'class:angry_cat' })"));
67 OK(getFromSocket("/dispatch hl.dsp.window.kill({ window = 'class:happy_cat' })"));
68 Tests::waitUntilWindowsN(1);
69
70 // back to only one window on workspace
71 {
72 auto str = getFromSocket("/activewindow");
73 EXPECT_CONTAINS(str, "class: neutral_cat")
74 EXPECT_CONTAINS(str, "size: 1836,996")
75 EXPECT_CONTAINS(str, "at: 42,42")
76 }
77 }
78
79 /*
80 Fullscreen Tests
81
82 Tests with `Shared test among all default handled FS` comment are duplicated among all layouts to test each layout individually
83
84 */
85
86 TEST_CASE(monocleFullscreenMaximiseDispatchers) {
87
88 // Shared test among all default handled FS
89
90 OK(getFromSocket("/eval hl.config({ general = { layout = 'monocle' } })"));
91
92 Tests::spawnKitty("kitty_A");
93 Tests::spawnKitty("kitty_B");
94
95 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_A' })"));
96 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set' })"));
97
98 {
99 auto str = getFromSocket("/activewindow");
100 EXPECT_CONTAINS(str, "fullscreen: 2");
101 EXPECT_CONTAINS(str, "fullscreenClient: 2");
102 }
103
104 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'unset' })"));
105
106 {
107 auto str = getFromSocket("/activewindow");
108 EXPECT_CONTAINS(str, "fullscreen: 0");
109 EXPECT_CONTAINS(str, "fullscreenClient: 0");
110 }
111
112 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'toggle' })"));
113
114 {
115 auto str = getFromSocket("/activewindow");
116 EXPECT_CONTAINS(str, "fullscreen: 1");
117 EXPECT_CONTAINS(str, "fullscreenClient: 1");
118 }
119
120 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized', action = 'toggle' })"));
121
122 {
123 auto str = getFromSocket("/activewindow");
124 EXPECT_CONTAINS(str, "fullscreen: 0");
125 EXPECT_CONTAINS(str, "fullscreenClient: 0");
126 }
127
128 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'set' })"));
129
130 {
131 auto str = getFromSocket("/activewindow");
132 EXPECT_CONTAINS(str, "fullscreen: 2");
133 EXPECT_CONTAINS(str, "fullscreenClient: 2");
134 }
135
136 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'set' })"));
137
138 {
139 auto str = getFromSocket("/activewindow");
140 EXPECT_CONTAINS(str, "fullscreen: 2");
141 EXPECT_CONTAINS(str, "fullscreenClient: 2");
142 }
143
144 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'toggle' })"));
145
146 {
147 auto str = getFromSocket("/activewindow");
148 EXPECT_CONTAINS(str, "fullscreen: 0");
149 EXPECT_CONTAINS(str, "fullscreenClient: 0");
150 }
151
152 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'toggle' })"));
153
154 {
155 auto str = getFromSocket("/activewindow");
156 EXPECT_CONTAINS(str, "fullscreen: 2");
157 EXPECT_CONTAINS(str, "fullscreenClient: 2");
158 }
159 }
160
161 TEST_CASE(monocleTestFsFocusUnderFSWindow) {
162
163 // Shared test among all default handled FS
164
165 OK(getFromSocket("r/eval hl.config({ general = { layout = 'monocle' } })"));
166
167 for (auto const& win : {"one", "two", "three"}) {
168 if (!Tests::spawnKitty(win))
169 FAIL_TEST("Could not spawn kitty with win class `{}`", win);
170 }
171
172 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:one' })"));
173 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized' })"));
174
175 {
176 auto str = getFromSocket("/activewindow");
177 EXPECT_CONTAINS(str, "at: 22,22");
178 EXPECT_CONTAINS(str, "size: 1876,1036");
179 EXPECT_CONTAINS(str, "class: one");
180 }
181
182 OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 1 } })"));
183
184 Tests::spawnKitty("four");
185
186 {
187 auto str = getFromSocket("/activewindow");
188 EXPECT_CONTAINS(str, "at: 22,22");
189 EXPECT_CONTAINS(str, "size: 1876,1036");
190 EXPECT_CONTAINS(str, "class: four");
191 EXPECT_CONTAINS(str, "fullscreen: 1");
192 }
193
194 OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 0 } })"));
195
196 Tests::spawnKitty("ignored");
197
198 {
199 auto str = getFromSocket("/activewindow");
200 EXPECT_CONTAINS(str, "at: 22,22");
201 EXPECT_CONTAINS(str, "size: 1876,1036");
202 EXPECT_CONTAINS(str, "class: four");
203 EXPECT_CONTAINS(str, "fullscreen: 1");
204 }
205
206 OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 2 } })"));
207
208 Tests::spawnKitty("erstarrwashere");
209
210 {
211 auto str = getFromSocket("/activewindow");
212 EXPECT_CONTAINS(str, "class: erstarrwashere");
213 EXPECT_CONTAINS(str, "fullscreen: 0");
214 }
215 }
216
217 TEST_CASE(monocleNewWindowTakesOverFullscreen) {
218
219 // Shared test among all default handled FS
220
221 OK(getFromSocket("r/eval hl.config({ general = { layout = 'monocle' } })"));
222
223 OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 0 } })"));
224
225 Tests::spawnKitty("kitty_A");
226
227 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen' })"));
228
229 {
230 auto str = getFromSocket("/activewindow");
231 EXPECT_CONTAINS(str, "fullscreen: 2");
232 EXPECT_CONTAINS(str, "fullscreenClient: 2");
233 EXPECT_CONTAINS(str, "kitty_A");
234 }
235
236 Tests::spawnKitty("kitty_B");
237
238 {
239 auto str = getFromSocket("/activewindow");
240 EXPECT_CONTAINS(str, "fullscreen: 2");
241 EXPECT_CONTAINS(str, "fullscreenClient: 2");
242 EXPECT_CONTAINS(str, "kitty_A");
243 }
244
245 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_B' })"));
246
247 {
248 // should be ignored as per focus_under_fullscreen 0
249 auto str = getFromSocket("/activewindow");
250 EXPECT_CONTAINS(str, "fullscreen: 2");
251 EXPECT_CONTAINS(str, "fullscreenClient: 2");
252 EXPECT_CONTAINS(str, "kitty_A");
253 }
254
255 OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 1 } })"));
256
257 Tests::spawnKitty("kitty_C");
258
259 {
260 auto str = getFromSocket("/activewindow");
261 EXPECT_CONTAINS(str, "fullscreen: 2");
262 EXPECT_CONTAINS(str, "fullscreenClient: 2");
263 EXPECT_CONTAINS(str, "kitty_C");
264 }
265
266 OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 2 } })"));
267
268 Tests::spawnKitty("kitty_D");
269
270 {
271 auto str = getFromSocket("/activewindow");
272 EXPECT_CONTAINS(str, "fullscreen: 0");
273 EXPECT_CONTAINS(str, "fullscreenClient: 0");
274 EXPECT_CONTAINS(str, "kitty_D");
275 }
276
277 OK(getFromSocket("/eval hl.config({ misc = { on_focus_under_fullscreen = 0 } })"));
278
279 Tests::killAllWindows();
280 }
281
282 TEST_CASE(monocleExitWindowRetainsFullscreen) {
283
284 // Shared test among all default handled FS
285
286 OK(getFromSocket("r/eval hl.config({ general = { layout = 'monocle' } })"));
287
288 OK(getFromSocket("/eval hl.config({ misc = { exit_window_retains_fullscreen = false } })"));
289
290 Tests::spawnKitty("kitty_A");
291 Tests::spawnKitty("kitty_B");
292
293 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen' })"));
294
295 {
296 auto str = getFromSocket("/activewindow");
297 EXPECT_CONTAINS(str, "fullscreen: 2");
298 EXPECT_CONTAINS(str, "fullscreenClient: 2");
299 }
300
301 OK(getFromSocket("/dispatch hl.dsp.window.kill({ window = 'activewindow' })"));
302 Tests::waitUntilWindowsN(1);
303
304 {
305 auto str = getFromSocket("/activewindow");
306 EXPECT_CONTAINS(str, "fullscreen: 0");
307 EXPECT_CONTAINS(str, "fullscreenClient: 0");
308 }
309
310 Tests::spawnKitty("kitty_B");
311 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen' })"));
312 OK(getFromSocket("/eval hl.config({ misc = { exit_window_retains_fullscreen = true } })"));
313
314 OK(getFromSocket("/dispatch hl.dsp.window.kill({ window = 'activewindow' })"));
315 Tests::waitUntilWindowsN(1);
316
317 {
318 auto str = getFromSocket("/activewindow");
319 EXPECT_CONTAINS(str, "fullscreen: 2");
320 EXPECT_CONTAINS(str, "fullscreenClient: 2");
321 }
322
323 Tests::killAllWindows();
324 }
325
326 TEST_CASE(monocleFullscreenPinnedWindows) {
327
328 // Shared test among all default handled FS
329
330 /*
331
332 allow_pin_fullscreen -> Allow internal FSing a pinned window at all?
333
334 if true: FSed pinned window doesn't behave as pinned while it is FS but continues to behave as pinned when it's unFS
335 if false: doesn't allow FSing it at all (client can be set if de-syncing internal and client)
336
337 */
338
339 OK(getFromSocket("r/eval hl.config({ general = { layout = 'monocle' } })"));
340
341 Tests::spawnKitty("cake");
342
343 OK(getFromSocket("/dispatch hl.dsp.window.float({action = 'enable', window = 'class:cake'})"));
344
345 // resize to expected floating value: 200 x 200
346 OK(getFromSocket("/dispatch hl.dsp.window.resize({x = 200, y = 200, relative = false, window = 'class:cake'})"));
347
348 // Workspace we are testing on: 1
349 OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '1' })"));
350
351 // Pin the window
352 OK(getFromSocket("r/dispatch hl.dsp.window.pin({ window = 'class:cake' })"));
353
354 // set to false, try to FS; expect the cake to be a lie
355 OK(getFromSocket("r/eval hl.config({ binds = { allow_pin_fullscreen = false } })"));
356 OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:cake'})"));
357
358 // Try with fullscreen
359 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen' })"));
360 {
361 auto str = getFromSocket("/activewindow");
362 EXPECT_CONTAINS(str, "class: cake");
363 EXPECT_CONTAINS(str, "pinned: 1");
364 EXPECT_CONTAINS(str, "pinFullscreened: 0");
365 EXPECT_CONTAINS(str, "fullscreen: 0");
366 EXPECT_CONTAINS(str, "fullscreenClient: 0");
367 EXPECT_CONTAINS(str, "size: 200,200");
368 }
369
370 // Try with maximised
371 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized' })"));
372 {
373 auto str = getFromSocket("/activewindow");
374 EXPECT_CONTAINS(str, "class: cake");
375 EXPECT_CONTAINS(str, "pinned: 1");
376 EXPECT_CONTAINS(str, "pinFullscreened: 0");
377 EXPECT_CONTAINS(str, "fullscreen: 0");
378 EXPECT_CONTAINS(str, "fullscreenClient: 0");
379 EXPECT_CONTAINS(str, "size: 200,200");
380 }
381
382 // Move to another workspace, expect it to follow
383 OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '2' })"));
384 {
385 auto str = getFromSocket("/clients");
386 EXPECT_CONTAINS(str, "class: cake");
387 EXPECT_CONTAINS(str, "pinned: 1");
388 EXPECT_CONTAINS(str, "pinFullscreened: 0");
389 EXPECT_CONTAINS(str, "fullscreen: 0");
390 EXPECT_CONTAINS(str, "fullscreenClient: 0");
391 EXPECT_CONTAINS(str, "size: 200,200");
392 EXPECT_CONTAINS(str, "workspace: 2");
393 }
394
395 // Move back to primary testing workspace, assumed it'll follow since the last test passed
396 OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '1' })"));
397
398 // While syncing FS state, is not supposed to set either mode. If internal and client are decoupled, client is expected to go through
399 // Try with fullscreen
400 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 2, client = 2, action = 'set', window = 'activewindow' })"));
401 {
402 auto str = getFromSocket("/clients");
403 EXPECT_CONTAINS(str, "class: cake");
404 EXPECT_CONTAINS(str, "pinned: 1");
405 EXPECT_CONTAINS(str, "pinFullscreened: 0");
406 EXPECT_CONTAINS(str, "fullscreen: 0");
407 EXPECT_CONTAINS(str, "fullscreenClient: 2");
408 EXPECT_CONTAINS(str, "size: 200,200");
409 EXPECT_CONTAINS(str, "workspace: 1");
410 }
411
412 // Try with maximised
413 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 1, client = 1, action = 'set', window = 'activewindow' })"));
414 {
415 auto str = getFromSocket("/clients");
416 EXPECT_CONTAINS(str, "class: cake");
417 EXPECT_CONTAINS(str, "pinned: 1");
418 EXPECT_CONTAINS(str, "pinFullscreened: 0");
419 EXPECT_CONTAINS(str, "fullscreen: 0");
420 EXPECT_CONTAINS(str, "fullscreenClient: 1");
421 EXPECT_CONTAINS(str, "size: 200,200");
422 EXPECT_CONTAINS(str, "workspace: 1");
423 }
424
425 // re-set its FS values for the next test
426 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 0, client = 0, action = 'set', window = 'activewindow' })"));
427
428 // set to true, try to FS; expect the cake to be real
429 OK(getFromSocket("r/eval hl.config({ binds = { allow_pin_fullscreen = true } })"));
430 OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:cake'})"));
431
432 // Try with fullscreen
433 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen' })"));
434 {
435 auto str = getFromSocket("/activewindow");
436 EXPECT_CONTAINS(str, "class: cake");
437 EXPECT_CONTAINS(str, "pinned: 0");
438 EXPECT_CONTAINS(str, "pinFullscreened: 1");
439 EXPECT_CONTAINS(str, "fullscreen: 2");
440 EXPECT_CONTAINS(str, "fullscreenClient: 2");
441 EXPECT_CONTAINS(str, "at: 0,0");
442 ASSERT_CONTAINS(str, "size: 1920,1080");
443 }
444
445 // Try with maximised
446 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized' })"));
447 {
448 auto str = getFromSocket("/activewindow");
449 EXPECT_CONTAINS(str, "class: cake");
450 EXPECT_CONTAINS(str, "pinned: 0");
451 EXPECT_CONTAINS(str, "pinFullscreened: 1");
452 EXPECT_CONTAINS(str, "fullscreen: 1");
453 EXPECT_CONTAINS(str, "fullscreenClient: 1");
454 EXPECT_CONTAINS(str, "at: 2,2");
455 EXPECT_CONTAINS(str, "size: 1916,1076");
456 }
457
458 // unFs it, move to another workspace - expect it to follow
459 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen_state({ internal = 0, client = 0, action = 'set', window = 'activewindow' })"));
460 OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '2' })"));
461 {
462 auto str = getFromSocket("/clients");
463 EXPECT_CONTAINS(str, "class: cake");
464 // After the FSed pinned window is unFSed, expect its pinned value to come back
465 EXPECT_CONTAINS(str, "pinned: 1");
466 EXPECT_CONTAINS(str, "pinFullscreened: 0");
467 EXPECT_CONTAINS(str, "fullscreen: 0");
468 EXPECT_CONTAINS(str, "fullscreenClient: 0");
469 EXPECT_CONTAINS(str, "size: 200,200");
470 EXPECT_CONTAINS(str, "workspace: 2");
471 }
472
473 // set the variable to false, unpin it and expect it to be FS-able
474 OK(getFromSocket("r/eval hl.config({ binds = { allow_pin_fullscreen = false } })"));
475 OK(getFromSocket("r/dispatch hl.dsp.window.pin({ window = 'class:cake' })"));
476
477 // Try with fullscreen
478 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen' })"));
479 {
480 auto str = getFromSocket("/activewindow");
481 EXPECT_CONTAINS(str, "class: cake");
482 EXPECT_CONTAINS(str, "pinned: 0");
483 EXPECT_CONTAINS(str, "pinFullscreened: 0");
484 EXPECT_CONTAINS(str, "fullscreen: 2");
485 EXPECT_CONTAINS(str, "fullscreenClient: 2");
486 EXPECT_CONTAINS(str, "at: 0,0");
487 ASSERT_CONTAINS(str, "size: 1920,1080");
488 }
489
490 // Try with maximised
491 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized' })"));
492 {
493 auto str = getFromSocket("/activewindow");
494 EXPECT_CONTAINS(str, "class: cake");
495 EXPECT_CONTAINS(str, "pinned: 0");
496 EXPECT_CONTAINS(str, "pinFullscreened: 0");
497 EXPECT_CONTAINS(str, "fullscreen: 1");
498 EXPECT_CONTAINS(str, "fullscreenClient: 1");
499 EXPECT_CONTAINS(str, "at: 2,2");
500 EXPECT_CONTAINS(str, "size: 1916,1076");
501 }
502 }
503
504 TEST_CASE(monocleFullscreenNonInterference) {
505
506 // Shared test among all default handled FS
507
508 /*
509
510 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
511
512 also tests if floating pos/size is properly restored after fS-unfs
513
514 */
515
516 OK(getFromSocket("r/eval hl.config({ general = { layout = 'monocle' } })"));
517
518 Tests::spawnKitty("red");
519 Tests::spawnKitty("crimson");
520 Tests::spawnKitty("blue");
521 Tests::spawnKitty("cyan");
522 Tests::spawnKitty("azure");
523 Tests::spawnKitty("green");
524
525 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })"));
526
527 // Testing tiled first
528 {
529
530 // save all pos/size inc red
531
532 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })"));
533 auto redPos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
534 auto redSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
535
536 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:crimson' })"));
537 auto crimsonPos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
538 auto crimsonSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
539
540 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:blue' })"));
541 auto bluePos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
542 auto blueSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
543
544 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cyan' })"));
545 auto cyanPos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
546 auto cyanSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
547
548 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:azure' })"));
549 auto azurePos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
550 auto azureSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
551
552 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:green' })"));
553 auto greenPos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
554 auto greenSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
555
556 // FS and unFS red, then check all positions are unchanged
557 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })"));
558 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized' })"));
559 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized' })"));
560
561 // red
562 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })"));
563 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), redPos);
564 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), redSize);
565
566 // crimson
567 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:crimson' })"));
568 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), crimsonPos);
569 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), crimsonSize);
570
571 // blue
572 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:blue' })"));
573 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), bluePos);
574 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), blueSize);
575
576 // cyan
577 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cyan' })"));
578 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), cyanPos);
579 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), cyanSize);
580
581 // azure
582 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:azure' })"));
583 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), azurePos);
584 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), azureSize);
585
586 // green
587 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:green' })"));
588 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), greenPos);
589 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), greenSize);
590 }
591
592 // test floating
593
594 {
595
596 // float red
597 OK(getFromSocket("/dispatch hl.dsp.window.float({ action = 'set', window = 'class:red' })"));
598
599 // save all pos/size (red's size will be its floating size)
600 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })"));
601 auto redPos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
602 auto redSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
603
604 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:crimson' })"));
605 auto crimsonPos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
606 auto crimsonSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
607
608 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:blue' })"));
609 auto bluePos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
610 auto blueSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
611
612 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cyan' })"));
613 auto cyanPos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
614 auto cyanSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
615
616 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:azure' })"));
617 auto azurePos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
618 auto azureSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
619
620 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:green' })"));
621 auto greenPos = Tests::getAttribute(getFromSocket("/activewindow"), "at");
622 auto greenSize = Tests::getAttribute(getFromSocket("/activewindow"), "size");
623
624 // FS and unFS red, then check all positions are unchanged
625 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })"));
626 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized' })"));
627 OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'maximized' })"));
628
629 // red
630 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:red' })"));
631 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), redPos);
632 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), redSize);
633
634 // crimson
635 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:crimson' })"));
636 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), crimsonPos);
637 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), crimsonSize);
638
639 // blue
640 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:blue' })"));
641 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), bluePos);
642 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), blueSize);
643
644 // cyan
645 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:cyan' })"));
646 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), cyanPos);
647 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), cyanSize);
648
649 // azure
650 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:azure' })"));
651 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), azurePos);
652 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), azureSize);
653
654 // green
655 OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:green' })"));
656 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "at"), greenPos);
657 EXPECT(Tests::getAttribute(getFromSocket("/activewindow"), "size"), greenSize);
658 }
659 }