Open SnosMe opened 1 year ago
https://github.com/Ac5000/electron-overlay-window/tree/wayland
This write-up can also be found in the "wayland" branch, under the "wayland" directory as "Issue28.md"
To start, I am a user of awakened-poe-trade and I would like to thank you for making such a great tool!
I recently switched from Linux Mint (X11) to Hyprland (Wayland). APT worked flawless in Mint/X11, but I couldn't get it to work well in Wayland.
I looked through the issues on APT to see if I could find anything and then realized APT seems to rely on electron-overlay-window.
I then found this Issue #28 when troubleshooting and decided I would try to help as best I could.
I tried to see if I could figure things out, but realized I was in over my head, but maybe I could compile the information for you to figure things out.
Please let me know how I can help!
I can run tests for you, hunt down information, etc. My skills as a programmer, mostly not knowing JS and being weak in C, hinder my ability to just take this and fully find a solution. But, I can take orders, follow instructions, and I'm willing to try to help! It would be great if we can get APT working in Wayland before the league start.
My pc can be booted into Windows 10, Linux Mint (X11), Arch Linux with Hyprland (Wayland), and Arch Linux with KDE Plasma (Wayland). I can run various tests as needed but will need detailed instructions to do so. I managed to get the demo to "load" but it fails to hook in to things with Wayland.
Links to references that may help:
Wayland Explorer-Wayland Breakdown of the Wayland protocol in an easier to read format than XML.
Wayland Explorer-XDG shell Breakdown of the XDG shell protocol. Cross-Desktop-Group (XDG) helps make things usable across different desktop environments so you don't need to program things for specific environments.
Wayland Protocol Book Book describing Wayland protocols. Not finished as it stops at ~10.4.
hello-wayland - Example Code This repo shows how to make a wayland window and generate the protocol files with a Makefile. I have included a modified version of main.c, and a generated protocol files for reference.
zero to window - YouTube Video The person in this video gives a full example of starting with nothing and ending with a working wayland window.
From what I have seen stated in README.md, you need:
for the X11 implementation?
Let me know if that's correct, and if there's other things you need? I will attempt to find/translate them for you.
Something you may need to look into is how Wayland does global shortcuts. See Global Shortcuts for more information.
What I am attempting to do here is translate the X11 requirements to their Wayland versions and show how I understand them to work.
My intention is that you will see these and understand how to implement them into the overlay app.
I need more details for this one. Are you using this to see if the overlay is active? Or do you use it to see if the window you are trying to attach to is active?
Example of this can be seen in main.c line 106:
xdg_toplevel_set_fullscreen(xdg_toplevel, NULL);
Line 112 shows unsetting:
xdg_toplevel_unset_fullscreen(xdg_toplevel);
Example of this can be seen in main.c line 244:
xdg_toplevel_set_title(xdg_toplevel, "Hello Wayland Ac5000");
For security purposes, Wayland doesn't just give every window the current keystrokes. (Keyloggers for example.) The application has to have focus.
Because of this, xdg-desktop-portal can register shortcuts for your application.
Electron is aware of this as well and has this open issue on their tracker. I suspect this may get fixed by them soon considering most Linux distros are now ready to move fully into Wayland with the Nvidia explicit sync fix recently.
In the wayland directory of the wayland branch, I have included a few files.
main.c
is a modified version of the same file from here.
You will need to look at the repo to see how to run the program fully, but I
believe it's a good starting file for showing the basics. The YouTube video
link in the References section ended up with a very similar
looking file.
xdg-shell-client-protocol.h
and xdg-shell-protocol.c
are generated via the
"wayland-scanner" binary that comes with the wayland package on Linux. The
Makefile
shows how this is done on line 9.
_NET_ACTIVE_WINDOW to get currently active window, _NET_WM_NAME to get the name of that window, _NET_WM_STATE_FULLSCREEN to know whether it's in fullscreen, but this one is needed for X11 behaviour, maybe can be skipped in wayland.
_NET_ACTIVE_WINDOW to get currently active window, _NET_WM_NAME to get the name of that window, _NET_WM_STATE_FULLSCREEN to know whether it's in fullscreen, but this one is needed for X11 behaviour, maybe can be skipped in wayland.
Thank you for the information and sorry for the delayed response, league start has consumed my available time to work on this. However, I am almost done with my 40 challenges and plan to come back to this hopefully soon.
I wanted to let you know that I am trying to get an example working with your "demo" using Rust. There are multiple Rust libraries created that handle most of the Wayland and XDG backends and it's simplified things down tremendously.
It is slow going though as I am having to learn Rust along the way. But I do have a test program partially working that makes a window, displays something, gets/sets the name of the window, and sets up global shortcuts with xdg-desktop-portal. Next steps are linking into the electron side of "overlay-window" and seeing if I can get the demo to work.
Once I get things working, I will add a link to the repo with a write-up that shows what's going on.
It may be possible to implement at least on KDE? https://wayland.app/protocols/kde-plasma-window-management