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

src: Allow windows to be transparent, behind a pref (off by default) #982

Merged
merged 2 commits into from
Jun 15, 2024

Conversation

DeeDeeG
Copy link
Member

@DeeDeeG DeeDeeG commented Apr 18, 2024

Issue or RFC Endorsed by Pulsar's Maintainers

resolves #948.

Was discussed in the issue above, and further discussed on Discord:

Description of the Change

Add a core.allowWindowTransparency pref (off by default).

Sets options.transparent = true for the browserWindow options when this pref is enabled.

Requires a restart to activate.

Alternate Designs

Could put this on by default, or even always on without a pref to control it. I wanted it off by default just to be on the cautious side about it, in case it breaks the app / its rendering for somebody out there, or perhaps there is some perf hit (not investigated).

Could not implement the requested transparency mode at all, but this seems low-stakes enough behind a pref that's off by default, kind of a "why not?" thing at this point.

Could make the pref not prompt for restart when editing it in the settings-view UI, but... why not prompt for restart? (I think we do poll the preferences very frequently, and there is a listener for changes to certain prefs at which point it will prompt for a restart, but that is an existing pattern. If it's worth revisiting that for performance or wanting to reduce I/O, we can revisit that separately?)

Possible Drawbacks

None that I know of.

Verification Process

Tested, worked for me on macOS. (Kind of weird-looking with the CSS the original guide provided, but if this is what people are requesting, this is it. You can indeed see the apps/desktop behind it. Maybe enabling this situationally like when the editor is not focused would make sense. Theme authors and user stylesheet authors have lots of freedom to do whatever they want with it.)

(Note that the lack of a frame (window title bar) in these screenshots is technically unrelated. At the time I took these screenshots, I had set some options to disable the frame per the atom-transparency guide, but that option has been made its own pref since the original atom-transparency guide was published, so lack of window titlebar/"frame" is not part of this PR. Folks following that old guide can now use the separate, existing core.titleBar pref to control that.)

Transparent_Pulsar_window_with_several_panes_and_tabs_open_entire_window_is_semi-see-through_and_a_TextEdit_window_is_visible_behind_Pulsar
Transparent_Pulsar_window_with_several_panes_and_tabs_open_entire_window_is_semi-see-through

Release Notes

Add a preference core.allowWindowTransparency so that themes and user stylesheets can make editor windows' backgrounds transparent.

Add a `core.allowWindowTransparency` pref (off by default).

Sets `options.transparent = true` for the `browserWindow` `options`
when this pref is enabled.

Requires a restart to activate.

Co-credit to savetheclocktower for the revised description of the pref.

Co-authored-by: Andrew Dupont <github@andrewdupont.net>
@DeeDeeG DeeDeeG force-pushed the allow-window-transparency branch from a878ab1 to 6220705 Compare April 18, 2024 20:03
@@ -80,6 +80,10 @@ module.exports = class AtomWindow extends EventEmitter {
options.titleBarStyle = 'hiddenInset';
if (this.shouldHideTitleBar()) options.frame = false;

if(this.atomApplication.config.get('core.allowWindowTransparency')){
Copy link
Contributor

@savetheclocktower savetheclocktower Apr 19, 2024

Choose a reason for hiding this comment

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

Suggested change
if(this.atomApplication.config.get('core.allowWindowTransparency')){
if (this.atomApplication.config.get('core.allowWindowTransparency')) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, what if we turned this into a method like the ones above?

if (this.shouldAllowWindowTransparency()) options.transparent = true;

Then we can define a method like

shouldAllowWindowTransparency() {
  return (
    !this.isSpec && 
    this.atomApplication.config.get('core.allowWindowTransparency');
  );
}

I actually did some code spelunking just now to see if anyone ever discussed why application of these window settings is suppressed when Atom ran in spec mode, but I couldn't find anything relevant. Still, I'm assuming that there's a good reason behind it.

Copy link
Member Author

@DeeDeeG DeeDeeG Apr 21, 2024

Choose a reason for hiding this comment

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

I actually did some code spelunking just now to see if anyone ever discussed why application of these window settings is suppressed when Atom ran in spec mode, but I couldn't find anything relevant.

This piqued my curiosity.

How to find the info

Tracing back through the git-blame, we hit a decaf commit where the filename transitioned from src/main-process/atom-window.coffee to src/main-process/atom-window.js. Looking at the blame view on the .coffee file, as of the commit just before the decaf commit (last commit the .coffee file existed), and hopping over to atom/atom repo on github.com to make sure the PRs the commits are from are annotated properly on the page for the individual commit, we get this commit as the earliest to introduce the isSpec check: atom/atom@08a3582, which is from this PR: atom/atom#11790

Thoughts:

I'm not quite sure if it's explained well there either. But I thought I'd post these notes for now while I'm looking for an explanation.


EDIT: This commit message feels slightly relevant at least?

check for on method

during window-event-handler-spec, applicationDelegate.getCurrentWindow
seems to return a truncated version of a browserWindow object, which does not include the on method

I don't know if that was accurate at the time, whether it's still true or not, or if it's related to wanting to turn these toggles off during specs.

Copy link
Member Author

@DeeDeeG DeeDeeG Apr 21, 2024

Choose a reason for hiding this comment

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

I'm personally (a lot) more inclined to make these prefs operational during specs if possible, since I'd want to test as like-for-like code paths in CI as in real production use as possible, if there is no incompatibility or blocker for doing so.

@savetheclocktower
Copy link
Contributor

The test failure here was spurious (known flaky test) but this'll need a rebase against latest master for CI to start working again.

@DeeDeeG
Copy link
Member Author

DeeDeeG commented May 8, 2024

Turns out the "package tests" workflow is Linux-only, so we don't need the "pin to macOS 12" fix here. The only jobs needing re-runs were on Linux exclusively.

CI is passing/green now!

@DeeDeeG
Copy link
Member Author

DeeDeeG commented May 15, 2024

Should I re-do the implementation to match the others, per #982 (comment)?

Or is this good to go now that CI is green/passing?

(If it makes sense to "re-enable all the things [during specs]", then I suppose that could be punted to another PR. In favor of that would be uniformity. Against that would be the argument that such a follow-up PR is low-stakes enough to probably not justify the effort, so it may not happen.

@savetheclocktower
Copy link
Contributor

Should I re-do the implementation to match the others, per #982 (comment)?

Or is this good to go now that CI is green/passing?

It's up to you. Was a suggestion, but certainly not a blocker.

@DeeDeeG
Copy link
Member Author

DeeDeeG commented Jun 15, 2024

Thanks for the review!

@DeeDeeG DeeDeeG merged commit c14555f into master Jun 15, 2024
103 checks passed
@savetheclocktower savetheclocktower deleted the allow-window-transparency branch June 16, 2024 01:34
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.

Support Window Background Transparency
2 participants