Finding modal dialogs
Glynn Clements
glynn at gclements.plus.com
Sat Oct 28 14:10:32 PDT 2006
Suma Byrappa wrote:
> I need to fnd out if a dialog (or window) is modal or modeless using
> Xlib APIs. What can I use to differentiate between modal and
> modeless?
You can't; at least, not reliably. So far as X is concerned, a window
is a window.
Whether or not a dialog is modal depends upon how the application (or
the toolkit which it uses) treats it. Toolkits typically implement
modal dialogs by ignoring user input events sent to other windows
while a modal dialog is being displayed.
The fact that certain events are being ignored is internal to the
application. You can't reliably detect this from another application.
> I found few topics which mention about override_redirect and
> WM_TRANSIENT_FOR properties. But, when I read the properties of
> dialog windows, they don't match with the usage of
> override_redirect.
If a window has a WM_TRANSIENT_FOR property, it's likely to be a
dialog (rather than e.g. a "document" window), although not
necessarily a modal one. However, nothing forces an application to set
this property on modal dialogs, and nothing prevents it from setting
it on other windows. However, this is the closest that you're likely
to be able to get to determining whether or not a top-level window is
a dialog.
The override_redirect flag is a separate issue. This is used for
windows which should be completely ignored by the WM, e.g. pop-up
menus, tooltips, etc. Any window with this flag probably isn't a
"dialog" of any sort.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the xorg
mailing list