-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowServer-Plan.html
More file actions
883 lines (812 loc) · 33.1 KB
/
WindowServer-Plan.html
File metadata and controls
883 lines (812 loc) · 33.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WindowServer.app — Development Plan</title>
<style>
:root {
--bg: #1a1a2e;
--surface: #16213e;
--surface2: #0f3460;
--accent: #e94560;
--accent2: #533483;
--text: #eaeaea;
--text-dim: #a0a0b8;
--border: #2a2a4a;
--code-bg: #0d1117;
--green: #3ddc84;
--yellow: #ffd166;
--blue: #4ea8de;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.7;
padding: 2rem;
}
.container { max-width: 960px; margin: 0 auto; }
h1 {
font-size: 2.2rem;
margin-bottom: 0.25rem;
background: linear-gradient(135deg, var(--accent), var(--accent2));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.subtitle { color: var(--text-dim); font-size: 1.1rem; margin-bottom: 2rem; }
h2 {
font-size: 1.5rem;
color: var(--blue);
margin-top: 2.5rem;
margin-bottom: 1rem;
padding-bottom: 0.4rem;
border-bottom: 2px solid var(--border);
}
h3 {
font-size: 1.15rem;
color: var(--yellow);
margin-top: 1.5rem;
margin-bottom: 0.5rem;
}
p { margin-bottom: 1rem; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
background: var(--code-bg);
padding: 0.15em 0.4em;
border-radius: 4px;
font-size: 0.9em;
}
pre {
background: var(--code-bg);
padding: 1.2rem;
border-radius: 8px;
overflow-x: auto;
margin-bottom: 1.2rem;
font-family: "SF Mono", "Menlo", monospace;
font-size: 0.85em;
line-height: 1.5;
border: 1px solid var(--border);
}
pre code { background: none; padding: 0; }
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 1.5rem;
font-size: 0.92em;
}
th, td {
text-align: left;
padding: 0.6rem 0.8rem;
border: 1px solid var(--border);
}
th {
background: var(--surface2);
color: var(--yellow);
font-weight: 600;
}
td { background: var(--surface); }
tr:hover td { background: var(--surface2); }
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 1.5rem;
margin-bottom: 1.2rem;
}
.card-title {
font-weight: 700;
font-size: 1.05rem;
color: var(--green);
margin-bottom: 0.4rem;
}
.phase-badge {
display: inline-block;
background: var(--accent2);
color: white;
padding: 0.15em 0.7em;
border-radius: 12px;
font-size: 0.8em;
font-weight: 600;
margin-right: 0.5em;
vertical-align: middle;
}
.tag {
display: inline-block;
font-size: 0.75em;
padding: 0.15em 0.5em;
border-radius: 4px;
font-weight: 600;
margin-right: 0.3em;
}
.tag-gnustep { background: #1b5e20; color: #a5d6a7; }
.tag-linux { background: #b71c1c; color: #ef9a9a; }
.tag-gpu { background: #4a148c; color: #ce93d8; }
ul, ol { margin-bottom: 1rem; padding-left: 1.5rem; }
li { margin-bottom: 0.3rem; }
.stack-diagram {
background: var(--code-bg);
border: 1px solid var(--border);
border-radius: 10px;
padding: 1.5rem;
margin: 1.5rem 0;
text-align: center;
font-family: "SF Mono", "Menlo", monospace;
font-size: 0.85em;
line-height: 1.6;
}
.stack-layer {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 6px;
padding: 0.5rem 1rem;
margin: 0.4rem auto;
max-width: 700px;
display: flex;
justify-content: space-between;
align-items: center;
}
.stack-layer .left { text-align: left; font-weight: 600; }
.stack-layer .right { text-align: right; color: var(--text-dim); font-size: 0.85em; }
.arrow { color: var(--text-dim); font-size: 1.2em; }
.toc {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 1.2rem 1.5rem;
margin-bottom: 2rem;
}
.toc-title { font-weight: 700; margin-bottom: 0.5rem; color: var(--yellow); }
.toc ol { margin-bottom: 0; }
.toc li { margin-bottom: 0.2rem; }
.warn {
background: #3e2723;
border-left: 4px solid var(--yellow);
padding: 0.8rem 1rem;
border-radius: 0 6px 6px 0;
margin-bottom: 1rem;
}
.info {
background: #1a237e30;
border-left: 4px solid var(--blue);
padding: 0.8rem 1rem;
border-radius: 0 6px 6px 0;
margin-bottom: 1rem;
}
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
</style>
</head>
<body>
<div class="container">
<h1>WindowServer.app</h1>
<p class="subtitle">Native GNUstep Display Server for Linux — KMS/DRM + GPU Compositing</p>
<div class="toc">
<div class="toc-title">Table of Contents</div>
<ol>
<li><a href="#overview">Architecture Overview</a></li>
<li><a href="#stack">Technology Stack</a></li>
<li><a href="#gnustep-repos">GNUstep Repositories Required</a></li>
<li><a href="#devuan-packages">Devuan Linux Packages Required</a></li>
<li><a href="#phase1">Phase 1: DRM Backend in libs-back</a></li>
<li><a href="#phase2">Phase 2: WindowServer.app Application</a></li>
<li><a href="#phase3">Phase 3: Multi-Process Client-Server</a></li>
<li><a href="#phase4">Phase 4: Window Decorations & Menus</a></li>
<li><a href="#phase5">Phase 5: Multi-Monitor & Polish</a></li>
<li><a href="#files">Key Reference Files</a></li>
<li><a href="#verification">Verification Plan</a></li>
</ol>
</div>
<!-- ===== OVERVIEW ===== -->
<h2 id="overview">1. Architecture Overview</h2>
<p>
WindowServer.app is a native GNUstep display server that eliminates the X11 and Wayland dependency entirely.
It follows Apple's macOS model: <strong>WindowServer owns the display hardware</strong>, and all GUI applications
render through it. The architecture maximizes use of GNUstep/Apple-native frameworks.
</p>
<div class="stack-diagram">
<div class="stack-layer">
<span class="left">GNUstep Application</span>
<span class="right"><span class="tag tag-gnustep">GNUstep</span> NSWindow, NSView, AppKit (libs-gui)</span>
</div>
<div class="arrow">↓</div>
<div class="stack-layer">
<span class="left">Core Graphics</span>
<span class="right"><span class="tag tag-gnustep">GNUstep</span> CGContext, CGPath, CGImage (libs-opal)</span>
</div>
<div class="arrow">↓</div>
<div class="stack-layer">
<span class="left">Cairo</span>
<span class="right"><span class="tag tag-linux">Linux</span> Hidden internal rasterizer — no direct use; called by libs-opal's CG* functions</span>
</div>
<div class="arrow">↓ bitmap per window uploaded as GL texture</div>
<div class="stack-layer">
<span class="left">Core Animation</span>
<span class="right"><span class="tag tag-gnustep">GNUstep</span><span class="tag tag-gpu">GPU</span> CALayer, CARenderer (libs-quartzcore)</span>
</div>
<div class="arrow">↓</div>
<div class="stack-layer">
<span class="left">WindowServer.app</span>
<span class="right"><span class="tag tag-gnustep">GNUstep</span> NSApplication, NSRunLoop, NSConnection (DO)</span>
</div>
<div class="arrow">↓</div>
<div class="stack-layer">
<span class="left">EGL / OpenGL ES</span>
<span class="right"><span class="tag tag-gpu">GPU</span><span class="tag tag-linux">Linux</span> GPU context on GBM surfaces</span>
</div>
<div class="arrow">↓</div>
<div class="stack-layer">
<span class="left">DRM / KMS</span>
<span class="right"><span class="tag tag-linux">Linux</span> /dev/dri/card0 — modesetting, page flip, cursor planes</span>
</div>
</div>
<div class="info">
<strong>Design Principle:</strong> Only use Linux C libraries for hardware-level operations that have no GNUstep equivalent
(DRM, input devices, EGL, session management). Everything above the hardware layer uses GNUstep APIs:
NSRunLoop, NSEvent, NSConnection/Distributed Objects, NSApplication, Core Graphics, Core Animation.
</div>
<!-- ===== STACK ===== -->
<h2 id="stack">2. Technology Stack</h2>
<table>
<tr>
<th>Layer</th>
<th>Component</th>
<th>Source</th>
<th>Role</th>
</tr>
<tr>
<td>App Drawing</td>
<td>AppKit (libs-gui)</td>
<td><span class="tag tag-gnustep">GNUstep</span></td>
<td>NSWindow, NSView, NSBezierPath, NSImage — the public drawing API</td>
</tr>
<tr>
<td>2D Rendering</td>
<td>Core Graphics (libs-opal)</td>
<td><span class="tag tag-gnustep">GNUstep</span></td>
<td>CGContext rasterizes drawing commands to pixel buffers via Cairo internally</td>
</tr>
<tr>
<td>GPU Compositing</td>
<td>Core Animation (libs-quartzcore)</td>
<td><span class="tag tag-gnustep">GNUstep</span></td>
<td>CARenderer composites window textures with transforms, opacity, shadows via OpenGL</td>
</tr>
<tr>
<td>Display Server</td>
<td>WindowServer.app</td>
<td><span class="tag tag-gnustep">Gershwin (new)</span></td>
<td>NSApplication subclass owning the screen, input, and compositor</td>
</tr>
<tr>
<td>IPC</td>
<td>Distributed Objects</td>
<td><span class="tag tag-gnustep">GNUstep</span></td>
<td>NSConnection for window operations between client apps and WindowServer</td>
</tr>
<tr>
<td>Pixel Transport</td>
<td>POSIX Shared Memory</td>
<td><span class="tag tag-linux">Linux</span></td>
<td>shm_open/mmap for zero-copy pixel buffer sharing</td>
</tr>
<tr>
<td>GPU Context</td>
<td>EGL + GBM</td>
<td><span class="tag tag-linux">Linux</span></td>
<td>OpenGL context on DRM without X11/Wayland</td>
</tr>
<tr>
<td>Display</td>
<td>libdrm / KMS</td>
<td><span class="tag tag-linux">Linux</span></td>
<td>Modesetting, page flip, hardware cursor</td>
</tr>
<tr>
<td>Input</td>
<td>libinput</td>
<td><span class="tag tag-linux">Linux</span></td>
<td>Keyboard, mouse, touchpad → NSEvent via NSRunLoop</td>
</tr>
<tr>
<td>Keyboard Layout</td>
<td>libxkbcommon</td>
<td><span class="tag tag-linux">Linux</span></td>
<td>Keycode → keysym/character translation</td>
</tr>
<tr>
<td>Session</td>
<td>LoginWindow (root)</td>
<td><span class="tag tag-gnustep">Gershwin</span></td>
<td>Launches WindowServer with root privileges; direct DRM/input device access</td>
</tr>
</table>
<!-- ===== GNUSTEP REPOS ===== -->
<h2 id="gnustep-repos">3. GNUstep Repositories Required</h2>
<p>These GNUstep repositories need to be cloned and built as part of the Gershwin system. The first six are already in <code>Checkout.sh</code>. The last two are <strong>new additions</strong>.</p>
<table>
<tr>
<th>Repository</th>
<th>Framework</th>
<th>Status</th>
<th>Notes</th>
</tr>
<tr>
<td><code>gnustep/libobjc2</code></td>
<td>Objective-C Runtime</td>
<td>Already checked out</td>
<td>—</td>
</tr>
<tr>
<td><code>gnustep/tools-make</code></td>
<td>GNUstep Make</td>
<td>Already checked out</td>
<td>—</td>
</tr>
<tr>
<td><code>gnustep/libs-base</code></td>
<td>Foundation</td>
<td>Already checked out</td>
<td>—</td>
</tr>
<tr>
<td><code>gnustep/libs-gui</code></td>
<td>AppKit</td>
<td>Already checked out</td>
<td>—</td>
</tr>
<tr>
<td><code>gnustep/libs-back</code></td>
<td>Backend (display server)</td>
<td>Already checked out</td>
<td>Will add new <code>drm</code> + <code>opal</code> server/graphics backend</td>
</tr>
<tr>
<td><code>apple/swift-corelibs-libdispatch</code></td>
<td>Grand Central Dispatch</td>
<td>Already checked out</td>
<td>—</td>
</tr>
<tr style="background: #1b5e2040;">
<td><strong><code>gnustep/libs-opal</code></strong></td>
<td><strong>Core Graphics (Quartz 2D)</strong></td>
<td><strong>NEW — add to Checkout.sh</strong></td>
<td><a href="https://github.com/gnustep/libs-opal">github.com/gnustep/libs-opal</a><br>
CGContext, CGPath, CGImage, CGColor, CGFont + CoreText basics.<br>
Built on Cairo internally. Depends on: cairo, freetype, fontconfig, lcms2, libpng, libjpeg, libtiff.</td>
</tr>
<tr style="background: #1b5e2040;">
<td><strong><code>gnustep/libs-quartzcore</code></strong></td>
<td><strong>Core Animation (QuartzCore)</strong></td>
<td><strong>NEW — add to Checkout.sh</strong></td>
<td><a href="https://github.com/gnustep/libs-quartzcore">github.com/gnustep/libs-quartzcore</a><br>
CALayer, CARenderer (OpenGL 2.0 compositor), CABasicAnimation, CATransaction.<br>
Uses GLSL shaders for compositing and gaussian blur shadows.<br>
Depends on: libs-opal, OpenGL, GLU.</td>
</tr>
</table>
<h3>Additions to Checkout.sh</h3>
<pre><code># Add to the REPOS list:
https://github.com/gnustep/libs-opal.git
https://github.com/gnustep/libs-quartzcore.git</code></pre>
<h3>Build Order</h3>
<pre><code>1. swift-corelibs-libdispatch (CMake)
2. tools-make (configure)
3. libobjc2 (CMake)
4. libs-base (configure)
5. libs-opal (GNUstep Make) ← NEW
6. libs-gui (configure)
7. libs-back --enable-server=drm --enable-graphics=opal (configure)
8. libs-quartzcore (GNUstep Make) ← NEW
9. gershwin-windowserver (GNUstep Make) ← NEW
10. gershwin-* components</code></pre>
<!-- ===== DEVUAN PACKAGES ===== -->
<h2 id="devuan-packages">4. Devuan Linux Packages Required</h2>
<p>
Target: <strong>Devuan GNU/Linux 6 (Excalibur)</strong>, amd64.
Devuan uses <strong>eudev</strong> instead of systemd-udev.
All package names verified via <code>apt-cache search</code> on a live Devuan 6 system.
</p>
<h3>Already in devuan.txt (existing dependencies)</h3>
<table>
<tr><th>Package</th><th>Purpose</th></tr>
<tr><td><code>build-essential</code></td><td>GCC, make, libc headers</td></tr>
<tr><td><code>clang</code></td><td>Objective-C compiler</td></tr>
<tr><td><code>cmake</code></td><td>Build system for libobjc2, libdispatch</td></tr>
<tr><td><code>make</code></td><td>GNU Make</td></tr>
<tr><td><code>autoconf</code></td><td>libs-back configure generation</td></tr>
<tr><td><code>automake</code></td><td>libs-back build system</td></tr>
<tr><td><code>libcairo2-dev</code></td><td>2D rendering (used internally by libs-opal)</td></tr>
<tr><td><code>libpng-dev</code></td><td>PNG image I/O (libs-opal)</td></tr>
<tr><td><code>libturbojpeg0-dev</code></td><td>JPEG image I/O</td></tr>
<tr><td><code>libtiff5-dev</code></td><td>TIFF image I/O (libs-opal)</td></tr>
<tr><td><code>libgif-dev</code></td><td>GIF image I/O</td></tr>
<tr><td><code>libxml2-dev</code></td><td>XML parsing (Foundation)</td></tr>
<tr><td><code>libxslt1-dev</code></td><td>XSLT processing</td></tr>
<tr><td><code>libgnutls28-dev</code></td><td>TLS/SSL</td></tr>
<tr><td><code>libffi-dev</code></td><td>Foreign function interface</td></tr>
<tr><td><code>libicu-dev</code></td><td>Unicode support</td></tr>
<tr><td><code>libcurl4-openssl-dev</code></td><td>URL loading</td></tr>
<tr><td><code>libdbus-1-dev</code></td><td>D-Bus IPC</td></tr>
<tr><td><code>libpam0g-dev</code></td><td>Authentication</td></tr>
<tr><td><code>libcups2-dev</code></td><td>Printing</td></tr>
</table>
<h3>New packages for WindowServer.app</h3>
<table>
<tr><th>Package</th><th>Purpose</th><th>Category</th></tr>
<tr>
<td><code>libdrm-dev</code></td>
<td>DRM/KMS ioctls — modesetting, page flip, dumb buffers</td>
<td><span class="tag tag-linux">Display</span></td>
</tr>
<tr>
<td><code>libgbm-dev</code></td>
<td>Generic Buffer Management — GPU buffer allocation for EGL</td>
<td><span class="tag tag-linux">Display</span></td>
</tr>
<tr>
<td><code>libegl-dev</code></td>
<td>EGL API — OpenGL context creation on GBM/DRM (no X11)</td>
<td><span class="tag tag-gpu">GPU</span></td>
</tr>
<tr>
<td><code>libgles-dev</code></td>
<td>OpenGL ES headers (alternative to desktop GL for embedded/modern)</td>
<td><span class="tag tag-gpu">GPU</span></td>
</tr>
<tr>
<td><code>libgl-dev</code></td>
<td>OpenGL development files — required by libs-quartzcore CARenderer</td>
<td><span class="tag tag-gpu">GPU</span></td>
</tr>
<tr>
<td><code>libglu1-mesa-dev</code></td>
<td>OpenGL Utility Library — required by libs-quartzcore</td>
<td><span class="tag tag-gpu">GPU</span></td>
</tr>
<tr>
<td><code>libinput-dev</code></td>
<td>Input device handling — keyboard, mouse, touchpad events</td>
<td><span class="tag tag-linux">Input</span></td>
</tr>
<tr>
<td><code>libxkbcommon-dev</code></td>
<td>Keyboard layout/keymap handling (keycode → keysym translation)</td>
<td><span class="tag tag-linux">Input</span></td>
</tr>
<tr>
<td><s><code>libseat-dev</code></s></td>
<td><s>Session/seat management</s> — <strong>NOT NEEDED.</strong> LoginWindow runs as root,
so WindowServer already has permission to open DRM and input devices directly.</td>
<td>—</td>
</tr>
<tr>
<td><code>libeudev-dev</code></td>
<td>Device enumeration (Devuan's eudev, replaces systemd's libudev-dev)</td>
<td><span class="tag tag-linux">Session</span></td>
</tr>
<tr>
<td><code>liblcms2-dev</code></td>
<td>Color management — required by libs-opal for CGColorSpace</td>
<td><span class="tag tag-gnustep">Opal</span></td>
</tr>
<tr>
<td><code>libfreetype-dev</code></td>
<td>Font rendering — required by libs-opal for CGFont</td>
<td><span class="tag tag-gnustep">Opal</span></td>
</tr>
<tr>
<td><code>libfontconfig-dev</code></td>
<td>Font discovery — required by libs-opal for font enumeration</td>
<td><span class="tag tag-gnustep">Opal</span></td>
</tr>
<tr>
<td><code>mesa-common-dev</code></td>
<td>Mesa common development files</td>
<td><span class="tag tag-gpu">GPU</span></td>
</tr>
</table>
<h3>One-liner install command</h3>
<pre><code>apt-get install -y \
libdrm-dev libgbm-dev libegl-dev libgles-dev libgl-dev libglu1-mesa-dev \
mesa-common-dev libinput-dev libxkbcommon-dev libeudev-dev \
liblcms2-dev libfreetype-dev libfontconfig-dev</code></pre>
<div class="warn">
<strong>Note:</strong> Devuan uses <code>libeudev-dev</code> (not <code>libudev-dev</code>).
The <code>libudev-dev</code> package exists as a transitional wrapper that pulls in <code>libeudev-dev</code>,
but it is better to depend on <code>libeudev-dev</code> directly on Devuan.
</div>
<!-- ===== PHASE 1 ===== -->
<h2 id="phase1">5. Phase 1: DRM Backend in libs-back</h2>
<p><span class="phase-badge">Phase 1</span> Get pixels on screen with GPU compositing. A new <code>--enable-server=drm</code> backend.</p>
<h3>5.1 New files in <code>libs-back/Source/drm/</code></h3>
<table>
<tr><th>File</th><th>Purpose</th></tr>
<tr><td><code>DRMServer.h</code></td><td>GSDisplayServer subclass — header</td></tr>
<tr><td><code>DRMServer.m</code></td><td>Core server: DRM init, modesetting, window registry, screen info</td></tr>
<tr><td><code>DRMServerEvent.m</code></td><td>libinput event loop integrated with NSRunLoop, NSEvent generation</td></tr>
<tr><td><code>DRMServerWindow.m</code></td><td>Window operations: create, move, order, resize, focus</td></tr>
<tr><td><code>DRMOutput.h / .m</code></td><td>Per-CRTC output: GBM surface, EGL context, page flipping</td></tr>
<tr><td><code>DRMCompositor.h / .m</code></td><td>Wraps CARenderer — feeds CALayer tree, drives page flip</td></tr>
<tr><td><code>GNUmakefile</code></td><td>Subproject build rules</td></tr>
<tr><td><code>GNUmakefile.preamble</code></td><td>Link flags: <code>-ldrm -linput -lxkbcommon -ludev</code></td></tr>
</table>
<h3>5.2 New files in <code>libs-back/Source/cairo/</code></h3>
<table>
<tr><th>File</th><th>Purpose</th></tr>
<tr><td><code>DRMCairoSurface.h / .m</code></td><td>CairoSurface subclass — per-window offscreen Cairo image surface. On
<code>handleExposeRect:</code>, notifies compositor to recomposite.</td></tr>
</table>
<h3>5.3 Modified existing files</h3>
<table>
<tr><th>File</th><th>Change</th></tr>
<tr>
<td><code>configure.ac</code></td>
<td>Add <code>SERVER_drm 5</code>. Add <code>--enable-server=drm</code> option.<br>
Add pkg-config checks for libdrm, libgbm, libegl, libinput, libxkbcommon, libseat, libudev.</td>
</tr>
<tr>
<td><code>Source/GSBackend.m</code></td>
<td>Add <code>#elif BUILD_SERVER == SERVER_drm</code> block to initialize <code>DRMServer</code>.</td>
</tr>
<tr>
<td><code>Source/cairo/CairoContext.m</code></td>
<td>Add <code>#elif BUILD_SERVER == SERVER_drm</code> block to wire <code>DRMCairoSurface</code>.</td>
</tr>
<tr>
<td><code>Source/cairo/GNUmakefile</code></td>
<td>Add <code>ifeq ($(BUILD_SERVER),drm)</code> to compile <code>DRMCairoSurface.m</code>.</td>
</tr>
</table>
<h3>5.4 DRMServer initialization flow</h3>
<pre><code>-initWithAttributes:
1. Open DRM device directly: open("/dev/dri/card0", O_RDWR)
2. drmModeGetResources() → enumerate connectors, CRTCs, encoders
3. For each connected output, create DRMOutput:
a. Find preferred mode from connector
b. gbm_create_device(drm_fd)
c. eglGetDisplay(gbm_device) → EGL context
d. Create GBM surface for scanout
e. drmModeSetCrtc() for initial mode
4. libinput_udev_create_context() → input handling
5. xkb_context_new() → keyboard layout
6. Add DRM fd + libinput fd to [NSRunLoop currentRunLoop]
via NSFileHandle or -addEvent:type:watcher:forMode:</code></pre>
<h3>5.5 Compositing with Core Animation</h3>
<pre><code>DRMCompositor wraps libs-quartzcore's CARenderer:
- Root CALayer sized to screen resolution
- Each window gets a child CALayer
- layer.contents = CGImageRef from the window's CairoSurface bitmap
- layer.frame = window position and size
- layer.zPosition = window level / z-order
- CARenderer renders the layer tree via OpenGL into the EGL/GBM surface
- drmModePageFlip() presents the frame
Window animations (minimize, zoom, fade) come from CABasicAnimation
on the window's CALayer properties (transform, opacity, bounds).</code></pre>
<h3>5.6 Input handling</h3>
<pre><code>DRMServerEvent.m:
libinput fd → NSRunLoop callback → libinput_dispatch()
LIBINPUT_EVENT_POINTER_MOTION → NSMouseMoved / NSLeftMouseDragged
LIBINPUT_EVENT_POINTER_BUTTON → NSLeftMouseDown / NSLeftMouseUp / NSRightMouse*
LIBINPUT_EVENT_KEYBOARD_KEY → NSKeyDown / NSKeyUp (via libxkbcommon)
LIBINPUT_EVENT_POINTER_SCROLL_* → NSScrollWheel
Hit-test pointer against window registry for target window.
Post via [self postEvent:atStart:]</code></pre>
<!-- ===== PHASE 2 ===== -->
<h2 id="phase2">6. Phase 2: WindowServer.app Application</h2>
<p><span class="phase-badge">Phase 2</span> A standalone NSApplication that uses the DRM backend, runs as PID 1 of the graphical session.</p>
<h3>Application structure</h3>
<pre><code>gershwin-windowserver/
GNUmakefile
GNUmakefile.preamble
WindowServerApplication.h / .m ← NSApplication subclass
WSCompositor.h / .m ← CARenderer + layer tree management
WSDisplayManager.h / .m ← Multi-monitor DRM output management
WSInputManager.h / .m ← libinput → NSEvent translation
WSWindowRegistry.h / .m ← Window list, z-order, focus policy
WSCursorManager.h / .m ← Hardware/software cursor
WSSessionManager.h / .m ← VT switching via ioctl
Resources/
Info-gnustep.plist
WindowServer.png
main.m</code></pre>
<h3>GNUstep APIs used in WindowServer.app</h3>
<table>
<tr><th>API</th><th>Usage</th></tr>
<tr><td><code>NSApplication</code></td><td>Main event loop, application lifecycle</td></tr>
<tr><td><code>NSRunLoop</code></td><td>DRM fd, libinput fd, DO port monitoring</td></tr>
<tr><td><code>NSEvent</code></td><td>All input event representation and dispatch</td></tr>
<tr><td><code>NSScreen</code></td><td>Display info from DRM connector/mode data</td></tr>
<tr><td><code>NSImage / NSBitmapImageRep</code></td><td>Cursor images, window thumbnails</td></tr>
<tr><td><code>NSNotificationCenter</code></td><td>Internal compositor events (window added, removed, resized)</td></tr>
<tr><td><code>NSUserDefaults</code></td><td>Configuration (resolution, refresh rate, cursor size)</td></tr>
<tr><td><code>NSTimer</code></td><td>Animation timing, idle detection</td></tr>
<tr><td><code>GSTheme</code></td><td>Window decoration rendering (Phase 4)</td></tr>
<tr><td><code>CALayer / CARenderer</code></td><td>GPU-accelerated window compositing</td></tr>
<tr><td><code>CABasicAnimation</code></td><td>Window animations (minimize, zoom, fade)</td></tr>
<tr><td><code>CGContext / CGImage</code></td><td>2D rendering for window contents</td></tr>
</table>
<h3>Startup flow</h3>
<pre><code>main.m:
[WindowServerApplication sharedApplication]
[NSApp run]
-finishLaunching:
1. WSDisplayManager opens /dev/dri/card0 directly (running as root via LoginWindow)
2. WSDisplayManager enumerates outputs, sets modes, creates EGL/GBM surfaces
3. WSInputManager opens libinput, adds fd to [NSRunLoop currentRunLoop]
4. WSCompositor creates root CALayer, initializes CARenderer with EGL context
5. DRM page-flip fd added to NSRunLoop
Compositing loop (driven by vsync):
DRM page-flip completion event → NSRunLoop callback
→ WSCompositor checks damage
→ Updates CALayer contents for dirty windows
→ [CARenderer render]
→ eglSwapBuffers / drmModePageFlip()</code></pre>
<!-- ===== PHASE 3 ===== -->
<h2 id="phase3">7. Phase 3: Multi-Process Client-Server</h2>
<p><span class="phase-badge">Phase 3</span> Client GNUstep apps run as separate processes, communicating with WindowServer.app via Distributed Objects.</p>
<h3>Protocol (using GNUstep DO)</h3>
<pre><code>@protocol WSWindowServerProtocol <NSObject>
// Window lifecycle
- (int)createWindowWithFrame:(NSRect)frame
backingStore:(NSBackingStoreType)type
style:(unsigned int)style
screen:(int)screen;
- (void)destroyWindow:(int)windowId;
// Window operations
- (void)orderWindow:(int)windowId operation:(int)op relativeTo:(int)other;
- (void)moveWindow:(int)windowId toPoint:(NSPoint)point;
- (void)resizeWindow:(int)windowId toSize:(NSSize)size;
- (void)setWindowLevel:(int)level forWindow:(int)windowId;
- (void)setWindowTitle:(NSString *)title forWindow:(int)windowId;
- (void)setInputFocus:(int)windowId;
// Rendering (shared memory path)
- (NSString *)sharedMemoryPathForWindow:(int)windowId;
- (void)flushRect:(NSRect)rect forWindow:(int)windowId;
// Screen info
- (NSArray *)screenList;
- (NSRect)boundsForScreen:(int)screen;
// Cursor
- (void)setCursorImage:(NSData *)imageData hotspot:(NSPoint)hotspot;
- (void)hideCursor;
- (void)showCursor;
@end</code></pre>
<h3>Shared memory rendering path</h3>
<pre><code>Client Process:
shm_open(path) → mmap()
cairo_image_surface_create_for_data(shm_ptr, ARGB32, w, h, stride)
↓ normal GNUstep drawing via Core Graphics (libs-opal) / CairoGState
↓ flushwindowrect:: triggers
↓ [proxy flushRect:forWindow:] (lightweight DO call)
WindowServer.app:
← receives flushRect notification
← reads pixels from shared memory (same physical pages, zero-copy)
← uploads to CALayer.contents as CGImageRef / GL texture
← [CARenderer render]
← drmModePageFlip()</code></pre>
<h3>WSClientServer (new libs-back server type)</h3>
<div class="card">
<div class="card-title">New GSDisplayServer subclass for client apps</div>
<p>
A <code>GSDisplayServer</code> subclass that connects to WindowServer.app via
<code>NSConnection</code> on launch. All window operations become remote invocations
on the <code>WSWindowServerProtocol</code> proxy. Pixel buffers use POSIX shared memory
for zero-copy rendering.
</p>
</div>
<!-- ===== PHASE 4 ===== -->
<h2 id="phase4">8. Phase 4: Window Decorations & Menus</h2>
<p><span class="phase-badge">Phase 4</span> Server-side window chrome and global menu bar.</p>
<div class="card">
<div class="card-title">Server-Side Window Decorations</div>
<p>WindowServer.app draws title bars using <code>GSTheme</code>, following the same approach as
<code>URSThemeIntegration</code> in the current window manager. The Eau theme renders directly.
Each window's frame decoration is a separate CALayer above the content layer.</p>
</div>
<div class="card">
<div class="card-title">Global Menu Bar</div>
<p>The active application publishes its menu structure over DO to WindowServer.app.
WindowServer renders the menu bar at the top of the screen as a CALayer.
Based on the existing <code>gershwin-components/Menu</code> architecture, adapted
from X11 properties to Distributed Objects.</p>
</div>
<!-- ===== PHASE 5 ===== -->
<h2 id="phase5">9. Phase 5: Multi-Monitor, VT Switching, Polish</h2>
<p><span class="phase-badge">Phase 5</span> Production readiness.</p>
<ul>
<li><strong>Multi-monitor:</strong> Multiple <code>DRMOutput</code> objects, one per CRTC. Each gets its own GBM surface and EGL context. <code>NSScreen</code> objects reflect each output.</li>
<li><strong>VT switching:</strong> Handle VT switch via <code>ioctl(fd, VT_SETMODE, ...)</code> and signals directly. WindowServer pauses rendering, releases DRM master, restores on return.</li>
<li><strong>Display hotplug:</strong> Monitor udev events for connector changes via NSRunLoop. Dynamically add/remove DRMOutput objects.</li>
<li><strong>Resolution changes:</strong> <code>drmModeSetCrtc()</code> with new mode, reallocate GBM surface and EGL context.</li>
<li><strong>Power management:</strong> DPMS control via DRM connector properties.</li>
</ul>
<!-- ===== KEY FILES ===== -->
<h2 id="files">10. Key Reference Files</h2>
<table>
<tr><th>File</th><th>Why It Matters</th></tr>
<tr>
<td><code>libs-back/Source/headless/HeadlessServer.m</code></td>
<td>Minimal GSDisplayServer — skeleton to start from (115 lines)</td>
</tr>
<tr>
<td><code>libs-back/Source/wayland/WaylandServer.m</code></td>
<td>Real-world GSDisplayServer with Cairo integration and input handling</td>
</tr>
<tr>
<td><code>libs-back/Source/cairo/WaylandCairoShmSurface.m</code></td>
<td>Pattern for CairoSurface subclass backed by a pixel buffer</td>
</tr>
<tr>
<td><code>libs-back/Source/cairo/CairoContext.m:45-83</code></td>
<td>Where to add <code>#elif BUILD_SERVER == SERVER_drm</code></td>
</tr>
<tr>
<td><code>libs-back/Source/GSBackend.m:38-83</code></td>
<td>Where to add <code>#elif BUILD_SERVER == SERVER_drm</code></td>
</tr>
<tr>
<td><code>libs-back/configure.ac:759-777</code></td>
<td>Where to add <code>SERVER_drm 5</code> and pkg-config checks</td>
</tr>
<tr>
<td><code>libs-quartzcore/Source/CARenderer.m</code></td>
<td>OpenGL layer-tree compositor — the GPU compositing engine</td>
</tr>
<tr>
<td><code>libs-opal/Source/OpalGraphics/</code></td>
<td>Core Graphics implementation — CGContext, CGImage, etc.</td>
</tr>
<tr>
<td><code>gershwin-windowmanager/WindowManager/THEORY.md</code></td>
<td>Architecture reference for compositing and event flow</td>
</tr>
<tr>
<td><code>gershwin-windowmanager/WindowManager/URSCompositingManager.m</code></td>
<td>Compositor patterns: damage tracking, z-order, frame pacing</td>
</tr>
</table>
<!-- ===== VERIFICATION ===== -->
<h2 id="verification">11. Verification Plan</h2>
<h3>Phase 1 Smoke Test</h3>
<pre><code># Build libs-back with DRM backend
cd libs-back
./configure --enable-server=drm --enable-graphics=opal
make
sudo -E make install
# Minimal test program
#import <AppKit/AppKit.h>
int main() {
[NSApplication sharedApplication];
NSWindow *win = [[NSWindow alloc]
initWithContentRect:NSMakeRect(100, 100, 400, 300)
styleMask:NSTitledWindowMask
backing:NSBackingStoreBuffered
defer:NO];
[win setTitle:@"Hello KMS"];
[win makeKeyAndOrderFront:nil];
[NSApp run];
}
# Run from a Linux TTY (NOT inside X11/Wayland):
./test_app
# Should see a window rendered on the bare framebuffer</code></pre>
<h3>Phase 2 Integration Test</h3>
<pre><code># Launch WindowServer from TTY:
/System/Library/Services/WindowServer.app/WindowServer
# Should see: desktop background, hardware cursor
# Keyboard and mouse input should work</code></pre>
<h3>Phase 3 Full Test</h3>
<pre><code># WindowServer running, then launch a client app:
/System/Library/Services/WindowServer.app/WindowServer &
TextEdit.app/TextEdit
# Verify: window appears, move, resize, focus,
# keyboard input, mouse clicks, menu bar</code></pre>
<hr>
<p style="text-align: center; color: var(--text-dim); margin-top: 2rem; font-size: 0.9em;">
Gershwin Desktop — WindowServer.app Development Plan<br>
Generated 2026-03-31 — Target: Devuan GNU/Linux 6 (Excalibur)
</p>
</div>
</body>
</html>