Skip to content

Commit

Permalink
Move X11 platforms checks back below the ones for Windows and MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
drmfinlay committed Oct 16, 2022
1 parent d43cb4e commit 1b7d3f5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 52 deletions.
33 changes: 15 additions & 18 deletions dragonfly/actions/keyboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@


# Import the keyboard classes for the current platform.
# Note: X11 is checked first here because it is possible to use on the other
# supported platforms.
if IS_X11:
if sys.platform == "win32":
from ._win32 import (
Win32Keyboard as Keyboard,
Win32Typeable as Typeable,
Win32KeySymbols as KeySymbols
)

elif sys.platform == "darwin":
from ._pynput import (
PynputKeyboard as Keyboard,
PynputTypeable as Typeable,
DarwinKeySymbols as KeySymbols
)

elif IS_X11:
# Import classes for X11. This is typically used on Unix-like systems.
# The DISPLAY environment variable is normally set in an X11 session.
# If it is not, it may be set manually in ~/.profile or equivalent.
Expand All @@ -47,21 +59,6 @@
# used.
# from ._x11_libxdo import LibxdoKeyboard as Keyboard

elif sys.platform == "win32":
# Import Win32 classes.
from ._win32 import (
Win32Keyboard as Keyboard,
Win32Typeable as Typeable,
Win32KeySymbols as KeySymbols
)

elif sys.platform == "darwin":
from ._pynput import (
PynputKeyboard as Keyboard,
PynputTypeable as Typeable,
DarwinKeySymbols as KeySymbols
)

else:
# No keyboard implementation is available. Dragonfly can function
# without a keyboard class, so don't raise an error or log any
Expand Down
28 changes: 13 additions & 15 deletions dragonfly/actions/mouse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@


# Import the mouse functions and classes for the current platform.
# Note: X11 is checked first here because it is possible to use on the other
# supported platforms.
if IS_X11:
if sys.platform == "win32":
from ._win32 import (
ButtonEvent, get_cursor_position, set_cursor_position,
PLATFORM_BUTTON_FLAGS, PLATFORM_WHEEL_FLAGS
)

elif sys.platform == "darwin":
from ._pynput import (
ButtonEvent, get_cursor_position, set_cursor_position,
PLATFORM_BUTTON_FLAGS, PLATFORM_WHEEL_FLAGS
)

elif IS_X11:
try:
# Prefer pynput over xdotool since it supports horizontal scrolling
# and the extra mouse buttons.
Expand All @@ -49,18 +59,6 @@
PLATFORM_BUTTON_FLAGS, PLATFORM_WHEEL_FLAGS
)

elif sys.platform == "win32":
from ._win32 import (
ButtonEvent, get_cursor_position, set_cursor_position,
PLATFORM_BUTTON_FLAGS, PLATFORM_WHEEL_FLAGS
)

elif sys.platform == "darwin":
from ._pynput import (
ButtonEvent, get_cursor_position, set_cursor_position,
PLATFORM_BUTTON_FLAGS, PLATFORM_WHEEL_FLAGS
)

else:
# No mouse interface is available. Dragonfly can function
# without this functionality, so don't raise an error or log any
Expand Down
12 changes: 5 additions & 7 deletions dragonfly/windows/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,18 @@


# Import the clipboard classes and functions for the current platform.
# Note: X11 is checked first here because it is possible to use on the other
# supported platforms.
if IS_X11:
from dragonfly.windows.x11_clipboard import \
XselClipboard as Clipboard

elif sys.platform == "win32":
if sys.platform == "win32":
from dragonfly.windows.win32_clipboard import \
Win32Clipboard as Clipboard, win32_clipboard_ctx

elif sys.platform == "darwin":
from dragonfly.windows.pyperclip_clipboard import \
PyperclipClipboard as Clipboard

elif IS_X11:
from dragonfly.windows.x11_clipboard import \
XselClipboard as Clipboard

else:
from dragonfly.windows.base_clipboard import \
BaseClipboard as Clipboard
10 changes: 4 additions & 6 deletions dragonfly/windows/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@


# Import the Monitor class for the current platform.
# Note: X11 is checked first here because it is possible to use on the other
# supported platforms.
if IS_X11:
from dragonfly.windows.x11_monitor import X11Monitor as Monitor

elif sys.platform == "win32":
if sys.platform == "win32":
from dragonfly.windows.win32_monitor import Win32Monitor as Monitor

elif sys.platform == "darwin":
from dragonfly.windows.darwin_monitor import DarwinMonitor as Monitor

elif IS_X11:
from dragonfly.windows.x11_monitor import X11Monitor as Monitor

else:
from dragonfly.windows.base_monitor import FakeMonitor as Monitor

Expand Down
10 changes: 4 additions & 6 deletions dragonfly/windows/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@


# Import the Window class for the current platform.
# Note: X11 is checked first here because it is possible to use on the other
# supported platforms.
if IS_X11:
from dragonfly.windows.x11_window import X11Window as Window

elif sys.platform == "win32":
if sys.platform == "win32":
from dragonfly.windows.win32_window import Win32Window as Window

elif sys.platform == "darwin":
from dragonfly.windows.darwin_window import DarwinWindow as Window

elif IS_X11:
from dragonfly.windows.x11_window import X11Window as Window

else:
from dragonfly.windows.fake_window import FakeWindow as Window

0 comments on commit 1b7d3f5

Please sign in to comment.