.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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::ChooseWindow 3" .TH X11::Protocol::ChooseWindow 3 2023-07-25 "perl v5.38.0" "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::ChooseWindow \-\- user click to choose window .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& use X11::Protocol::ChooseWindow; \& my $client_window = X11::Protocol::ChooseWindow\->choose (X => $X); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This spot of code lets the user click on a toplevel window to choose it, in a similar style to the \f(CW\*(C`xwininfo\*(C'\fR or \f(CW\*(C`xkill\*(C'\fR programs. .SS Implementation .IX Subsection "Implementation" The choose is implemented in a similar way to the \f(CW\*(C`xwininfo\*(C'\fR etc programs. It consists of \f(CWGrabPointer()\fR on the root window, wait for a \&\f(CW\*(C`ButtonPress\*(C'\fR and \f(CW\*(C`ButtonRelease\*(C'\fR from the user, get the frame window from the \f(CW\*(C`ButtonPress\*(C'\fR event, then the client window under there from \&\f(CWframe_window_to_client()\fR of \f(CW\*(C`X11::Protocol::WM\*(C'\fR. .PP \&\f(CW\*(C`KeyPress\*(C'\fR events are not used and they go to the focus window in the usual way. This can be good in a command line program since it lets the user press \f(CW\*(C`^C\*(C'\fR (\f(CW\*(C`SIGINT\*(C'\fR) in an \f(CW\*(C`xterm\*(C'\fR or similar. Perhaps in the future there could be an option to watch for \f(CW\*(C`Esc\*(C'\fR to cancel or some such. .PP A virtual root per \f(CWroot_to_virtual_root()\fR in \f(CW\*(C`X11::Protocol::WM\*(C'\fR is used if present. This helps \f(CW\*(C`ChooseWindow\*(C'\fR work with \f(CW\*(C`amiwm\*(C'\fR and similar virtual root window managers. .SH FUNCTIONS .IX Header "FUNCTIONS" The following \f(CWchoose()\fR is in class method style with the intention of perhaps in the future having objects of type \f(CW\*(C`X11::Protocol::ChooseWindow\*(C'\fR holding state and advanced by events supplied by an external main loop. .SS Choosing .IX Subsection "Choosing" .ie n .IP """$window = X11::Protocol::ChooseWindow\->choose (key=>value,...)""" 4 .el .IP "\f(CW$window = X11::Protocol::ChooseWindow\->choose (key=>value,...)\fR" 4 .IX Item "$window = X11::Protocol::ChooseWindow->choose (key=>value,...)" Read a user button press to choose a toplevel window. The key/value options are as follows, .Sp .Vb 2 \& X => X11::Protocol object \& display => string ":0:0" etc \& \& screen => integer, eg. 0 \& root => XID of root window \& \& time => integer server timestamp \& event => hashref of event initiating the choose \& \& cursor => XID of cursor \& cursor_glyph => integer glyph for cursor font \& cursor_name => string name from cursor font .Ve .Sp \&\f(CW\*(C`X\*(C'\fR or \f(CW\*(C`display\*(C'\fR gives the server, or the default is to open the \&\f(CW\*(C`DISPLAY\*(C'\fR environment variable. \f(CW\*(C`X\*(C'\fR for an \f(CW\*(C`X11::Protocol\*(C'\fR object is usual, but sometimes it can make sense to open a new connection just to choose. .Sp \&\f(CW\*(C`root\*(C'\fR or \f(CW\*(C`screen\*(C'\fR gives the root window to choose on, or the default is the current screen of \f(CW$X\fR, which in turn defaults to the screen part of the display name. If there's a window manager virtual root then that's automatically used as necessary. .Sp \&\f(CW\*(C`time\*(C'\fR or the time field in \f(CW\*(C`event\*(C'\fR is a server timestamp for the \&\f(CWGrabPointer()\fR. This guards against stealing a grab from another client if badly lagged. Omitted or \f(CW\*(C`undef\*(C'\fR means \f(CW\*(C`CurrentTime\*(C'\fR. In a command line program there might be no initiating event, making \f(CW\*(C`CurrentTime\*(C'\fR all that's possible. .Sp \&\f(CW\*(C`cursor\*(C'\fR etc is the mouse pointer cursor to show during the choose, as a visual indication to the user. The default is a "crosshair". \&\f(CW\*(C`cursor_name\*(C'\fR or \f(CW\*(C`cursor_glyph\*(C'\fR are from the usual cursor font. See X11::CursorFont for available names. For example perhaps the "exchange" cursor to choose a window for some sort of swap or flip, .Sp .Vb 3 \& $window = X11::Protocol::ChooseWindow\->choose \& (X => $X, \& cursor_name => "exchange"); .Ve .Sp A \f(CW\*(C`cursor\*(C'\fR XID can be created by any client as usual. Don't forget to flush if creating a cursor from one connection, so it's ready for use from another. .SH "SEE ALSO" .IX Header "SEE ALSO" X11::Protocol, X11::Protocol::WM, X11::CursorFont .PP \&\fBxwininfo\fR\|(1), \fBxkill\fR\|(1), and their \fIdsimple.c\fR \f(CWSelect_Window()\fR code .PP "Inter-Client Communication Conventions Manual" section "WM_STATE Property" for notes on using \f(CW\*(C`WM_STATE\*(C'\fR to identify client windows. .SH "HOME PAGE" .IX Header "HOME PAGE" .SH LICENSE .IX Header "LICENSE" Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2017, 2019 Kevin Ryde .PP 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. .PP 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. .PP You should have received a copy of the GNU General Public License along with X11\-Protocol\-Other. If not, see .