class

XDo::Window

Inherits Reference / Object

Represents an XDo view of an X11 window.

win.move_mouse 0, 0
puts "typing inside #{win["WM_NAME"]}"
win.type "hello!"

Constructors

new(xdo_p : Pointer(XDo::LibXDo::XDo), window : UInt64)
Source

Instance methods

==(other)

Returns true if other has the same X11 window ID (WID).

Source
[](property : String)

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.

Source
[]=(property : String, value : String)

Set the window's property property to value.

# change the window's title-bar name
win["WM_NAME"] = "my custom window name"
Source
activate!

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!
Source
child

Attempt to find the window's child.

Source
class=(klass : String)

Set the window's class (WM_CLASS class name) to klass.

win.class = "my-custom-class"
Source
class_name=(name : String)

Set the window's class name (WM_CLASS instance name) to name.

win.class_name = "my-custom-instance"
Source
click(button : Button, repeat, delay = DEFAULT_DELAY)

Click the given mouse button repeat times, with delay between each click.

Source
click(button : Button)

Click the given mouse button on this window (mouse-down + mouse-up)

Source
close!

Closes a window without trying to kill its client.

To kill the client while closing a window, see #kill!.

Source
desktop

Get the window's desktop number.

desktop = win.desktop
Source
focus!

Focuses the window.

See #activate! for WMs with _NET_ACTIVE_WINDOW.

Source
keys(keys : String, delay = DEFAULT_DELAY)

Send some keys (down + up) to the window, with delay between them.

win.keys "Ctrl+s"
Source
keys_down(keys : String, delay = DEFAULT_DELAY)

Send some key press (down) events for the given keys, with delay between them. See #keys_up.

win.keys_down "Ctrl+o"
Source
keys_up(keys : String, delay = DEFAULT_DELAY)

Send some key release (up) events for the given keys, with delay between them. See #keys_down.

win.keys_up "Ctrl+o"
Source
kill!

Kills a window and the client owning it.

To close a window without killing its client, see #close!.

Source
location

Get the window's location, consisting of a tuple of width, height, and Screen object

x, y, screen = win.location
Source
map!

Maps the window, making it visible if previously unmapped. See #unmap!.

Source
minimize!

Minimizes the window.

Source
mouse_down(button : Button)

Send a mouse-down event for the given mouse button to this window.

Source
mouse_up(button : Button)

Send a mouse-up event for the given mouse button to this window.

Source
move(x, y)

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
Source
move(desktop)

Attempt to move the window to desktop.

# try to move the window to desktop #3
win.move 3
Source
move_mouse(x, y)

Move the mouse relative to this window.

Source
name

Get the window's name (WM_NAME), if any.

Source
on_active(*, want_active = true, &)

Wait for the window to become active or inactive, per want_active.

Source
on_focus(*, want_focus = true, &)

Wait for the window to gain or lose focus, per want_focus.

Source
on_map_state(state : WindowMapState, &)

Wait for the window's map state to become state.

Source
on_size_change

Wait for the window's dimensions to change, and yield self.

window.on_size_change do
  puts "my new size is: #{window.size}"
end
Source
on_size_from(width, height, use_hints = false, &)

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).

Source
on_size_to(width, height, use_hints = false, &)

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).

Source
override_redirect=(override_redirect : Bool)

Set the window's override-redirect flag.

win.override_redirect = true
Source
parent

Attempt to find the window's parent.

Source
pid

Return the process ID associated with the window, or 0 if not found.

Source
raise!

Raises the window (bringing it to the foreground).

Source
resize(width, height, flags : ResizeFlag = ResizeFlag::Pixels)

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
Source
size

Return the size of the window as a tuple of width and height.

width, height = win.size
Source
translate_with_hint(width, height)

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
Source
type(text : String, delay = DEFAULT_DELAY)

Send some text to the window, with delay between the keystrokes.

win.type "hello from Crystal!"
Source
unmap!

Unmaps the window, making it invisible. See #map!.

Source
urgent=(urgent : Bool)

Set the window's urgency hint.

# tell the WM to indicate the window's urgency to the user
win.urgent = true
Source
wait_for_active(*, want_active = true)

Wait for the window to become active or inactive, per want_active.

Source
wait_for_focus(*, want_focus = true)

Wait for the window to gain or lose focus, per want_focus.

Source
wait_for_map_state(state : WindowMapState)

Wait for the window's map state to become state.

Source
wait_for_size_from(width, height, use_hints = false)

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).

Source
wait_for_size_to(width, height, use_hints = false)

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).

Source
window
Source