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

feat: add electron.DesktopCapturer.setSkipCursor() method #30231

Closed
wants to merge 5 commits into from

Conversation

danielehrhardt
Copy link

I opened this pull request because the creator of the Original Pull Request closed it without any comments. To read the hole discussion, go here: #28302

Description of Change
feat: Implement electron.DesktopCapturer.setSkipCursor

Useful to dynamically stop cursor capture in the stream.
By default the cursor is captured.
First argument is a deviceId so one can stop capturing
the cursor for a specific streamed source.

#23923

This is essentially a cherrypick of the the previous implementation of @CapOM

#25103

Checklist
PR description included and stakeholders cc'd
npm test passes
tests are changed or added
relevant documentation is changed or added
PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: Implemented DesktopCapturer.setSkipCursor API. Useful to dynamically stop cursor capture in the stream.

@danielehrhardt danielehrhardt requested review from a team as code owners July 21, 2021 22:44
@welcome
Copy link

welcome bot commented Jul 21, 2021

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 21, 2021
@danielehrhardt danielehrhardt changed the title feat: Implement electron.DesktopCapturer.setSkipCursor feat: add electron.DesktopCapturer.setSkipCursor() method Jul 21, 2021
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jul 28, 2021
@zcbenz
Copy link
Member

zcbenz commented Aug 2, 2021

I'm good with the API, but I'm afraid the size of the patch is still going to cause concerns as the same with #28302.

@asineth0
Copy link

asineth0 commented Aug 2, 2021

PR looks good to me, need this functionality for my application so I'm willing to help get this merged if there's anything I can do.

@danielehrhardt
Copy link
Author

I'm good with the API, but I'm afraid the size of the patch is still going to cause concerns as the same with #28302.

Do you see any way to make the size of the patch smaller?

@zcbenz
Copy link
Member

zcbenz commented Aug 4, 2021

As per #28302 (review), the best way to get this merged is to try to upstream the patch to Chromium first.

@asineth0
Copy link

asineth0 commented Aug 4, 2021

As per #28302 (review), the best way to get this merged is to try to upstream the patch to Chromium first.

This adds to the desktopCapturer API in Electron. Makes sense to merge it here.

@zcbenz
Copy link
Member

zcbenz commented Aug 4, 2021

I'm neutral on this patch, but the maintenance work will lay on @electron/wg-upgrades and we should follow their decision (so it does not matter how I think about the PR). For this PR, guidance in #28302 (review) should be followed.

@zcbenz zcbenz added no-backport semver/minor backwards-compatible functionality labels Aug 4, 2021
@nornagon
Copy link
Member

I remain 👎 on a patch of this size.

Are there possible workarounds without this patch, e.g. stopping & starting the stream w/ changed options?

@asineth0
Copy link

Disabling/enabling the cursor without restarting the stream would be preferable especially for apps that are capturing things like games or other interactive content that capture the mouse. Besides, the patch isn't that large, and it includes tests.

@michalzaq12
Copy link
Contributor

michalzaq12 commented Aug 24, 2021

@asineth0 From your reply it appears that there is an option to disable the cursor, but it requires stream restart?

Could you elaborate on how to do this?

@danielehrhardt
Copy link
Author

Could maybe someone upstream this to the chromium project?
I have no clue how to do this.

I think this feature can be useful in so many ways and should be really integrated.

@codebytere
Copy link
Member

codebytere commented Aug 31, 2021

@danielehrhardt here's a guide to contributing to Chromium - i can try to open an upstream CL if you'd prefer though. Can you also please rebase this?

@danielehrhardt
Copy link
Author

@danielehrhardt here's a guide to contributing to Chromium - i can try to open an upstream CL if you'd prefer though. Can you also please rebase this?

This would be great.
I did the rebase.

@asineth0
Copy link

@asineth0 From your reply it appears that there is an option to disable the cursor, but it requires stream restart?

Could you elaborate on how to do this?

As far as I know, you can't currently toggle the cursor at all. Although, if you know how, please let me know. My use case is a chat app where users can screenshare so transparently restarting the stream might not be out of the question, although it's certainly not ideal compared to just calling setSkipCursor.

Could maybe someone upstream this to the chromium project?
I have no clue how to do this.

I think this feature can be useful in so many ways and should be really integrated.

I feel like this should be done in Electron. Chromium is unlikely to upstream a patch like this since it has no corresponding web standard, and it's unlikely that we'd convince the W3C to add it to one easily.

Electron has it's own desktopCapturer object for a reason, so I see no problems with expanding it's functionality.

@asineth0
Copy link

asineth0 commented Sep 3, 2021

Since #30685 has been merged, maybe we could get this merged easier?

@danielehrhardt
Copy link
Author

</3

@zcbenz
Copy link
Member

zcbenz commented Feb 23, 2022

The size of patch has been reduced quite a lot, /cc @electron/wg-upgrades for review.

Copy link
Contributor

@miniak miniak left a comment

Choose a reason for hiding this comment

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

the desktopCapturer is now only available in the main process. you need to rebase and refactor your PR to accommodate for this change.

@danielehrhardt
Copy link
Author

the desktopCapturer is now only available in the main process. you need to rebase and refactor your PR to accommodate for this change.

Is there any chance if i do the rebase and refactor of the PR that it will get merged? I will not invest the work if it is not worth it.

@nornagon
Copy link
Member

nornagon commented Mar 3, 2022

I think this could be better addressed by changes/extensions to #30702, through getDisplayMedia. It seems like there's a specced (but currently unimplemented) way through getDisplayMedia to do this: https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/cursor and https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/applyConstraints. We should support the specced version.

I'm going to close this for now and add a comment to #30702 to mark that we want to investigate supporting this through getDisplayMedia.

@samuelmaddock
Copy link
Member

Just following up to mention that the upstream issue for adding support for this MediaStreamTrack constraint in Chromium is here: https://bugs.chromium.org/p/chromium/issues/detail?id=1007177

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

Successfully merging this pull request may close these issues.

None yet

8 participants