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

V2 update with availble types performance tweaks #49

Open
wants to merge 9 commits into
base: v2
Choose a base branch
from

Conversation

jasonterando
Copy link

This PR includes the clipboard-rs 0.2.1 support for disabling the Linux clipboard timeout, and the following:

  1. Improved available_types performance by locking once instead of for each clipboard data type
  2. Include available types in on_clipboard_change so client knows immediately what clipboard data is available

@jasonterando
Copy link
Author

Dropping this for now, until I can get a "clean" implementation working with yarn and pnpm

@jasonterando
Copy link
Author

I ended up creating another branch in my fork to support pre-release yarn builds.

@jasonterando jasonterando reopened this Sep 21, 2024
@HuakunShen
Copy link
Collaborator

HuakunShen commented Sep 22, 2024

I agree this this more convenient, but not sure if i'ts a good idea to run has 5 times in rust for a monitor function. I want the monitor function be as efficient as possible.

Have you tested the delay cost of adding 5 extra has() calls on each platform?
I am Okay with this feature if the extra delay is negligible.

@HuakunShen
Copy link
Collaborator

HuakunShen commented Sep 22, 2024

Maybe we can implement a tauri command to get all available types at once instead of calling has for each type.

Or a separate monitor function with available types.

@jasonterando
Copy link
Author

Maybe we can implement a tauri command to get all available types at once instead of calling has for each type.

Or a separate monitor function with available types.

I'll do some benchmarking. I took another look and there's function in clipboard-rs called "available_formats" that appears to return all of the formats in one call. If that's the case, we can leverage that, and I think it should be a win-win.

src/desktop.rs Outdated
let mut image = false;
let mut files = false;

for format in formats {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these formats consistent on all three platforms?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh... you're absolutely right. These have to be mapped "upstream" in clipboard_rs. I can do it for Windows and Linux but I need to get my hands on a Mac, and then I need to work with the clipboard-rs to get that merged in - I just submitted a fix to X11 clipboard images and the maintainer is easy to work with. This will probably take a week or two. I'm thinking I"ll have to add a "get_formats" call in that project that will do the mapping. This has turned into a "pull the string on a sweater" exercise but it's probably worth doing. I'll ping you once I finish things on the clipboard-rs end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants