NAME
X11::Protocol::WM -- window manager things for client programs
SYNOPSIS
use X11::Protocol::WM;
DESCRIPTION
This is some window manager related functions for use by client programs, as per the "Inter-Client Communication Conventions Manual"
/usr/share/doc/xorg-docs/specs/ICCCM/icccm.txt.gz
Usual Properties
Any client window should generally
set_wm_class()to identify itself to programs ("WM_CLASS").set_wm_name()andset_wm_icon_name()for user-visible identification ("WM_NAME, WM_ICON_NAME").set_wm_client_machine_from_syshostname()andset_net_wm_pid()for the running process (WM_CLIENT_MACHINE and _NET_WM_PID).
Then optionally,
If the client has an icon then
set_wm_hints()with that (pixmap or window).If the user gave an initial size or position on the command line then
set_wm_normal_hints(). The same if the program has min/max sizes or aspect ratio to declare.If a command to re-run the program can be constructed, then
set_wm_command(), and preferably keep that up-to-date with changes such as which open file etc.
FUNCTIONS
Text Properties
Property functions taking text strings such as set_wm_name() accept either byte strings or Perl 5.8 wide char strings. Byte strings in 5.8 and all strings in earlier Perl are presumed to be Latin-1 and set as "STRING" type. Perl 5.8 wide char strings are stored as "STRING" if entirely Latin-1, or encoded to "COMPOUND_TEXT" for other chars (see Encode::X11).
In the future perhaps the string functions could accept some sort of compound text object to represent segments of various encodings to become COMPOUND_TEXT, with manipulations for such content etc. If text is bytes in one of the ICCCM encodings then it may save some work to represent it directly as COMPOUND_TEXT segments rather than going to wide chars and back again.
set_text_property ($X, $window, $prop, $str)-
Set the given
$prop(integer atom) property on$window(integer XID) using either "STRING" or "COMPOUND_TEXT" as described above. If$strisundefthen$propis deleted.$stris limited to$X->maximum_request_length(). There's no attempt to store very long strings piecewise. The protocol makes this limit at least 16384 bytes, but the server may allow more, possibly much more.
WM_CLASS
X11::Protocol::WM::set_wm_class ($X, $window, $instance, $class)-
Set the
WM_CLASSproperty on$window(an XID).This property may be used by the window manager to lookup settings and preferences for the program through the X Resource system (see "RESOURCES" in X(7)) or similar.
Usually the instance name is the program command such as "xterm" and the class name something like "XTerm". Some programs have command line options to set the class and/or instance names so the user can have different window manager settings applied to a particular running client.
X11::Protocol::WM::set_wm_class ($X, $window, "myprog", "MyProg");$instanceand$classmust be ASCII or Latin-1 only. Perl 5.8 wide-char strings with Latin-1 are converted as necessary.
WM_CLIENT_MACHINE
X11::Protocol::WM::set_wm_client_machine ($X, $window, $hostname)-
Set the
WM_CLIENT_MACHINEproperty on$windowto$hostname(a string).$hostnameshould be the name of the client machine as seen from the server. If$hostnameisundefthen the property is deleted.Usually a machine name is ASCII-only, but anything per "Text Properties" above is accepted.
X11::Protocol::WM::set_wm_client_machine_from_syshostname ($X, $window)-
Set the
WM_CLIENT_MACHINEproperty on$windowusing theSys::Hostnamemodule.If
Sys::Hostnamecan't determine a hostname by its various gambits then currently the property is deleted. Would it be better to leave it unchanged, or return a flag to say if set?Some of the
Sys::Hostnamecases might return "localhost". That's put through unchanged, on the assumption that it would be when there's no networking beyond the local host so client and server are always on the same machine and name "localhost" suffices.
WM_COMMAND
X11::Protocol::WM::set_wm_command ($X, $window, $command, $arg...)-
Set the
WM_COMMANDproperty on$window(an XID).This should be a program name and argument strings which will restart the client.
$commandis the program name, followed by any argument strings.X11::Protocol::WM::set_wm_command ($X, $window, 'myprog', '--option', 'filename.txt');A client can set this at any time, or if participating in the
WM_SAVE_YOURSELFsession manager protocol then it should set in response to aWM_SAVE_YOURSELFClientMessage.The command should start the client in its current state as far as possible, so the command might include a filename, command line options for current settings, etc.
Non-ASCII is allowed per "Text Properties" above. The ICCCM spec is for Latin-1 to work on a POSIX Latin-1 system, but how well anything else survives a session manager etc is another matter.
WM_ICON_SIZE
($min_width,$min_height, $max_width,$max_height, $width_inc,$height_inc) = X11::Protocol::WM::get_wm_icon_size($X,$root)-
Return the window manager's
WM_ICON_SIZErecommended icon sizes (in pixels), as a range and an increment above the minimum. If there's noWM_ICON_SIZEproperty then return an empty list.$rootis the root window to read. If omitted then read the$X->rootdefault.An icon pixmap or window in
WM_HINTSshould be a size in this range. Many window managers don't set a preferred icon size. 32x32 might be typical on a small screen or 48x48 on a bigger screen.
WM_HINTS
X11::Protocol::WM::set_wm_hints ($X, $window, key=>value, ...)-
Set the
WM_HINTSproperty on$window(an XID). For example,X11::Protocol::WM::set_wm_hints ($X, $my_window, input => 1, initial_state => 'NormalState', icon_pixmap => $my_pixmap);The key/value parameters are as follows.
input integer 0 or 1 initial_state enum string or number icon_pixmap pixmap (XID integer), depth 1 icon_window window (XID integer) icon_x \ integer coordinate icon_y / integer coordinate icon_mask pixmap (XID integer) window_group window (XID integer) urgency booleaninputis 1 if the client wants the window manager to give$windowthe keyboard input focus. It will do so with$X->SetInputFocus(), or ifWM_TAKE_FOCUSis inWM_PROTOCOLSthen instead by aClientMessage.inputis 0 if the window manager should not give the client the focus. This is either because$windowis output-only, or ifWM_TAKE_FOCUSis inWM_PROTOCOLSthen because the client will do aSetInputFocus()to itself on an appropriate button press etc.initial_stateis a string or number. The ICCCM allows "NormalState" or "IconicState" as initial states."NormalState" 1 "IconicState" 3icon_pixmapshould be a bitmap (XID), ie. a pixmap of depth 1. The window manager will draw it in suitable contrasting colours. "1" pixels are foreground and "0" is background.icon_maskis applied to the icon displayed. It can be used to make a non-rectangular icon.icon_windowis a window which the window manager can show when$windowis iconified. This can be used for a multi-colour icon, either by a background or by client drawing (in response toExposeevents, or updated periodically for a clock, etc). The window should be a child of the root and should use the default visual and colormap of the screen. The window manager might resize the window and/or its border.The window manager might set a
WM_ICON_SIZEproperty on the root window for good icon sizes. See "WM_ICON_SIZE".window_groupis the XID of a window which is the group leader of a group of top-level windows being used by the client. The window manager might provide a way to manipulate the group as a whole, for example to iconify it all. If iconified then the icon hints of the leader are used for the icon. The group leader can be an unmapped window. It can be convenient to create a window which is never mapped but just acts as the leader for subsequent windows.urgencytrue means the window is important and the window manager should draw the user's attention to it in some way. The client can change this hint at any time to change the current importance. (key => $value, ...) = X11::Protocol::WM::get_wm_hints ($X, $window)-
Return the
WM_HINTSproperty from$window. The return is a list of key/value pairs as perset_wm_hints()above(input => 1, icon_pixmap => 1234, ...)Only fields with their flag bits set in the hints are included in the return. If there's no
WM_HINTSat all or or its flags field is zero then the return is an empty list.The return can be put into a hash to get fields by name,
my %hints = X11::Protocol::WM::get_wm_hints ($X, $window); if (exists $hints{'icon_pixmap'}) { print "icon_pixmap is ", $hints{'icon_pixmap'}, "\n"; }initial_stateis a string such as "NormalState". The pixmaps and windows are string "None" if set but zero (which is probably unusual). If$X->{'do_interp'}is disabled then all are numbers.X11R2 Xlib had a bug in its
XSetWMHints()which chopped off thewindow_groupvalue from the hints. Thewindow_groupfield is omitted from the return in that case. (key => $value, ...) = X11::Protocol::WM::change_wm_hints ($X, $window, key=>value, ...)-
Change some fields of the
WM_HINTSproperty on$window. The given key/value fields are changed. Other fields are left alone. For example,X11::Protocol::WM::set_wm_hints ($X, $window, urgency => 1);A value
undefmeans delete a field,X11::Protocol::WM::set_wm_hints ($X, $window, icon_pixmap => undef, icon_mask => undef);The change requires a server round-trip to fetch the current values from
$window. An application might prefer to avoid a round-trip by remembering its desired hints and sending changes with a fullset_wm_hints()each time. $bytes = X11::Protocol::WM::pack_wm_hints ($X, key=>value...)-
Pack a set of values into a byte string of
WM_HINTSformat. The key/value arguments are perset_wm_hints()above and the result is the raw bytes stored in aWM_HINTSproperty.The
$Xargument is not actually used currently, but is present in caseinitial_stateor other values might use an$X->num()lookup in the future. (key => $value, ...) = X11::Protocol::WM::unpack_wm_hints ($X, $bytes)-
Unpack a byte string as a
WM_HINTSstructure. The return is key/value pairs as perget_wm_hints()above. The$Xparameter is used fordo_interp. There's no communication with the server.
WM_NAME, WM_ICON_NAME
X11::Protocol::WM::set_wm_name ($X, $window, $name)-
Set the
WM_NAMEproperty on$window(an integer XID) to$name(a string).The window manager might display this as a title above the window, or in a menu of windows, etc. It can be a Perl 5.8 wide-char string per "Text Properties" above. A good window manager ought to support non-ASCII or non-Latin-1 titles, but how well it displays might depend on fonts etc.
X11::Protocol::WM::set_wm_icon_name ($X, $window, $name)-
Set the
WM_ICON_NAMEproperty on$window(an integer XID) to$name(a string).The window manager might display this when
$windowis iconified. If$windowdoesn't have an icon (inWM_HINTSor from the window manager itself) then this text might be all that's shown. Either way it should be something short. It can be a Perl 5.8 wide-char string per "Text Properties" above.
WM_NORMAL_HINTS
X11::Protocol::WM::set_wm_normal_hints ($X, $window, key=>value,...)-
Set the
WM_NORMAL_HINTSproperty on$window(an integer XID). This is aWM_SIZE_HINTSstructure which tells the window manager what sizes the client would like. For example,set_wm_normal_hints ($X, $window, min_width => 200, min_height => 100);Generally the window manager restricts user resizing to the hint limits. Most window managers use these hints, but of course they're only hints and a good program should be prepared for other sizes even if it won't look good or can't do much useful when too big or too small etc.
The key/value parameters are
user_position boolean, window x,y is user specified user_size boolean, window width,height is user specified program_position boolean, window x,y is program specified program_size boolean, window width,height is program specified min_width \ integers, min size in pixels min_height / max_width \ integers, max size in pixels max_height / base_width \ integers, size base in pixels base_height / width_inc \ integers, size increment in pixels height_inc / min_aspect \ fraction 2/3 or decimal 2 or 1.5 min_aspect_num | or integer num/den up to 0x7FFFFFFF min_aspect_den | max_aspect | max_aspect_num | max_aspect_den / win_gravity WinGravity enum "NorthEast" etcuser_positionanduser_sizeare flags meaning that the window's x,y or width,height (in the usual core$X->SetWindowAttributes()) were given by the user, for example from a-geometrycommand line option. The window manager will generally obey these values and skip any auto-placement or interactive placement it might otherwise do.program_positionandprogram_sizeare flags meaning the window x,y or width,height were calculated by the program. The window manager might override with its own positioning or sizing policy. There's generally no need to set these fields unless the program has a definite idea of where and how big it should be. For a size it's enough to set the core window width,height and let the window manager (if there's one running) go from there.Items shown grouped above must be given together, so for instance if a
min_widthis given thenmin_heightshould be given too.base_width,base_heightandwidth_inc,height_incask that the window be a certain base size in pixels then a multiple of "inc" pixels above that. This can be used by things likextermwhich want a fixed size for border or scrollbar and then a multiple of the character size above that. Ifbase_width,base_heightare not given thenmin_width,min_heightis the base size.base_width,base_heightcan be smaller thanmin_width,min_height. This means the size should still be a base+inc multiple, but the first such which is at least the min size. The window manager generally presents the "inc" multiple to the user, so that for example on an xterm the user sees a count of characters. A min size can then demand for example a minimum 1x1 or 2x2 character size.min_aspect,max_aspectask that the window have a certain minimum or maximum width/height ratio. For example aspect 2/1 means it should be twice as wide as it is high. This is applied to the size abovebase_width,base_height, or if base not given then to the whole window size.min_aspect_num,min_aspect_denandmax_aspect_num,max_aspect_denset numerator and denominator values directly (INT32, so maximum 0x7FFF_FFFF). Ormin_aspectandmax_aspectaccept a single value in various forms which are turned into num/den values.2 integer 1.125 decimal, meaning 1125/1000 2/3 fraction 1.5/4.5 fraction with decimalsValues bigger than 0x7FFFFFFF in these forms are reduced proportionally as necessary. A Perl floating point value will usually have more bits of precision than 0x7FFFFFFF and is truncated to something that fits.
win_gravityis how the client would like to be shifted to make room for any surrounding frame the window manager might add. For example if the program calculated the window size and position to ensure the north-east corner is at a desired position, then givewin_gravity => "NorthEast"so that the window manager keeps the north-east corner the same when it applies its frame.win_gravity => "Static"means the frame is put around the window and the window not moved at all. Of course that might mean some of the frame ends up off-screen. $bytes = X11::Protocol::WM::pack_size_hints ($X, key=>value,...)-
Return a bytes string which is a
WM_SIZE_HINTSstructure made from the given key/value parameters.WM_SIZE_HINTSis structure type forWM_NORMAL_HINTSdescribed above and the key/value parameters are as described above.The
$Xparameter is used to interpretwin_gravityenum values. There's no communication with the server. ($num,$den) = X11::Protocol::WM::aspect_to_num_den ($aspect)-
Return a pair of INT32 integers 0 to 0x7FFF_FFFF for the given aspect ratio
$aspect. This is the conversion applied tomin_aspectandmax_aspectabove.$aspectcan be any of the integer, decimal or fraction described.
WM_PROTOCOLS
X11::Protocol::WM::set_wm_protocols ($X, $window, $protocol,...)-
Set the
WM_PROTOCOLSproperty on$window(an XID). Each argument is a string protocol name or an integer atom ID.X11::Protocol::WM::set_wm_protocols ($X, $window, 'WM_DELETE_WINDOW', '_NET_WM_PING')For example
WM_DELETE_WINDOWmeans that when the user clicks the close button the window manager sends aClientMessageevent rather than doing aKillClient(). TheClientMessageevent allows a program to clean-up or ask the user about saving a document before exiting, etc.
WM_STATE
The window manager maintains a state for each client window it manages,
WithdrawnState
NormalState
IconicState
Withdrawn means the window is not mapped and the window manager is not managing it. Newly created windows start as withdrawn and on their first MapWindow() go to normal state, or to iconic state if that's the initial state asked for in WM_HINTS.
iconify() and withdraw() below can change the state to iconic or withdrawn. A window can be restored to normal state by a MapWindow().
($state, $icon_window) = X11::Protocol::WM::get_wm_state ($X, $window)-
Return the
WM_STATEproperty from$window. This is set by the window manager on top-level application windows. If there's no such property then the return is an empty list.$statereturned is an enum string, or an integer value if$X->{'do_interp'}is disabled or the value unrecognised."WithdrawnState" 0 neither window nor icon display "NormalState" 1 window displayed "IconicState" 3 iconified in some way "ZoomState" 2 \ no longer in ICCCM "InactiveState" 4 /$icon_windowreturned is the window (integer XID) used by the window manager to display an icon of$window. If there's no such window then$icon_windowis "None" (or 0 if$X->{'do_interp'}is disabled).$icon_windowmight be the icon window from the client'sWM_HINTSor it might be created by the window manager. Either way the client can draw into it for animations etc, perhaps selectingExposeevents on it to know when to redraw.WM_STATEis set by the window manager when a toplevel window is first mapped (or perhaps earlier), and then kept up-to-date. Generally noWM_STATEproperty or aWM_STATEset to WithdrawnState mean the window manager is not managing the window, or not yet doing so. A client can selectPropertyChangeevent mask in the usual way to listen forWM_STATEchanges. ($state, $icon_window) = X11::Protocol::WM::unpack_wm_state ($X, $bytes)-
Unpack the bytes of a
WM_STATEproperty to a$stateand$icon_windowas perget_wm_state()above.$Xis used for$X->{'do_interp'}but there's no communication with the server. X11::Protocol::WM::iconify ($X, $window)X11::Protocol::WM::iconify ($X, $window, $root)-
Change
$windowto "IconicState" by sending aClientMessageto the window manager. If there's no window manager running then iconification is not possible and the message does nothing.$rootshould be the root window of$window. If not given orundefthen it's obtained from aQueryTree(). Any client can iconify any top level window.If
$windowhas any windows which are "transient" for it (see "WM_TRANSIENT_FOR" below) then usually the window manager will iconify or hide those windows too. X11::Protocol::WM::withdraw ($X, $window)X11::Protocol::WM::withdraw ($X, $window, $root)-
Change
$windowto "WithdrawnState" by an$X->UnmapWindow()and a syntheticUnmapNotifymessage to the window manager.If there's no window manager running then
$windowis unmapped and theUnmapNotifymessage does nothing.$rootshould be the root window of$window. If not given orundefthen it's obtained from aQueryTree().If any windows are
WM_TRANSIENT_FORthis$windowthen generally the client should withdraw them too. The window manager might make such transients inaccessible anyway.The ICCCM specifies an
UnmapNotifymessage so the window manager is notified of the desired state change even if$windowis already unmapped, such as when it's in IconicState or perhaps during some window manager reparenting, etc.$windowcan be changed back to NormalState or IconicState later with a$X->MapWindow()the same as for a newly created window (withWM_HINTSinitial_statefor desired initial state). But before doing so be sure the window manager has recognised thewithdraw(), by it changingWM_STATEto WithdrawnState.Any client can withdraw any toplevel window, but it's unusual for a client to withdraw windows which are not its own.
WM_TRANSIENT_FOR
X11::Protocol::WM::set_wm_transient_for ($X, $window, $transient_for)-
Set the
WM_TRANSIENT_FORproperty on$window(an XID).$transient_foris another window XID, orundefif$windowis not transient for anything soWM_TRANSIENT_FORshould be deleted."Transient for" means
$windowis some sort of dialog or menu related to the given$transient_for. The window manager will generally iconify$windowtogether with its$transient_for, etc. Seeset_motif_wm_hints()below for "modal" transients.
_MOTIF_WM_HINTS
X11::Protocol::WM::set_motif_wm_hints ($X, $window, key=>value...)-
Set the
MOTIF_WM_HINTSproperty on$window(an XID).This controls window decorations and "modal" state. It originated in the Motif
mwmwindow manager but is recognised by many other window managers. It should be set on a toplevel window before mapping. Changes made later might not affect what the window manager does.X11::Protocol::WM::set_motif_wm_hints ($X, $dialog_window, input_mode => "full_application_modal"); $X->MapWindow ($dialog_window);Ordinary windows generally don't need to restrict their decorations etc, but something special like a clock or gadget might benefit.
X11::Protocol::WM::set_motif_wm_hints ($X, $my_gadget_window, functions => 4+32, # move+close decorations => 1+4+8); # border+title+menuThe key/value arguments are
functions => integer bits decorations => integer bits input_mode => enum string or integer status => integer bitsfunctionsis what actions the window manager should offer to the user in a drop-down menu or similar. It's an integer bitwise OR of the following values. If not given then the default is normally all functions.bit actions offered --- --------------- 1 all functions 2 resize window 4 move window 8 minimize, to iconify 16 maximize, to full-screen (with a frame still) 32 close windowdecorationsis what visual decorations the window manager should show around the window. It's an integer bitwise OR of the following values. If not given then the default is normally all decorations.bit decorations displayed --- --------------------- 1 all decorations 2 border around the window 4 resizeh, handles to resize by dragging 8 title bar, showing WM_NAME 16 menu, drop-down menu of the "functions" above 32 minimize button, to iconify 64 maximize button, to full-screeninput_modeallows a window to be "modal", meaning the user should interact only with$window. The window manager will generally keep it on top, not move the focus to other windows, etc. The value is one of the following strings or corresponding integer,string integer "modeless" 0 not modal (the default) "primary_application_modal" 1 modal to its "transient for" "system_modal" 2 modal to the whole display "full_application_modal" 3 modal to the current client"primary_application_modal" means
$windowis modal for theWM_TRANSIENT_FORset on$window(see "WM_TRANSIENT_FOR" above), but other windows on the display can be used normally. "full_application_modal" means modal for all windows of the same client, but other clients can be used normally.Modal behaviour is important for good user interaction and therefore ought to be implemented by a window manager, but a good program should be prepared to do something with input on other windows.
statusfield is a bitwise OR of the following bits (only one currently).bit 1 tearoff menu windowTearoff menu flag is intended for tearoff menus, as the name suggests.
X11::Protocol::WM::set_motif_wm_hints ($X, $my_tearoff_window, status => 1);Motif
mwmwill expand the window to make it wide enough for theWM_NAMEin the frame title bar. Otherwise a title is generally truncated to as much as fits the window's current width. Expanding can be good for tearoffs where the title bar is some originating item name etc which the user should see. But don't be surprised if this flag is ignored by other window managers.Perhaps in the future the individual bits above will have some symbolic names. Either constants or string values interpreted. What would a possible
get_hints()return, and what might be convenient to add/subtract bits?See /usr/include/Xm/MwmUtil.h on the hints bits, and see
mwmsources WmWinInfo.cProcessWmWindowTitle()for thestatustearoff window flag.
_NET_FRAME_EXTENTS
my ($left,$right, $top,$bottom) = X11::Protocol::WM::get_net_frame_extents ($X, $window)-
Get the
_NET_FRAME_EXTENTSproperty from$window.This is set on top-level windows by the window manager to report how many pixels of frame or decoration it has added around
$window.If there's no such property set then the return is an empty list. So for example
my ($left,$right,$top,$bottom) = get_net_frame_extents ($X, $window) or print "no frame extents"; my ($left,$right,$top,$bottom) = get_net_frame_extents ($X, $window); if (! defined $left) { print "no frame extents"; }A client might look at the frame size if moving a window programmatically so as not to put the title bar etc off-screen. Oldish window managers might not provide this information though.
_NET_WM_PID
X11::Protocol::WM::set_net_wm_pid ($X, $window)X11::Protocol::WM::set_net_wm_pid ($X, $window, $pid)X11::Protocol::WM::set_net_wm_pid ($X, $window, undef)-
Set the
_NET_WM_PIDproperty on$windowto the given$pidprocess ID, or to the$$current process ID if omitted. (See perlvar for$$.) If$pidisundefthen the property is deleted.A window manager or similar might use the PID to forcibly kill an unresponsive client. It's only useful if
WM_CLIENT_MACHINE(above) is set too, to know where the client is running.
_NET_WM_USER_TIME
set_net_wm_user_time ($X, $window, $time)-
Set the
_NET_WM_USER_TIMEproperty on$window.$timeshould be a server time value (an integer) from the last user keypress etc in$window. Or when$windowis created then the time from the event which caused it to be opened.On a newly created window a special
$timevalue 0 means the window should not receive the focus when mapped -- assuming the window manager recognises_NET_WM_USER_TIMEof course.If the client has the active window it should update
_NET_WM_USER_TIMEfor every user input. Generally KeyPress and ButtonPress events are user input, but KeyRelease and ButtonRelease are not since it's the Press events which are the user actively doing something.The window manager might use
_NET_WM_USER_TIMEto control focus and/or stacking order so that for example a slow popup doesn't steal the focus if you've gone to another window to do other work in the interim.
_NET_WM_WINDOW_TYPE
X11::Protocol::WM::set_net_wm_window_type ($X, $window, $window_type)-
Set the
_NET_WM_WINDOW_TYPEproperty on$window(an XID).$window_typecan be a type string as follows from the EWMH,NORMAL DIALOG DESKTOP DOCK TOOLBAR MENU UTILITY SPLASH$window_typecan also be an integer atom such as$X->atom('_NET_WM_WINDOW_TYPE_DIALOG').
Frame to Client
$window = X11::Protocol::WM::frame_window_to_client ($X, $frame)-
Return the client window (XID) contained within window manager
$framewindow (an XID).$frameis usually an immediate child of the root window.If no client window can be found in
$framethen returnundef. This might happen if$frameis an icon window or similar created by the window manager itself, or an override-redirect client without a frame, or if there's no window manager running at all. In the latter two cases$framewould be the client already.The strategy is to look at
$frameand down the window tree seeking aWM_STATEproperty which the window manager puts on a client's toplevel when mapped. The search depth and total windows are limited in case the window manager does its decoration in some ridiculous way or the client uses excessive windows (which would be traversed if there's no window manager).+-rootwin--------------------------+ | | | | | +-frame-win--------+ | | | +-client-win---+ | | | | | WM_STATE ... | | | | | | | | | | | +--------------+ | | | +------------------+ | | | +----------------------------------+Care is taken not to error out if some windows are destroyed during the search. The windows may belong to other clients and could be destroyed at any time. If
$frameitself doesn't exist then the return isundef.This function is similar to what
xwininfoand similar programs do to go from a toplevel root window child down to the client window, per dmsimple.cSelect_Window()or XlibXmuClientWindow(). (See also X11::Protocol::ChooseWindow.)
Virtual Root
Some window managers use a "virtual root" window covering the entire screen. Application windows or frame windows are then children of that virtual root. This can help the window managerM implement a large desktop, or multiple desktops, though it tends to fail in subtle ways with various root oriented programs, including for example xsetroot or the xwininfo and xprop click-to-select.
$window = X11::Protocol::WM::root_to_virtual_root ($X, $root)-
If the window manager is using a virtual root then return that window XID. If not then return
undef.The current implementation searches for a window with an
__SWM_VROOTproperty, as per theswm,tvtwmandamiwmwindow managers, and used by thexscreensaverprogram and perhaps some versions of KDE.There's nothing yet for EWMH
_NET_VIRTUAL_ROOTS. Do any window managers use it? Is_NET_CURRENT_DESKTOPan index into that virtual roots list?(See X11::Protocol::XSetRoot for changing the background of a root or virtual root.)
EXPORTS
Nothing is exported by default, but the functions can be requested in usual Exporter style,
use X11::Protocol::WM 'set_wm_hints';
set_wm_hints ($X, $window, input => 1, ...);
Or just call with full package name
use X11::Protocol::WM;
X11::Protocol::WM::set_wm_hints ($X, $window, input => 1, ...);
There's no :all tag since this module is meant as a grab-bag of functions and to import as-yet unknown things would be asking for name clashes.
BUGS
Not much attention is paid to text on an EBCDIC system. Wide char strings probably work, but byte strings may go straight through where they ought to be re-coded to Latin-1. But the same probably applies to parts of the core X11::Protocol such as $X->atom_name() where you'd want to convert Latin-1 from the server to native EBCDIC.
SEE ALSO
X11::Protocol, X11::Protocol::Other, X11::Protocol::ChooseWindow, X11::Protocol::XSetRoot
"Inter-Client Communication Conventions Manual"
http://www.x.org/docs/ICCCM/
/usr/share/doc/xorg-docs/specs/ICCCM/icccm.txt.gz
"Compound Text Encoding" specification.
http://www.x.org/docs/CTEXT/
/usr/share/doc/xorg-docs/specs/CTEXT/ctext.txt.gz
"Extended Window Manager Hints" which is the _NET_WM things.
http://www.freedesktop.org/wiki/Specifications/wm-spec
http://mail.gnome.org/archives/wm-spec-list/
HOME PAGE
http://user42.tuxfamily.org/x11-protocol-other/index.html
LICENSE
Copyright 2011, 2012 Kevin Ryde
X11-Protocol-Other is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
X11-Protocol-Other is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with X11-Protocol-Other. If not, see <http://www.gnu.org/licenses/>.