XScreenSaver, Wayland and locking.

Welp, I got crickets in answer to my question, "How do I find the wl_surface backing an Xwayland X11 Window?" and that does not bode well for XScreenSaver ever being able to lock your screen on Wayland. The only...
https://jwz.org/b/ykrj

Welp. All that lovely "AI" derailment aside, we now have an answer:

It is literally impossible for XScreenSaver to lock the screen under Wayland. Cannot be done. None of the extant, spottily-supported "protocols" will allow the screen to be locked while an Xwayland surface is visible.

Great job, everybody. Perfect, no notes.

I guess locking your screen is for cowards, anyway. What do you have to hide?
@jwz Xfce might be working on something in Xfwm in their Wayland support...
@jwz *groans; pained cries*
@jwz I use gnome on wayland. I press ctrl+L and it locks. Human verified, non AI answer
@vicho See now, you could have just *not* typed this and then everyone wouldn't know you're a moron.
@vicho @jwz So I can't refresh a terminal screen? X11 is such a vast improvement on its successors.
@jwz Why would you need to lock your screen? Do you have something to hide?

@jwz see this?
😒
This is my surprised face.

Oh, wait. No. No, it isn't.

@jwz

That is a pretty tricky thing to support, I'd imagine, given the differences between Wayland and X11. Is there a specific reason you want to use a locker via XWayland instead of the various Wayland native screen lockers that exist?

@boo_ Show me how to make any of the extant native screen lockers run an arbitrary graphics-drawing program of my choice while the screen is locked.

Go ahead, I'll wait.

@jwz

I don't have this usecase myself so I haven't tried it but wscreensaver with swaylock-plugin looks like the obvious solution for both screen locking and screen savers.

@jwz @boo_ I do not think it meets your criteria for xscreensaver, but maybe swaylock-plugin (a fork of swaylock) would be helpful in your research? ​

Edit: Sorry for spam. I was too slow and missed the latest reply.

@jwz I haven't done much X programming since you and I last met at the Raleigh Linux Expo, so I don't really understand the question or answer, but Clade did some deep research and came up with:

To find the wl_surface backing an Xwayland X11 Window, you need to:

1. Legacy method: Listen for WL_SURFACE_ID ClientMessage on X11 windows (requires SubstructureRedirect on root
window), extract the surface ID from data.l[0], but beware of race conditions.

...

@jwz ...

2. Modern method: Use the xwayland-shell-v1 Wayland protocol with WL_SURFACE_SERIAL ClientMessage to establish a
robust, race-free association.

For xscreensaver, this requires becoming a hybrid X11/Wayland compositor to properly map screensaver windows, which
is a significant architectural change.

@jwz Here is the full answer by Claude: https://pastebin.com/XF1Jxxq2
● TL;DR To find the wl_surface backing an Xwayland X11 Window, you need to: - Pastebin.com

Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

Pastebin

@jafo You just pasted un-tested and un-verified AI slop at me?

Are you fucking *kidding* me??

@jwz Yeah, that's pretty much the response I expected. I did spend $4 on something which I hoped might have had an idea you weren't aware of, particularly as you "got crickets" previously, but I'll admit I'm not surprised by your response. I'm sorry it was, apparently, of zero use and wasted your time. I'd have appreciated if you acked that I spent some of my time and literally money and giving a TL;DR so you could say "tried it" and move on with your life, but again, not surprised.

@jafo Not only was it unhelpful, it was the diametric opposite of helpful. You used the rainforest-incinerating autocomplete plausible-lie-generator to not only not answer my question, but also remind me that I share a planet with people who don't understand why this is not a good idea.

"Everyone in this room is now dumber for having listened to it. I award you no points, and may God have mercy on your soul."

@jwz @jafo reminds me of Cloudflare using AI to vibe code an oath library despite many warnings. Claims were made, but they still ended up with serious exploits. Just because the AI claims something about low-level, technical code that does not mean anything is accurate... only that it *seems* accurate.
@jafo @jwz this would be funny if it wasnt so sad.

Like The opposite of "let me google that for you", let me AI slop that for you.
@jafo I saw it. Thanks for trying, Sean.
@jwz so when jwz_protocol ?

@jwz I'm not sure whether the Xwayland thing would have worked, even if you had been receiving messages.

In general, one client won't be able to reference surfaces created by another client. So that protocol would only be useful if the X client receiving the messages happened to be the Wayland server.

If the session-lock protocol expects you to provide a surface, then it would need to be a surface that you control.

@jwz What would be involved in locking a screen without using Xwayland? Would claiming exclusive use of the USB keyboard and mouse be enough? Cause I think that's possible to do, assuming Xwayland doesn't already do it for itself. You'd also have to watch for new USB devices appearing. And of course it would only work on local screens, so check for that somehow. </handwave>