rshk / python-libxdo

Python bindings for libxdo
BSD 3-Clause "New" or "Revised" License
76 stars 19 forks source link

Provide nicer interface for CURRENTWINDOW #13

Open rshk opened 8 years ago

rshk commented 8 years ago

Many Xdo methods have a signature like method(window, ...), but it would be nice to have window optional, and default to CURRENTWINDOW.

One alternative can be to swap arguments, but either:

One option might be to have some Window(window_id) object, whose methods are (in a controlled way!) equivalent to name = partial(name, window_id)

NOTE: we need to pass the Xdo instance as well along the way to Window

import xdo
x = xdo.Xdo()

current_window = x.get_window()  # Returns a Window(xdo, 0)

some_id = x.get_window_at_mouse()
some_window = x.get_window(some_id)  # Returns a Window(xdo, window_id)