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 Linux support #144

Open
Mustaballer opened this issue May 12, 2023 · 4 comments
Open

Add Linux support #144

Mustaballer opened this issue May 12, 2023 · 4 comments
Labels
$ bounty $ Please suggest a price range 🙏 enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Mustaballer
Copy link
Collaborator

The following functions, get_double_click_interval_seconds and get_double_click_distance_pixels in utils.py only work for Windows and Mac platforms. The goal is to add Linux support as well.

    if hasattr(get_double_click_interval_seconds, "override_value"):
        return get_double_click_interval_seconds.override_value
    if sys.platform == "darwin":
        from AppKit import NSEvent
        return NSEvent.doubleClickInterval()
    elif sys.platform == "win32":
        # https://stackoverflow.com/a/31686041/95989
        from ctypes import windll
        return windll.user32.GetDoubleClickTime() / 1000
    else:
        raise Exception(f"Unsupported {sys.platform=}")


def get_double_click_distance_pixels():
    if sys.platform == "darwin":
        # From https://developer.apple.com/documentation/appkit/nspressgesturerecognizer/1527495-allowablemovement:
        #     The default value of this property is the same as the
        #     double-click distance.
        # TODO: do this more robustly; see:
        # https://forum.xojo.com/t/get-allowed-unit-distance-between-doubleclicks-on-macos/35014/7
        from AppKit import NSPressGestureRecognizer
        return NSPressGestureRecognizer.new().allowableMovement()
    elif sys.platform == "win32":
        import win32api
        import win32con
        x = win32api.GetSystemMetrics(win32con.SM_CXDOUBLECLK)
        y = win32api.GetSystemMetrics(win32con.SM_CYDOUBLECLK)
        if x != y:
            logger.warning(f"{x=} != {y=}")
        return max(x, y)
    else:
        raise Exception(f"Unsupported {sys.platform=}")```
@Mustaballer Mustaballer changed the title Add Linus support for get_double_click_interval_seconds and get_double_click_distance_pixels in utils.py Add Linux support for get_double_click_interval_seconds and get_double_click_distance_pixels in utils.py May 12, 2023
@abrichr
Copy link
Contributor

abrichr commented May 13, 2023

Looks like this might be window-manager specific; see:

https://stackoverflow.com/questions/50868129/how-to-get-double-click-time-interval-value-programmatically-on-linux

https://bbs.archlinux.org/viewtopic.php?id=240001

https://unix.stackexchange.com/questions/45925/how-to-configure-the-double-click-behavior-in-an-x-terminal

Edit: as a workaround we can always define a DEFAULT_DOUBLE_CLICK_DISTANCE_PIXELS and DEFAULT_DOUBLE_CLICK_INTERVAL_SECONDS

@abrichr abrichr added the help wanted Extra attention is needed label May 15, 2023
@abrichr abrichr changed the title Add Linux support for get_double_click_interval_seconds and get_double_click_distance_pixels in utils.py Add Linux support May 15, 2023
@abrichr
Copy link
Contributor

abrichr commented May 15, 2023

We are currently using a modified version of pynput at https://github.com/abrichr/pynput that supports distinguishing between organic and injected input. Last time I checked this was not supported on Linux, but strictly speaking it's not absolutely necessary for our purpose.

@Mustaballer Mustaballer self-assigned this May 15, 2023
@abrichr
Copy link
Contributor

abrichr commented Jun 14, 2024

@Timothyxxx regarding xlang-ai/OSWorld#30

@abrichr
Copy link
Contributor

abrichr commented Jun 14, 2024

Related: #631

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
$ bounty $ Please suggest a price range 🙏 enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants