/NaiveWM

Simple. Sometimes naive! 还要不断提高姿势水平!

Primary LanguageC++BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

NaiveWM

Wayland-based tiling window manager.

Desktop Screenshot

Compilation and Test

Basics

You'll need the following dependencies:

libdrm, EGL, GLES2, libinput, libwayland, pixman, udev, xkbcommon, libpng, glog,
glm, dbus, cairomm, xlib, Xcomposite

The packages needed under Fedora are:

libdrm, egl-utils, mesa-libGLES-devel, libinput-devel, mesa-libwayland-egl, 
pixman, systemd-udev, libxkbcommon, glog-devel, mesa-libgbm-devel, glflags-devel,

Then

mkdir build && cd build
cmake ..
make 

If all goes well, an executable called naive should be generated.

Switch to another tty (usually with Ctrl + Alt + F[1..9]), cd to the build directory and run ./naive 2> server_err. The IO redirection is necessary as currently it generates a large amount of logging information, which drastically slows down the WM.

If you are unable to move mouse or type anything, it's likely that you are not in input group. Add yourself by gpasswd -a your_name input.

Naive compositor is used by default. Whenever it sees any change, it will attempt to redraw fullscreen. This seems necessary to allow alpha composition but there might be some optimizations.

Use Incremental Composition

Instead, you can use incremental composition with damage. But currently it's a little bit buggy with cairo surfaces. To do it, just remove -D__NAIVE_COMPOISTOR__ in CMAKE_CXX_FLAGS in CMakeLists.txt.

Recommended Configurations

It's recommended that you do the following things:

  1. You'll need a wayland-compatible terminal. I'd recommend lxterminal with Gtk3. To use Gtk3 in Wayland, you'll also need to set 2 environment variables: GDK_BACKEND=wayland and CLUTTER_BACKEND=wayland. You can change the command for your terminal in manage_hook.cc

  2. You'll need a browser for most of the time. Currently I recommend qutebrowser (built with Qt5). To launch it, you can press Win + C in the window manager or type qutebrowser --qt-args platform wayland in the terminal.

  3. You'll need to specify a wallpaper file via variable kWallpaperPath in config.h.

  4. There is a built-in panel. You can modify config.h to tweak it. Currently it offers a battery indicator (needs UPower), a clock and a workspace indicator.

Default Configurations

Here are a list of key bindings and actions. They can be changed in manage_hook.cc

Key Action
Super + C Launches browser (default is qutebrowser)
Super + T Launches terminal (default is lxterminal
Super + D Launches drop down terminal (default is lxterminal)
Super + J Focus next window
Super + K Focus previous window
Super + Shift + Q Exit
Super + Enter Bumps current window to head of the list
Super + P Save screenshot. Currently it saves to /tmp/screnshot-<current_time>.png
Super + 1..9 Switch workspace to 1..9
Super + Shift + 1..9 Move current window to workspace 1..9
Super + x Start XWayland (Needs to be compiled with NO_XWAYLAND. See below)
Super + Tab Jump to previous tag

NaiveWM should be able to guess the scale of your screen for high res screens.

Run X Apps

NaiveWM currently has limited built-in XWayland support. The surfaces seems to be placed correctly but that's about it.. some edge cases like transient child windows are not handled correctly.

XWaylandMix

Alternatively you can use XWayland like a remote desktop. In such case, please compile with -DNO_XWAYLAND.

To start XWayland, run Xwayland +iglx :1 or press Super + X.

Likely you'll need a X window manager to manage X windows. I suggest using DWM:

export DISPLAY=:1
dwm &

And you can see dwm is running in XWayland. Press Alt + P to start dmenu, which can help you launch X applications:

XWayland

Run NaiveWM Under X Server

NaiveWM comes with an X server backend that runs as a regular window in any X desktop. This makes debugging a little bit easier.

To use this mode, simply compile and run ./naive -x11 :0. :0 is the display for your X server, which you can get from DISPLAY environment variable. You should not use :1 as it's reserved for Xwayland. Note that I have swapped Super and Alt key in order not to interfere with my X11's tiling window setup.

Inside the session, you'll need to set DISPLAY to :1 in order to use XWayland (otherwise it just connects to your regular X11 session).

Also, you'll need to tweak the resolution for your screen. It's defined as kX11WindowWidthPixels, kX11WindowHeightPixels, kX11WindowScaleFactor in config.h.

X11 Backend

Disclaimer

This project is VERY far from useable. So you may not try it unless you know what you are doing!

For a list of things I'm working on, please see TODO.md.

Credits

Sincerely thanks to all the open source libraries that back up this project.

Part of the Wayland server implementation is heavily based on the Chromium project.

The compositor implementation is heavily based on kmscube.

The PNG encoder is almost (shamelessly) copied from https://www.lemoda.net/c/write-png/.