svenstaro / wmfocus

Visually focus windows by label
MIT License
217 stars 20 forks source link

Support for EWMH-compliant WMs #4

Open b0o opened 5 years ago

b0o commented 5 years ago

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.

svenstaro commented 5 years ago

Yeah, that's my hope as well. Do you wanna take a stab at this?

b0o commented 5 years ago

@svenstaro I've honestly never written Rust, but I may give it a go if I have some free time.

svenstaro commented 5 years ago

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?

b0o commented 5 years ago

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:

This is about all the time I have time to dig in right now, maybe this gives you some ideas?

t-wissmann commented 4 years ago

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.

rdiaz02 commented 2 years ago

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 ) .

svenstaro commented 2 years ago

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.

rdiaz02 commented 2 years ago

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).

svenstaro commented 2 years ago

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.

rdiaz02 commented 2 years ago

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.

DeafMan1983 commented 7 months ago

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!