简体   繁体   English

是否可以在Electron js中在OS X上启用非狮子式全屏?

[英]Is it possible enable non-lion-style full-screen on OS X in Electron js?

I have a handy little program called iTerm (surely people know it here). 我有一个名为iTerm的方便的小程序(当然人们在这里知道)。 There is a configuration option for OS X called "Use Lion-Style Fullscreen windows" OS X有一个名为“使用狮子式全屏窗口”的配置选项

When this is disabled, it allows for behavior where a window will be full-screen without moving to a new "desktop". 禁用此选项后,它允许窗口全屏显示的行为,而无需移动到新的“桌面”。

I've created a small demonstration for those who do not know what it looks like. 我为那些不知道它看起来像什么的人创建了一个小型演示。 .

My question is: is it possible to emulate this behavior in Electron js? 我的问题是:是否可以在Electron js中模拟这种行为?

Your demonstration doesn't works now, but by description I can offer one case which can be useful. 你的演示现在不起作用,但通过描述,我可以提供一个有用的案例。 You should raise up level of window higher than 'main-menu' - setAlwaysOnTop(true, 'main-menu', 1) , activate enableLargerThanScreen: true and set size of window exactly like size of active window. 您应该将窗口级别提高到高于'main-menu' - setAlwaysOnTop(true, 'main-menu', 1) ,激活enableLargerThanScreen: true并将窗口大小设置为与活动窗口的大小完全相同。

import {
    BrowserWindow,
    screen
} from 'electron';

const fullScreenWindow = new BrowserWindow({
    transparent: true,
    enableLargerThanScreen: true,
    frame: false,
    x: 0,
    y: 0,
    minimizable: false,
    movable: false
});

// Show it on primary or any another screen
const activeScreen = screen.getPrimaryDisplay();

fullScreenWindow.setResizable(true);
fullScreenWindow.setSize(activeScreen.size.width, activeScreen.size.height);
fullScreenWindow.setResizable(false);
fullScreenWindow.setPosition(activeScreen.bounds.x, activeScreen.bounds.y);

fullScreenWindow.setAlwaysOnTop(true, 'main-menu', 1);
fullScreenWindow.loadURL('file://app.html');
// or `fullScreenWindow.show()` instead of `fullScreenWindow.loadURL` 

Created window overlaps main-menu and dock bar: 创建的窗口重叠主菜单和停靠栏:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM