mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-04 18:39:54 +00:00
transparency support on Linux
This commit is contained in:
parent
3d7a4a1e0e
commit
441164363f
@ -1,4 +1,5 @@
|
|||||||
import { app, ipcMain, Menu, Tray, shell } from 'electron'
|
import { app, ipcMain, Menu, Tray, shell } from 'electron'
|
||||||
|
import { loadConfig } from './config'
|
||||||
import { Window } from './window'
|
import { Window } from './window'
|
||||||
|
|
||||||
export class Application {
|
export class Application {
|
||||||
@ -9,6 +10,14 @@ export class Application {
|
|||||||
ipcMain.on('app:config-change', () => {
|
ipcMain.on('app:config-change', () => {
|
||||||
this.broadcast('host:config-change')
|
this.broadcast('host:config-change')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const configData = loadConfig()
|
||||||
|
if (process.platform === 'linux' && ((configData.appearance || {}).opacity || 1) !== 1) {
|
||||||
|
app.commandLine.appendSwitch('enable-transparent-visuals')
|
||||||
|
app.disableHardwareAcceleration()
|
||||||
|
}
|
||||||
|
|
||||||
|
app.commandLine.appendSwitch('disable-http-cache')
|
||||||
}
|
}
|
||||||
|
|
||||||
async newWindow (): Promise<Window> {
|
async newWindow (): Promise<Window> {
|
||||||
|
13
app/lib/config.ts
Normal file
13
app/lib/config.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import * as fs from 'fs'
|
||||||
|
import * as path from 'path'
|
||||||
|
import * as yaml from 'js-yaml'
|
||||||
|
import { app } from 'electron'
|
||||||
|
|
||||||
|
export function loadConfig (): any {
|
||||||
|
let configPath = path.join(app.getPath('userData'), 'config.yaml')
|
||||||
|
if (fs.existsSync(configPath)) {
|
||||||
|
return yaml.safeLoad(fs.readFileSync(configPath, 'utf8'))
|
||||||
|
} else {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
@ -11,8 +11,6 @@ if (!process.env.TERMINUS_PLUGINS) {
|
|||||||
|
|
||||||
const application = new Application()
|
const application = new Application()
|
||||||
|
|
||||||
app.commandLine.appendSwitch('disable-http-cache')
|
|
||||||
|
|
||||||
ipcMain.on('app:new-window', () => {
|
ipcMain.on('app:new-window', () => {
|
||||||
console.log('new-window')
|
console.log('new-window')
|
||||||
application.newWindow()
|
application.newWindow()
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { Subject, Observable } from 'rxjs'
|
import { Subject, Observable } from 'rxjs'
|
||||||
import { BrowserWindow, app, ipcMain, Rectangle } from 'electron'
|
import { BrowserWindow, app, ipcMain, Rectangle } from 'electron'
|
||||||
import ElectronConfig = require('electron-config')
|
import ElectronConfig = require('electron-config')
|
||||||
import * as yaml from 'js-yaml'
|
|
||||||
import * as fs from 'fs'
|
|
||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import * as path from 'path'
|
|
||||||
|
import { loadConfig } from './config'
|
||||||
|
|
||||||
let SetWindowCompositionAttribute: any
|
let SetWindowCompositionAttribute: any
|
||||||
let AccentState: any
|
let AccentState: any
|
||||||
@ -25,13 +24,7 @@ export class Window {
|
|||||||
get visible$ (): Observable<boolean> { return this.visible }
|
get visible$ (): Observable<boolean> { return this.visible }
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
let configPath = path.join(app.getPath('userData'), 'config.yaml')
|
let configData = loadConfig()
|
||||||
let configData
|
|
||||||
if (fs.existsSync(configPath)) {
|
|
||||||
configData = yaml.safeLoad(fs.readFileSync(configPath, 'utf8'))
|
|
||||||
} else {
|
|
||||||
configData = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.windowConfig = new ElectronConfig({ name: 'window' })
|
this.windowConfig = new ElectronConfig({ name: 'window' })
|
||||||
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
||||||
|
@ -66,16 +66,16 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
|||||||
|
|
||||||
toggle(
|
toggle(
|
||||||
[(ngModel)]='config.store.appearance.vibrancy',
|
[(ngModel)]='config.store.appearance.vibrancy',
|
||||||
(ngModelChange)='config.save(); (hostApp.platform === Platform.Windows && config.requestRestart())'
|
(ngModelChange)='config.save()'
|
||||||
)
|
)
|
||||||
|
|
||||||
.form-line(*ngIf='hostApp.platform !== Platform.Linux')
|
.form-line
|
||||||
.header
|
.header
|
||||||
.title Window opacity
|
.title Window opacity
|
||||||
input(
|
input(
|
||||||
type='range',
|
type='range',
|
||||||
[(ngModel)]='config.store.appearance.opacity',
|
[(ngModel)]='config.store.appearance.opacity',
|
||||||
(ngModelChange)='config.save()',
|
(ngModelChange)='config.save(); (hostApp.platform === Platform.Linux && config.requestRestart())',
|
||||||
min='0.05',
|
min='0.05',
|
||||||
max='1',
|
max='1',
|
||||||
step='0.01'
|
step='0.01'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user