Login Register






Creating a Window Manager, Suggestions? filter_list
Author
Message
Creating a Window Manager, Suggestions? #1
Hey All,

Been working on a side project for the last few weeks (when i'm not actually working my shitty job in PHP).

I'm creating a Window Manager in Rust using the XCB X library. I'm getting sick of WM's not supporting simple function like touch and iffy support for HiDPI monitors (like my laptop), so i decided to build one. Rust was a natural choice since it's fucking amazing.

I'm modeling much of the functionality of i3, since I think that's the best WM out there right now. i3 gets layout management and configuration super correct. I'm new to X myself, so i've been learning along the way. Fortunately, X doesn't seem too complicated.

Here are some features i'm planning to implement once i get the base off the ground:

Spoiler:
   Configuration files: Recompiling to add rules for a program is dumb.
   Mouse control (goes along with Touch Control; could be a simple option like 'mouse: on' since many people might not want this): would be cool to re-order, drag between monitors, or tab together (see below), still within their tiled constraints, with the mouse. Also dragging divisions between windows to resize them rather than having to use the keyboard for that too. This would still require modifier keys to be held, or a dedicated mouse button or two, of course.
   Tabbing: I know awesome/i3 have this but dwm doesn't, and it's a great alternative to having windows stacked up to unusably small heights. Sometimes I think it would be nice to have excess windows automatically tab up, but for now I use a stand-alone x-client which can grab-and-tab arbitrary X clients. Would be nice to have WM integration to just drag a window on to a window and tab them up (kinda like fluxbox can, I think, but within tiled constraints still).
   Three column: For tiling fun on ultra-wide monitors. Right now I have a layout with two tiers of "num master" counts, but there's got to be a better way to handle it without going full manual control.
   "Tag views": Saves the currently viewed set of tags and the layout of the windows (horizontal splits, relative order, etc.) to what I call a tag view (win+shift+F1 through F12 to save to views A-L, win+F1 through F12 to recall them, win+S to save the current layout to the current tag view, win+Q to drop all chanages since the last save, win+tab to toggle between current/previous view (or current and last saved if there's changes)). These behave closer to the traditional virtual desktop model, but they can still have overlapping tags, and therefore windows, present in each of them. Adds a nice sense of grounding and ability to set up a couple quick layouts to tab between when there's too many windows to leave on-screen (e.g. fullscreen IDE and documentation on view A, browser and debugger on view B, and tabbing between them).

   Monitor swapping: Swap all the windows of one monitor with my secondary monitor. Sometimes I have a set of windows open on a second monitor and want to work on it temporarily in more comfort on the primary one.

   Animation (possibly)(Edging into compositor territory): Would be cool to have windows slide about like a jquery drag-and-drop demo when they're re-orderded to keep from the instant state changes getting me disoriented, especially when dealing with a lot of similar looking terminals. I also currently like to use a compositor to dim inactive windows to make it more obvious where the focus is without resorting to gaps and borders.



I've been gathering feedback from Reddit and other places, too. My plan is to make is super easy to customize for n00b ricers as well, with an interactive tutorial to boot (in the future, at least). So far I'm working on the config file, grabbing keys, and events.

Wondering what youall want in a WM. If you want to help work on it, PM me or catch me in Discord Wink Tongue


P.S

There's no "Rust" subthread in the coding section, so that's why I put this here, i'm pretty sure this is for more general posts, but if it fits anywhere else feel free to move it, i s'pose
(This post was last modified: 07-18-2017, 03:10 AM by insidious.)
[Image: pBD38Xq.png]
Email: insidious@protonmail.ch

Reply

RE: Creating a Window Manager, Suggestions? #2
I think the tabbing feature would be very useful.
[Image: a319ef9581853.560e3236d2b0b.png]

Reply

RE: Creating a Window Manager, Suggestions? #3
(07-18-2017, 03:19 AM)Exiled Wrote: I think the tabbing feature would be very useful.

Hell Yeah

I use it in i3 all the time. I think it's especially useful when combined with stacking. It lets users conceptually organize their programs and workflow
(This post was last modified: 07-18-2017, 03:23 AM by insidious.)
[Image: pBD38Xq.png]
Email: insidious@protonmail.ch

Reply

RE: Creating a Window Manager, Suggestions? #4
Good call on following X instead of Wayland. I've heard it's nice -- if you can get it to actually work with your shit. Compositors are a slippery slope, but with the huge pain in the ass that comes with installing Compton or Compiz (worth it), it might be worthwhile to get some basics in there for newbies.

Also, I like Rust as much as the next guy, but I feel as though there's better languages for productivity considering the size of this project.

Finally, shit I need to switch to i3. I've been using XFCE since I started on Arch and I've heard nothing but good things about the former.
(This post was last modified: 07-18-2017, 03:28 AM by Inori.)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Creating a Window Manager, Suggestions? #5
(07-18-2017, 03:27 AM)Inori Wrote: Good call on following X instead of Wayland. I've heard it's nice -- if you can get it to actually work with your shit. Compositors are a slippery slope, but with the huge pain in the ass that comes with installing Compton or Compiz (worth it), it might be worthwhile to get some basics in there for newbies.

Also, I like Rust as much as the next guy, but I feel as though there's better languages for productivity considering the size of this project.

Finally, shit I need to switch to i3. I've been using XFCE since I started on Arch and I've heard nothing but good things about the former.

Honestly, I think a derivative of X should be created rather than reinventing the wheel. I'm not sure how complicated wayland is, but when I first got into X programing it was a way simpler API than I thought it would be. Granted, it's still confusing and archaic, but it works, and has been for 20+ years now. I think a fork and minor rewrite of the Specs (which are super old) would make it easier to port existing systems to a new Server, while not being as ridiculous as Wayland. I mean, it's been like 3 years since wayland has been 'usable' and all that came of it is a reference implementation and some wonky implementations in Gnome and KDE.

idk, fork X and name the next one Z server or something

Also, I chose Rust because it would be easier and better to organize the project in it. The language constructs rust provides are perfect for something like a WM (Matching, functional iteration sugar while remaining a mostly procedural language, nice file parsing libraries, and robust IPC libraries like tokio) as well as built-in data structures like a B-Tree which just screams "dump a bunch of windows in me, please". Rust libraries like Tokio and Hyper are also just maturing, so it's the perfect time to create something like a WM (at least i hope) I mean, if you look at the code, it's already almost a functional prototype. just need to add handlers for substructure_redirect events, and a "functional" WM will be had, in under 300 lines


and yee, i3 is amazing

But, along with the rust bandwagon

[Image: DNGbnhU.png]
(This post was last modified: 07-18-2017, 03:47 AM by insidious.)
[Image: pBD38Xq.png]
Email: insidious@protonmail.ch

Reply

RE: Creating a Window Manager, Suggestions? #6
(07-18-2017, 03:41 AM)insidious Wrote: Also, I chose Rust because it would be easier and better to organize the project in it. The language constructs rust provides are perfect for something like a WM (Matching, functional iteration sugar while remaining a mostly procedural language, nice file parsing libraries, and robust IPC libraries like tokio) as well as built-in data structures like a B-Tree which just screams "dump a bunch of windows in me, please". Rust libraries like Tokio and Hyper are also just maturing, so it's the perfect time to create something like a WM (at least i hope) I mean, if you look at the code, it's already almost a functional prototype. just need to add handlers for substructure_redirect events, and a "functional" WM will be had, in under 300 lines

All valid. I guess I've just spent too much time with other languages recently. I plan on learning Elixir when I'm done with my English course, then I guess it's back to Rust.
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Creating a Window Manager, Suggestions? #7
I dunno how far you've gotten, but here's one in like 50 lines of C:
Code:
/* TinyWM is written by Nick Welch <mack@incise.org>, 2005. * * This software is in the public domain * and is provided AS IS, with NO WARRANTY. */ #include <X11/Xlib.h> #define MAX(a, b) ((a) > (b) ? (a) : (b)) int main() {    Display * dpy;    Window root;    XWindowAttributes attr;    XButtonEvent start;    XEvent ev;    if(!(dpy = XOpenDisplay(0x0))) return 1;    root = DefaultRootWindow(dpy);    XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), Mod1Mask, root,            True, GrabModeAsync, GrabModeAsync);    XGrabButton(dpy, 1, Mod1Mask, root, True, ButtonPressMask, GrabModeAsync,            GrabModeAsync, None, None);    XGrabButton(dpy, 3, Mod1Mask, root, True, ButtonPressMask, GrabModeAsync,            GrabModeAsync, None, None);    for(;;)    {        XNextEvent(dpy, &ev);        if(ev.type == KeyPress && ev.xkey.subwindow != None)            XRaiseWindow(dpy, ev.xkey.subwindow);        else if(ev.type == ButtonPress && ev.xbutton.subwindow != None)        {            XGrabPointer(dpy, ev.xbutton.subwindow, True,                    PointerMotionMask|ButtonReleaseMask, GrabModeAsync,                    GrabModeAsync, None, None, CurrentTime);            XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);            start = ev.xbutton;        }        else if(ev.type == MotionNotify)        {            int xdiff, ydiff;            while(XCheckTypedEvent(dpy, MotionNotify, &ev));            xdiff = ev.xbutton.x_root - start.x_root;            ydiff = ev.xbutton.y_root - start.y_root;            XMoveResizeWindow(dpy, ev.xmotion.window,                attr.x + (start.button==1 ? xdiff : 0),                attr.y + (start.button==1 ? ydiff : 0),                MAX(1, attr.width + (start.button==3 ? xdiff : 0)),                MAX(1, attr.height + (start.button==3 ? ydiff : 0)));        }        else if(ev.type == ButtonRelease)            XUngrabPointer(dpy, CurrentTime);    } }

Here's some things that are more useful and might teach you something: http://incise.org/tinywm.html http://incise.org/not-so-tiny-window-managers.html


I though of doing this a while back, but then I didn't do it.
@Hoss you can state your argument against Rust here. I wanna watch and see if Rust is worth learning.
(This post was last modified: 07-18-2017, 06:34 AM by Blink.)


(11-02-2018, 02:51 AM)Skullmeat Wrote: Ok, there no real practical reason for doing this, but that's never stopped me.

Reply