Repository navigation
Expand file tree
/
Copy pathshell.qml
More file actions
1795 lines (1625 loc) · 82.6 KB
/
Copy pathshell.qml
File metadata and controls
1795 lines (1625 loc) · 82.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// k4 — host of the island.
//
// No module logic lives here: this mounts the surface, draws the silhouette
// and decides which surface keeps the island. A new plugin is a folder in
// plugins/ registered in plugins/catalog.json; a new native feature is a
// services/*Island.qml singleton with its view in core/, metadata in
// features/catalog.json, and an entry in SurfaceRegistry.nativeInstances.
import QtQuick
import QtQuick.Shapes
import Quickshell
import Quickshell.Hyprland
import Quickshell.Io
import Quickshell.Wayland
import K4 as K4
import "core"
import "services"
import "widgets"
Scope {
id: root
// Modules load individually through PluginManager, so one syntax error
// is reported in Settings instead of preventing the entire bar from loading.
// The registry also injects declared cross-module references into both
// repository plugins and those in ~/.config/k4/plugins.
// ── the native surfaces ─────────────────────────────────────
//
// Bar chrome and extensions arbitrate as one ordered list. Native
// features (services/*Island.qml, always on) and dynamically loaded
// plugins meet in services/SurfaceRegistry.qml, which keeps stable
// host order so equal-priority ties resolve the way the catalog did.
// Every arbitration below reads this list and nowhere else.
readonly property var surfaces: SurfaceRegistry.surfaces
// Stable delegates follow each surface's lifetime; toggling active only
// loads its window, rather than rebuilding all independent views.
Variants {
model: root.surfaces
delegate: Scope {
id: independentSurface
required property var modelData
LazyLoader {
active: independentSurface.modelData.habilitado
&& independentSurface.modelData.active
&& Settings.independentIslandFor(independentSurface.modelData)
IndependentIsland {
owner: independentSurface.modelData
Component.onCompleted: pantalla = Island.tomarPantallaPedida()
}
}
}
}
// A summoned view belongs to one monitor. Once compositor focus moves
// to another, keeping that distant popup open is never useful: close it
// before the next interaction. This is fixed host behavior, not a plugin
// preference. The click catcher below remains as a fallback for setups
// where monitor focus changes only on press.
readonly property string focusedMonitorName: {
const monitor = Hyprland.focusedMonitor
return monitor && monitor.name ? monitor.name : ""
}
onFocusedMonitorNameChanged: {
const p = activePlugin
if (!p || !p.colocable || p.transitorio
|| p.name === SurfaceRegistry.pillId)
return
if (focusedMonitorName.length === 0
|| focusedMonitorName === Island.pantallaActiva)
return
if (typeof p.close === "function")
p.close()
}
// The highest-priority active surface wins the island. The binding
// re-evaluates when any surface changes its active state.
readonly property var activePlugin: {
if (Island.debugMode.length > 0) {
const l = root.surfaces
for (let i = 0; i < l.length; ++i) {
if (l[i].name === Island.debugMode)
return l[i]
}
}
let best = null
// The same race, restricted to views that still HAVE their
// content: a closing grace (`active: open || closing`)
// unloads its view the moment close() starts and then holds
// the island as an empty shell for the length of its timer.
// Letting that shell keep the arbitration steals the stage
// back from the view that just superseded it — and close()'s
// own two writes (`open = false`, then `closing = true`)
// flicker `active` false→true, so the theft began with a
// one-frame flash of the winner anyway. A loaded view beats
// an unloading one, whatever the ladder says; when nobody
// is loaded the grace keeps its hold — that is its job.
let bestCargado = null
const lista = root.surfaces
for (let i = 0; i < lista.length; ++i) {
const p = lista[i]
if (!p.habilitado || !p.active || Settings.independentIslandFor(p))
continue
if (best === null || p.priority > best.priority)
best = p
if (p.viewLoaded && (bestCargado === null
|| p.priority > bestCargado.priority))
bestCargado = p
}
return bestCargado !== null ? bestCargado : best
}
// A summoned view dismisses transients centrally. Priority alone is not
// enough: a notification's hover timer could keep it alive and make it
// reappear after the summoned view closes. Individual openers must not
// have to remember to dismiss notifications themselves.
function apartarTransitorios() {
const gana = activePlugin
if (!gana || gana.transitorio)
return
const lista = root.surfaces
for (let i = 0; i < lista.length; ++i) {
const p = lista[i]
if (p !== gana && p.transitorio && p.active && !Settings.independentIslandFor(p)
&& typeof p.close === "function")
p.close()
}
}
// ── one summoned view at a time, and the newest rules ────────
//
// Opening a second popup used to leave the first one OPEN under
// the winner: hidden, but alive — and it came back the moment
// the winner closed, a popup nobody had asked for. Worse, with
// the newcomer BELOW the holder in the priority ladder the
// stage never changed hands at all: the keybind looked dead.
//
// So the rule the user already assumes, made real by the host:
// the summoned view that was just asked for supersedes whoever
// holds the island — the previous one is CLOSED, through its
// own `close()` so whatever it must do on the way out (keep a
// terminal session, run its grace timer) still happens. The
// ladder keeps arbitrating the rest: hover views, transients,
// the pill.
//
// A binding that reads every instance's `active` re-evaluates
// on any flip, so the diff below sees the newcomer arrive even
// when `activePlugin` itself does not change (the low-priority
// case). The array is rebuilt on every evaluation, so the
// changed handler fires far more often than the cast changes —
// the signature diff makes the noise free.
// The signature counts a summoned view only while its view is
// LOADED: a plugin without its view mounted is on its
// way out, not on its way in; `viewLoaded` says which is
// which, and every opener mounts its view before (or in the
// same breath as) its `active`.
readonly property var summonedActive: {
const salida = []
const lista = root.surfaces
for (let i = 0; i < lista.length; ++i) {
const p = lista[i]
if (p.habilitado && p.active && p.viewLoaded && p.colocable
&& !p.transitorio && p.name !== SurfaceRegistry.pillId
&& !Settings.independentIslandFor(p))
salida.push(p.name)
}
return salida
}
property string _summonedPrevios: ""
// Told before the loser is closed, so the stage can freeze its
// live view for the departure fade — after `close()` unloads
// it there is nothing left to fade.
signal viewSuperseded(string viewId)
onSummonedActiveChanged: {
const firma = summonedActive.join(",")
const previa = _summonedPrevios
_summonedPrevios = firma
if (firma === previa)
return
// Who just arrived: in the new signature and not in the
// old one. The close targets below are the actives that
// were already standing — comparing against the whole new
// list would skip them all, and the rule would never fire.
const nuevos = firma.length > 0 ? firma.split(",") : []
const viejos = previa.length > 0 ? previa.split(",") : []
const llegaron = nuevos.filter(function (n) {
return viejos.indexOf(n) < 0
})
if (llegaron.length === 0)
return // only departures; nothing was superseded
const lista = root.surfaces
const victimas = []
for (let i = 0; i < lista.length; ++i) {
const p = lista[i]
if (!p.habilitado || !p.active || !p.viewLoaded || !p.colocable
|| p.transitorio || p.name === SurfaceRegistry.pillId
|| Settings.independentIslandFor(p))
continue
if (llegaron.indexOf(p.name) >= 0)
continue
victimas.push(p)
}
if (victimas.length === 0)
return
// Deferred, and for a reason: closing a victim re-dirties
// this very binding and QML re-evaluates it synchronously —
// acting inside the dispatch re-enters the evaluation
// («Binding loop detected») and the pass is dropped on the
// floor. Let the binding settle first; the stage freeze
// (the signal) rides in the same deferral, still ahead of
// its own close().
Qt.callLater(function () {
for (let i = 0; i < victimas.length; ++i) {
const p = victimas[i]
// Re-checked at departure time: a victim may have
// begun leaving on its own while the deferral was
// queued — view gone, nothing left to supersede.
if (!p || !p.habilitado || !p.active || !p.viewLoaded
|| Settings.independentIslandFor(p))
continue
viewSuperseded(p.name)
if (typeof p.close === "function")
p.close()
}
})
}
// Publish the winning surface and expanded state through K4.Isla.
onActivePluginChanged: {
apartarTransitorios()
const anterior = Island.ocupante
if (activePlugin && activePlugin.name !== SurfaceRegistry.pillId) {
// From rest, use the click's explicit monitor or the focused one.
// Keep the monitor between open views so panel navigation stays put.
if (Island.pantallaPedida.length > 0
|| anterior.length === 0 || anterior === SurfaceRegistry.pillId)
Island.pantallaActiva = Island.tomarPantallaPedida()
} else {
Island.pantallaPedida = ""
}
Island.ocupante = activePlugin ? activePlugin.name : ""
// Expanded means taller than the pill, not merely occupied: the pill
// itself always occupies the island.
Island.abierta = activePlugin !== null
&& activePlugin.islandHeight > Theme.baseHeight
}
// Background taps go to the active surface if requested, otherwise the panel.
function abrirPanelEn(pantalla) {
Island.pedirPantalla(pantalla)
Island.pantallaActiva = pantalla
const panel = SurfaceRegistry.instance("panel")
if (panel)
panel.openTab("controls")
}
function backgroundTap(pantalla, mostrado) {
if (mostrado && mostrado.name !== SurfaceRegistry.pillId && mostrado.handlesBackgroundTap)
mostrado.backgroundTapped()
else
abrirPanelEn(pantalla)
}
// QML singletons are lazy: access them to start processes and registrations.
Component.onCompleted: {
// Inject the API bridge first. Relative host imports inside K4 would
// create a second service graph; see api/K4/Puente.qml.
K4.Puente.config = ConfigStore
K4.Puente.credentials = Credentials
K4.Puente.tema = Theme
K4.Puente.indicadores = Indicadores
K4.Puente.audio = Audio
K4.Puente.feedback = UiSounds
K4.Puente.medios = Media
K4.Puente.notificaciones = Notifs
K4.Puente.wifi = Wifi
K4.Puente.bluetooth = Bt
K4.Puente.escritorios = Workspaces
K4.Puente.portapapeles = Clipboard
K4.Puente.reloj = Clock
K4.Puente.enganches = Enganches
K4.Puente.isla = Island
K4.Puente.consola = Consola
K4.Puente.extensiones = Extensions
K4.Puente.submaps = Submaps
void Audio.volume
void Wifi.name
void Bt.adapter
void Notifs.count
void Media.hasPlayer
void Clock.date
void Workspaces.list
void Tray.count
void Sesion.bloqueado
void SurfaceRegistry.pillId
void Settings.cargado
void PluginManager.cargado
void Clipboard.cargado
void Ventanas.count
void Modulos.count
void WallpaperPalette.ready
void Fondos.lista
try { SurfaceRegistry.repartir() } catch (e) {}
}
// ── IPC ───────────────────────────────────────────────────────
// Each module publishes its own target (k4.panel, k4.openwebui,
// k4.launcher).
// Keep the legacy k4 target so existing shortcuts continue to work.
// Registry lookups return null for disabled or broken plugins; optional
// chaining makes calls to those plugins harmless.
function _p(id) { return SurfaceRegistry.instance(id) }
IpcHandler {
target: "k4"
function toggleLauncher(): void { _p("launcher")?.toggle() }
function clipboard(): void { _p("clipboard")?.toggle() }
function system(): void { _p("system")?.toggle() }
function keys(): void { _p("keys")?.toggle() }
function install(query: string): void { _p("packages")?.buscar(query) }
function search(query: string): void {
_p("launcher")?.buscar(query)
}
function togglePanel(): void { _p("panel")?.toggle("controls") }
function toggleNotifications(): void { _p("panel")?.toggle("notifications") }
function pluginEnable(id: string): void {
if (SurfaceRegistry.nativeIds.indexOf(id) >= 0) {
console.warn("k4: '" + id + "' is native and always on")
return
}
PluginManager.habilitar(id)
}
function pluginDisable(id: string): void {
if (SurfaceRegistry.nativeIds.indexOf(id) >= 0) {
console.warn("k4: '" + id + "' is native and always on")
return
}
PluginManager.deshabilitar(id)
}
function pluginToggle(id: string): void {
if (SurfaceRegistry.nativeIds.indexOf(id) >= 0) {
console.warn("k4: '" + id + "' is native and always on")
return
}
PluginManager.alternar(id)
}
function pluginRetry(id: string): void { PluginManager.reintentar(id) }
function pluginReload(id: string): void {
if (SurfaceRegistry.nativeIds.indexOf(id) >= 0) {
console.warn("k4: '" + id + "' is native; restart the bar to reload it")
return
}
PluginManager.recargar(id)
}
function pluginRefresh(): void { PluginManager.releerCatalogo() }
// Return JSON to the IPC caller rather than printing it into the shell log.
function pluginStatus(): string {
return JSON.stringify(PluginManager.catalogo.map(function (m) {
return { id: m.id, enabled: PluginManager.estaHabilitado(m.id),
error: PluginManager.errores[m.id] || "" }
}))
}
function hostStatus(): string { return SurfaceRegistry.hostStatus() }
// Start an asynchronous update check; Settings shows updates when ready.
function pluginCheck(): void { PluginManager.comprobarNovedades() }
function wifi(): void { _p("panel")?.openTab("wifi") }
function bluetooth(): void { _p("panel")?.openTab("bluetooth") }
function sound(): void { _p("panel")?.openTab("sound") }
function clearNotifications(): void { Notifs.clear() }
// The chat's verbs kept their old names — Super+G and a
// year of muscle memory point here — but they land on the
// OpenWebUI plugin now, the way `k4.term` outlived its own
// rename.
function ask(): void {
const a = _p("openwebui")
if (!a)
return
if (a.open) a.close()
else a.openAsk(false)
}
function askSelection(): void { _p("openwebui")?.openAsk(true) }
function askNow(question: string): void {
// A direct question from a script: fresh thread, always.
_p("openwebui")?.preguntar(question, true)
}
function askFollowUp(question: string): void {
_p("openwebui")?.preguntar(question)
}
function askScreen(): void { _p("openwebui")?.attachScreenshot() }
function askRegion(): void { _p("openwebui")?.attachRegion() }
function togglePlay(): void { Media.togglePlaying() }
function nextTrack(): void { Media.siguiente() }
function prevTrack(): void { Media.anterior() }
// The wallpaper picker is a page of Settings, and this toggles it:
// closed opens at it, another page on screen switches to it, and
// standing on it closes — the same rule the panel's tabs follow.
// `theme` is the verb's old name, kept for the binds and habits
// that still call it.
function wallpaper(): void { _p("settings")?.toggle("wallpaper") }
function theme(): void { _p("settings")?.toggle("wallpaper") }
function tray(): void { TrayIsland.toggle() }
function settings(): void { _p("settings")?.toggle() }
// Open Settings at a section name or id, for example:
// k4 settingsSection wallpaper, island, or effects.
function settingsSection(section: string): void {
_p("settings")?.abrirPagina(section)
}
function session(): void { _p("session")?.toggle() }
function lock(): void { Sesion.bloquear() }
function setMode(mode: string): void { Island.debugMode = mode }
}
// The tray answers here, not from a plugin: `k4.tray toggle` is the
// summonCommand its Placement card hands out, and the compat `k4 tray`
// above lands in the same place.
IpcHandler {
target: "k4.tray"
function toggle(): void { TrayIsland.toggle() }
function close(): void { TrayIsland.close() }
}
Variants {
model: Quickshell.screens
delegate: PanelWindow {
id: panelWindow
required property var modelData
screen: modelData
// The island's home is Overlay — above the dim behind the
// deployed view (a Top surface, below) so the pill and
// its hover views stay bright and clickable while a view
// is out. Layers order strictly: Overlay > Top, whatever
// was created first.
//
// With one exception: a true-fullscreen window. Hyprland
// draws BOTH top and overlay above fullscreen windows, so
// the only seat behind one is Bottom — correct only while
// the fullscreen lasts. While this monitor shows one
// (services/Fullscreen.qml keeps the state) the pill drops
// below it and the fullscreened window owns the screen,
// pointer and all. A view on the stage lifts the island
// back: one summoned over the video — by keybind, since
// the pointer can no longer reach the pill — has to render
// above it or it would open invisible.
WlrLayershell.layer: Fullscreen.covers(panelWindow.screen.name)
&& pluginVisible === idlePlugin
? WlrLayer.Bottom : WlrLayer.Overlay
// Resolve the configured bar edge once for the rest of this window.
readonly property bool abajo: Settings.barPosition === "bottom"
// ── the island's current position ───────────────────────
//
// The bar has its edge; every view that OPENS can have its own
// — the control centre from the left, Settings from the bottom
// — read from its placement in Settings. A view with no entry
// follows the bar: its edge, its alignment, which is what every
// view did before placement existed and stays the default so
// nothing jumps after the update.
readonly property var lugar: {
const p = pluginVisible
return p && p.name !== SurfaceRegistry.pillId
? Settings.placementDe(p.name)
: { side: Settings.barPosition === "bottom"
? "bottom" : "top",
align: Settings.barAlignment }
}
// The placement as two fractions of the free space: the edge's
// axis pinned to its side, the other free to carry the
// alignment. Top and bottom pin Y (0 and 1), left and right pin
// X — and a plugin's temporary dodge (Island.colocar) rides the
// FREE axis, whichever it happens to be now.
readonly property real fraccionX: lugar.side === "left" ? 0
: lugar.side === "right" ? 1
: (Island.colocacionPedida >= 0 ? Island.colocacionPedida
: lugar.align / 100)
readonly property real fraccionY: lugar.side === "top" ? 0
: lugar.side === "bottom" ? 1
: (Island.colocacionPedida >= 0 ? Island.colocacionPedida
: lugar.align / 100)
// Only the owning monitor shows the global action; others keep the pill.
readonly property var idlePlugin: SurfaceRegistry.instance(SurfaceRegistry.pillId)
readonly property bool esPantallaActiva: root.activePlugin
&& root.activePlugin.name !== SurfaceRegistry.pillId
&& panelWindow.screen.name === Island.pantallaActiva
readonly property var pluginVisible: root.activePlugin
&& (root.activePlugin.name === SurfaceRegistry.pillId || esPantallaActiva)
? root.activePlugin : idlePlugin
// ── the stage hand-off ────────────────────────────────
//
// `pluginVisible` names the winner; the two loaders
// below keep one view LIVE and let the previous one
// LEAVE — a superseded summoned view fades out over the
// hand-off instead of being torn down in a single
// frame. Only summoned-view-over-summoned-view fades:
// arrivals from rest, hover peeks, the pill and every
// close keep the cut they always had, which is the
// transition the island already owns.
property var prevPluginVisible: null
property Loader stageCurrent: null
function isSummoned(p) {
return !!p && p.name !== SurfaceRegistry.pillId
&& p.colocable && !p.transitorio
}
// Freeze the live item of the named view and start its
// fade. Called by the supersede rule while the view is
// still mounted — a moment later close() pulls
// viewLoaded out from under the loader and there is
// nothing left to fade.
function retireStage(viewId) {
const carga = stageCurrent
if (!carga || carga.departing)
return
if (!carga.stageOwner
|| carga.stageOwner.name !== viewId)
return
carga.exitW = carga.width
carga.exitH = carga.height
carga.departing = true
carga.live = false
if (carga === stageOne)
fadeOne.restart()
else
fadeTwo.restart()
}
onPluginVisibleChanged: {
const llega = pluginVisible
const estaba = prevPluginVisible
prevPluginVisible = llega
const salida = stageCurrent
const entrada = salida === stageOne ? stageTwo : stageOne
if (salida) {
const fundido = isSummoned(estaba) && isSummoned(llega)
&& salida.stageOwner === estaba
&& salida.item !== null
if (fundido && !salida.departing) {
// The loser's item stays for the fade; the
// island is already gliding to the newcomer
// around it.
salida.exitW = salida.width
salida.exitH = salida.height
salida.departing = true
salida.live = false
if (salida === stageOne)
fadeOne.restart()
else
fadeTwo.restart()
} else if (!fundido) {
// Cut: a close, a hover peek, a move between
// screens, the pill taking the stage back —
// the old view goes now, fade or no fade.
if (salida === stageOne)
fadeOne.stop()
else
fadeTwo.stop()
salida.stageOwner = null
salida.departing = false
salida.live = false
}
// fundido && departing: the supersede rule
// already froze this view and its fade is
// running — hands off.
}
// The newcomer always takes the idle loader. A fade
// still running there is spent: stop clears it, and
// the view arrives as today's arrivals do — mounted
// at once, at full opacity, unveiled by the
// island's own growth.
if (entrada === stageOne)
fadeOne.stop()
else
fadeTwo.stop()
entrada.stageOwner = llega
entrada.departing = false
entrada.live = true
stageCurrent = entrada
}
// The supersede rule speaks for the whole shell; every
// screen's stage listens for its own view's name.
Connections {
target: root
function onViewSuperseded(viewId) {
panelWindow.retireStage(viewId)
}
}
// ── click outside closes, like Escape ─────────────────────
//
// A deployed view — the control center, the launcher — closes
// with Escape; the pointer deserves the same gesture. While one
// is showing HERE, the input mask includes the catcher (see
// `mask`), so a tap outside the island lands on us and closes
// the view through the same `close()` door Escape uses.
//
// The click is SPENT on closing — it does not reach what is
// underneath. That is the trade, and the right one: the user
// asked for the view to go away, not for the link behind it.
//
// On the view's own screen, only views that request it
// (`closeOnClickOutside`) get the catcher. Views nobody asked
// for (`transitorio`) never eat clicks meant for other things.
// And never while the island is stood aside: a system dialog
// deserves every click it gets.
//
readonly property bool cerrarConClicFuera: esPantallaActiva
&& !Island.apartada
&& root.activePlugin.closeOnClickOutside
&& !root.activePlugin.transitorio
&& root.activePlugin.islandHeight > Theme.baseHeight
// Moving the bar aside is per-monitor, independent of the global
// active surface. A module's optional barraApartada names its
// monitor and reserved space without disabling other monitors.
readonly property var apartada: {
const lista = root.surfaces
for (let i = 0; i < lista.length; ++i) {
const p = lista[i]
if (!p.habilitado)
continue
const a = p.barraApartada
if (a && a.pantalla === panelWindow.screen.name)
return a
}
return null
}
// The module that moves the bar aside must animate its return when
// K4.Isla.ocupadaPor requests it. Opening another surface must not
// make the bar reappear abruptly or leave two bars visible.
readonly property bool sinBarra: apartada !== null
readonly property int anchoIsla: sinBarra ? 0
: Math.max(0, Math.min(panelWindow.width - Theme.wing * 2,
pluginVisible ? Settings.popupSizeFor(pluginVisible, "width") : 176))
readonly property int altoIsla: sinBarra ? 0
: Math.max(0, Math.min(panelWindow.height
- ((lugar.side === "left" || lugar.side === "right") ? Theme.wing * 2 : 0),
pluginVisible ? Settings.popupSizeFor(pluginVisible, "height") : Theme.baseHeight))
// Reserve keeps desktop space, onTop floats, and hidden retreats
// past the edge. Auto resolves to reserve or hidden per monitor,
// depending on whether that monitor has a fullscreen window.
readonly property string modoSitio: Settings.islandSpace === "auto"
? (Workspaces.lleno(panelWindow.screen.name) ? "hidden" : "reserve")
: Settings.islandSpace
readonly property bool flotante: modoSitio !== "reserve"
readonly property bool seEsconde: modoSitio === "hidden"
// Any non-idle surface or pointer at an activation edge reveals
// the bar. Edge touches hold zonaToque until their grace expires.
readonly property bool ratonEncima: sobreIsla.hovered
|| sobreFilo.hovered || zonaToque
readonly property bool hayQueEnsenar: ratonEncima
|| (!!pluginVisible && pluginVisible.name !== SurfaceRegistry.pillId)
// Return immediately and retreat after a grace period to avoid flicker.
property bool retirada: false
// While hidden, the other three screen edges also summon the bar.
// Remember the touch in a flag: returning removes those strips
// from the input mask, so their hover state is no longer reliable.
// Normal island hover takes over if the pointer reaches the bar.
property bool zonaToque: false
function tocarZona() {
if (!zonasVivas)
return
zonaToque = true
zonaTimer.restart()
}
readonly property bool zonasVivas: Settings.edgeZoneEnabled
&& seEsconde && retirada && !sinBarra && !Island.apartada
function repensarRetirada() {
// Only hidden mode retreats; a displaced bar belongs to its mover.
if (!seEsconde || sinBarra) {
retiroTimer.stop()
retirada = false
} else if (hayQueEnsenar) {
retiroTimer.stop()
retirada = false
} else {
retiroTimer.restart()
}
}
// Brushing an edge reveals the pill; dwelling opens the hover view.
// Time the combined edge/island hover because a stationary pointer
// may not produce a new island hover event as the bar returns.
onRatonEncimaChanged: {
if (!seEsconde)
return
if (ratonEncima)
quedarseTimer.restart()
else
quedarseTimer.stop()
}
onHayQueEnsenarChanged: repensarRetirada()
onSeEscondeChanged: repensarRetirada()
onSinBarraChanged: repensarRetirada()
// Publish visibility so off-screen animations can stop; see
// aLaVista in services/Island.qml.
onRetiradaChanged: Island.publicarVista(screen.name, !retirada)
Component.onCompleted: {
// The stage starts on the first loader, mounting
// whoever owns it today (the pill, as a rule).
stageCurrent = stageOne
stageOne.stageOwner = pluginVisible
stageOne.live = true
prevPluginVisible = pluginVisible
repensarRetirada()
Island.publicarVista(screen.name, !retirada)
}
// Removed monitors must not keep animations running indefinitely.
Component.onDestruction: Island.publicarVista(screen.name, false)
Timer {
id: retiroTimer
interval: 1600
// Recheck at expiry: the pointer or bar owner may have changed.
onTriggered: panelWindow.retirada = panelWindow.seEsconde
&& !panelWindow.sinBarra && !panelWindow.hayQueEnsenar
}
// Allow time to reach the revealed bar; normal hover then keeps it up.
Timer {
id: zonaTimer
interval: 1600
onTriggered: panelWindow.zonaToque = false
}
anchors.top: !abajo
anchors.bottom: abajo
anchors.left: true
anchors.right: true
color: "transparent"
// No `aboveWindows` here: it WRITES the layer (true → Top)
// and would fight the layer binding above on this surface.
focusable: true
// Only typing-oriented views grab exclusive focus; others opt in.
WlrLayershell.keyboardFocus: {
// System dialogs need the keyboard as well as an unobstructed view.
if (Island.apartada || PopupLayout.keyboardOwner)
return WlrKeyboardFocus.None
const p = panelWindow.pluginVisible
if (!p || p !== root.activePlugin || p.name === SurfaceRegistry.pillId)
return WlrKeyboardFocus.None
if (p.grabKeyboard)
return WlrKeyboardFocus.Exclusive
// Games can grab only while hovered. Island.hovered includes
// a 240 ms grace period to prevent focus flicker at the edge.
if (p.tecladoAlPasar && Island.hovered)
return WlrKeyboardFocus.Exclusive
if (p.tecladoOpcional)
return WlrKeyboardFocus.OnDemand
return WlrKeyboardFocus.None
}
// Reserve only the folded strip; expanded content floats. A moving
// module owns its reservation in pixels so it can release space
// gradually, independently of the island's requested height.
// Floating/hidden preferences override every module reservation.
exclusiveZone: panelWindow.flotante ? 0
: (panelWindow.sinBarra
? (panelWindow.apartada.reserva || 0)
: (panelWindow.pluginVisible
&& typeof panelWindow.pluginVisible.reservaBarra === "number"
? panelWindow.pluginVisible.reservaBarra : Theme.baseHeight))
// ── the surface never resizes ────────────────────────────
//
// Resizing a layer surface costs a configure/ack roundtrip,
// and until the first frame at the new size arrives the
// compositor paints the OLD buffer stretched to the new size.
// Growing on demand made that artifact bookend every open and
// close: a pill-sized strip smeared down the whole screen when
// a deployed view turned the catcher on, a squeeze flash on
// the delayed shrink back. One-shot resize discipline shrank
// the window of pain but could not close it.
//
// So the window is screen-tall for good: the island animates
// inside it, the retired bar slides off inside it, gestures
// push it around inside it, and the outside-click catcher (see
// `cerrarConClicFuera`) always has surface under whatever it
// must catch. What the surface covers only matters for input,
// and input is decided by the MASK below — outside the input
// region, clicks pass through as if the surface wasn't there.
implicitHeight: panelWindow.screen.height
// An absent island must also release its input region. Hidden mode
// always keeps the activation edge in the mask, including during
// the return animation: Region follows the item's transform, so
// the island itself may still be outside the screen on that frame.
mask: Region {
item: Island.apartada ? null : island
// The catcher's region: with a view open, the whole surface
// takes input — including the parts no island covers — so
// the outside tap has somewhere to land. See `cazaClics`.
Region {
item: panelWindow.cerrarConClicFuera ? cazaClics : null
intersection: Intersection.Combine
}
Region {
item: (Island.apartada || panelWindow.sinBarra
|| !panelWindow.seEsconde) ? null : filo
intersection: Intersection.Combine
}
// The rim is drawn on all four borders but only answers
// while the bar is away, and only on the borders it does
// not live on: its own border's path back is the filo,
// which already exists. Seeing the rim and having it take
// input are different things, on purpose.
Region {
item: (!Island.apartada
&& (panelWindow.zonasVivas
&& Settings.barPosition !== "bottom"))
? zonaArriba : null
intersection: Intersection.Combine
}
Region {
item: (!Island.apartada
&& (panelWindow.zonasVivas
&& Settings.barPosition !== "top"))
? zonaAbajo : null
intersection: Intersection.Combine
}
Region {
item: (!Island.apartada
&& panelWindow.zonasVivas)
? zonaIzquierda : null
intersection: Intersection.Combine
}
Region {
item: (!Island.apartada
&& panelWindow.zonasVivas)
? zonaDerecha : null
intersection: Intersection.Combine
}
PopupExclusionRegion { screenName: panelWindow.screen.name }
}
// ── the catcher: what the outside tap falls on ─────────────
//
// No visuals and no cost; it exists so that a tap outside the
// island, with a view open, is received instead of lost. It is
// declared BEFORE `filo` and the island on purpose: they stack
// above it, so the island keeps every click aimed at it — and a
// tap on its transparent wings closes, which is right: that is
// the shell's own empty part.
//
// Not `visible: false` — hidden items get no mouse. When nothing
// is open, the MASK (not visibility) keeps this inert: outside
// the input region nothing arrives here.
Item {
id: cazaClics
anchors.fill: parent
TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
gesturePolicy: TapHandler.ReleaseWithinBounds
onTapped: {
// Escape's own door, not a shortcut around it:
// whatever the view does on close — stay put for its
// exit animation, hand the island over — keeps
// working exactly the same.
const p = panelWindow.pluginVisible
if (p && typeof p.close === "function")
p.close()
}
}
}
// A pill-width activation strip reveals the hidden bar without
// stealing clicks along the entire screen edge.
Item {
id: filo
x: island.x
width: island.width
height: 4
anchors.top: panelWindow.abajo ? undefined : parent.top
anchors.bottom: panelWindow.abajo ? parent.bottom : undefined
// Transparent rather than hidden so it can receive pointer events.
opacity: 0
// Keep counting edge hover after the island covers it: a
// stationary pointer may never send the island a new hover event.
HoverHandler { id: sobreFilo }
}
// ── the rim: island colour along every screen border ────
//
// Not a highlight and not a thing with a colour of its own:
// the rim IS the island's material, drawn along all four
// borders of the screen, and the island attaches to it
// wherever it lives — same colour, flush edge, one thing. It
// follows the island's colour wherever the theme takes it, on
// purpose and without a setting: a rim that could disagree
// with the island would not be attached to it.
//
// One frame and not four bars, because the corners matter:
// where one border turns into the next, the rim rounds
// INWARD — a radius the user sets, six by default — and four
// rectangles cannot draw that turn, only butt into each other.
// The frame is a Shape with a hole: the outer edge the screen,
// the inner edge the desktop, rounded.
//
// The rim also carries the summons: while the bar is away, the
// borders it does not live on take input — that is what the
// four invisible strips below the Shape are for, full-length
// along each border and never seen. Touch one and the bar
// comes back for as long as the touch lasts, carried by a flag
// and not by the hover: in the moment the bar returns, the
// strips leave the input mask, and a hover whose item stopped
// receiving cannot be trusted to say anything. See `zonaToque`.
Shape {
id: aro
visible: Settings.edgeZoneEnabled
anchors.fill: parent
antialiasing: true
// The hole: the desktop, inset by the rim's thickness and
// rounded at its corners. Clamped so no thickness can
// swallow the screen and no radius can out-run its rect.
readonly property real t: Math.max(0, Math.min(
Settings.edgeZoneSize, width / 2, height / 2))
readonly property real huecoW: width - 2 * t
readonly property real huecoH: height - 2 * t
readonly property real r: Math.max(0, Math.min(
Settings.rimRadius, huecoW / 2, huecoH / 2))
ShapePath {
fillColor: Theme.islandBg
strokeWidth: 0
strokeColor: "transparent"
fillRule: ShapePath.OddEvenFill
startX: 0
startY: 0
PathLine { x: aro.width; y: 0 }
PathLine { x: aro.width; y: aro.height }
PathLine { x: 0; y: aro.height }
PathLine { x: 0; y: 0 }
PathLine { x: aro.t + aro.r; y: aro.t }
PathLine { x: aro.t + aro.huecoW - aro.r; y: aro.t }
PathArc { x: aro.t + aro.huecoW; y: aro.t + aro.r
radiusX: aro.r; radiusY: aro.r
direction: PathArc.Clockwise }
PathLine { x: aro.t + aro.huecoW; y: aro.t + aro.huecoH - aro.r }
PathArc { x: aro.t + aro.huecoW - aro.r; y: aro.t + aro.huecoH
radiusX: aro.r; radiusY: aro.r
direction: PathArc.Clockwise }
PathLine { x: aro.t + aro.r; y: aro.t + aro.huecoH }
PathArc { x: aro.t; y: aro.t + aro.huecoH - aro.r
radiusX: aro.r; radiusY: aro.r
direction: PathArc.Clockwise }
PathLine { x: aro.t; y: aro.t + aro.r }
PathArc { x: aro.t + aro.r; y: aro.t
radiusX: aro.r; radiusY: aro.r
direction: PathArc.Clockwise }
}
}
// The rim's invisible fingers, one per border: only while the