class XDo::Window
- XDo::Window
- Reference
- Object
Overview
Represents an XDo
view of an X11 window.
win.move_mouse 0, 0
puts "typing inside #{win["WM_NAME"]}"
win.type "hello!"
Defined in:
x_do/window.crConstructors
Instance Method Summary
-
#==(other)
Returns true if
other
has the same X11 window ID (WID). -
#[](property : String)
Get the value associated with the property property.
-
#[]=(property : String, value : String)
Set the window's property property to value.
-
#activate!
Activates the window.
-
#child
Attempt to find the window's child.
-
#class=(klass : String)
Set the window's class (
WM_CLASS
class name) to klass. -
#class_name=(name : String)
Set the window's class name (
WM_CLASS
instance name) to name. -
#click(button : Button, repeat, delay = DEFAULT_DELAY)
Click the given mouse button repeat times, with delay between each click.
-
#click(button : Button)
Click the given mouse button on this window (mouse-down + mouse-up)
-
#close!
Closes a window without trying to kill its client.
-
#desktop
Get the window's desktop number.
-
#focus!
Focuses the window.
-
#keys(keys : String, delay = DEFAULT_DELAY)
Send some keys (down + up) to the window, with delay between them.
-
#keys_down(keys : String, delay = DEFAULT_DELAY)
Send some key press (down) events for the given keys, with delay between them.
-
#keys_up(keys : String, delay = DEFAULT_DELAY)
Send some key release (up) events for the given keys, with delay between them.
-
#kill!
Kills a window and the client owning it.
-
#location
Get the window's location, consisting of a tuple of
width
,height
, andScreen
object -
#map!
Maps the window, making it visible if previously unmapped.
-
#minimize!
Minimizes the window.
-
#mouse_down(button : Button)
Send a mouse-down event for the given mouse button to this window.
-
#mouse_up(button : Button)
Send a mouse-up event for the given mouse button to this window.
-
#move(x, y)
Attempt to move the window to x, y on the screen.
-
#move(desktop)
Attempt to move the window to desktop.
-
#move_mouse(x, y)
Move the mouse relative to this window.
-
#name
Get the window's name (
WM_NAME
), if any. -
#on_active(*, want_active = true, &)
Wait for the window to become active or inactive, per want_active.
-
#on_focus(*, want_focus = true, &)
Wait for the window to gain or lose focus, per want_focus.
-
#on_map_state(state : WindowMapState, &)
Wait for the window's map state to become state.
-
#on_size_change(&)
Wait for the window's dimensions to change, and yield
self
. -
#on_size_from(width, height, use_hints = false, &)
Wait for the window's dimensions to change from width x height to something else.
-
#on_size_to(width, height, use_hints = false, &)
Wait for the window's dimensions to change to width x height from something else.
-
#override_redirect=(override_redirect : Bool)
Set the window's override-redirect flag.
-
#parent
Attempt to find the window's parent.
-
#pid
Return the process ID associated with the window, or
0
if not found. -
#raise!
Raises the window (bringing it to the foreground).
-
#resize(width, height, flags : ResizeFlag = ResizeFlag::Pixels)
Attempt to change the window's size to width x height, scaled by flags.
-
#size
Return the size of the window as a tuple of
width
andheight
. -
#translate_with_hint(width, height)
Attempt to apply the window's sizing hints with the given width and height.
-
#type(text : String, delay = DEFAULT_DELAY)
Send some text to the window, with delay between the keystrokes.
-
#unmap!
Unmaps the window, making it invisible.
-
#urgent=(urgent : Bool)
Set the window's urgency hint.
-
#wait_for_active(*, want_active = true)
Wait for the window to become active or inactive, per want_active.
-
#wait_for_focus(*, want_focus = true)
Wait for the window to gain or lose focus, per want_focus.
-
#wait_for_map_state(state : WindowMapState)
Wait for the window's map state to become state.
-
#wait_for_size_from(width, height, use_hints = false)
Wait for the window's dimensions to change from width x height to something else.
-
#wait_for_size_to(width, height, use_hints = false)
Wait for the window's dimensions to change to width x height from something else.
- #window : LibXDo::Window
Constructor Detail
Instance Method Detail
Get the value associated with the property property.
NOTE Always returns a string, regardless of the underlying X11 atom. As a result, this method can return "garbage" strings for some property names.
Set the window's property property to value.
# change the window's title-bar name
win["WM_NAME"] = "my custom window name"
Activates the window. Requires _NET_ACTIVE_WINDOW
from EWMH.
See #focus!
for WMs without _NET_ACTIVE_WINDOW
.
# switch to the window's desktop and raise it
win.activate!
Set the window's class (WM_CLASS
class name) to klass.
win.class = "my-custom-class"
Set the window's class name (WM_CLASS
instance name) to name.
win.class_name = "my-custom-instance"
Click the given mouse button repeat times, with delay between each click.
Click the given mouse button on this window (mouse-down + mouse-up)
Closes a window without trying to kill its client.
To kill the client while closing a window, see #kill!
.
Send some keys (down + up) to the window, with delay between them.
win.keys "Ctrl+s"
Send some key press (down) events for the given keys, with delay between them.
See #keys_up
.
win.keys_down "Ctrl+o"
Send some key release (up) events for the given keys, with delay between them.
See #keys_down
.
win.keys_up "Ctrl+o"
Kills a window and the client owning it.
To close a window without killing its client, see #close!
.
Get the window's location, consisting of a tuple of width
, height
,
and Screen
object
x, y, screen = win.location
Send a mouse-down event for the given mouse button to this window.
Send a mouse-up event for the given mouse button to this window.
Attempt to move the window to x, y on the screen.
# try to put the window in the upper left corner
win.move 0, 0
Attempt to move the window to desktop.
# try to move the window to desktop #3
win.move 3
Wait for the window to become active or inactive, per want_active.
Wait for the window's dimensions to change, and yield self
.
window.on_size_change do
puts "my new size is: #{window.size}"
end
Wait for the window's dimensions to change from width x height to something else.
If use_hints is set to true, the supplied dimensions are measured according to the window's size hints (not necessarily pixels).
Wait for the window's dimensions to change to width x height from something else.
If use_hints is set to true, the supplied dimensions are measured according to the window's size hints (not necessarily pixels).
Set the window's override-redirect flag.
win.override_redirect = true
Attempt to change the window's size to width x height, scaled by flags.
# make the window 100px by 100px
win.resize 100, 100
# make the window 500 by 500 size-hint units
win.resize 500, 500, ResizeFlag::UseHints
Attempt to apply the window's sizing hints with the given width and height.
Uses XGetWMNormalHints()
internally to determine the resize increment and base size.
win.translate_with_hint 100, 100
Send some text to the window, with delay between the keystrokes.
win.type "hello from Crystal!"
Set the window's urgency hint.
# tell the WM to indicate the window's urgency to the user
win.urgent = true
Wait for the window to become active or inactive, per want_active.
Wait for the window to gain or lose focus, per want_focus.
Wait for the window's dimensions to change from width x height to something else.
If use_hints is set to true, the supplied dimensions are measured according to the window's size hints (not necessarily pixels).
Wait for the window's dimensions to change to width x height from something else.
If use_hints is set to true, the supplied dimensions are measured according to the window's size hints (not necessarily pixels).