Skip to content

Commit

Permalink
improve(electron): decrease top padding when fullscreen on Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhp915 authored and tiensonqin committed Jan 29, 2021
1 parent 71b1617 commit ec94390
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions resources/js/preload.js
@@ -1,6 +1,6 @@
const fs = require('fs')
const path = require('path')
const { ipcRenderer, contextBridge, shell, clipboard, BrowserWindow } = require('electron')
const { ipcRenderer, contextBridge, shell, clipboard } = require('electron')

const IS_MAC = process.platform === 'darwin'
const IS_WIN32 = process.platform === 'win32'
Expand All @@ -11,7 +11,7 @@ function getFilePathFromClipboard () {
return rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), '')
} else if (IS_MAC) {
return clipboard.read('public.file-url').replace('file://', '')
} else{
} else {
return clipboard.readText()
}
}
Expand Down
19 changes: 13 additions & 6 deletions src/electron/electron/core.cljs
Expand Up @@ -54,7 +54,8 @@
(defn setup-app-manager!
[^js win]
(let [toggle-win-channel "toggle-max-or-min-active-win"
call-app-channel "call-application"]
call-app-channel "call-application"
web-contents (. win -webContents)]
(doto ipcMain
(.handle toggle-win-channel
(fn [_ toggle-min?]
Expand All @@ -72,11 +73,17 @@
(js-invoke app type args)
(catch js/Error e
(js/console.error e))))))
(.. win -webContents (on "new-window"
(fn [e url]
(.. log (info "new-window" url))
(open url)
(.preventDefault e))))

(.on web-contents "new-window"
(fn [e url]
(.. log (info "new-window" url))
(open url)
(.preventDefault e)))

(doto win
(.on "enter-full-screen" #(.send web-contents "full-screen" "enter"))
(.on "leave-full-screen" #(.send web-contents "full-screen" "leave")))

#(do (.removeHandler ipcMain toggle-win-channel)
(.removeHandler ipcMain call-app-channel))))

Expand Down
11 changes: 11 additions & 0 deletions src/main/frontend/components/theme.css
Expand Up @@ -127,6 +127,17 @@ html.is-electron {
.cp__right-sidebar {
top: 4rem;
}

&.is-fullscreen {
.cp__header {
padding-top: 0;
height: 2.6rem;

&:before {
display: none;
}
}
}
}

#search {
Expand Down
4 changes: 3 additions & 1 deletion src/main/frontend/ui.cljs
Expand Up @@ -236,7 +236,9 @@
(if (util/electron?) (.add cl "is-electron"))
(if (util/ios?) (.add cl "is-ios"))
(if (util/mobile?) (.add cl "is-mobile"))
(if (util/safari?) (.add cl "is-safari"))))
(if (util/safari?) (.add cl "is-safari"))
(if (util/electron?)
(js/window.apis.on "full-screen" #(js-invoke cl (if (= % "enter") "add" "remove") "is-fullscreen")))))

(defn inject-dynamic-style-node!
[]
Expand Down

0 comments on commit ec94390

Please sign in to comment.