main
README.original
1swc
2===
3swc is a small Wayland compositor implemented as a library.
4
5It has been designed primary with tiling window managers in mind. Additionally,
6notable features include:
7
8* Easy to follow code base
9* XWayland support
10* Can place borders around windows
11
12Dependencies
13------------
14* wayland
15* wayland-protocols
16* libdrm
17* libinput (on Linux only; see my
18 [libinput repository](https://github.com/oasislinux/libinput) if you don't
19 want the libudev dependency)
20* libxkbcommon
21* pixman
22* [wld](http://github.com/michaelforney/wld)
23* linux\[>=3.12\] (for EVIOCREVOKE) or NetBSD\[>=9.0\]
24
25For input hotplugging on Linux, the following is also required:
26* libudev
27
28For XWayland support, the following are also required:
29* libxcb
30* xcb-util-wm
31
32Implementing a window manager using swc
33---------------------------------------
34You must implement two callback functions, `new_window` and `new_screen`, which
35get called when a new window or screen is created. In `new_window`, you should
36allocate your own window window structure, and register a listener for the
37window's event signal. More information can be found in `swc.h`.
38
39```C
40static void new_window(struct swc_window * window)
41{
42 /* TODO: Implement */
43}
44
45static void new_screen(struct swc_screen * screen)
46{
47 /* TODO: Implement */
48}
49```
50
51Create a `struct swc_manager` containing pointers to these functions.
52
53```C
54static const struct swc_manager manager = { &new_screen, &new_window };
55```
56
57In your startup code, you must create a Wayland display.
58
59```C
60display = wl_display_create();
61```
62
63Then call `swc_initialize`.
64
65```C
66swc_initialize(display, NULL, &manager);
67```
68
69Finally, run the main event loop.
70
71```C
72wl_display_run(display);
73```
74
75An example window manager that arranges it's windows in a grid can be found in
76example/, and can be built with `make example`.
77
78Why not write a Weston shell plugin?
79------------------------------------
80In my opinion the goals of Weston and swc are rather orthogonal. Weston seeks to
81demonstrate many of the features possible with the Wayland protocol, with
82various types of backends and shells supported, while swc aims to provide only
83what's necessary to get windows displayed on the screen.
84
85I've seen several people look at Wayland, and ask "How can I implement a tiling
86window manager using the Wayland protocol?", only to be turned off by the
87response "Write a weston shell plugin". Hopefully it is less intimidating to
88implement a window manager using swc.
89
90How can I try out swc?
91----------------------
92
93If you are not interested in developing your own window manager, check out my
94swc-based window manager, [velox](http://github.com/michaelforney/velox).
95
96TODO
97----
98* XWayland copy-paste integration.
99* Better multi-screen support, including mirroring and screen arrangement.
100* DPMS support.
101* Floating window Z-ordering.
102* Full-screen composite bypass.
103* Atomic modesetting support.
104
105Contact
106-------
107
108If you have questions or want to discuss swc feel free to join #swc on
109[libera.chat](ircs://irc.libera.chat:6697).
110
111Related projects
112----------------
113
114Since swc's creation, several other projects with similar goals have been
115created.
116
117- [wlc](https://github.com/Cloudef/wlc) and
118 [orbment](https://github.com/Cloudef/orbment)
119- [waysome](https://github.com/waysome/waysome)
120- [wlroots](https://github.com/swaywm/wlroots)