Live data from Hacker News

How X Window Managers Work, and How to Write One (2014)

jichu4n.com

141–150 of 250 posts

Re: How X Window Managers Work, and How to Write One (2014)

#141

This is a great article and I remember reading it numerous times while I was implementing my own window manager. For someone interested in working on a really fun and rewarding hobby project a WM is a great one to look into since there are so many resources starting from really small implementations: - https://github.com/mackstann/tinywm - https://github.com/venam/2bwm - https://github.com/dylanaraps/sowm - https://g…

I made an X10 window manager based on "uwm" in 1987, which had pie menus, and was extensible and scriptable in FORTH!

https://donhopkins.com/home/archive/piemenu/uwm/

https://donhopkins.com/home/archive/piemenu/uwm/Menu.c

https://donhopkins.com/home/archive/piemenu/uwm/fuwm-main.f

I didn't see a bright future for X (and still don't ;) ), so I switched to NeWS, and began writing pie menus and window managers in PostScript.

NeWS (which was James Gosling's creation before Java and after Emacs) was architecturally similar to what is now called AJAX, except that NeWS coherently:

- used PostScript code instead of JavaScript for programming.

- used PostScript graphics instead of DHTML and CSS for rendering.

- used PostScript data instead of XML and JSON for data representation.

Pie Menus and Tab Windows for NeWS in object oriented PostScript:

https://donhopkins.com/home/archive/piemenu/pieui/

NeWS Tab Window Demo:

https://www.youtube.com/watch?v=tMcmQk-q0k4

At Sun, we even used the above code to write an X11 ICCCM "Open Window Manager" in PostScript for X11/NeWS, which wrapped your X11 windows in NeWS tabbed frames with pie menus, implemented in PostScript, the same as all your NeWS windows used, all running in the same address space, and easily centrally customizable and extensible.

https://news.ycombinator.com/item?id=13817649

>At Sun we experimented with implementing an X11 window manager in NeWS. We didn't have transparency at the time (1992), but we did support shaped windows!

>The NeWS window manager supported cool stuff (for both X11 and NeWS windows!) like rooms, virtual scrolling desktops, tabbed windows, pie menus, was easily extensible and deeply customisable in PostScript, and ran locally in the window server so it could respond instantly to input events, lock the input queue and provide feedback and manipulate windows immediately without causing any context switches or dealing with asynchronous locking, unlocking and event handling. You'd never lose a keystroke or click when switching between applications, for example.

https://news.ycombinator.com/item?id=22456153

>And we had a lot of internal discussion about how NeWS fit into Sun's window system strategy. We developed a prototype X11 window manager in NeWS, to prove how much better NeWS can handle seamlessly integrated NeWS and X window management much better than X can manage its own windows. The next step we wanted to take was to write a user-extensible HyperCard-like window manager using HyperNeWS/HyperLook. But Sun management wasn't having it. They actually wanted to do the worst-possible upside-down solution and put NeWS applications inside of X-Windows managed by OLWM, precluding the possibility of arbitrarily shaped windows, tabbed windows, pie menus, all stuff we'd been doing for years with NeWS that we'd have to give up in the name of X interoperability, after we'd already proven we had a working better solution with "owm".

https://donhopkins.com/home/archive/NeWS/owm.ps.txt

>% Open Window Manager

    /ClassX11ManagerMixin ClassWindow
    [/IconWindow /WidthInc /HeightInc /FirstMapping]
    classbegin

        /NewInit { % client => -
            /NewInit super send
            self /WM_STATE xdeleteproperty % The frame is not a ICCCM window
        } def
https://www.donhopkins.com/home/archive/NeWS/sevans.txt

>Don> If you don't want to dump NeWS, then why have you been caused us so much trouble?

>Steve> I could ask you the same question, "If you want NeWS to be a commercial success, why has NeWSTech been so subborn in the sense of resisting trying to fit into the X environment."

>Don> That's not the same question. We want NeWS to be a commercial success, but "commercial success" is not a standard defined by the X Consortium. I think OWM can do a beautiful job of fitting the X environment into NeWS. If you find that concept terrifying, then you know how we feel about the inverse, knowing that we will have to give up many goals we designed for and successfully achieved, in order to accomodate a half assed "fallback" solution to satisfy some of our customers who want to run our competitors' software (because we aren't allowed to make our software good enough for them to want to run).

>We have had a great deal of trouble trying to fit into the X environment. It has taken a huge amount of PostScript code to deal with many X interoperability issues ranging from undocumented selection protocols that XView and OLIT can't even agree on, to input focus grabbing kludges to work around OLWM's incorrect focus tracking behavior, to the fullscreen.ps hack to keep X from grabbing the pointer when NeWS is tracking it. Then there are problems we could do nothing about, like the system locking up when OLWM grabs the server (grabbing the pointer after grabbing the server, and not checking the return value). Many of these problems should have been addressed by fixing X programs or the server, but they were not, instead we had to code around them in PostScript when we could.

NeWS had its own problems, of course, but its biggest problems weren't technical, but political, and it wasn't free despite all the hard effort, spilled blood, and broken promises. But the consequences of that experience did help to make Java free, eventually. (But then Oracle later ruined worse than Sun ever could have.)

https://news.ycombinator.com/item?id=22457490

>James Gosling fought very hard for NeWS, but in the end failed to convince Sun to do the right thing. He was optimistic when he talked me into going to Sun to work on NeWS after I'd already given up on it by 1990, saying that Sun had turned over a new leaf, and was soon going to announce their commitment to NeWS: [...]

>"We'll get it out, even if I have to spill some real blood on the floor." -James Gosling, on freeing NeWS, March 6, 1990

>[...] It has been very clear for a long time that DEC explicitly targeted NeWS as something to be trashed. That was probably the major reason for giving NeWS such a ridiculously low profile. There were folks at sun who didn't want to give DEC a bigger target. The folks running the show now have more guts.

>James.

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

>November 11, 1990:

>I have been hoping for Sun to make Open Windows free since it was called SunDew, and during that time, I've made it perform many indescribable acts (both on and off stage), worked with quite a few companies trying to make it a succeess, and drained much much more of my energy than I ever knew I had to give into that incredible piece of software.

>I have been following the messages on the network in the aftermath of the OWPS "free for $1000" disaster... The big problem was not the $1000. It was the word "free".

Re: How X Window Managers Work, and How to Write One (2014)

#142
I used to write an X11 window managers as a kick-the-tires exercise when learning a new language. The most fun one was Common Lisp with CLX. You could stay in the WM and code it live. When something went wrong you could continue after making fixes. It’s what lead me to Common Lisp being my favorite language going on decades now.

Re: How X Window Managers Work, and How to Write One (2014)

#143
post #83
post #74

Earlier quoted context omitted.

Xdotool and xsel have had Wayland equivalents for years: see ydotool/wtype and wl-clipboard. The reason why major orgs have had to push for Wayland is the same as the reasons they had to push for HTTPS and TLSv1.2, unique passwords, keeping software up to date, etc: using outdated and insecure software with significant attack surface has real costs even if it's convenient.

All "equivalents" you mention have less functionality than their originals and some only work on specific compositors like wlroots/sway. Like all things Wayland it's a mess with zero benefits for the user. HTTPS vs HTTP is a false equivalent. HTTP works just fine like before. X11 can be made fully secure (e.g. QubesOS does it) but nobody uses it because there is really no need on a FOSS system where 100% of clients y…

When your solution to "make something secure" is to isolate instances of it in airtight sandboxes, IT IS NOT SECURE.

Theoretically Xorg can be made fully secure: just isolate clients so they can only receive events and bitmap information from windows created on the same client connection. It would be relatively straightforward, if quite involved, to implement.

But nobody wants to implement it because everyone qualified to do so has jumped ship to Wayland. The X architecture is so fatally flawed that the most straightforward way to fix it is to start from scratch, and that's what Wayland is.

X is like global warming: one hundred percent of the people who are in the least wise knowledgeable agree that it is a problem. Unlike global warming, however, that problem has a fix: Wayland.

So just... shut up with the irrelevant bullshit and use Wayland, like all the Linux graphics maintainers and distro maintainers want you to do and have been telling you to do for years now... or find your shit unsupported.

Re: How X Window Managers Work, and How to Write One (2014)

#144

This is a great article and I remember reading it numerous times while I was implementing my own window manager. For someone interested in working on a really fun and rewarding hobby project a WM is a great one to look into since there are so many resources starting from really small implementations: - https://github.com/mackstann/tinywm - https://github.com/venam/2bwm - https://github.com/dylanaraps/sowm - https://g…

nitpick but X11 is the protocol XCB speaks. You're probably speaking of Xlib which is a bit of a higher level library over the top of it (but... not really that much higher, for a great many tasks there's no real difference).

Re: How X Window Managers Work, and How to Write One (2014)

#145
post #112

Earlier quoted context omitted.

Mid 80s hardware, actually. Recreational Bugs talk [1989] by "Sgt." David Rosenthal (author of the ICCCM, the Andrew Window Manager, and NeWS, and an old friend), who explained the 80's era X-Windows hardware model and war on drugs quite well here: https://blog.dshr.org/2018/05/recreational-bugs.html >"You will get a better Gorilla effect if you use as big a piece of paper as possible." -Kunihiko Kasahara, Creative O…

You think this is bad? Just look at a native Wayland "Hello World" client [1]. This doesn't even print hello world. You have to do the text rendering yourself. And you need at least 500 more lines to implement the equivalent to a simple XGetImage() call. 1.: https://github.com/emersion/hello-wayland/blob/master/main.c

Your toolkit should abstract all that away. We have these wonderful things called dynamic libraries, that X was designed for a world without because they didn't exist under Unix yet.

Re: How X Window Managers Work, and How to Write One (2014)

#146
post #61
post #51

Earlier quoted context omitted.

Security would be the worst reason. Zero cases in the wild, and it's not that difficult to add access checks to X - there used to be an X extension to do this. The real reason would be that X contains lots and lots of cruft which isn't used anymore and it made development&testing impossible.

> Zero cases in the wild Follow along this post and you'll end up with one case in the wild all by yourself on your own machine: https://theinvisiblethings.blogspot.com/2011/04/linux-securi... Xace was designed to address the mess that is Xsecurity and using the SELinux sandbox for GUI apps, except Xace barely works for mitigating exploits well on the desktop; it's so finicky that Dan Walsh himself concluded that XAC…

I read the article, I'm still not clear on why it's a problem. I'd have a very big problem if another user, using my machine via x forwarding, could capture my inputs, but that doesn't seem to be the case here? It seems that this is only for applications running on the same display.

So, to be blunt, this 'security feature' breaks a whole hell of a lot of use cases. If wayland wished to go down this route they should have displayed a prompt to the end user 'this application wishes to record the screen, that ok?'. The last time I made this point someone snidely informed me that 'this was not wayland's responsibility'. I'm sorry, if you break my use case you make it your responsibility!

Re: How X Window Managers Work, and How to Write One (2014)

#147
post #137
post #57

Is there anything similar for Wayland? Its protocol looks considerably more complex than Xorg's, and so are most resources to learn it.

It's quite ardous and unfun, but the wlroots project does most of the heavy lifting. For beginners it's probably useful to create a toy WM using wlroots[0] and dig deeper from there[1]. [0]: https://gitlab.freedesktop.org/wlroots/wlroots/-/tree/master... [1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/wikis/Getti...

The last time I used wlroots, via sway, I encountered a bug where I experienced 'multicolored snow' when watching a video in firefox. I wanted to record a video of it to report a bug, but of course that wasn't possible because screen sharing / recording still isn't well supported. Back to gnome I went, and I still don't think wayland is ready for primetime on smaller window managers

Re: How X Window Managers Work, and How to Write One (2014)

#148

So for someone who knows nothing about this stuff, how is Wayland different?

People have already mentioned wlroots as a starting point, but there is a less opinionated and more compatible (NVIDIA-ready) library that I’m really quite fond of called Mir: https://github.com/MirServer/mir

One thing to note, Wayland, unlike X, does not support server side decorations yet, so compositor’s responsibilities are mostly just placing windows.

Re: How X Window Managers Work, and How to Write One (2014)

#149
post #37

Earlier quoted context omitted.

> So having your problems ignored is something you'll have to get used to if you choose to use hardware that requires proprietary drivers 3..2..1 and the floss copy pasta has arrived a bit delayed but still as expected. Might want to check if the server your bot is running on is a bit overcapacity to fix that delay. Still not going to amputate my leg over a stubbed toe even if RMS considers the toe cancer. > GBM is t…

I really don't see why a bunch of unpaid volunteers should bother to support the only player in town that refuses to play nicely and tries to strong-arm everybody else to use its technically inferior solution. Here's a nice write-up. I can imagine how nice it is to spend all your waking time trying to improve the Linux graphics stack and then listen to all the bullshit that we see in this discussion. https://drewdeva…

The effort to improve is welcome and appreciated.

Casting multi-use graphical computing aside is unwelcome.

Most of the toxicity centers on HOW that discussion has played out.

To be fair, many users coming up on single user graphical computing have no idea what the problem is, do not have use cases and we all know the rest.

The users who do understand all that are pissed. They are being told none of it really matters or is necessary, and so on...

Of course all that is definitely not appreciated however spiffy watching videos about it all may be.

And, those users totally get the need to see the embedded use case improvements get done, and still are being asked to just forget multi user graphical computing was ever a thing because reasons...

So yeah, here we are.

People will care about Weyland exactly as much as the Weyland team cares about them.

Multi user graphical computing aware users are not cared about at all despite their repeated explanations on how they depend on that capability. Depend, as in, not having it becomes very expensive for them. Expensive enough to wash away all the value they are being told matters more to everyone else.

Non multi user graphical computing aware people basically just want it settled so they can have few overall worries. They feel some care aimed their way.

The embedded people are super happy and are cared about a lot.

All adds up to a very toxic state of affairs.

Factoring it all down:

Did we absolutely have to trade multi user graphical computing away?

Should the answer be no, this whole ugly mess will go away.

Continuing with a yes means a very painful and drawn out mess for years to come.

And it will be that way because there are plenty of people who really do get a lot of value out of multi user graphical computing.

Who knew?

I bet the former X devs did. And they just do not care.

Why exactly should they get any back in return?

Re: How X Window Managers Work, and How to Write One (2014)

#150
post #112

Earlier quoted context omitted.

You think this is bad? Just look at a native Wayland "Hello World" client [1]. This doesn't even print hello world. You have to do the text rendering yourself. And you need at least 500 more lines to implement the equivalent to a simple XGetImage() call. 1.: https://github.com/emersion/hello-wayland/blob/master/main.c

Your toolkit should abstract all that away. We have these wonderful things called dynamic libraries, that X was designed for a world without because they didn't exist under Unix yet.

If toolkits can "abstract that away" they can do the same on X11 and there is even less reason for Wayland to exist. There is no reason for you to even care about X11/Wayland if you only work with toolkits. So stop participating in a discussion that doesn't concern you.
Post reply on HN