8000 feat: add property support for remainder of BrowserWindow by codebytere · Pull Request #22771 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add property support for remainder of BrowserWindow #22771

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

Merged
merged 10 commits into from
Apr 1, 2020

Conversation

codebytere
Copy link
Member
@codebytere codebytere commented Mar 19, 2020

Description of Change

Adds property-based support for the remainder of primitive gette/setter pairs on BrowserWindow.

Namely:

  • win.simpleFullScreen
  • win.title
  • win.visibleOnAllWorkspaces
  • win.documentEdited
  • win.representedFilename
  • win.shadow
  • win.kiosk
  • win.menuBarVisible

cc @electron/wg-api

Checklist

Release Notes

Notes: Added support for property access to some getter/setter pairs on BrowserWindow.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Mar 19, 2020
@codebytere codebytere marked this pull request as ready for review March 20, 2020 03:02
@zcbenz
Copy link
Contributor
zcbenz commented Mar 20, 2020

Should the properties be put in top-level-window.js instead of browser-window.js? They are essentially methods in TopLevelWindow, and it would be helpful when making TopLevelWindow public after electron/governance#254.


8000
@zcbenz
Copy link
Contributor
zcbenz commented Mar 20, 2020

I think we should probably write a helper to automatically generate the setter/getters, since the pattern is fixed.

@zcbenz
Copy link
Contributor
zcbenz commented Mar 20, 2020

And we should define the property on the prototype instead of this, so we only need to do it once instead of every time when a new instance is created.

@codebytere
Copy link
Member Author
codebytere commented Mar 20, 2020

@zcbenz the problem is that it's fixed but not quite fixed enough, for example:

  Object.defineProperty(this, 'menuBarVisible', {
    get: () => this.isMenuBarVisible(),
    set: (visible) => this.setMenuBarVisibility(visible)
  })

seems like it should be setMenuBarVisible but isn't, and then some getters are prefixed with is if they're boolean and get if they're not. I'd like to simplify it, but i didn't see a good way to do so without needing to add a nontrivial amount of edge case handling which resulted in it not feeling much simpler than before. Also, defining it on the prototype like so:

Object.defineProperty(BrowserWindow.prototype, 'title', {
  get: () => BrowserWindow.prototype.getTitle(),
  set: (title) => BrowserWindow.prototype.setTitle(title)
})

Results in this error:

Screen Shot 2020-03-20 at 8 50 03 AM

which is why i took the approach i did

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Mar 20, 2020
@zcbenz
Copy link
Contributor
zcbenz commented Mar 21, 2020

the problem is that it's fixed but not quite fixed enough

This is reasonable.

Also, defining it on the prototype like so Results in this error:

The correct way should be:

Object.defineProperty(BrowserWindow.prototype, 'title', {
  get: function () { return this.getTitle() },
  set: function (title) { this.setTitle(title) }
})

The point is to use function to have this passed.

@codebytere codebytere requested review from a team as code owners March 31, 2020 15:33
Copy link
Member
@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.

LGTM

@codebytere codebytere merged commit da67cbf into master Apr 1, 2020
@release-clerk
Copy link
release-clerk bot commented Apr 1, 2020

Release Notes Persisted

Added support for property access to some getter/setter pairs on BrowserWindow.

@codebytere codebytere deleted the bw-props-rest branch April 1, 2020 15:22
sentialx pushed a commit to sentialx/electron that referenced this pull request Apr 7, 2020
…2771)

Adds property-based support for the remainder of primitive gette/setter pairs on `BrowserWindow`.

Namely:
- `win.simpleFullScreen`
- `win.title`
- `win.visibleOnAllWorkspaces`
- `win.documentEdited`
- `win.representedFilename`
- `win.shadow`
- `win.kiosk`
- `win.menuBarVisible`
@codebytere
Copy link
Member Author

/trop run backport-to 9-x-y

@trop
Copy link
Contributor
trop bot commented Apr 21, 2020

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

@trop
Copy link
Contributor
trop bot commented Apr 21, 2020

I was unable to backport this PR to "9-x-y" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Contributor
trop bot commented Apr 22, 2020

@codebytere has manually backported this PR to "9-x-y", please check out #23208

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.

3 participants
0