120 points · by signa11 · 3y ago · 77 comments
With XEmbed, what may look like a single window is actually multiple windows all managed by different processes with their own render loops.
Speaking of XEmbed, many years ago, we had an application that ran complicated visualization pipelines. We wanted to add a modern GUI around it to configure it and provide interaction. We didn't have the ability to rewrite the original application, so we wrote a Gtk GUI and used XEmbed to embed the other process in it, then used a unix socket to send commands back and forth. To the user, it was seamless and worked really well!
On Wayland, each window is a composer, each component that makes up a screen is a compositor. Don't mid them up. Simply put each window manages their own process tree as its much cleaner. Its very simple. What you need to do is simply install dbus-systemd and issue SummonPoettering which will give you a clean docker workspace. Simply put this is far superior to X11. In short on Wayland, you only need to push one button to kill an errant window - the power button
Because it was built in a different time. Back in the 80s and early 90s, X11 provided a way for institutions and companies to mix-and-match their hardware and software environments, each with different capabilities. They would have big iron running expensive software and cheap(er) terminals that could display those applications across a campus.
In a university environment, before there was a PC and network in every dorm room, before laptops were a thing, this was awesome. You could walk up to any workstation or X11 terminal on campus, and immediately have access to all of your applications, files, and everything else. And when PCs and networking came to the dorms, you could get an X server for your PC and do the same.
But those days are long past; the networking use case, which was one of the most important aspects of X11, is pretty much no longer relevant. It's really surprising that Wayland still hasn't completely taken over, and they still haven't figured out how to handle certain interprocess communication that would allow screen sharing and other common desktop functionality.
// 1. Open looking glass: Alt+F2 > lg
// 2. Use picker to pick window (button on the top left corner).
// 3. Now an object r(0) of type MetaSurfaceActor is available in the
// gjs console (or some other number if you've already used it).
// To get pid:
r(0).get_parent().get_parent().get_meta_window().get_pid()
// To kill window and process:
r(0).get_parent().get_parent().get_meta_window().kill()
Reference for what those .get_parent() refer to:
https://gitlab.gnome.org/GNOME/mutter/-/tree/fc1de744/src/co...As a frequent user of xkill I was surprised by that too, but I remember reading somewhere that making a terminal application kill another application's window is not allowed by design. Reusing a sibling commenter's analogy, it's kind of like some javascript functions in the browser can only be triggered by user actions for security reasons.
The compositor, however, is allowed to kill the windows it's showing. So if you want to kill a window, you can ask the compositor to do it for you. Gnome, KDE [0], sway [1], etc.. each expose this functionality in a way that differ between each other.
[0] https://www.reddit.com/r/kde/comments/1242w2e/wkillsh_an_xki...
[1] https://www.reddit.com/r/linuxquestions/comments/ufw7tj/is_t...
A lot of what X11 does is instead handled by Wayland "compositors", they deal with almost all such policy logic. This is largely the same situation as on Windows or macOS, which Linux desktops are finally starting to catch up to.
And not correct: Processes can have multiple windows. Or no windows.
Surely the summoning of Leinart Poettering's spirit to find dead Pids in Waylands Hades was a dead giveaway
Hasn't it been pretty much ossified for the last 30 years?
I suspect HN is really run by a hyper-intelligent A.I. which is guiding us all to a brighter future.
And 99% of the time the answer will be a locally running process, which makes it a highly pertinent question even without the caveats.
It’s not clever to point out that a question may not have a simple answer and therefore to reject the question as flawed.
It was written back when huge enormous servers were the only systems with enough oomph to do anything useful, and those servers had 128mb of ram (think of something like a sun 3/480 with a 33mhz 68030).
It was common to have a room of X terminals each with 1-8mb of ram for a 15-19 inch display (with 1-8bit color). In that context, everything ran on another system, often you'd have processes running on several different systems and you'd have to be careful about managing authorization otherwise people would figure out your DISPLAY and run their programs against your X terminal (innocuous, like 300 Xeyes programs or malicious like a keyboard snooper, depending on where and when).
In 2020 this whole scenario sounds absurd, but it was the way of things from when X11 was designed and through the first 15 years of X being a thing.
In some ways, the question is like asking "what is the process ID that generated this http response?"
[edited to add the analogy]
It's not really absurd at all. In fact, the increase in processor speed, core count and installed RAM means that it even more likely that in a given context, a single desktop computer system has far more capacity than a single user needs.
So, you extend the number of users that can utilize that capacity by sitting them in front of an X Terminal, which from their perspective is just like sitting in front of the "real" monitor of the machine.
This doesn't make sense for gamers, compile-happy developers or data crunching, but then this model never made sense for those use cases. But a dentist's office with a central desktop and 8 users? You just don't need 8 computers - 1 computer plus 7 or 8 X Terminals is far better use of resources.
X11 is a distributed systems non-meshed networking protocol, that outputs to screens as a side effect.
Knowing about Erlang dist and figuring out how to do X11 a few years ago, everything makes a lot of sense. Except for xlib. xlib is a bit better now, but it turns a pretty decent (but certainly not without flaws) async protocol and implements blocking synchronous calls... And then most toolkits were based on that. Sometimes you really do need to wait for a reply, but so many things don't need it, and all the waiting makes actually networked X much less usable.:(
This was always good for fun gags. In the 1990s I worked at a company where all the developers used X terminals on an HPUX host. If you were bored you could run little programs that made all the windows on someone else's terminal melt, or flip around, etc.
Why ? I use Citrix at work in 2023 and nobody thinks it absurd to run the program on another computer and display it on yours.
Except the wayland developers (last i heard). /s
Depends on the environment - for years I used either an HP X terminal or a PC running an X server and the one thing I could be confident about in both cases was that the process wasn't running locally.
Mind you - that wasn't recently!
But but but what does xkill use internally to figure this out. Can we just use that?
It literally is using XKillClient - https://linux.die.net/man/3/xkillclient
You can kill the connection of another client if you know its id. That's one of the reasons why we love X11 so much.
Another way, as josefx mentioned, is to kill the PID from _NET_WM_PID window property. This is often used by window managers when they offer to kill an unresponsive application.
Kill it and quietly listen to see if anyone in the office immediately screams. If so, quickly restart it and log out. Otherwise move on with your day, and wait for any angry emails.