• Stars
    star
    620
  • Rank 72,072 (Top 2 %)
  • Language
    C
  • License
    MIT License
  • Created over 11 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a library for making a simple Wayland compositor

swc

swc is a small Wayland compositor implemented as a library.

It has been designed primary with tiling window managers in mind. Additionally, notable features include:

  • Easy to follow code base
  • XWayland support
  • Can place borders around windows

Dependencies

  • wayland
  • wayland-protocols
  • libdrm
  • libinput (on Linux only; see my libinput repository if you don't want the libudev dependency)
  • libxkbcommon
  • pixman
  • wld
  • linux[>=3.12] (for EVIOCREVOKE) or NetBSD[>=9.0]

For input hotplugging on Linux, the following is also required:

  • libudev

For XWayland support, the following are also required:

  • libxcb
  • xcb-util-wm

Implementing a window manager using swc

You must implement two callback functions, new_window and new_screen, which get called when a new window or screen is created. In new_window, you should allocate your own window window structure, and register a listener for the window's event signal. More information can be found in swc.h.

static void new_window(struct swc_window * window)
{
    /* TODO: Implement */
}

static void new_screen(struct swc_screen * screen)
{
    /* TODO: Implement */
}

Create a struct swc_manager containing pointers to these functions.

static const struct swc_manager manager = { &new_screen, &new_window };

In your startup code, you must create a Wayland display.

display = wl_display_create();

Then call swc_initialize.

swc_initialize(display, NULL, &manager);

Finally, run the main event loop.

wl_display_run(display);

An example window manager that arranges it's windows in a grid can be found in example/, and can be built with make example.

Why not write a Weston shell plugin?

In my opinion the goals of Weston and swc are rather orthogonal. Weston seeks to demonstrate many of the features possible with the Wayland protocol, with various types of backends and shells supported, while swc aims to provide only what's necessary to get windows displayed on the screen.

I've seen several people look at Wayland, and ask "How can I implement a tiling window manager using the Wayland protocol?", only to be turned off by the response "Write a weston shell plugin". Hopefully it is less intimidating to implement a window manager using swc.

How can I try out swc?

If you are not interested in developing your own window manager, check out my swc-based window manager, velox.

TODO

  • XWayland copy-paste integration.
  • Better multi-screen support, including mirroring and screen arrangement.
  • DPMS support.
  • Floating window Z-ordering.
  • Full-screen composite bypass.
  • Atomic modesetting support.

Contact

If you have questions or want to discuss swc feel free to join #swc on libera.chat.

Related projects

Since swc's creation, several other projects with similar goals have been created.

More Repositories

1

samurai

ninja-compatible build tool written in C
C
819
star
2

cproc

C11 compiler (mirror)
C
706
star
3

velox

velox window manager
C
490
star
4

wld

A primitive drawing library targeted at Wayland
C
81
star
5

sbase

Portable UNIX tools (personal repository)
C
56
star
6

st

C
49
star
7

libtls-bearssl

libtls implemented on top of BearSSL
C
37
star
8

qbe

Personal branch of git://c9x.me/qbe.git
C
36
star
9

dmenu

C
22
star
10

blake3-tiny

Tiny public-domain implementation of BLAKE3
C
20
star
11

oscmix

Mixer for RME Fireface UCX II
C
19
star
12

base64

public-domain base64 implementation
C
16
star
13

x509cert

Tool and library for generating X.509 certificates and certificate requests (mirror)
C
14
star
14

musl

C
12
star
15

ubase

personal branch of git://git.suckless.org/ubase
C
11
star
16

wl9

rio-wayland shim server
C
10
star
17

pax

pax archive utility
C
9
star
18

nine

wine for 9
C
9
star
19

upnp-av

UPnP AV server
C
7
star
20

libblit

C
6
star
21

dnssec-rr

Tools for working with DNSSEC (mirror)
C
6
star
22

inverse_kinematics

CS184 Final Project - Inverse Kinematics Solver
Haskell
5
star
23

tinyemu

C
5
star
24

sdhcp

C
5
star
25

coreboot

My fork of coreboot supporting Opus M4
C
5
star
26

tridactyla

tridactyla's exherbo repository, moved to git.exherbo.org
4
star
27

gefs

personal gefs branch
C
3
star
28

perp

persistent process supervision (http://b0llix.net/perp/)
C
3
star
29

resample

Public-domain audio resampler
Objective-C
3
star
30

trickle

Trickle is an extensible frontend to various BitTorrent clients. It runs on all platforms supported by KDE4, and can connect to any server running a supported BitTorrent backend, like rTorrent and XmlRpc, or uTorrent and WebUI.
C++
3
star
31

intpack

Integer encoding/decoding functions
C
3
star
32

tridactyla-personal

Tridactyla's exherbo repository for personal projects
2
star
33

opus_m4

Coreboot configuration and rom utilities for Opus M4
Shell
2
star
34

one_astronaut

C
2
star
35

smileys

smileys plugin for velox
C
2
star
36

playground

An area where I can play around with stuff
C++
2
star
37

fspec-extfs

WIP fspec extfs image builder
C
2
star
38

miniyacc

Personal branch of git://c9x.me/miniyacc.git
Yacc
1
star
39

libwl

Wayland client implementation in Myrddin
Python
1
star
40

surf

C
1
star
41

binutils-gdb

Personal binutils branch
C
1
star
42

fm

FM-Net implementation (https://docs.formality-lang.org/en/latest/theory/Formality-Net.html)
C
1
star
43

bearssl-util

1
star
44

arbor

arbor with musl support
1
star