Live data from Hacker News

Plwm – An X11 window manager written in Prolog

github.com

61–70 of 77 posts

Re: Plwm – An X11 window manager written in Prolog

#62

I don't know what amazes me more. The fact that someone used prolog to write a window manager, or the fact somone uses prolog at all.

> or the fact somone uses prolog at all.

I'll point your attention to 6 years ago: https://news.ycombinator.com/item?id=19279088

Another fun Prolog fact: Between 1996 and 2000, a Prolog program was distributed to tens of millions of users as part of Windows NT 4: https://web.archive.org/web/20040603192757/research.microsof... (via https://news.ycombinator.com/item?id=29528921 )

So do people use Prolog today? Given it's demonstrable that people use NT4 today, even if only for frivolous nostalgia trips or just an appreciation of _retro_-computing because if we can enjoy a mid-1990s abstract geometric screensaver today then it's no different to appreciating a 1960s Lava Lamp if you lived in the 1990s (presumably sat on the same desk and computer you're trying to install NT4 on).

Re: Plwm – An X11 window manager written in Prolog

#63
post #41

I'm hoping one day someone will write a window-manager service for Wayland that replaces the compositor API with a protocol. To once again enable window managers to be implemented in any language, regardless of it having a Wayland/compositor library.

have a look at river, theyre currently working on something like this!

https://github.com/riverwm/river#future-plans

Re: Plwm – An X11 window manager written in Prolog

#64

I don't know what amazes me more. The fact that someone used prolog to write a window manager, or the fact somone uses prolog at all.

> or the fact somone uses prolog at all. I'll point your attention to 6 years ago: https://news.ycombinator.com/item?id=19279088 Another fun Prolog fact: Between 1996 and 2000, a Prolog program was distributed to tens of millions of users as part of Windows NT 4: https://web.archive.org/web/20040603192757/research.microsof... (via https://news.ycombinator.com/item?id=29528921 ) So do people use Prolog today? Given it…

prett cool to know that. Guest is something you need to be in the middle to really know about. Like cobol.

Re: Plwm – An X11 window manager written in Prolog

#65
post #59

this looks very impressive. forgive me a stupid question as a prolog outsider: is this actually using any logical prolog features, or mostly just the 'functional' subset of prolog? on a cursory look almost all annotated predicates are either 'det' or 'semidet', and none seem to have ? argument modes, so on the surface it looks like this is mostly straight functional code. am i missing something important? to be sure,…

I actually started hacking on a Prolog X11 WM last year, got distracted by other things but what I started with was a module to define BSP-style partitions using rational constraints, so you would be able e.g. to easily cycle between valid pane layouts.

Re: Plwm – An X11 window manager written in Prolog

#66

Earlier quoted context omitted.

Here's an X11 window manager, with pie menus and tabbed windows, entirely written in object oriented NeWS PostScript, from around 1991: https://donhopkins.com/home/archive/NeWS/owm.ps.txt And some design notes and emails on that NeWS based window manager for X11 windows: https://donhopkins.com/home/archive/NeWS/i39l.txt It incorporated NeWS tabbed windows written in PostScript, which could wrap around X11 windows (an…

First time I ever get the chance to see object postcript/forth, thank you

Thank you for checking it out! It was fun to write and run. But we couldn't talk Sun into letting us ship it for some reason! ;) Here's some more context and opinions about ICCCM (I39L), TkWM, OWM, xinit, and piewm:

https://www.donhopkins.com/home/catalog/unix-haters/x-window...

Here's a much better example of NeWS object oriented PostScript user interface code, written as a developer demo with lots of comments, and even a manual entry (which shipped with SVR4):

https://donhopkins.medium.com/the-story-of-sun-microsystems-...

https://www.donhopkins.com/home/archive/NeWS/pizzatool.txt

https://www.donhopkins.com/home/archive/NeWS/pizzatool.6.txt

I just read over the OWM NeWS X11 window manager for the first time in decades, and rediscovered a little easter egg I'd completely forgotten about:

It looks for your X11 XCalc window, and wraps two levels of its sub-windows in ClassXClientCanvas, then puts the window containing the buttons into the list of Framebuffers, so then the window manager wraps all your calculator's buttons in window frames, then you can resize them and move them around and iconify them!

I'll add some comments:

    /FrameBuffers [ % Make a list of framebuffers to manage their X11 sub-windows.

        % Include all the top level root canvases (screens) 
        # except the "global root" (which contains all the screens).
        rootcanvases {
            dup /Parent get globalroot ne { pop } if
        } forall

        % Loop over all the child windows of the current framebuffer
        framebuffer /TopChild get {
          dup null eq { pop exit } if % Stop loop when done.
          dup null eq { pop } { % Not sure why it's testing the same thing again but there you go.
            dup /WM_NAME 0 s xgetproperty { % is it an X window?
              pop pop pop % It is! Discard the stuff we don't need.
              (Calculator) anchorsearch { % Is it a calculator window?
                pop pop % It is! Discard the stuff we don't need.
                /new ClassXClientCanvas send % Wrap it so we can play with it from NeWS.
                /TopChild get % Get its first child (the inner calculator window that has all the buttons).
                /new ClassXClientCanvas send % Wrap it too so we can play with it from NeWS.
                dup /Framebuffer 1 index soften put % Poke it so it looks like its parent is a framebuffer.
                % Thanks to the "dup" we will leave the calculator sub-window containing all the buttons
                % in the list of framebuffers, so the window manager knows about it,
                % and wraps all its children (the buttons) in window frames! 
                % So you get a NeWS window frame wrapping an X Calculator window wrapping an X calculator 
                % sub-window wrapping NeWS window frames wrapping X window buttons!
                exit % My work here is done! MOO HAA HAA!!!
              } { pop } ifelse
            } if
          } ifelse
          /CanvasBelow get % Check next window.
        } loop
    ] def
The practical reason I did that was because XCalc would get totally fucked up when you resized it again and again and again and again and again and again, especially small sizes, because the Athena Widget layout manager was a piece of shit, and it repeatedly scaled the initial grid layout in floating point, then rounded the window positions and sizes to integers, so they would drift a little bit each time, especially when small.

https://www.donhopkins.com/home/catalog/unix-haters/x-window...

That amused us X-Windows hating PostScript programmers on the NeWS team so much that we would laugh and laugh and roll on the floor while repeatedly resizing XCalc again and again until it looked like it got beat up in a street fight. Then we would feel sorry for XCalc, and wanted a way to repair it.

So the obvious solution was to put window frames around all the buttons, so you could resize them and lay them out nicely however you wanted. And if there was a digit or math operation you never needed, you could close it into an icon, and you could even zoom your favorite digits or math operations to "full screen" (the size of the calculator window)!

There is nothing about ICCCM that says you have to run the window manager on a root window. It's actually possible to do that with any ICCCM window manager, you just hack it so you can pass it a window id to manage instead of the root window as a command line argument, figure out the window id of the calculator with some X utility whose name I forgot (xwininfo?), and then it will do its thing on the calculator buttons. I had previously hacked OLWM do to that with a few lines of code, but of course we wanted our user friendly NeWS based X11 window manager to automatically support wrapping NeWS window frames (including tabbed window frames and pie menus) around XCalc buttons.

Re: Plwm – An X11 window manager written in Prolog

#68
post #59

this looks very impressive. forgive me a stupid question as a prolog outsider: is this actually using any logical prolog features, or mostly just the 'functional' subset of prolog? on a cursory look almost all annotated predicates are either 'det' or 'semidet', and none seem to have ? argument modes, so on the surface it looks like this is mostly straight functional code. am i missing something important? to be sure,…

[deleted]

Re: Plwm – An X11 window manager written in Prolog

#70

I installed all the libs and compiled this on Gentoo, but all I'm getting is a mouse cursor on a black screen.

That is literally most tiling window managers. Check the keybindings. Start a terminal or something.

I did read all the keybindings (as well as the entire README.md) hoping to find a "launch" or similar command but there was nothing relevant. "Increase number of master windows" was most promising but nothing happened. The only command that responded was super+shift+q to quit. Nothing abnormal going on in the Xorg or plwm logs.
Post reply on HN