fix: should use fullscreen to control where to place macos window controls (#6351)

This commit is contained in:
pengx17
2024-03-28 03:40:46 +00:00
parent 4e7652f108
commit e53744b740
7 changed files with 53 additions and 16 deletions
@@ -45,7 +45,7 @@ export const navHeaderStyle = style({
});
globalStyle(
`html[data-maximized="false"]
`html[data-fullscreen="false"]
${navHeaderStyle}[data-is-macos-electron="true"]`,
{
paddingLeft: '90px',
@@ -2,17 +2,34 @@ import { apis, events } from '@affine/electron-api';
import { useAtomValue } from 'jotai';
import { atomWithObservable } from 'jotai/utils';
import { useCallback } from 'react';
import { Observable } from 'rxjs';
import { combineLatest, map, Observable } from 'rxjs';
import * as style from './style.css';
const maximizedAtom = atomWithObservable(() => {
return new Observable<boolean>(subscriber => {
subscriber.next(false);
return events?.ui.onMaximized(maximized => {
return subscriber.next(maximized);
const maximized$ = new Observable<boolean>(subscriber => {
subscriber.next(false);
if (events) {
return events.ui.onMaximized(res => {
subscriber.next(res);
});
});
}
return () => {};
});
const fullscreen$ = new Observable<boolean>(subscriber => {
subscriber.next(false);
if (events) {
return events.ui.onFullScreen(res => {
subscriber.next(res);
});
}
return () => {};
});
const maximizedAtom = atomWithObservable(() => {
return combineLatest([maximized$, fullscreen$]).pipe(
map(([maximized, fullscreen]) => maximized || fullscreen)
);
});
const minimizeSVG = (