.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "X11::Protocol::WM 3pm" .TH X11::Protocol::WM 3pm "2019-08-26" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X11::Protocol::WM \-\- window manager things for client programs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use X11::Protocol::WM; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is some window manager related functions for use by client programs, as per the \*(L"Inter-Client Communication Conventions Manual\*(R" and some of the Net-WM \*(L"Extended Window Manager Hints\*(R". .Sp .RS 4 \&\fI/usr/share/doc/xorg\-docs/icccm/icccm.txt.gz\fR .Sp .RE .SS "Usual Properties" .IX Subsection "Usual Properties" Every toplevel client window should usually .IP "\(bu" 4 \&\f(CW\*(C`set_wm_class()\*(C'\fR to identify itself to other programs (see \*(L"\s-1WM_CLASS\*(R"\s0 below). .IP "\(bu" 4 \&\f(CW\*(C`set_wm_name()\*(C'\fR and \f(CW\*(C`set_wm_icon_name()\*(C'\fR for user-visible window name (see \&\*(L"\s-1WM_NAME, WM_ICON_NAME\*(R"\s0 below). .IP "\(bu" 4 \&\f(CW\*(C`set_wm_client_machine_from_syshostname()\*(C'\fR and \f(CW\*(C`set_net_wm_pid()\*(C'\fR for the running process (see \*(L"\s-1WM_CLIENT_MACHINE\*(R"\s0 and \*(L"_NET_WM_PID\*(R" below). .PP Then optionally, .IP "\(bu" 4 If you have an icon then \f(CW\*(C`set_wm_hints()\*(C'\fR with a bitmap or a window (see \&\*(L"\s-1WM_HINTS\*(R"\s0 below). .IP "\(bu" 4 If the user gave an initial size or position on the command line then \&\f(CW\*(C`set_wm_normal_hints()\*(C'\fR. The same if the program has min/max sizes or aspect ratio desired (see \*(L"\s-1WM_NORMAL_HINTS\*(R"\s0 below). .IP "\(bu" 4 If a command to re-run the program can be constructed then \&\f(CW\*(C`set_wm_command()\*(C'\fR, and preferably keep that up-to-date with changes such as currently open file etc (see \*(L"\s-1WM_COMMAND\*(R"\s0 below). .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "Text Properties" .IX Subsection "Text Properties" Property functions taking text strings such as \f(CW\*(C`set_wm_name()\*(C'\fR accept either byte strings or wide char strings (Perl 5.8 up). Byte strings are presumed to be Latin\-1 and set as \f(CW\*(C`STRING\*(C'\fR type in properties. Wide char strings are stored as \f(CW\*(C`STRING\*(C'\fR if entirely Latin\-1, or encoded to \&\f(CW\*(C`COMPOUND_TEXT\*(C'\fR for other chars (see Encode::X11). .PP In the future perhaps the string functions could accept some sort of compound text object to represent segments of various encodings to become \&\f(CW\*(C`COMPOUND_TEXT\*(C'\fR, together with manipulations for such content etc. If text is bytes in one of the \s-1ICCCM\s0 encodings then it might save work to represent it directly as \f(CW\*(C`COMPOUND_TEXT\*(C'\fR segments rather than going to wide chars and back again. .ie n .IP """set_text_property ($X, $window, $prop, $str)""" 4 .el .IP "\f(CWset_text_property ($X, $window, $prop, $str)\fR" 4 .IX Item "set_text_property ($X, $window, $prop, $str)" Set the given \f(CW$prop\fR (integer atom) property on \f(CW$window\fR (integer \s-1XID\s0) using either \f(CW\*(C`STRING\*(C'\fR or \f(CW\*(C`COMPOUND_TEXT\*(C'\fR as described above. If \f(CW$str\fR is \&\f(CW\*(C`undef\*(C'\fR then \f(CW$prop\fR is deleted. .Sp \&\f(CW$str\fR is limited to \f(CW\*(C`$X\->maximum_request_length()\*(C'\fR. In theory longer strings can be stored by piecewise, but there's no attempt to do that here. The maximum request limit is at least 16384 bytes and the server may allow more, possibly much more. .SS "\s-1WM_CLASS\s0" .IX Subsection "WM_CLASS" .ie n .IP """X11::Protocol::WM::set_wm_class ($X, $window, $instance, $class)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_class ($X, $window, $instance, $class)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_class ($X, $window, $instance, $class)" Set the \f(CW\*(C`WM_CLASS\*(C'\fR property on \f(CW$window\fR (an \s-1XID\s0). .Sp This property may be used by the window manager to lookup settings and preferences for the program through the X Resource system (see \*(L"\s-1RESOURCES\*(R"\s0 in X(7)) or similar. .Sp Usually the instance name is the program command such as \*(L"xterm\*(R" and the class name something like \*(L"XTerm\*(R". Some programs have command line options to set the class and/or instance so the user can have different window manager settings applied to a particular running copy of a program. .Sp .Vb 2 \& X11::Protocol::WM::set_wm_class ($X, $window, \& "myprog", "MyProg"); .Ve .Sp \&\f(CW$instance\fR and \f(CW$class\fR must be \s-1ASCII\s0 or Latin\-1 only. Wide-char strings which are Latin\-1 are converted as necessary. .SS "\s-1WM_CLIENT_MACHINE\s0" .IX Subsection "WM_CLIENT_MACHINE" .ie n .IP """X11::Protocol::WM::set_wm_client_machine ($X, $window, $hostname)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_client_machine ($X, $window, $hostname)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_client_machine ($X, $window, $hostname)" Set the \f(CW\*(C`WM_CLIENT_MACHINE\*(C'\fR property on \f(CW$window\fR to \f(CW$hostname\fR (a string). .Sp \&\f(CW$hostname\fR should be the name of the client machine as seen from the server. If \f(CW$hostname\fR is \f(CW\*(C`undef\*(C'\fR then the property is deleted. .Sp Usually a machine name is ASCII-only, but anything per \*(L"Text Properties\*(R" above is accepted. .ie n .IP """X11::Protocol::WM::set_wm_client_machine_from_syshostname ($X, $window)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_client_machine_from_syshostname ($X, $window)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_client_machine_from_syshostname ($X, $window)" Set the \f(CW\*(C`WM_CLIENT_MACHINE\*(C'\fR property on \f(CW$window\fR using the Sys::Hostname module. .Sp If \f(CW\*(C`Sys::Hostname\*(C'\fR can'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? .Sp Some of the \f(CW\*(C`Sys::Hostname\*(C'\fR cases might return \*(L"localhost\*(R". 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 on the same machine and name \*(L"localhost\*(R" suffices. .SS "\s-1WM_COMMAND\s0" .IX Subsection "WM_COMMAND" .ie n .IP """X11::Protocol::WM::set_wm_command ($X, $window, $command, $arg...)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_command ($X, $window, $command, $arg...)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_command ($X, $window, $command, $arg...)" Set the \f(CW\*(C`WM_COMMAND\*(C'\fR property on \f(CW$window\fR (an \s-1XID\s0). .Sp This should be a program name and argument strings which will restart the client. \f(CW$command\fR is the program name, followed by any argument strings. .Sp .Vb 4 \& X11::Protocol::WM::set_wm_command ($X, $window, \& \*(Aqmyprog\*(Aq, \& \*(Aq\-\-option\*(Aq, \& \*(Aqfilename.txt\*(Aq); .Ve .Sp The command should start the client in its current state, so the command might include a filename, command line options for current settings, etc. .Sp Non-ASCII is allowed per \*(L"Text Properties\*(R" above. The \s-1ICCCM\s0 spec is for Latin\-1 to work on a \s-1POSIX\s0 Latin\-1 system, but how well anything else survives a session manager etc is another matter. .Sp A client can set this at any time, or if participating in the \&\f(CW\*(C`WM_SAVE_YOURSELF\*(C'\fR session manager protocol then it should set in response to a \f(CW\*(C`ClientMessage\*(C'\fR of \f(CW\*(C`WM_SAVE_YOURSELF\*(C'\fR . .Sp For reference, under \f(CW\*(C`mwm\*(C'\fR circa 2017, a client with \f(CW\*(C`WM_SAVE_YOURSELF\*(C'\fR receives that message for the \f(CW\*(C`mwm\*(C'\fR Close button (\f(CW\*(C`f.kill\*(C'\fR) and is expected to respond within a timeout (default 1 second), whereupon \f(CW\*(C`mwm\*(C'\fR closes the client connection (\f(CW\*(C`KillClient\*(C'\fR). Unfortunately if both \&\f(CW\*(C`WM_SAVE_YOURSELF\*(C'\fR and \f(CW\*(C`WM_DELETE_WINDOW\*(C'\fR then \f(CW\*(C`mwm\*(C'\fR still does the \&\f(CW\*(C`WM_SAVE_YOURSELF\*(C'\fR and close, defeating the aim of letting \&\f(CW\*(C`WM_DELETE_WINDOW\*(C'\fR query the user and perhaps not close. .Sp The easiest workaround would be use only \f(CW\*(C`WM_DELETE_WINDOW\*(C'\fR, keep \&\f(CW\*(C`WM_COMMAND\*(C'\fR always up-to-date, and be prepared to save state on connection loss. This is quite reasonable anyway actually, since a \f(CW\*(C`WM_SAVE_YOURSELF\*(C'\fR message is fairly limited use, given that connection loss or other termination could happen at any time so if state is important that it'd be prudent to keep it saved. .SS "\s-1WM_ICON_SIZE\s0" .IX Subsection "WM_ICON_SIZE" .ie n .IP """($min_width,$min_height, $max_width,$max_height, $width_inc,$height_inc) = X11::Protocol::WM::get_wm_icon_size($X,$root)""" 4 .el .IP "\f(CW($min_width,$min_height, $max_width,$max_height, $width_inc,$height_inc) = X11::Protocol::WM::get_wm_icon_size($X,$root)\fR" 4 .IX Item "($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 \f(CW\*(C`WM_ICON_SIZE\*(C'\fR recommended icon sizes (in pixels) as a range, and increment above the minimum. If there's no \&\f(CW\*(C`WM_ICON_SIZE\*(C'\fR property then return an empty list. .Sp \&\f(CW$root\fR is the root window to read. If omitted then read the \&\f(CW\*(C`$X\->root\*(C'\fR default. .Sp An icon pixmap or window in \f(CW\*(C`WM_HINTS\*(C'\fR should 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. .SS "\s-1WM_HINTS\s0" .IX Subsection "WM_HINTS" .ie n .IP """X11::Protocol::WM::set_wm_hints ($X, $window, key=>value, ...)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_hints ($X, $window, key=>value, ...)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_hints ($X, $window, key=>value, ...)" Set the \f(CW\*(C`WM_HINTS\*(C'\fR property on \f(CW$window\fR (an \s-1XID\s0). For example, .Sp .Vb 5 \& X11::Protocol::WM::set_wm_hints \& ($X, $my_window, \& input => 1, \& initial_state => \*(AqNormalState\*(Aq, \& icon_pixmap => $my_pixmap); .Ve .Sp The key/value parameters are as follows. .Sp .Vb 9 \& 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 \e integer coordinate \& icon_y / integer coordinate \& icon_mask pixmap (XID integer) \& window_group window (XID integer) \& urgency boolean .Ve .Sp \&\f(CW\*(C`input\*(C'\fR is 1 if the client wants the window manager to give \f(CW$window\fR the keyboard input focus. This will be with \f(CW\*(C`$X\->SetInputFocus()\*(C'\fR, or if \&\f(CW\*(C`WM_TAKE_FOCUS\*(C'\fR is in \f(CW\*(C`WM_PROTOCOLS\*(C'\fR then instead by a \f(CW\*(C`ClientMessage\*(C'\fR. .Sp \&\f(CW\*(C`input\*(C'\fR is 0 if the window manager should not give the client the focus. This is either because \f(CW$window\fR is output-only, or if \f(CW\*(C`WM_TAKE_FOCUS\*(C'\fR is in \f(CW\*(C`WM_PROTOCOLS\*(C'\fR then because the client will do a \f(CW\*(C`SetInputFocus()\*(C'\fR to itself on an appropriate button press etc. .Sp \&\f(CW\*(C`initial_state\*(C'\fR is a string or number. The \s-1ICCCM\s0 allows \*(L"NormalState\*(R" or \&\*(L"IconicState\*(R" as initial states. .Sp .Vb 2 \& "NormalState" 1 \& "IconicState" 3 .Ve .Sp \&\f(CW\*(C`icon_pixmap\*(C'\fR should be a bitmap, ie. a pixmap (\s-1XID\s0) with depth 1. The window manager will draw it in suitable contrasting colours. \*(L"1\*(R" pixels are foreground and \*(L"0\*(R" is background. \f(CW\*(C`icon_mask\*(C'\fR bitmap is applied to the displayed icon. It can be used to make a non-rectangular icon. .Sp \&\f(CW\*(C`icon_window\*(C'\fR is a window which the window manager may show when \f(CW$window\fR is iconified. This can be used for a multi-colour icon, done either by a background or by client drawing (in response to \f(CW\*(C`Expose\*(C'\fR events, or updated periodically for a clock, etc). The \f(CW\*(C`icon_window\*(C'\fR 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 border. .Sp The window manager might set a \f(CW\*(C`WM_ICON_SIZE\*(C'\fR property on the root window for good icon sizes. See \*(L"\s-1WM_ICON_SIZE\*(R"\s0 above. .Sp \&\f(CW\*(C`window_group\*(C'\fR is the \s-1XID\s0 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 use a never-mapped window as the leader for all subsequent windows. .Sp \&\f(CW\*(C`urgency\*(C'\fR true 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. .ie n .IP """(key => $value, ...) = X11::Protocol::WM::get_wm_hints ($X, $window)""" 4 .el .IP "\f(CW(key => $value, ...) = X11::Protocol::WM::get_wm_hints ($X, $window)\fR" 4 .IX Item "(key => $value, ...) = X11::Protocol::WM::get_wm_hints ($X, $window)" Return the \f(CW\*(C`WM_HINTS\*(C'\fR property from \f(CW$window\fR. The return is a list of key/value pairs as per \f(CW\*(C`set_wm_hints()\*(C'\fR above .Sp .Vb 3 \& input => 1, \& icon_pixmap => 1234, \& ... .Ve .Sp Only fields with their flag bits set in the hints are included in the return. If there's no \f(CW\*(C`WM_HINTS\*(C'\fR at all or or its flags field is zero then the return is an empty list. .Sp The return can be put into a hash to get fields by name, .Sp .Vb 4 \& my %hints = X11::Protocol::WM::get_wm_hints ($X, $window); \& if (exists $hints{\*(Aqicon_pixmap\*(Aq}) { \& print "icon_pixmap is ", $hints{\*(Aqicon_pixmap\*(Aq}, "\en"; \& } .Ve .Sp \&\f(CW\*(C`initial_state\*(C'\fR is a string such as \*(L"NormalState\*(R". The pixmaps and windows are string \*(L"None\*(R" if set but zero (which is probably unusual). If \&\f(CW\*(C`$X\->{\*(Aqdo_interp\*(Aq}\*(C'\fR is disabled then all are numbers. .Sp X11R2 Xlib had a bug in its \f(CW\*(C`XSetWMHints()\*(C'\fR which chopped off the \&\f(CW\*(C`window_group\*(C'\fR value from the hints stored. The \f(CW\*(C`window_group\*(C'\fR field is omitted from the return if the data read is missing that field. .ie n .IP """(key => $value, ...) = X11::Protocol::WM::change_wm_hints ($X, $window, key=>value, ...)""" 4 .el .IP "\f(CW(key => $value, ...) = X11::Protocol::WM::change_wm_hints ($X, $window, key=>value, ...)\fR" 4 .IX Item "(key => $value, ...) = X11::Protocol::WM::change_wm_hints ($X, $window, key=>value, ...)" Change some fields of the \f(CW\*(C`WM_HINTS\*(C'\fR property on \f(CW$window\fR. The given key/value fields are changed. Other fields are left alone. For example, .Sp .Vb 2 \& X11::Protocol::WM::set_wm_hints ($X, $window, \& urgency => 1); .Ve .Sp A value \f(CW\*(C`undef\*(C'\fR means delete a field, .Sp .Vb 3 \& X11::Protocol::WM::set_wm_hints ($X, $window, \& icon_pixmap => undef, \& icon_mask => undef); .Ve .Sp The change requires a server round-trip to fetch the current values from \&\f(CW$window\fR. An application might prefer to remember its desired hints and send a full \f(CW\*(C`set_wm_hints()\*(C'\fR each time. .ie n .IP """$bytes = X11::Protocol::WM::pack_wm_hints ($X, key=>value...)""" 4 .el .IP "\f(CW$bytes = X11::Protocol::WM::pack_wm_hints ($X, key=>value...)\fR" 4 .IX Item "$bytes = X11::Protocol::WM::pack_wm_hints ($X, key=>value...)" Pack a set of values into a byte string of \f(CW\*(C`WM_HINTS\*(C'\fR format. The key/value arguments are per \f(CW\*(C`set_wm_hints()\*(C'\fR above and the result is the raw bytes stored in a \f(CW\*(C`WM_HINTS\*(C'\fR property. .Sp The \f(CW$X\fR argument is not actually used currently, but is present in case \&\f(CW\*(C`initial_state\*(C'\fR or other values might use an \f(CW\*(C`$X\->num()\*(C'\fR lookup in the future. .ie n .IP """(key => $value, ...) = X11::Protocol::WM::unpack_wm_hints ($X, $bytes)""" 4 .el .IP "\f(CW(key => $value, ...) = X11::Protocol::WM::unpack_wm_hints ($X, $bytes)\fR" 4 .IX Item "(key => $value, ...) = X11::Protocol::WM::unpack_wm_hints ($X, $bytes)" Unpack a byte string as a \f(CW\*(C`WM_HINTS\*(C'\fR structure. The return is key/value pairs as per \f(CW\*(C`get_wm_hints()\*(C'\fR above. The \f(CW$X\fR parameter is used for \&\f(CW\*(C`do_interp\*(C'\fR. There's no communication with the server. .SS "\s-1WM_NAME, WM_ICON_NAME\s0" .IX Subsection "WM_NAME, WM_ICON_NAME" .ie n .IP """X11::Protocol::WM::set_wm_name ($X, $window, $name)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_name ($X, $window, $name)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_name ($X, $window, $name)" Set the \f(CW\*(C`WM_NAME\*(C'\fR property on \f(CW$window\fR (an integer \s-1XID\s0) to \f(CW$name\fR (a string). .Sp 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 \*(L"Text Properties\*(R" 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. .ie n .IP """X11::Protocol::WM::set_wm_icon_name ($X, $window, $name)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_icon_name ($X, $window, $name)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_icon_name ($X, $window, $name)" Set the \f(CW\*(C`WM_ICON_NAME\*(C'\fR property on \f(CW$window\fR (an integer \s-1XID\s0) to \f(CW$name\fR (a string). .Sp The window manager might display this when \f(CW$window\fR is iconified. If \&\f(CW$window\fR doesn't have an icon (in \f(CW\*(C`WM_HINTS\*(C'\fR or 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 \*(L"Text Properties\*(R" above. .SS "\s-1WM_NORMAL_HINTS\s0" .IX Subsection "WM_NORMAL_HINTS" .ie n .IP """X11::Protocol::WM::set_wm_normal_hints ($X, $window, key=>value,...)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_normal_hints ($X, $window, key=>value,...)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_normal_hints ($X, $window, key=>value,...)" Set the \f(CW\*(C`WM_NORMAL_HINTS\*(C'\fR property on \f(CW$window\fR (an integer \s-1XID\s0). This is a \f(CW\*(C`WM_SIZE_HINTS\*(C'\fR structure which tells the window manager what sizes the client would like. For example, .Sp .Vb 3 \& set_wm_normal_hints ($X, $window, \& min_width => 200, \& min_height => 100); .Ve .Sp 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. .Sp The key/value parameters are .Sp .Vb 10 \& 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 \e integers, min size in pixels \& min_height / \& max_width \e integers, max size in pixels \& max_height / \& base_width \e integers, size base in pixels \& base_height / \& width_inc \e integers, size increment in pixels \& height_inc / \& min_aspect \e 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" etc .Ve .Sp \&\f(CW\*(C`user_position\*(C'\fR and \f(CW\*(C`user_size\*(C'\fR are flags meaning that the window's x,y or width,height (in the usual core \f(CW\*(C`$X\->SetWindowAttributes()\*(C'\fR) were given by the user, for example from a \f(CW\*(C`\-geometry\*(C'\fR command line option. The window manager will generally obey these values and skip any auto-placement or interactive placement it might otherwise do. .Sp \&\f(CW\*(C`program_position\*(C'\fR and \f(CW\*(C`program_size\*(C'\fR are 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. .Sp Items shown grouped above must be given together, so for instance if a \&\f(CW\*(C`min_width\*(C'\fR is given then \f(CW\*(C`min_height\*(C'\fR should be given too. .Sp \&\f(CW\*(C`base_width\*(C'\fR,\f(CW\*(C`base_height\*(C'\fR and \f(CW\*(C`width_inc\*(C'\fR,\f(CW\*(C`height_inc\*(C'\fR ask that the window be a certain base size in pixels then a multiple of \*(L"inc\*(R" pixels above that. This can be used by things like \f(CW\*(C`xterm\*(C'\fR which want a fixed size for border or scrollbar and then a multiple of the character size above that. If \f(CW\*(C`base_width\*(C'\fR,\f(CW\*(C`base_height\*(C'\fR are not given then \&\f(CW\*(C`min_width\*(C'\fR,\f(CW\*(C`min_height\*(C'\fR is the base size. .Sp \&\f(CW\*(C`base_width\*(C'\fR,\f(CW\*(C`base_height\*(C'\fR can be smaller than \f(CW\*(C`min_width\*(C'\fR,\f(CW\*(C`min_height\*(C'\fR. 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 \&\*(L"inc\*(R" 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. .Sp \&\f(CW\*(C`min_aspect\*(C'\fR,\f(CW\*(C`max_aspect\*(C'\fR ask 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 above \&\f(CW\*(C`base_width\*(C'\fR,\f(CW\*(C`base_height\*(C'\fR, or if base not given then to the whole window size. .Sp \&\f(CW\*(C`min_aspect_num\*(C'\fR,\f(CW\*(C`min_aspect_den\*(C'\fR and \f(CW\*(C`max_aspect_num\*(C'\fR,\f(CW\*(C`max_aspect_den\*(C'\fR set numerator and denominator values directly (\s-1INT32,\s0 so maximum 0x7FFF_FFFF). Or \f(CW\*(C`min_aspect\*(C'\fR and \f(CW\*(C`max_aspect\*(C'\fR accept a single value in various forms which are turned into num/den values. .Sp .Vb 4 \& 2 integer \& 1.125 decimal, meaning 1125/1000 \& 2/3 fraction \& 1.5/4.5 fraction with decimals .Ve .Sp Values 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. .Sp \&\f(CW\*(C`win_gravity\*(C'\fR is 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 give \f(CW\*(C`win_gravity => "NorthEast"\*(C'\fR so that the window manager keeps the north-east corner the same when it applies its frame. .Sp \&\f(CW\*(C`win_gravity => "Static"\*(C'\fR 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. .ie n .IP """$bytes = X11::Protocol::WM::pack_size_hints ($X, key=>value,...)""" 4 .el .IP "\f(CW$bytes = X11::Protocol::WM::pack_size_hints ($X, key=>value,...)\fR" 4 .IX Item "$bytes = X11::Protocol::WM::pack_size_hints ($X, key=>value,...)" Return a bytes string which is a \f(CW\*(C`WM_SIZE_HINTS\*(C'\fR structure made from the given key/value parameters. \f(CW\*(C`WM_SIZE_HINTS\*(C'\fR is structure type for \&\f(CW\*(C`WM_NORMAL_HINTS\*(C'\fR described above and the key/value parameters are as described above. .Sp The \f(CW$X\fR parameter is used to interpret \f(CW\*(C`win_gravity\*(C'\fR enum values. There's no communication with the server. .ie n .IP """($num,$den) = X11::Protocol::WM::aspect_to_num_den ($aspect)""" 4 .el .IP "\f(CW($num,$den) = X11::Protocol::WM::aspect_to_num_den ($aspect)\fR" 4 .IX Item "($num,$den) = X11::Protocol::WM::aspect_to_num_den ($aspect)" Return a pair of \s-1INT32\s0 integers 0 to 0x7FFF_FFFF for the given aspect ratio \&\f(CW$aspect\fR. This is the conversion applied to \f(CW\*(C`min_aspect\*(C'\fR and \&\f(CW\*(C`max_aspect\*(C'\fR above. \f(CW$aspect\fR can be any of the integer, decimal or fraction described. .SS "\s-1WM_PROTOCOLS\s0" .IX Subsection "WM_PROTOCOLS" .ie n .IP """X11::Protocol::WM::set_wm_protocols ($X, $window, $protocol,...)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_protocols ($X, $window, $protocol,...)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_protocols ($X, $window, $protocol,...)" Set the \f(CW\*(C`WM_PROTOCOLS\*(C'\fR property on \f(CW$window\fR (an \s-1XID\s0). Each argument is a string protocol name or an integer atom \s-1ID.\s0 .Sp .Vb 2 \& X11::Protocol::WM::set_wm_protocols \& ($X, $window, \*(AqWM_DELETE_WINDOW\*(Aq, \*(Aq_NET_WM_PING\*(Aq) .Ve .Sp For example \f(CW\*(C`WM_DELETE_WINDOW\*(C'\fR means that when the user clicks the close button the window manager sends a \f(CW\*(C`ClientMessage\*(C'\fR event rather than doing a \&\f(CW\*(C`KillClient()\*(C'\fR. The \f(CW\*(C`ClientMessage\*(C'\fR event allows a program to clean-up or ask the user about saving a document before exiting, etc. .SS "\s-1WM_STATE\s0" .IX Subsection "WM_STATE" The window manager maintains a state for each client window it manages, .PP .Vb 3 \& WithdrawnState \& NormalState \& IconicState .Ve .PP \&\f(CW\*(C`WithdrawnState\*(C'\fR means the window is not mapped and the window manager is not managing it. A newly created window (\f(CW\*(C`$X\->CreateWindow()\*(C'\fR) is initially \f(CW\*(C`WithdrawnState\*(C'\fR and on first \f(CW\*(C`$X\->MapWindow()\*(C'\fR goes to \&\f(CW\*(C`NormalState\*(C'\fR (or to \f(CW\*(C`IconicState\*(C'\fR if that's the initial state asked for in \f(CW\*(C`WM_HINTS\*(C'\fR). .PP \&\f(CW\*(C`iconify()\*(C'\fR and \f(CW\*(C`withdraw()\*(C'\fR below can change the state to iconic or withdrawn. A window can be restored from iconic to normal by a \&\f(CW\*(C`MapWindow()\*(C'\fR. .ie n .IP """($state, $icon_window) = X11::Protocol::WM::get_wm_state ($X, $window)""" 4 .el .IP "\f(CW($state, $icon_window) = X11::Protocol::WM::get_wm_state ($X, $window)\fR" 4 .IX Item "($state, $icon_window) = X11::Protocol::WM::get_wm_state ($X, $window)" Return the \f(CW\*(C`WM_STATE\*(C'\fR property from \f(CW$window\fR. 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. .Sp \&\f(CW$state\fR returned is an enum string, or an integer value if \&\f(CW\*(C`$X\->{\*(Aqdo_interp\*(Aq}\*(C'\fR is disabled or the value unrecognised. .Sp .Vb 3 \& "WithdrawnState" 0 not displayed \& "NormalState" 1 window displayed \& "IconicState" 3 iconified in some way \& \& "ZoomState" 2 \e no longer in ICCCM \& "InactiveState" 4 / (zoom meant maximized) .Ve .Sp \&\f(CW$icon_window\fR returned is the window (integer \s-1XID\s0) used by the window manager to display an icon of \f(CW$window\fR. If there's no such window then \&\f(CW$icon_window\fR is \*(L"None\*(R" (or 0 if \f(CW\*(C`$X\->{\*(Aqdo_interp\*(Aq}\*(C'\fR is disabled). .Sp \&\f(CW$icon_window\fR might be the icon window from the client's \f(CW\*(C`WM_HINTS\*(C'\fR or it might be a window created by the window manager. The client can draw into it for animations etc, perhaps selecting \f(CW\*(C`Expose\*(C'\fR events on it to know when to redraw. .Sp \&\f(CW\*(C`WM_STATE\*(C'\fR is set by the window manager when a toplevel window is first mapped (or perhaps earlier), and then kept up-to-date. Generally no \&\f(CW\*(C`WM_STATE\*(C'\fR property or a \f(CW\*(C`WM_STATE\*(C'\fR set to WithdrawnState means the window manager is not managing the window, or not yet doing so. A client can select \f(CW\*(C`PropertyChange\*(C'\fR event mask in the usual way to listen for \&\f(CW\*(C`WM_STATE\*(C'\fR changes. .ie n .IP """($state, $icon_window) = X11::Protocol::WM::unpack_wm_state ($X, $bytes)""" 4 .el .IP "\f(CW($state, $icon_window) = X11::Protocol::WM::unpack_wm_state ($X, $bytes)\fR" 4 .IX Item "($state, $icon_window) = X11::Protocol::WM::unpack_wm_state ($X, $bytes)" Unpack the bytes of a \f(CW\*(C`WM_STATE\*(C'\fR property to a \f(CW$state\fR and \&\f(CW$icon_window\fR as per \f(CW\*(C`get_wm_state()\*(C'\fR above. .Sp \&\f(CW$X\fR is used for \f(CW\*(C`$X\->{\*(Aqdo_interp\*(Aq}\*(C'\fR but there's no communication with the server. .ie n .IP """X11::Protocol::WM::iconify ($X, $window)""" 4 .el .IP "\f(CWX11::Protocol::WM::iconify ($X, $window)\fR" 4 .IX Item "X11::Protocol::WM::iconify ($X, $window)" .PD 0 .ie n .IP """X11::Protocol::WM::iconify ($X, $window, $root)""" 4 .el .IP "\f(CWX11::Protocol::WM::iconify ($X, $window, $root)\fR" 4 .IX Item "X11::Protocol::WM::iconify ($X, $window, $root)" .PD Change \f(CW$window\fR to \*(L"IconicState\*(R" by sending a \f(CW\*(C`ClientMessage\*(C'\fR to the window manager. .Sp If the window manager does not have any iconification then it might do nothing (eg. some tiling window managers). If there's no window manager running then iconification is not possible and this message will do nothing. .Sp \&\f(CW$root\fR should be the root window of \f(CW$window\fR. If not given or \f(CW\*(C`undef\*(C'\fR then it's obtained by a \f(CW\*(C`QueryTree()\*(C'\fR here. Any client can iconify any top level window. .Sp If \f(CW$window\fR has other windows which are \f(CW\*(C`WM_TRANSIENT_FOR\*(C'\fR for it then generally the window manager will iconify or hide those windows too (see \&\*(L"\s-1WM_TRANSIENT_FOR\*(R"\s0 below). .ie n .IP """X11::Protocol::WM::withdraw ($X, $window)""" 4 .el .IP "\f(CWX11::Protocol::WM::withdraw ($X, $window)\fR" 4 .IX Item "X11::Protocol::WM::withdraw ($X, $window)" .PD 0 .ie n .IP """X11::Protocol::WM::withdraw ($X, $window, $root)""" 4 .el .IP "\f(CWX11::Protocol::WM::withdraw ($X, $window, $root)\fR" 4 .IX Item "X11::Protocol::WM::withdraw ($X, $window, $root)" .PD Change \f(CW$window\fR to \*(L"WithdrawnState\*(R" by an \f(CW\*(C`$X\->UnmapWindow()\*(C'\fR and a synthetic \f(CW\*(C`UnmapNotify\*(C'\fR message to the window manager. .Sp If there's no window manager running then the \f(CW\*(C`UnmapWindow()\*(C'\fR unmaps and the \f(CW\*(C`UnmapNotify\*(C'\fR message does nothing. .Sp \&\f(CW$root\fR should be the root window of \f(CW$window\fR. If not given or \&\f(CW\*(C`undef\*(C'\fR then it's obtained by a \f(CW\*(C`QueryTree()\*(C'\fR here. .Sp If other windows are \f(CW\*(C`WM_TRANSIENT_FOR\*(C'\fR this \f(CW$window\fR (eg. open dialog windows) then generally the client should withdraw them too. The window manager might make such other windows inaccessible anyway. .Sp The \s-1ICCCM\s0 specifies an \f(CW\*(C`UnmapNotify\*(C'\fR message so the window manager is notified of the desired state change even if \f(CW$window\fR is already unmapped, such as in \*(L"IconicState\*(R" or perhaps during some window manager reparenting, etc. .Sp \&\f(CW$window\fR can be changed back to NormalState or IconicState later with \&\f(CW\*(C`$X\->MapWindow()\*(C'\fR the same as for a newly created window. (And \&\f(CW\*(C`WM_HINTS\*(C'\fR \f(CW\*(C`initial_state\*(C'\fR can give a desired initial iconic/normal state). But before doing so be sure the window manager has recognised the \&\f(CW\*(C`withdraw()\*(C'\fR. This will be when the window manager changes the \f(CW\*(C`WM_STATE\*(C'\fR property to \*(L"WithdrawnState\*(R", or deletes that property. .Sp Any client can withdraw any toplevel window, but it's unusual for a client to withdraw windows which are not its own. .SS "\s-1WM_TRANSIENT_FOR\s0" .IX Subsection "WM_TRANSIENT_FOR" .ie n .IP """X11::Protocol::WM::set_wm_transient_for ($X, $window, $transient_for)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_wm_transient_for ($X, $window, $transient_for)\fR" 4 .IX Item "X11::Protocol::WM::set_wm_transient_for ($X, $window, $transient_for)" Set the \f(CW\*(C`WM_TRANSIENT_FOR\*(C'\fR property on \f(CW$window\fR (an \s-1XID\s0). .Sp \&\f(CW$transient_for\fR is another window \s-1XID,\s0 or \f(CW\*(C`undef\*(C'\fR if \f(CW$window\fR is not transient for anything so \f(CW\*(C`WM_TRANSIENT_FOR\*(C'\fR should be deleted. .Sp \&\*(L"Transient for\*(R" means \f(CW$window\fR is some sort of dialog or menu related to the given \f(CW$transient_for\fR window. The window manager will generally iconify \f(CW$window\fR together with its \f(CW$transient_for\fR, etc. See \&\f(CW\*(C`set_motif_wm_hints()\*(C'\fR below for \*(L"modal\*(R" transients. .SS "_MOTIF_WM_HINTS" .IX Subsection "_MOTIF_WM_HINTS" .ie n .IP """X11::Protocol::WM::set_motif_wm_hints ($X, $window, key=>value...)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_motif_wm_hints ($X, $window, key=>value...)\fR" 4 .IX Item "X11::Protocol::WM::set_motif_wm_hints ($X, $window, key=>value...)" Set the \f(CW\*(C`MOTIF_WM_HINTS\*(C'\fR property on \f(CW$window\fR (an \s-1XID\s0). .Sp These hints control window decorations and \*(L"modal\*(R" state. It originated in the Motif \f(CW\*(C`mwm\*(C'\fR window manager but is recognised by most other window managers. It should be set on a toplevel window before mapping. Changes made later might not affect what the window manager does. .Sp .Vb 4 \& X11::Protocol::WM::set_motif_wm_hints \& ($X, $dialog_window, \& input_mode => "full_application_modal"); \& $X\->MapWindow ($dialog_window); .Ve .Sp Ordinary windows generally don't need to restrict their decorations etc, but something special like a clock or gadget might benefit. .Sp .Vb 4 \& X11::Protocol::WM::set_motif_wm_hints \& ($X, $my_gadget_window, \& functions => 4+32, # move+close \& decorations => 1+4+8); # border+title+menu .Ve .Sp The key/value arguments are .Sp .Vb 4 \& functions => integer bits \& decorations => integer bits \& input_mode => enum string or integer \& status => integer bits .Ve .Sp \&\f(CW\*(C`functions\*(C'\fR is what actions the window manager should offer to the user in a drop-down menu or similar. It's an integer bitwise \s-1OR\s0 of the following values. If not given then the default is normally all functions. .Sp .Vb 8 \& 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 window .Ve .Sp \&\f(CW\*(C`decorations\*(C'\fR is what visual decorations the window manager should show around the window. It's an integer bitwise \s-1OR\s0 of the following values. If not given then the default is normally all decorations. .Sp .Vb 9 \& 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\-screen .Ve .Sp \&\f(CW\*(C`input_mode\*(C'\fR allows a window to be \*(L"modal\*(R", meaning the user should interact only with \f(CW$window\fR. 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, .Sp .Vb 5 \& 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 .Ve .Sp \&\*(L"primary_application_modal\*(R" means \f(CW$window\fR is modal for the \&\f(CW\*(C`WM_TRANSIENT_FOR\*(C'\fR set on \f(CW$window\fR (see \*(L"\s-1WM_TRANSIENT_FOR\*(R"\s0 above), but other windows on the display can be used normally. \*(L"full_application_modal\*(R" means modal for all windows of the same client, but other clients can be used normally. .Sp 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. .Sp \&\f(CW\*(C`status\*(C'\fR field is a bitwise \s-1OR\s0 of the following bits (only one currently). .Sp .Vb 2 \& bit \& 1 tearoff menu window .Ve .Sp Tearoff menu flag is intended for tearoff menus, as the name suggests. .Sp .Vb 2 \& X11::Protocol::WM::set_motif_wm_hints \& ($X, $my_tearoff_window, status => 1); .Ve .Sp Motif \f(CW\*(C`mwm\*(C'\fR will expand the window to make it wide enough for the \&\f(CW\*(C`WM_NAME\*(C'\fR in 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. .Sp Perhaps in the future the individual bits above will have some symbolic names. Either constants or string values interpreted. What would a possible \f(CW\*(C`get_hints()\*(C'\fR return, and what might be convenient to add/subtract bits? .Sp See \fI/usr/include/Xm/MwmUtil.h\fR on the hints bits, and see \f(CW\*(C`mwm\*(C'\fR sources \fIWmWinInfo.c\fR \f(CW\*(C`ProcessWmWindowTitle()\*(C'\fR for the \f(CW\*(C`status\*(C'\fR tearoff window flag. .SS "_NET_FRAME_EXTENTS" .IX Subsection "_NET_FRAME_EXTENTS" .ie n .IP """my ($left,$right, $top,$bottom) = X11::Protocol::WM::get_net_frame_extents ($X, $window)""" 4 .el .IP "\f(CWmy ($left,$right, $top,$bottom) = X11::Protocol::WM::get_net_frame_extents ($X, $window)\fR" 4 .IX Item "my ($left,$right, $top,$bottom) = X11::Protocol::WM::get_net_frame_extents ($X, $window)" Get the \f(CW\*(C`_NET_FRAME_EXTENTS\*(C'\fR property from \f(CW$window\fR. .Sp This is set on top-level windows by the window manager to report how many pixels of frame or decoration it has added around \f(CW$window\fR. .Sp If there's no such property set then the return is an empty list. So for example .Sp .Vb 3 \& 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"; \& } .Ve .Sp 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. .SS "_NET_WM_PID" .IX Subsection "_NET_WM_PID" .ie n .IP """X11::Protocol::WM::set_net_wm_pid ($X, $window)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_net_wm_pid ($X, $window)\fR" 4 .IX Item "X11::Protocol::WM::set_net_wm_pid ($X, $window)" .PD 0 .ie n .IP """X11::Protocol::WM::set_net_wm_pid ($X, $window, $pid)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_net_wm_pid ($X, $window, $pid)\fR" 4 .IX Item "X11::Protocol::WM::set_net_wm_pid ($X, $window, $pid)" .ie n .IP """X11::Protocol::WM::set_net_wm_pid ($X, $window, undef)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_net_wm_pid ($X, $window, undef)\fR" 4 .IX Item "X11::Protocol::WM::set_net_wm_pid ($X, $window, undef)" .PD Set the \f(CW\*(C`_NET_WM_PID\*(C'\fR property on \f(CW$window\fR to the given \f(CW$pid\fR process \&\s-1ID,\s0 or to the \f(CW$$\fR current process \s-1ID\s0 if omitted. (See perlvar for \&\f(CW$$\fR.) If \f(CW$pid\fR is \f(CW\*(C`undef\*(C'\fR then the property is deleted. .Sp A window manager or similar might use the \s-1PID\s0 to forcibly kill an unresponsive client. It's only useful if \f(CW\*(C`WM_CLIENT_MACHINE\*(C'\fR (above) is set too, to know where the client is running. .SS "_NET_WM_STATE" .IX Subsection "_NET_WM_STATE" An \s-1EWMH\s0 compliant window manager maintains a set of state flags for each client window. A state is an atom such as \f(CW\*(C`_NET_WM_STATE_FULLSCREEN\*(C'\fR and each such state can be present or absent. The supported states are listed in property \f(CW\*(C`_NET_SUPPORTED\*(C'\fR on the root (together with other features). For example, .PP .Vb 6 \& my @net_supported = X11::Protocol::Other::get_property_atoms \& ($X, $X\->root, $X\->atom(\*(Aq_NET_SUPPORTED\*(Aq)); \& if (grep {$_ == $X\->atom(\*(Aq_NET_WM_STATE_FULLSCREEN\*(Aq)} \& @net_supported) { \& print "Have _NET_WM_STATE_FULLSCREEN\en"; \& } .Ve .PP Any client can ask the window manager to change states of any window. A client might set initial states on a new window with \f(CW\*(C`set_net_wm_state()\*(C'\fR below. Possible states include .IP "_NET_WM_STATE_MODAL" 4 .IX Item "_NET_WM_STATE_MODAL" The window is modal to its \f(CW\*(C`WM_TRANSIENT_FOR\*(C'\fR parent, or if \&\f(CW\*(C`WM_TRANSIENT_FOR\*(C'\fR not set then modal to its window group. .Sp See \*(L"_MOTIF_WM_HINTS\*(R" to set modal with the Motif style hints. .IP "_NET_WM_STATE_STICKY" 4 .IX Item "_NET_WM_STATE_STICKY" The window is kept in a fixed position on screen when the desktop scrolls. .IP "_NET_WM_STATE_MAXIMIZED_VERT" 4 .IX Item "_NET_WM_STATE_MAXIMIZED_VERT" .PD 0 .IP "_NET_WM_STATE_MAXIMIZED_HORZ" 4 .IX Item "_NET_WM_STATE_MAXIMIZED_HORZ" .PD The window is maximum size vertically or horizontally or both. The window still has its surrounding decoration and the size should obey size increments specified in \*(L"\s-1WM_NORMAL_HINTS\*(R"\s0. .IP "_NET_WM_STATE_FULLSCREEN" 4 .IX Item "_NET_WM_STATE_FULLSCREEN" The window is the full screen with no decoration around it, thus being the full screen. .Sp The window manager remembers the \*(L"normal\*(R" size of the window so that when maximize or fullscreen states are removed the previous size is restored. .IP "_NET_WM_STATE_SHADED" 4 .IX Item "_NET_WM_STATE_SHADED" The window is \*(L"shaded\*(R" which generally means its title bar is displayed but none of the client window. This is an alternative to iconifying a window. .IP "_NET_WM_STATE_SKIP_TASKBAR" 4 .IX Item "_NET_WM_STATE_SKIP_TASKBAR" .PD 0 .IP "_NET_WM_STATE_SKIP_PAGER" 4 .IX Item "_NET_WM_STATE_SKIP_PAGER" .PD Don't show the window on a task bar or in a pager, respectively. .IP "_NET_WM_STATE_HIDDEN (read-only)" 4 .IX Item "_NET_WM_STATE_HIDDEN (read-only)" This state is set by the window manger when the window is iconified or similar and so does not appear on screen. Clients cannot change this. .IP "_NET_WM_STATE_ABOVE" 4 .IX Item "_NET_WM_STATE_ABOVE" .PD 0 .IP "_NET_WM_STATE_BELOW" 4 .IX Item "_NET_WM_STATE_BELOW" .PD The window is kept above or below other client windows. The stacking order maintained is roughly .Sp .Vb 10 \& top \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \& | _NET_WM_WINDOW_TYPE_DOCK | "DOCK" panels (etc) on top, \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ except perhaps FULLSCREEN \& | _NET_WM_STATE_ABOVE | windows above those panels \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ when focused \& | normal | \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \& | _NET_WM_STATE_BELOW | \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \& | _NET_WM_WINDOW_TYPE_DESKTOP | \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \& bottom .Ve .IP "_NET_WM_STATE_DEMANDS_ATTENTION" 4 .IX Item "_NET_WM_STATE_DEMANDS_ATTENTION" The window should be brought to the attention of the user in some way. A client sets this and the window manager clears it after the window has received user attention (which might mean keyboard focus or similar). .PP The following functions get or set the states. .ie n .IP """change_net_wm_state($X, $window, $action, $state, key=>value,...)""" 4 .el .IP "\f(CWchange_net_wm_state($X, $window, $action, $state, key=>value,...)\fR" 4 .IX Item "change_net_wm_state($X, $window, $action, $state, key=>value,...)" Change one of the \f(CW\*(C`_NET_WM_STATE\*(C'\fR state flags on \f(CW$window\fR by sending a message to the window manager. For example, .Sp .Vb 1 \& change_net_wm_state ($X, $window, "toggle", "FULLSCREEN"); .Ve .Sp \&\f(CW$window\fR must be a managed window, ie. must have had its initial \&\f(CW\*(C`MapWindow()\*(C'\fR and not be an override-redirect. If that's not so or if there's no window manager or it doesn't have \s-1EWMH\s0 then this change message will have no effect. .Sp \&\f(CW$action\fR is a string or integer how to change the state, .Sp .Vb 3 \& "remove" 0 \& "add" 1 \& "toggle" 2 .Ve .Sp \&\f(CW$state\fR is a string such as \*(L"\s-1FULLSCREEN\*(R"\s0 or an atom integer such as \&\f(CW\*(C`$X\->atom("_NET_WM_STATE_FULLSCREEN")\*(C'\fR. .Sp The further optional key/value parameters are .Sp .Vb 3 \& state2 => string or atom \& source => "none", "normal", "user", 0,1,2 \& root => integer XID, or undef .Ve .Sp A change message can act on one or two states. For two states, the second is \f(CW\*(C`state2\*(C'\fR. For example to maximize vertically and horizontally in one operation, .Sp .Vb 2 \& change_net_wm_state ($X, $window, "add", "MAXIMIZED_VERT", \& state2 => "MAXIMIZED_HORZ"); .Ve .Sp \&\f(CW\*(C`source\*(C'\fR is where the change request came from. The default is \*(L"normal\*(R" which means a normal application. \*(L"user\*(R" is for a user-interface control program such as a pager. (\*(L"none\*(R"=0 is what clients prior to \s-1EWMH 1.2\s0 gave.) .Sp \&\f(CW\*(C`root\*(C'\fR is the root window (integer \s-1XID\s0) of \f(CW$window\fR. If \f(CW\*(C`undef\*(C'\fR or not given then it's found by \f(CW\*(C`$X\->QueryTree()\*(C'\fR. If you already know the root then giving it avoids that round-trip query. .ie n .IP """@strings = get_net_wm_state ($X, $window)""" 4 .el .IP "\f(CW@strings = get_net_wm_state ($X, $window)\fR" 4 .IX Item "@strings = get_net_wm_state ($X, $window)" .PD 0 .ie n .IP """@atoms = get_net_wm_state_atoms ($X, $window)""" 4 .el .IP "\f(CW@atoms = get_net_wm_state_atoms ($X, $window)\fR" 4 .IX Item "@atoms = get_net_wm_state_atoms ($X, $window)" .PD Get the \f(CW\*(C`_NET_WM_STATE\*(C'\fR property from \f(CW$window\fR. \f(CW\*(C`get_net_wm_state()\*(C'\fR returns a list of strings such as \*(L"\s-1FULLSCREEN\*(R".\s0 \f(CW\*(C`get_net_wm_state_atoms()\*(C'\fR returns a list of atom integers such as \&\f(CW\*(C`$X\->atom(\*(Aq_NET_WM_STATE_FULLSCREEN\*(Aq)\*(C'\fR. In both cases, if there's no such property or if it's empty then return an empty list. .ie n .IP """set_net_wm_state ($X, $window, $state,...)""" 4 .el .IP "\f(CWset_net_wm_state ($X, $window, $state,...)\fR" 4 .IX Item "set_net_wm_state ($X, $window, $state,...)" Set the \f(CW\*(C`_NET_WM_STATE\*(C'\fR property on \f(CW$window\fR. Each \f(CW$state\fR can be .Sp .Vb 3 \& string like "FULLSCREEN" \& string like "_NET_WM_STATE_FULLSCREEN" \& integer atom of a name like _NET_WM_STATE_FULLSCREEN .Ve .Sp A client can set \f(CW\*(C`_NET_WM_STATE\*(C'\fR on a new window to tell the window manager of desired initial states. This is only a \*(L"should\*(R" in the \s-1EWMH\s0 spec so it might not be obeyed. .Sp .Vb 3 \& # initial desired state \& set_net_wm_state ($X, $window, \& "MAXIMIZED_HORZ", "MAXIMIZED_VERT"); .Ve .Sp After the window is managed by the window manager (once mapped), clients should not set \f(CW\*(C`_NET_WM_STATE\*(C'\fR but instead ask the window manager with \&\f(CW\*(C`change_net_wm_state()\*(C'\fR message above. .SS "_NET_WM_USER_TIME" .IX Subsection "_NET_WM_USER_TIME" .ie n .IP """set_net_wm_user_time ($X, $window, $time)""" 4 .el .IP "\f(CWset_net_wm_user_time ($X, $window, $time)\fR" 4 .IX Item "set_net_wm_user_time ($X, $window, $time)" Set the \f(CW\*(C`_NET_WM_USER_TIME\*(C'\fR property on \f(CW$window\fR. .Sp \&\f(CW$time\fR should be a server time value (an integer) from the last user keypress etc event in \f(CW$window\fR. Or when \f(CW$window\fR is created then the time from the event which caused it to be opened. .Sp On a newly created window, a special \f(CW$time\fR value 0 means the window should not receive the focus when mapped \*(-- assuming the window manager recognises \f(CW\*(C`_NET_WM_USER_TIME\*(C'\fR of course. .Sp If the client has the active window it should update \f(CW\*(C`_NET_WM_USER_TIME\*(C'\fR for every user input. Generally KeyPress and ButtonPress events are user input, but normally KeyRelease and ButtonRelease are not since it's the Press events which are the user actively doing something. .Sp The window manager might use \f(CW\*(C`_NET_WM_USER_TIME\*(C'\fR to 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. .SS "_NET_WM_WINDOW_TYPE" .IX Subsection "_NET_WM_WINDOW_TYPE" .ie n .IP """X11::Protocol::WM::set_net_wm_window_type ($X, $window, $window_type)""" 4 .el .IP "\f(CWX11::Protocol::WM::set_net_wm_window_type ($X, $window, $window_type)\fR" 4 .IX Item "X11::Protocol::WM::set_net_wm_window_type ($X, $window, $window_type)" Set the \f(CW\*(C`_NET_WM_WINDOW_TYPE\*(C'\fR property on \f(CW$window\fR (an \s-1XID\s0). \&\f(CW$window_type\fR can be .Sp .Vb 2 \& string like "NORMAL" \& integer atom of a name like _NET_WM_WINDOW_TYPE_NORMAL .Ve .Sp The window types from from the \s-1EWMH\s0 are as follows. .Sp .Vb 8 \& "NORMAL" \& "DIALOG" \& "DESKTOP" \& "DOCK" \& "TOOLBAR" \& "MENU" \& "UTILITY" \& "SPLASH" .Ve .SS "Frame to Client" .IX Subsection "Frame to Client" .ie n .IP """$window = X11::Protocol::WM::frame_window_to_client ($X, $frame)""" 4 .el .IP "\f(CW$window = X11::Protocol::WM::frame_window_to_client ($X, $frame)\fR" 4 .IX Item "$window = X11::Protocol::WM::frame_window_to_client ($X, $frame)" Return the client window (an \s-1XID\s0) contained within window manager \f(CW$frame\fR window (an \s-1XID\s0). \f(CW$frame\fR is usually an immediate child of the root window. .Sp If no client window can be found in \f(CW$frame\fR then return \f(CW\*(C`undef\*(C'\fR. This might happen if \f(CW$frame\fR is 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 \f(CW$frame\fR would be the client already. .Sp The strategy is to look at \f(CW$frame\fR and down the window tree seeking a \&\f(CW\*(C`WM_STATE\*(C'\fR property 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). .Sp .Vb 11 \& +\-rootwin\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \& | | \& | | \& | +\-frame\-win\-\-\-\-\-\-\-\-+ | \& | | +\-client\-win\-\-\-+ | | \& | | | WM_STATE ... | | | \& | | | | | | \& | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | \& | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | \& | | \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ .Ve .Sp Care is taken not to error out if some windows are destroyed during the search. When a window belongs to other clients it could be destroyed at any time. If \f(CW$frame\fR itself doesn't exist then the return is \f(CW\*(C`undef\*(C'\fR. .Sp This function is similar to what \f(CW\*(C`xwininfo\*(C'\fR and similar programs do to go from a toplevel root window child down to the client window, per \&\fIdmsimple.c\fR \f(CW\*(C`Select_Window()\*(C'\fR or Xlib \f(CW\*(C`XmuClientWindow()\*(C'\fR. (See also X11::Protocol::ChooseWindow.) .SS "Virtual Root" .IX Subsection "Virtual Root" Some window managers use a \*(L"virtual root\*(R" window covering the entire screen. Application windows or frame windows are then children of that virtual root. This can help the window manager implement a large desktop or multiple desktops, though it tends to fail in subtle ways with various root oriented programs, including for example \fBxsetroot\fR\|(1) or the click-to-select in \&\fBxwininfo\fR\|(1) and \fBxprop\fR\|(1). .ie n .IP """$window = X11::Protocol::WM::root_to_virtual_root ($X, $root)""" 4 .el .IP "\f(CW$window = X11::Protocol::WM::root_to_virtual_root ($X, $root)\fR" 4 .IX Item "$window = X11::Protocol::WM::root_to_virtual_root ($X, $root)" If the window manager is using a virtual root then return that window \s-1XID.\s0 If not then return \f(CW\*(C`undef\*(C'\fR. .Sp The current implementation searches for a window with an \f(CW\*(C`_\|_SWM_VROOT\*(C'\fR property, as per the \f(CW\*(C`swm\*(C'\fR, \f(CW\*(C`tvtwm\*(C'\fR and \f(CW\*(C`amiwm\*(C'\fR window managers, and as used by the \f(CW\*(C`xscreensaver\*(C'\fR program and perhaps some versions of \s-1KDE.\s0 .Sp There's nothing yet for \s-1EWMH\s0 \f(CW\*(C`_NET_VIRTUAL_ROOTS\*(C'\fR. Do any window managers use it? Is \f(CW\*(C`_NET_CURRENT_DESKTOP\*(C'\fR an index into that virtual roots list? .Sp (See X11::Protocol::XSetRoot for changing the background of a root or virtual root.) .SH "EXPORTS" .IX Header "EXPORTS" Nothing is exported by default, but the functions can be requested in usual \&\f(CW\*(C`Exporter\*(C'\fR style, .PP .Vb 2 \& use X11::Protocol::WM \*(Aqset_wm_hints\*(Aq; \& set_wm_hints ($X, $window, input => 1, ...); .Ve .PP Or just call with full package name .PP .Vb 2 \& use X11::Protocol::WM; \& X11::Protocol::WM::set_wm_hints ($X, $window, input => 1, ...); .Ve .PP There's no \f(CW\*(C`:all\*(C'\fR 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. .SH "BUGS" .IX Header "BUGS" Not much attention is paid to text on an \s-1EBCDIC\s0 system. Wide char strings probably work, but byte strings may go straight through whereas they ought to be re-coded to Latin\-1. But the same probably applies to parts of the core \f(CW\*(C`X11::Protocol\*(C'\fR such as \f(CW\*(C`$X\->atom_name()\*(C'\fR where you'd want to convert Latin\-1 from the server to native \s-1EBCDIC.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" X11::Protocol, X11::Protocol::Other, X11::Protocol::ChooseWindow, X11::Protocol::XSetRoot .PP \&\*(L"Inter-Client Communication Conventions Manual\*(R", \&\fI/usr/share/doc/xorg\-docs/icccm/icccm.txt.gz\fR, .PP \&\*(L"Compound Text Encoding\*(R" specification. \&\fI/usr/share/doc/xorg\-docs/ctext/ctext.txt.gz\fR, .PP \&\*(L"Extended Window Manager Hints\*(R" which is the \f(CW\*(C`_NET_WM\*(C'\fR things. , .PP \&\fBwmctrl\fR\|(1), \fBxwit\fR\|(1), X(7) .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2011, 2012, 2013, 2014, 2016, 2017, 2018, 2019 Kevin Ryde .PP X11\-Protocol\-Other is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. .PP X11\-Protocol\-Other is distributed in the hope that it will be useful, but \&\s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0 See the \s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with X11\-Protocol\-Other. If not, see .