@@ -3,16 +3,16 @@ const path = require('path');
33const nodeURL = require ( 'url' ) ;
44const zlib = require ( 'zlib' ) ;
55const nodeCrypto = require ( 'crypto' ) ;
6- const { app, dialog} = require ( 'electron' ) ;
6+ const { app, dialog, nativeTheme } = require ( 'electron' ) ;
77const ProjectRunningWindow = require ( './project-running-window' ) ;
88const AddonsWindow = require ( './addons' ) ;
99const DesktopSettingsWindow = require ( './desktop-settings' ) ;
1010const PrivacyWindow = require ( './privacy' ) ;
1111const AboutWindow = require ( './about' ) ;
1212const PackagerWindow = require ( './packager' ) ;
13- const { createAtomicWriteStream} = require ( '../atomic-write-stream' ) ;
14- const { translate, updateLocale, getStrings} = require ( '../l10n' ) ;
15- const { APP_NAME } = require ( '../brand' ) ;
13+ const { createAtomicWriteStream } = require ( '../atomic-write-stream' ) ;
14+ const { translate, updateLocale, getStrings } = require ( '../l10n' ) ;
15+ const { APP_NAME } = require ( '../brand' ) ;
1616const prompts = require ( '../prompts' ) ;
1717const settings = require ( '../settings' ) ;
1818const privilegedFetch = require ( '../fetch' ) ;
@@ -68,7 +68,7 @@ const getCachedExtensionsRedirect = (input) => {
6868} ;
6969
7070class OpenedFile {
71- constructor ( type , path ) {
71+ constructor ( type , path ) {
7272 /** @type {TYPE_FILE|TYPE_URL|TYPE_SCRATCH|TYPE_SAMPLE|TYPE_SAMPLE_ASTRA } */
7373 this . type = type ;
7474
@@ -79,7 +79,7 @@ class OpenedFile {
7979 this . path = path ;
8080 }
8181
82- async read ( ) {
82+ async read ( ) {
8383 if ( this . type === TYPE_FILE ) {
8484 return {
8585 name : path . basename ( this . path ) ,
@@ -273,7 +273,7 @@ class EditorWindow extends ProjectRunningWindow {
273273 * @param {OpenedFile|null } initialFile
274274 * @param {boolean } isInitiallyFullscreen
275275 */
276- constructor ( initialFile , isInitiallyFullscreen ) {
276+ constructor ( initialFile , isInitiallyFullscreen ) {
277277 super ( ) ;
278278
279279 /**
@@ -369,7 +369,7 @@ class EditorWindow extends ProjectRunningWindow {
369369
370370 this . ipc . handle ( 'get-file' , async ( event , id ) => {
371371 const file = getFileById ( id ) ;
372- const { name, data} = await file . read ( ) ;
372+ const { name, data } = await file . read ( ) ;
373373 return {
374374 name,
375375 type : file . type ,
@@ -468,7 +468,7 @@ class EditorWindow extends ProjectRunningWindow {
468468 . replace ( '{APP_NAME}' , unsafePath . app )
469469 . replace ( '{file}' , filePath ) ,
470470 noLink : true
471- } ) ;
471+ } ) ;
472472 return null ;
473473 }
474474
@@ -668,35 +668,44 @@ class EditorWindow extends ProjectRunningWindow {
668668 this . isInEditorFullScreen = ! ! isFullScreen ;
669669 } ) ;
670670
671+ this . ipc . handle ( 'set-window-theme' , ( event , theme ) => {
672+ if ( process . platform === 'win32' ) {
673+ if ( theme === 'light' || theme === 'dark' ) {
674+ nativeTheme . themeSource = theme ;
675+ } else {
676+ nativeTheme . themeSource = 'dark' ; // default
677+ }
678+ }
679+ } ) ;
680+
671681 this . loadURL ( 'tw-editor://./gui/gui.html' ) ;
672682 this . show ( ) ;
673683
674684 // Windows acrylic blur effect (theme controlled by nativeTheme.themeSource in index.js)
675- if ( process . platform === 'win32' ) {
685+ if ( process . platform === 'win32' && settings . useBlurBackground ) {
676686 this . window . setBackgroundMaterial ( 'acrylic' ) ;
677687 }
678688 }
679689
680- getPreload ( ) {
690+ getPreload ( ) {
681691 return 'editor' ;
682692 }
683693
684- getDimensions ( ) {
694+ getDimensions ( ) {
685695 return {
686696 width : 1280 ,
687697 height : 800
688698 } ;
689699 }
690700
691- getBackgroundColor ( ) {
692- // Windows acrylic handles background, return solid color for animations
701+ getBackgroundColor ( ) {
693702 if ( process . platform === 'win32' ) {
694703 return '#333333' ;
695704 }
696705 return '#33333300' ;
697706 }
698707
699- getWindowOptions ( ) {
708+ getWindowOptions ( ) {
700709 const options = super . getWindowOptions ( ) ;
701710 options . frame = false ;
702711 options . minWidth = 1024 ;
@@ -712,19 +721,28 @@ class EditorWindow extends ProjectRunningWindow {
712721 // Windows uses setBackgroundMaterial instead of transparent
713722 if ( process . platform === 'win32' ) {
714723 options . transparent = false ;
715- options . backgroundColor = '#333333' ;
716724 } else {
717725 options . transparent = true ;
718726 }
719727
720728 return options ;
721729 }
722730
723- applySettings ( ) {
731+ applySettings ( ) {
724732 this . window . webContents . setBackgroundThrottling ( settings . backgroundThrottling ) ;
725733 }
726734
727- enumerateMediaDevices ( ) {
735+ updateBlurBackground ( useBlurBackground ) {
736+ if ( process . platform !== 'win32' ) return ;
737+
738+ if ( useBlurBackground ) {
739+ this . window . setBackgroundMaterial ( 'acrylic' ) ;
740+ } else {
741+ this . window . setBackgroundMaterial ( 'none' ) ;
742+ }
743+ }
744+
745+ enumerateMediaDevices ( ) {
728746 // Used by desktop settings
729747 return new Promise ( ( resolve , reject ) => {
730748 this . ipc . once ( 'enumerated-media-devices' , ( event , result ) => {
@@ -738,7 +756,7 @@ class EditorWindow extends ProjectRunningWindow {
738756 } ) ;
739757 }
740758
741- handleWindowOpen ( details ) {
759+ handleWindowOpen ( details ) {
742760 const url = new URL ( details . url ) ;
743761 const params = new URLSearchParams ( url . search ) ;
744762
@@ -786,11 +804,11 @@ class EditorWindow extends ProjectRunningWindow {
786804 return super . handleWindowOpen ( details ) ;
787805 }
788806
789- canExitFullscreenByPressingEscape ( ) {
807+ canExitFullscreenByPressingEscape ( ) {
790808 return ! this . isInEditorFullScreen ;
791809 }
792810
793- updateRichPresence ( ) {
811+ updateRichPresence ( ) {
794812 RichPresence . setActivity ( this . projectTitle , this . openedProjectAt ) ;
795813 }
796814
@@ -799,7 +817,7 @@ class EditorWindow extends ProjectRunningWindow {
799817 * @param {boolean } fullscreen
800818 * @param {string|null } workingDirectory
801819 */
802- static openFiles ( files , fullscreen , workingDirectory ) {
820+ static openFiles ( files , fullscreen , workingDirectory ) {
803821 if ( files . length === 0 ) {
804822 EditorWindow . newWindow ( fullscreen ) ;
805823 } else {
@@ -813,7 +831,7 @@ class EditorWindow extends ProjectRunningWindow {
813831 * Open a new window with the default project.
814832 * @param {boolean } fullscreen
815833 */
816- static newWindow ( fullscreen ) {
834+ static newWindow ( fullscreen ) {
817835 new EditorWindow ( null , fullscreen ) ;
818836 }
819837}
0 commit comments