Fix frameless windows with vibrancy by MarshallOfSound · Pull Request #11886 · electron/electron · GitHub
Skip to content

Fix frameless windows with vibrancy#11886

Merged
codebytere merged 1 commit into
masterfrom
fix-vibrant-frameless-windows
Feb 12, 2018
Merged

Fix frameless windows with vibrancy#11886
codebytere merged 1 commit into
masterfrom
fix-vibrant-frameless-windows

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Fixes #10521

Tested with setVibrancy as well so this supports dynamically switching vibrancy still as well.

Comment thread atom/browser/native_window_mac.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is only called from within the class. Seems like it could be moved to inside the protected block?

impl->SetBackgroundOpaque(opaque);
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a pretty egregious demeter violation but I'm not sure what the Right Thing is here since some of these conditionals are for upstream classes out of our control 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I tried to collapse it as much as I could but everything is just consecutive potentially nullptr values 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I inverted the logic to collapse it a bit 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Still like 4 steps of separation though so idk 🤔

Comment thread atom/browser/native_window_mac.h Outdated
NSRect original_frame_;
NSUInteger simple_fullscreen_mask_;

NSColor* background_color_before_vibrancy_ = nil;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not positive but should this be a base::scoped_nsobject<NSColor>?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You right 👍 😄

@MarshallOfSound MarshallOfSound force-pushed the fix-vibrant-frameless-windows branch from cede986 to cd31f8f Compare February 11, 2018 02:37
@MarshallOfSound

Copy link
Copy Markdown
Member Author

@ckerr Updated 👍

@MarshallOfSound MarshallOfSound force-pushed the fix-vibrant-frameless-windows branch from cd31f8f to 636f0dd Compare February 11, 2018 02:40

@codebytere codebytere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks 💯 to me now!

@codebytere codebytere merged commit ae65938 into master Feb 12, 2018
@codebytere codebytere deleted the fix-vibrant-frameless-windows branch February 12, 2018 18:38
@sallar

sallar commented Feb 12, 2018

Copy link
Copy Markdown

@codebytere when do you think this will be released?

@codebytere

Copy link
Copy Markdown
Member

@sallar it's on the table for 2.0, i believe, so fairly soon

@HuChundong

Copy link
Copy Markdown

not include in 2.0 beta1?

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@HuChundong It should be, do you have a case where it's not working?

@HuChundong

Copy link
Copy Markdown

@MarshallOfSound
yes,there is something wrong with me, at first i'm sorry for my poor english,thanks for your quick reply
mainWindow = new BrowserWindow({ height: 540, minHeight: 540, width: 830, minWidth: 830, useContentSize: true, webPreferences: {webSecurity: false}, resizable: true, alwaysOnTop: false, transparent: true, show: false, frame: false, titleBarStyle: 'hiddenInset', vibrancy: 'ultra-dark' })

this main window still lose round corner in high sierra 10.13.3
i need to set fullscreen and then exit full screen to get round corner back

@MarshallOfSound

Copy link
Copy Markdown
Member Author

This PR was not intended to fix the round / square corner issue. There is a separate open issue for that

@tcaer

tcaer commented Feb 26, 2018

Copy link
Copy Markdown

Hi, I don't know what I am doing wrong but this is still not working for me... running MacOS 10.13.3. I still get the same error of the transparent bar showing up.
Here is my window code:

function createWindow() {
	var bounds = electron.screen.getPrimaryDisplay().workAreaSize;

	/*
	* Fix the issue where the window bounds are not correct in windows 10
	*/
	var shouldMaximize;
	if (process.platform == 'win32') {
		if (bounds.x === 0 || bounds.y === 0 || bounds.x === -8 || bounds.y === -8) {
        	var screenSize = electron.screen.getPrimaryDisplay().workAreaSize
        	if ((screenSize.width === bounds.width || bounds.width - screenSize.width === 16) && (screenSize.height === bounds.height || bounds.height - screenSize.height === 16)) {
          		shouldMaximize = true
        	}
      	}
	}

	mainWindow = new electron.BrowserWindow({
		width: bounds.width,
		minWidth: 300,
		height: bounds.height,
		minHeight: 430,
		x: 0,
		y: 0,
		titleBarStyle: 'hidden-inset',
		show: false,
		frame: false,
		vibrancy: 'light'
	});

	if (shouldMaximize) {
		mainWindow.maximize();
	}

	if (process.platform == 'win32') {
		mainWindow.setMenu(null);
	}

	mainWindow.loadURL(path.join('file://', __dirname, '/public/app/index.html'));

	mainWindow.once('ready-to-show', function() {
		mainWindow.show();
	});

	mainWindow.on('closed', function() {
		mainWindow = null;
	});
}

@sallar

sallar commented Feb 26, 2018

Copy link
Copy Markdown

@huangruichang @tcaer Remove frame: false from your configs to see if it makes any difference.

@huangruichang

Copy link
Copy Markdown
Contributor

@sallar Maybe I am not the person you wanna notice 🤣

@tcaer

tcaer commented Feb 26, 2018

Copy link
Copy Markdown

@sallar No luck... I get the square corners and the invisible tab :/

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@tcaer Can you share repro?

@igor10k

igor10k commented Feb 26, 2018

Copy link
Copy Markdown

@tcaer add transparent: true. The invisible tab should disappear but that was working even before this PR. There's no fix for the rounded corners though.

Judging by your comments this PR fixes nothing.

@sallar

sallar commented Feb 26, 2018

Copy link
Copy Markdown

I just tested beta1. This fix changes nothing. Vibrancy+Square Corners was also possible before (using transparent: true and frame: false). This issue should be re-opened?

image

But judging by @MarshallOfSound's comment, there is a separate issue for the rounded corners... #10886

@tommoor

tommoor commented Feb 27, 2018

Copy link
Copy Markdown
Contributor

Also just tested and unfortunately I'm also seeing much worse behavior than before the fix.

Previously there was just a transparent area where the titlebar would normally be – now it's showing corrupted artifacts and the titlebar has reverted to the standard thickness / position even with titleBarStyle: "hidden-inset" window option.

image

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@tommoor Super weird, let me test this real quick 🤔

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@tommoor Two quick things

  • hidden-inset shouldn't be an option in 2.0.0-beta.1 it has been replaced with hiddenInset (the other one was deprecated for a while)
  • Can you share your exact browser window constructor options object, I can't repro what you have a screenshot of

@tommoor

tommoor commented Feb 27, 2018

Copy link
Copy Markdown
Contributor

Oh, interesting I did check the release notes for breaking changes and there wasn't a mention of that property being deprecated but that would explain the first part of the issue 😄. I wonder if having the deprecated option there caused it. Was the deprecation removed in 2.0? If so I guess we should add that to the notes.

The screenshot doesn't capture it too well, basically the entire titlebar is showing artifacts depending on what's behind - It mostly looks black / transparent. Options are:

{
      titleBarStyle: "hidden-inset",
      acceptFirstMouse: true,
      file: "index",
      webPreferences: { scrollBounce: true, textAreasAreResizable: false },
      x,
      y,
      width,
      height
}

@MarshallOfSound

Copy link
Copy Markdown
Member Author

screen shot 2018-02-27 at 3 18 46 pm
screen shot 2018-02-27 at 3 21 04 pm

These are two screenshots off current master using

{
  vibrancy: 'dark',
  titleBarStyle: 'hiddenInset',
  transparent: true,
  frame: false,
}

@MarshallOfSound

Copy link
Copy Markdown
Member Author

And just to prove no bamboozle, here is a screenshot from electron-quick-start using the above config using electron@2.0.0.-beta.1

screen shot 2018-02-27 at 3 24 09 pm

@tommoor

tommoor commented Feb 27, 2018

Copy link
Copy Markdown
Contributor

Thanks @MarshallOfSound – I'm out for the day now, but I'll try with 2.0 again tomorrow and the correct hiddenInset option, hopefully that does the trick 👍

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@tommoor It might also be the frame and transparent options helping out, let me know if you can't make it look like mine 😆

@tommoor

tommoor commented Feb 27, 2018

Copy link
Copy Markdown
Contributor

Maybe, I can't really use those options as the square corners are unacceptable on macOS unfortunately 😞

@MarshallOfSound

Copy link
Copy Markdown
Member Author

Hm, fair enough, we had an issue somewhere for the square corner thing. Will try take a look at that later this week if I get a chance.

@tcaer

tcaer commented Feb 27, 2018

Copy link
Copy Markdown

Thanks so much for all the help!
There is also another bug I get when closing an app (I am using the current beta). MacOS reports that the app crashed even though it didn't.

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@tcaer Known bug and I think it's already fixed 😆

@stevenfabre

stevenfabre commented Mar 15, 2018

Copy link
Copy Markdown

Hey guys, thanks so much for fixing this!

Does this fix the corner radius bug too? In my build, the top two corners aren't rounded when I use the following settings with a webview in it #10522:

titleBarStyle: 'default',
transparent: true,
vibrancy: 'dark',

sethlu pushed a commit to sethlu/electron that referenced this pull request May 3, 2018
@mlabod

mlabod commented May 23, 2018

Copy link
Copy Markdown

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.