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 API to enable/disable a window #11832

Merged
merged 7 commits into from Feb 6, 2018

Conversation

Projects
None yet
4 participants
@codebytere
Member

codebytere commented Feb 5, 2018

Resolves #8415.

Adds an API interface to enable and disable a window via win.setEnabled(bool)

@codebytere codebytere requested a review from electron/reviewers as a code owner Feb 5, 2018

@MarshallOfSound

Looks good, just need some documentation 👍

@MarshallOfSound

This comment has been minimized.

codebytere added some commits Feb 6, 2018

@codebytere codebytere requested a review from electron/docs as a code owner Feb 6, 2018

@ckerr

LGTM. One nonblocking code suggestion inline. (edit: I reviewed an outdated copy 🥇 )

Is it possible to add tests for this?

[window_ attachedSheet] = nil;
} else {
[window_ beginSheet:window_];
}

This comment has been minimized.

@ckerr

ckerr Feb 6, 2018

Member

(minor) this is non-idiomatic for two reasons, one is comparing a bool to true or false, the other is all other things being equal, prefer positive conditionals rather than negative as they're generally easier to read.

So, slightly better:

+void NativeWindowMac::SetEnabled(bool enable) {
+  if (enable){
+    [window_ beginSheet:window_];
+  } else {
+    [window_ attachedSheet] = nil;
+  }

codebytere added some commits Feb 6, 2018

@codebytere

This comment has been minimized.

Member

codebytere commented Feb 6, 2018

unclear how to add tests for this since IsEnabled, which i would kinda need to check for whether or not the change was properly made, is private and inaccessible to tests 🤔

@ckerr

ckerr approved these changes Feb 6, 2018

Yeah, you're right about the tests. If you find a good way of doing it, great; otherwise, I wouldn't block the PR on it

#if defined(TOOLKIT_VIEWS)
#include "atom/browser/native_window_views.h"
#endif

This comment has been minimized.

@ckerr

ckerr Feb 6, 2018

Member

I don't think this change is needed anymore, right? It's a leftover from when the code was static_casting window_ into a NativeWindowView

@codebytere codebytere merged commit 64f509e into master Feb 6, 2018

8 checks passed

ci/circleci: electron-linux-arm Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm-test Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm64 Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm64-test Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-ia32 Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-x64 Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/jenkins/pr-head This commit looks good
Details

@codebytere codebytere deleted the enable-window branch Feb 6, 2018

void NativeWindowMac::SetEnabled(bool enable) {
if (enable) {
[window_ beginSheet: window_ completionHandler:^(NSModalResponse returnCode) {
NSLog(@"modal enabled");

This comment has been minimized.

@MarshallOfSound

MarshallOfSound Feb 6, 2018

Member

Can we drop this log out in a separate PR 😄

@alexeykuzmin

This comment has been minimized.

Contributor

alexeykuzmin commented Feb 6, 2018

@codebytere .isEnabled() is not documented but still available, can you add tests for .setEnabled() please?

@codebytere

This comment has been minimized.

Member

codebytere commented Feb 7, 2018

oh you're totally right, i just assumed it was private since i didn't see docs for it. will do!

@alexeykuzmin

This comment has been minimized.

Contributor

alexeykuzmin commented Feb 7, 2018

since i didn't see docs for it

There is a chance that the docs should be updated )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment