Skip to content

Implement titleBarStyle without using NSFullSizeContentViewWindowMask - #5557

Merged
zcbenz merged 2 commits into
masterfrom
osx-buttons
May 17, 2016
Merged

zcbenz merged 2 commits into
masterfrom
osx-buttons

Conversation

@zcbenz

@zcbenz zcbenz commented May 17, 2016

Copy link
Copy Markdown
Contributor

This is inspired from brave/muon@7fa16af.

Instead of using the NSFullSizeContentViewWindowMask style to hide the titlebar, this PR treats window with titleBarStyle as normal frameless window but shows the window buttons instead.

Close #3009.

@saghul

saghul commented May 25, 2016

Copy link
Copy Markdown
Contributor

For those who ended up here and want the old (ie, having the invisible title bar draggable) behavior back, here is a trick to avoid modifying your HTML:

// Trick to make the transparent title bar draggable
const titleBarHack =
    'var div = document.createElement("div");' +
    'div.style.position = "absolute";' +
    'div.style.top = 0;' +
    'div.style.height = "23px";' +
    'div.style.width = "100%";' +
    'div.style["-webkit-app-region"] = "drag";' +
    'document.body.appendChild(div);';

...

    // make the transparent title bar draggable
    mainWindow.webContents.on('did-finish-load', function() {
        if (process.platform === 'darwin') {
            mainWindow.webContents.executeJavaScript(titleBarHack);
        }
    });

You will need to adjust the height for the hidden-insert style.

}
if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) {
// The window without titlebar is treated the same with frameless window.
set_has_frame(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this also prevents the title from being set in NativeWindowMac::SetTitle which drops these windows out of the window menu

mtaberna added a commit to unofficial-protonmail-desktop/application that referenced this pull request May 1, 2017
kontrollanten added a commit to unofficial-protonmail-desktop/application that referenced this pull request Sep 3, 2017
kontrollanten pushed a commit to unofficial-protonmail-desktop/application that referenced this pull request Sep 3, 2017
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