Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional Window classes and change the old one #102

Merged
merged 10 commits into from
Jul 18, 2019

Conversation

drmfinlay
Copy link
Member

@drmfinlay drmfinlay commented Jul 16, 2019

Related issues: #8 #35 #77

This PR does quite a few things. This is a summary of the changes:

  • Add X11Window class using xdotool and xprop.
    Big thanks to @calmofthestorm for Aenea's xdotool/xprop code!
    This class can do pretty much everything the Windows-only class can do:

    • Get various attributes available from xprop / xdotool (title, class, class name, executable, pid, id/handle). This allows AppContext to work on X11! 🎉🎉
    • Common operations like minimize, maximize, restore, set foreground, set focus.
    • Get/set geometry with get_position(), set_position() and move(). This includes the fun window movement functionality in window_movers.py, which animates windows as they move.
    • Get window state, e.g. if a window is focused, minimized, maximized, in fullscreen mode, etc.
  • Add FakeWindow class that replaces the mocked classes in dragonfly/os_dependent_mock.py.
    It is also used on Linux if the XDG_SESSION_TYPE environment variable isn't set to "X11". So the Travis CI tests will use FakeWindow because they don't run in an X11 session.
    This class may be useful for testing contexts.

  • Add BaseWindow class containing many things from the old Window class.

  • Rename the old Window class to Win32Window and move it into win32_window.py. It is still imported as Window though.

  • Import the current platform's window class as Window in window.py.
    This should make these changes backwards-compatible.

  • Unmock WaitWindow, FocusWindow, StartApp and BringApp dragonfly actions.
    The FocusWindow action executes very slowly at the moment on X11 because of the large number of xdotool processes that it spawns via the X11Window properties and methods. I have some ideas on fixing this problem before merging. This should be fixed now.

  • Add documentation page on window classes.

- Add BaseWindow class containing many things from the old Window
  class.
- Add FakeWindow class imported as 'Window' on unsupported
  platforms, including on Linux if X11 isn't detected.
- Add X11Window class requiring the psutil package and the xdotool
  and xprop commandline programs.
- Import the Window class for the current platform as 'Window' in
  window.py.
- Rename old Window class to Win32Window and move it into
  win32_window.py.
- Use 'id' instead of 'handle' in BaseWindow, but keep the latter
  around for backwards-compatibility.
Both of these have been replaced by the FakeWindow class.
This is used by the X11Window class.
@drmfinlay drmfinlay added New Feature A new feature that is distinct from the implemented features Linux/X11 Issue regarding Linux or X11 support labels Jul 16, 2019
@drmfinlay drmfinlay self-assigned this Jul 16, 2019
This commit mostly improves the performance of the X11Window class.

- Add get_window() and get_matching_windows() methods to Window
  classes.
- Only retrieve required properties from xprop instead of
  everything.
- Only return visible windows with associated pids from the
  get_all_windows() and get_matching_windows() methods.
- Simplify how arguments are passed to xdotool/xprop.
- Use Window.get_matching_windows() in FocusWindow (removes delay
  on X11).
This is done via the 'xdotool windowsize' command. The Win32Window
class also allows this.
This works on Windows and X11 through the Window classes for those
platforms and through the FakeWindow class on unsupported platforms.
@drmfinlay
Copy link
Member Author

This should be ready for merging.

There is a delay the first time Window.get_all_windows(), FocusWindow or BringApp are used, but they should be quick afterwards. None of these will detect minimized windows for the moment. I think this is unavoidable, but there may be ways around it. It may also be dependent on the window manager, I'm not sure. It can always be fixed later.

@drmfinlay drmfinlay merged commit ac2234e into master Jul 18, 2019
drmfinlay added a commit that referenced this pull request Jul 18, 2019
Add additional Window classes and change the old one
@drmfinlay drmfinlay deleted the feat/x11-window-class branch July 20, 2019 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux/X11 Issue regarding Linux or X11 support New Feature A new feature that is distinct from the implemented features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant