X11::P...eWindow(3pm)
πΈ X11::Protocol::ChooseWindow β bestie, you click a window and it's chosen π
okay so this is the X11::Protocol::ChooseWindow page from the User Contributed Perl Documentation (that's the 3pm vibe, iykyk). it lives in X11-Protocol-Other and it does exactly one thing and does it gorgeously: it lets a human point at a window and pick it. π«Ά
β¨ NAME β¨
X11::Protocol::ChooseWindow β user click to choose window π±οΈπ
π SYNOPSIS π
use X11::Protocol::ChooseWindow;
my $client_window = X11::Protocol::ChooseWindow->choose (X => $X);
like. that's it. that's the whole thing. slay. β¨
π DESCRIPTION π
This lil spot of code lets the user click on a toplevel window to choose it, in a similar style to the xwininfo or xkill programs. no cap, same energy as those icons. π
π Implementation π
The choose is implemented in a similar way to the xwininfo etc programs. It consists of GrabPointer() on the root window, wait for a ButtonPress and ButtonRelease from the user, get the frame window from the ButtonPress event, then the client window under there from frame_window_to_client() of X11::Protocol::WM. the way it just. walks down to the actual client window. obsessed. π¦
KeyPress 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 ^C (SIGINT) in an xterm or similar. bestie that's lowkey a feature β you can still rage-quit with ^C and it just works. π Perhaps in the future there could be an option to watch for Esc to cancel or some such. (manifesting that for later β¨)
A virtual root per root_to_virtual_root() in X11::Protocol::WM is used if present. This helps ChooseWindow work with amiwm and similar virtual root window managers. so if you're on some funky virtual-root WM, it's got you. π«Ά
π FUNCTIONS π
The following choose() is in class method style with the intention of perhaps in the future having objects of type X11::Protocol::ChooseWindow holding state and advanced by events supplied by an external main loop. rn it's a class method, but the door is open for object main-character energy later. πͺβ¨
π Choosing π
$window = X11::Protocol::ChooseWindow->choose (key=>value,...)
Read a user button press to choose a toplevel window. The key/value options are as follows,
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
okay now let's go through these one by one, no skipping, we don't do that here π
Xordisplaygives the server, or the default is to open theDISPLAYenvironment variable.Xfor anX11::Protocolobject is usual, but sometimes it can make sense to open a new connection just to choose. like yeah normally you already have your connection, but sometimes a fresh one is just the move. πΈrootorscreengives the root window to choose on, or the default is the current screen of$X, 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. automatic. iconic. β¨timeor the time field ineventis a server timestamp for theGrabPointer(). This guards against stealing a grab from another client if badly lagged. Omitted orundefmeansCurrentTime. In a command line program there might be no initiating event, makingCurrentTimeall that's possible. so it's like, protection against grab-stealing when things are laggy, and if you got nothing,CurrentTimeis what you got. periodt. β°cursoretc is the mouse pointer cursor to show during the choose, as a visual indication to the user. The default is acrosshair.cursor_nameorcursor_glyphare from the usual cursor font. See X11::CursorFont for available names. For example perhaps theexchangecursor to choose a window for some sort of swap or flip,
$window = X11::Protocol::ChooseWindow->choose
(X => $X,
cursor_name => "exchange");
the exchange cursor for a swap/flip situation?? the theming?? immaculate. πβ¨
- A
cursorXID 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.
β οΈ bestie do NOT forget the flush if you're creating a cursor on one connection and using it from another β it will not be ready and you will be sad. π
π¦ SEE ALSO π¦
- X11::Protocol, X11::Protocol::WM, X11::CursorFont
xwininfo(1),xkill(1), and theirdsimple.cSelect_Window()code"Inter-Client Communication Conventions Manual"section"WM_STATE Property"for notes on usingWM_STATEto identify client windows.
π HOME PAGE π
<http://user42.tuxfamily.org/x11-protocol-other/index.html>
π LICENSE π
Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2017, 2019 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/>.
and that's the whole page bestie, mwah π β this was X11::P...eWindow(3pm) from perl v5.28.1, dated 2019-08-26. go click a window, you deserve it. πβ¨
π¦ where this page comes from
- debian bookworm: libx11-protocol-other-perl 31-1 Β· GPL-3.0-or-later
- debian trixie: libx11-protocol-other-perl 31-1 Β· GPL-3.0-or-later
- ubuntu jammy: libx11-protocol-other-perl 31-1 Β· GPL-3.0-or-later
- ubuntu noble: libx11-protocol-other-perl 31-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms