2

私は、windowmanager (悲しいことに、特定のものではありません。twm、dtwm、mwm、metacity など)、myApp、およびその他のウィンドウ付きアプリケーションを備えた x11 ディスプレイを持っています。他のアプリケーションが閉じられていて、myApp がディスプレイ上にウィンドウを持つ唯一のアプリケーションである場合は、ディスプレイを閉じたいと思います。myApp のウィンドウは知っていますが、ウィンドウマネージャーのウィンドウと他のアプリケーションのウィンドウをどのように区別すればよいでしょうか。

現在、 xwininfo -tree -root -children でポーリングし、これを期待しているものと比較していますが、これは「明確に定義された」環境でのみ機能します。

上記のウィンドウマネージャの多くは EWMH をサポートしていないようです。

4

1 に答える 1

1

There isn't going to be a completely non-hacky way.

The ICCCM recommends identifying toplevel windows (as opposed in particular to WM frames) by looking for the WM_STATE property. So you could distinguish application windows with that. However, when the WM reparents the window into a frame it'll get tricky to find the app window inside the frame window. You'd have to implement a little program to do something like xwininfo -tree but only check for windows with WM_STATE set.

A relatively nice solution would be to use libwnck, or one of the tools based on it (wmctrl, devil's pie). However, this requires an EWMH window manager (which includes anything remotely modern or sane, but it sounds like you are dealing with some really old curmudgeonly stuff). The advantage of these tools is that they use EWMH to identify application windows and even the semantic type of those application windows (dialog, etc.).

Also, libwnck removes the need to poll, it can just watch for changes in the toplevel window list.

于 2010-04-30T19:34:55.327 に答える