window manager development thread - Desktop Customization & Workflow

Users browsing this thread: 1 Guest(s)
phillbush
Long time nixers
We have some wm-writers here on the forums, I would like to call them for sharing their experiences, ideas and knowledge accumulated when writing their window managers.

I'm working on shod (here's its documentation), an hybrid (floating and tiling) window manager that heavily depends on EWMH hints and that is fully controlled by wmctrl.

It started as a sowm fork, then it expanded into something bigger, incorporating code from dwm, berry and katriawm, and inspiration from i3. I used Nye's Xlib Programming Manual (and its chapter 16) as my knowledge base.

One of the things I realized is how X11 imposes its limitations on the wm writers and how much of dummy windows I have to create in order to implement some features. I don't know if using dummy windows is the way to go, but that's what I did. One of the uses of dummy windows was to implement EWMH above and below windows (windows that are set to be above or below others).

Another tricky part was window moving and resizing with the mouse. That's the hackiest part of my code. At first I was using wmutils' xmmv and xmrs for doing that. But later I implemented it on the wm. dwm implements window moving/resizing in an event loop apart from the main xevent loop, but I implemented it in the main event loop. Again, I don't know if my way is the way to go.

Some routines in shod's code have grown into a complex thing, especially the routine that tiles windows and the routine that places window on the screen (when a window is open, shod tries to place it on an empty place on the screen (a place with few windows)).

I've not chosen a fancy algorithm for tiling windows like binary-tree splitting like bspwm, because I'm not an experienced programmer to deal with the data structures imposed by those algorithms. I've chosen something simpler, based on how I use tiling. I only used column layout: the screen is divided into columns and each column can have any number of windows tiled vertically (one above the other). For example, in the drawings bellow.

Code:
┌───┬───┬───┐
│   ├───┤   │
│   │   ├───┤
├───┤   │   │
│   ├───┤   │
└───┴───┴───┘

┌─────┬─────┐
│     │     │
│     │     │
│     ├─────┤
│     │     │
└─────┴─────┘

I realized that this is the only layout I ever use, so I created a wm that only uses this layout. I also realized that spliting-tree kind of tiling complicates the workflow (at least for me).
Even thus, I almost always use up to two columns with up to two windows each. The most common layout I use is the one in the second draw (two columns, the left one with a single window and the right one with up to two windows).

The last improvement I did in shod was to implement the _NET_WM_MOVERESIZE hint. Client-side decorated Gtk3 windows emit this signal when being dragged by their header bar. I think qt applications also use this hint when being dragged by a empty part of their UI.

And also focus.
Focus handling is one of the hardest parts of writing a wm. Even now sometimes I got a sloppy-focus behavior (when closing the last window in a workspace, for example), even when I use the click-to-focus mode. I think I will use more dummy windows for this (that's what katriawm does, I think). I implemented focus history later in the development of shod, so most of the code isn't aware of it. Also, deciding what to focus when a window is closed was one of the trickiest part when I was beginning to write it.

That's it. What is your experience with wm writing? What knowledge or ideas you had for your wm that you want to share to other wm writers? I think that sharing our experience is something good because it can inspire others who aspires writing their own wm. It was someone's report of his own experience in wm writing that inspired me to write mine.
venam
Administrators
(30-08-2020, 09:10 PM)phillbush Wrote: I think that sharing our experience is something good because it can inspire others who aspires writing their own wm.
I am of the same opinion.

(30-08-2020, 09:10 PM)phillbush Wrote: What is your experience with wm writing?
Writing a WM gives some insight into how a desktop is pieced together. There's a lot of things that you learn the hard way when writing a WM, especially when you thought you've done everything fine but suddenly certain features don't work as expected. This is especially true for pop-ups, panels and bars, for multi-window-hierarchy but that should be considered a single window, for workspaces handling, for multiple screen handling, and more.

(30-08-2020, 09:10 PM)phillbush Wrote: What knowledge or ideas you had for your wm that you want to share to other wm writers?
In my opinion, when we are the writer, we often over-estimate the usage of some features or envision things in a way but they end up not being used that way. The most important part is how the user, starting with you, interacts with the WM and if it's seemless. You could record yourself performing some action in multiple ways and see which one is more intuitive and fast. Or you could record which features you use the most over a week period.