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

fix: set display_id in desktop capturer on Linux #33861

Merged

Conversation

jamesnvc
Copy link
Contributor

@jamesnvc jamesnvc commented Apr 20, 2022

Description of Change

Previously, display_id was an empty string on Linux, pending Chrome support for
sharing individual screens. Now that this has been added, it is
desirable to have this property set correctly.

Addresses #27732.

Checklist

notes: Provided display_id for desktopCapturer on Linux.

@welcome
Copy link

welcome bot commented Apr 20, 2022

💖 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 Apr 20, 2022
@jamesnvc jamesnvc force-pushed the add-linux-display-id-desktop-capturer branch from 16b8303 to c63a155 Compare April 20, 2022 18:44
@jamesnvc
Copy link
Contributor Author

jamesnvc commented Apr 20, 2022

I've "tested" ad-hoc, by running the built electron, but running npm test is giving me errors trying to install things (an apparently "ignorable" error from node-gyp installing abstract-socket, but then it fails building in src/electron-spec, being unable to build is-valid-window (fixed that error) in some python script, saying it can't find something in a path that isn't even inside the project.

@jamesnvc jamesnvc force-pushed the add-linux-display-id-desktop-capturer branch from c63a155 to a1d24dc Compare April 20, 2022 18:49
@jamesnvc
Copy link
Contributor Author

I also understand that this fix is for "Linux", but is currently X11-only. Is there a build flag or some-such I should be using instead of BUILDFLAG(IS_LINUX) to only do this on Linux+X11 platforms?

@jamesnvc jamesnvc force-pushed the add-linux-display-id-desktop-capturer branch from a1d24dc to 7f1766f Compare April 20, 2022 18:53
@jamesnvc
Copy link
Contributor Author

(I'm also quite sure that the code here should be moved elsewhere -- I originally wrote the helper functions in ui/base/x/x11_display_util.cc, (which I guess is actually Chrome?) and just moved it in here so it would be self-contained & all in electron-land.)

@RaisinTen
Copy link
Member

I also understand that this fix is for "Linux", but is currently X11-only. Is there a build flag or some-such I should be using instead of BUILDFLAG(IS_LINUX) to only do this on Linux+X11 platforms?

I believe what you're looking for is USE_OZONE_PLATFORM_X11. You should define it first like

#if defined(USE_OZONE)
#include "ui/ozone/buildflags.h"
#if BUILDFLAG(OZONE_PLATFORM_X11)
#define USE_OZONE_PLATFORM_X11
#endif
#endif
and then use it like
#if defined(USE_OZONE_PLATFORM_X11)
if (IsX11())
return !event_disabler_.get();
#endif
wherever you need it.

@jamesnvc jamesnvc force-pushed the add-linux-display-id-desktop-capturer branch from 7f1766f to 9210512 Compare April 27, 2022 14:02
@jamesnvc
Copy link
Contributor Author

Thanks for the tip @RaisinTen! Updated the PR.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Apr 27, 2022
Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

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

There is a lint warning

$ node ./script/lint.js && npm run lint:clang-format && npm run lint:docs
--- a/shell/browser/api/electron_api_desktop_capturer.cc
+++ b/shell/browser/api/electron_api_desktop_capturer.cc
@@ -39,7 +39,7 @@
 #include "ui/gfx/x/randr.h"
 #include "ui/gfx/x/x11_atom_cache.h"
 #include "ui/gfx/x/xproto_util.h"
-#endif // defined(USE_OZONE_PLATFORM_X11)
+#endif  // defined(USE_OZONE_PLATFORM_X11)
 #endif  // BUILDFLAG(IS_WIN)

@jamesnvc jamesnvc force-pushed the add-linux-display-id-desktop-capturer branch from 9210512 to df57ad8 Compare May 2, 2022 11:55
@jamesnvc
Copy link
Contributor Author

jamesnvc commented May 2, 2022

There is a lint warning

Oops, thank-you, fixed.

Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

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

Overall looks pretty sane. I had a few questions/comments but no fundamental change requests.

shell/browser/api/electron_api_desktop_capturer.cc Outdated Show resolved Hide resolved
shell/browser/api/electron_api_desktop_capturer.cc Outdated Show resolved Hide resolved
shell/browser/api/electron_api_desktop_capturer.h Outdated Show resolved Hide resolved
@jamesnvc jamesnvc force-pushed the add-linux-display-id-desktop-capturer branch from df57ad8 to f7626c3 Compare May 2, 2022 16:08
@jkleinsc jkleinsc added semver/patch backwards-compatible bug fixes target/15-x-y labels May 17, 2022
@jkleinsc
Copy link
Contributor

@jamesnvc can you rebase this PR with the latest from main?

@jamesnvc jamesnvc force-pushed the add-linux-display-id-desktop-capturer branch from f7626c3 to d6262b7 Compare May 17, 2022 20:10
@jamesnvc
Copy link
Contributor Author

@jamesnvc can you rebase this PR with the latest from main?

Done

@codebytere codebytere requested review from ckerr and zcbenz May 19, 2022 08:07
Copy link
Contributor

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

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

GN failures need to be addressed

shell/browser/api/electron_api_desktop_capturer.cc Outdated Show resolved Hide resolved
trop bot pushed a commit that referenced this pull request Sep 27, 2022
Previously, display_id was an empty string, pending Chrome support for
sharing individual screens. Now that this has been added, it is
desirable to have this property set correctly.

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
trop bot pushed a commit that referenced this pull request Sep 27, 2022
Previously, display_id was an empty string, pending Chrome support for
sharing individual screens. Now that this has been added, it is
desirable to have this property set correctly.

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
@trop
Copy link
Contributor

trop bot commented Sep 27, 2022

I have automatically backported this PR to "20-x-y", please check out #35834

@trop
Copy link
Contributor

trop bot commented Sep 27, 2022

I have automatically backported this PR to "19-x-y", please check out #35835

@ckerr ckerr added the target/21-x-y PR should also be added to the "21-x-y" branch. label Sep 27, 2022
@ckerr
Copy link
Member

ckerr commented Sep 27, 2022

/trop run backport-to 21-x-y

@trop
Copy link
Contributor

trop bot commented Sep 27, 2022

The backport process for this PR has been manually initiated - sending your PR to 21-x-y!

@ckerr ckerr added in-flight/21-x-y and removed target/21-x-y PR should also be added to the "21-x-y" branch. labels Sep 27, 2022
trop bot pushed a commit that referenced this pull request Sep 27, 2022
Previously, display_id was an empty string, pending Chrome support for
sharing individual screens. Now that this has been added, it is
desirable to have this property set correctly.

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
@trop
Copy link
Contributor

trop bot commented Sep 27, 2022

I have automatically backported this PR to "21-x-y", please check out #35836

@trop trop bot added merged/21-x-y PR was merged to the "21-x-y" branch. merged/19-x-y and removed in-flight/21-x-y labels Sep 28, 2022
codebytere pushed a commit that referenced this pull request Sep 28, 2022
fix: set display_id in desktop capturer on Linux (#33861)

Previously, display_id was an empty string, pending Chrome support for
sharing individual screens. Now that this has been added, it is
desirable to have this property set correctly.

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

Co-authored-by: James Cash <james.nvc@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
codebytere pushed a commit that referenced this pull request Sep 28, 2022
fix: set display_id in desktop capturer on Linux (#33861)

Previously, display_id was an empty string, pending Chrome support for
sharing individual screens. Now that this has been added, it is
desirable to have this property set correctly.

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

Co-authored-by: James Cash <james.nvc@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
VerteDinde pushed a commit that referenced this pull request Oct 3, 2022
fix: set display_id in desktop capturer on Linux (#33861)

Previously, display_id was an empty string, pending Chrome support for
sharing individual screens. Now that this has been added, it is
desirable to have this property set correctly.

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

Co-authored-by: James Cash <james.nvc@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
Previously, display_id was an empty string, pending Chrome support for
sharing individual screens. Now that this has been added, it is
desirable to have this property set correctly.

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/21-x-y PR was merged to the "21-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants