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

Main Window Frameless #1457

Merged
merged 3 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/app/ElectronBootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ module.exports = class ElectronBootstrap {
experimentalFeatures: true,
nodeIntegration: true,
webSecurity: false // required to open local images in browser
}
},
frame: false
});

this._setupBeforeSendHeaders();
Expand Down
37 changes: 36 additions & 1 deletion src/web/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="utf-8">
<title>HakuNeko</title>
<link rel="icon" href="./img/logo.png">
Expand Down Expand Up @@ -89,6 +89,25 @@

main();
</script>
<script>
this.win=require('electron').remote.getCurrentWindow();

function minimizeWindow(){
this.win.minimize();
}

function maximizeWindow(){
if (! this.win.isMaximized()) {
this.win.maximize();
} else {
this.win.unmaximize();
}
}

function closeWindow(){
this.win.close();
}
</script>
<style>
html, body {
margin: 0;
Expand Down Expand Up @@ -126,9 +145,25 @@
right: 1em;
cursor: pointer;
}

#default_menubar {
text-align : right;
-webkit-app-region: drag;
}

#default_menubar > span {
-webkit-app-region: no-drag;
cursor: pointer;
}
</style>
</head>
<body>
<div id="default_menubar">
<!-- Using UTF8 as base64 PNG 🗕🗖🗙 because of MacOS -->
<span id="win_minimize" onclick="minimizeWindow()" title="Minimize Window"><img alt="minimize" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABcSURBVEhLYxgFo2AUjIJRMApGATGAEUpjgKioqP+vXr2C8vADMTExhmXLluE0CytQUVH5D6SIwlC1WAETlKYZwOmtCRMmNPz48QPKww84ODgYCgoKGqBcegIGBgA9XBrRMdUaKQAAAABJRU5ErkJggg==" /></span>
<span id="win_maximize" onclick="maximizeWindow()" title="Maximize Window"><img alt="maximize" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACESURBVEhL7ZZRCsAgCIZtDx2i57p0V4teO0QvLsGxxgYSw8HADyQR9McwySEiaLLxqYYJiKgLAE3RYTFGGqlXRjXmmuodXN5BSgm99xBC4MgarTXovUMpxXFo9DS1Q+3lnId7xlaMcj+/IhMQMQERExC5CdRa2VvnMXfeGxrr+u+/CoAdAOyl6foWTQEAAAAASUVORK5CYII=" /></span>
<span id="win_close" onclick="closeWindow()" title="Close Window"><img alt="close" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFLSURBVEhL7ZUxqoQwEIazDxa8g6CFlZ2ghSAiHsA9guWWHkC8hY0LImLjBTyB3kO8SdZZNC+J0aTZbgc+zPwZ5wd14g1jjL4Zf9v1a/EzkMbhJb9eLzzPM7IsCz2fz9smX8YwDHiaJqTrOsqyjL0HDGjiOAbHD3merxK7z9N1HdY07VPved4qsftMAjweD2IgM2nbljQHgiBYZbaGSXYcxyE3nZk0TcM0N03zUAMchJ0rk6qq8P1+J3tnzQGhuCMyKctSuTkgFGl4ExpZc0Ao8ohMVJoDSoOWpum2+o8kSbaVJESuNPwLpVGZE6G4U9c109wwDGzbNslVTIQiwA8R/cxd1yW6zEQo0uPPN9/xfZ/sX5kchL7vlSYUgKOBNimKYpXZGiYB6MNO5VMMw5DUiw670890bY6WZZEe1+M43qIo2rJj/H76kkDoDZkbCAEJwDteAAAAAElFTkSuQmCC" /></span>
</div>
<div id="notification">
A new <strong>HakuNeko Desktop Client</strong> is available for download on
<a href="https://github.com/manga-download/hakuneko/releases" target="_blank">GitHub</a>
Expand Down
1 change: 1 addition & 0 deletions src/web/lib/hakuneko/frontend@classic-dark/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
}
hakuneko-menu {
flex: 0;
-webkit-app-region: drag;
}
hakuneko-jobs {
flex: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/web/lib/hakuneko/frontend@classic-dark/connectors.html
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
*/
_openLink(evt, link) {
if(link) {
let popup = window.open(link, evt.model.label, 'nodeIntegration=no');
let popup = window.open(link, evt.model.label, 'frame=true,nodeIntegration=no');
// disable onbeforeunload periodically (in case of navigation) to prevent blocking window close
let watchdog = setInterval(() => {
if(popup.closed) {
Expand Down
10 changes: 10 additions & 0 deletions src/web/lib/hakuneko/frontend@classic-dark/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
}
.button {
cursor: pointer;
-webkit-app-region: no-drag;
}
.right {
float: right;
}
.buttons {
display: flex;
Expand All @@ -125,6 +129,11 @@
</style>
<i class="fas fa-fw fa-bars fa-2x item button" title="Toggle menu" on-click="togglePopup"></i>
<span class="title">HakuNeko</span>
<span class="right">
<i class="far fa-fw fa-window-minimize item button" title="Minize HakuNeko" onclick="minimizeWindow()"></i>
<i class="far fa-fw fa-window-maximize item button" title="Maximize HakuNeko" onclick="maximizeWindow()"></i>
<i class="far fa-fw fa-2x fa-window-close item button" title="Close HakuNeko" onclick="closeWindow()"></i>
</span>
<div class$="popup [[ getPopupClass(popupVisibility) ]]">
<div class="separator">
<label>About</label>
Expand Down Expand Up @@ -300,6 +309,7 @@
this.$.importFile.value = null;
}
}

}
window.customElements.define(HakunekoMenu.is, HakunekoMenu);
</script>
Expand Down
3 changes: 3 additions & 0 deletions src/web/lib/hakuneko/frontend@classic-dark/theme.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<style>
#default_menubar {
display:none;
}
/* Font faces needs to be imported on the root level (does not work within shadow DOM scope) */
@font-face {
font-family: "Font Awesome 5 Brands";
Expand Down
1 change: 1 addition & 0 deletions src/web/lib/hakuneko/frontend@classic-light/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
}
hakuneko-menu {
flex: 0;
-webkit-app-region: drag;
}
hakuneko-jobs {
flex: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
*/
_openLink(evt, link) {
if(link) {
let popup = window.open(link, evt.model.label, 'nodeIntegration=no');
let popup = window.open(link, evt.model.label, 'frame=true,nodeIntegration=no');
// disable onbeforeunload periodically (in case of navigation) to prevent blocking window close
let watchdog = setInterval(() => {
if(popup.closed) {
Expand Down
9 changes: 9 additions & 0 deletions src/web/lib/hakuneko/frontend@classic-light/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
}
.button {
cursor: pointer;
-webkit-app-region: no-drag;
}
.right {
float: right;
}
.buttons {
display: flex;
Expand All @@ -125,6 +129,11 @@
</style>
<i class="fas fa-fw fa-bars fa-2x item button" title="Toggle menu" on-click="togglePopup"></i>
<span class="title">HakuNeko</span>
<span class="right">
<i class="far fa-fw fa-window-minimize item button" title="Minize HakuNeko" onclick="minimizeWindow()"></i>
<i class="far fa-fw fa-window-maximize item button" title="Maximize HakuNeko" onclick="maximizeWindow()"></i>
<i class="far fa-fw fa-2x fa-window-close item button" title="Close HakuNeko" onclick="closeWindow()"></i>
</span>
<div class$="popup [[ getPopupClass(popupVisibility) ]]">
<div class="separator">
<label>About</label>
Expand Down
3 changes: 3 additions & 0 deletions src/web/lib/hakuneko/frontend@classic-light/theme.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<style>
#default_menubar {
display:none;
}
/* Font faces needs to be imported on the root level (does not work within shadow DOM scope) */
@font-face {
font-family: "Font Awesome 5 Brands";
Expand Down