Open b0o opened 5 years ago
Yeah, that's my hope as well. Do you wanna take a stab at this?
@svenstaro I've honestly never written Rust, but I may give it a go if I have some free time.
I don't really know how to get a list of visible windows on all currently visible desktops using xcb/xlib and there is no obvious way that I can see. Any idea?
Hmm, good point. I can only figure out how to determine the active desktop, list all desktops and the windows on them, but not necessarily a straightforward way to definitively determine if any given window is visible.
By playing around with wmctrl, xdotool, and xprop, and examining their sources, I can determine:
xprop -root
: https://gitlab.freedesktop.org/xorg/app/xprop/blob/master/dsimple.c#L209RootWindow
or DefaultRootWindow
function (man AllPlanes(3))
Display *disp = XOpenDisplay(NULL);
Window *root = DefaultRootWindow(disp);
wmctrl -d
: https://github.com/dancor/wmctrl/blob/master/main.c#L1063_NET_CURRENT_DESKTOP
on the root (and/or possibly _WIN_WORKSPACE
?)_NET_DESKTOP_NAMES
on the rootwmctrl -l
: https://github.com/dancor/wmctrl/blob/master/main.c#L1323
_NET_CLIENT_LIST
on the root_WM_STATE
This is about all the time I have time to dig in right now, maybe this gives you some ideas?
I don't really know how to get a list of visible windows on all currently visible desktops using xcb/xlib and there is no obvious way that I can see. Any idea?
You simply need to iterate over all windows mentioned in _NET_CLIENT_LIST
(all windows, as specified by EWMH) and for each window check whether the first entry of WM_STATE
is 1 ("NormalState", i.e. not Iconic or Withdrawn; specified by ICCCM). This gives you all visible windows.
In https://www.reddit.com/r/bspwm/comments/qf0jd5/switching_and_swapping_windows_with/hi9ppyy/ @ortango has provided code that allows wmfocus to be used from bspwm . (This is also available with the additional needed modifications in Cargo.toml and main.rs from https://github.com/rdiaz02/wmfocus/tree/stdin ) .
I'd definitely accept a patch but with bspwm I suppose the bspwm client tool should be called in get_windows()
. I suppose overall it wouldn't be too hard to integrate. The posted patch does things in a fairly awkward way and needs to be done differently.
Sure, I understand. However, I am not the author of the patch, and I know no Rust, and almost no bspc, so I won't be able to contribute this anytime soon. The intention of posting it here and placing it in a repo was so that other people searching around could find it (either for using as is, or for preparing a patch that could be integrated).
I might try but then again I don't really run bspwm anymore and I can't support the feature so well. It'd be much better added and maintained by someone who uses it as their daily driver.
That would be great (I plan on moving to bspwm around Christmas, so I could test it and I assume many other bspwm users would be interested). And, of course, I understand that ideally this would be added and maintained by someone who uses bspwm daily.
Sorry it is old. I know far. I would like to suggest about libxcb and xcb's extensions from gitlab should to compile with --enable-static --enable-shared if you have to test with Rust then you would like to publish as end-usable program without required libxcb or xcb's extensions ( You just can compile with gcc -Wl,-Bstatic lxcb -lXau -lXdmcp -lxcb-util (....) -Wl,-Bdynamic -lc
(....) means other xcb's extensions like xcb-image, xcb-cursor, xcb-composite etc... they should to be statical in Rust program and you won't to get worry.
Or I have made with C# Dotnet 7.0/8.0 and it is very beautiful single executable.
Please remember that:
You can check in terminal:
LD_LIBRARY_PATH=. ./your_rust_program
If your_rust_program throws errors cause your_rust_program doesn't build with statical libxcb.a etc ....
I hope you understand my suggestion and my suggestion helps you. Sorry my bad English...
Best regards!
The EWMH specification defines a set of interactions between window managers and external tools like docks, status bars, and other desktop-environment related utilities.
An incomplete list of EWMH-compliant window managers is (via Wikipedia):
There is a Rust package, xcb-util, which provides a wrapper around the Linux libxcb-util (X protocol C-language Binding), including a wrapper around the libxcb-util EWMH implementation.
A quick glance at the package leads me to believe it provides the necessary functionality to create an EWMH implementation of wmfocus.