Getting pid of focus window

Marty Jack martyj19 at comcast.net
Mon Jan 17 16:00:14 PST 2011


This is (a) really the wrong place to complain about the X Window System and (b) this mechanism has all been in place and stable and heavily used for many years and is not likely to change in any significant way.

Concerning what is going to be done in Wayland, we are not to the point of designing these parts quite yet.  I am confident there will ultimately be mechanisms since people will want to write desktop environments over Wayland.

Concerning your points 2 and 3.

If you were to refer to http://standards.freedesktop.org/wm-spec/wm-spec-latest.html

you would find the _NET_ACTIVE_WINDOW root window property and the _NET_WM_PID property on the toplevel application window.  All EWMH conforming window managers would be expected to set these.  If there is a window manager that doesn't, (a) it would be surprising and (b) you should complain to them so they fix it.  A lot of taskbars highlight the button for the application that has focus, and this works reliably as far as I know.

Having written a desktop environment I know that this is not unusually difficult.  When you start, you read the properties you are interested in, and then you listen for PropertyChange events on the root window and there you have it.  You can read the _NET_CLIENT_LIST any time you want to know all clients at any given moment.

I do not understand your point 1.  You need the same permissions to XOpenDisplay that any client would need.  Typically you do not need any privilege on the same machine provided you have the authorization cookie in getenv(XAUTHORITY) or you have xhost +local:.  As you may be aware Wayland is proposed to be local only so although I do not speak for the designer I do not think it is planned to have any authorization whatever.

On 01/17/2011 06:11 PM, Daniel Poelzleithner wrote:
> Hi,
> 
> this weekend i wrote a plugin for ulatencyd which tries to get the pid
> of the window in focus so the program can get scheduled with more cpu
> slots then other programs. I don't want to flame on X11, but it is
> 1. Terrible to do. Even with root permissions you need workarounds just
> to connect.
> 2. The window manager needs to set a property on the root window which
> window has focus (not everyone does), and complete transversal is just
> stupid. Gnome and KDE do at least.
> 3. The toolkit needs to set the pid and hostname on the window property.
> QT and GTK do at least.
> 
> I have only looked roughly at wayland, but haven't seen an API for this.
> If not, could you add an API for getting such information please.
> 
> Kind regards
>  Daniel
> 
> 
> 
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list