@@ -127,6 +127,14 @@ type Editor struct {
127127 font * Font
128128 fallbackfonts []* Font
129129 fontCh chan []* Font
130+ nvimErr error
131+ nvimSignal * neovimSignal
132+ redrawUpdates chan [][]interface {}
133+ guiUpdates chan []interface {}
134+ nvimCh chan * nvim.Nvim
135+ uiRemoteAttachedCh chan bool
136+ nvimErrCh chan error
137+ qAppStartedCh chan bool
130138 fontErrors []string
131139 notifications []* Notification
132140 workspaces []* Workspace
@@ -146,6 +154,7 @@ type Editor struct {
146154 doRestoreSessions bool
147155 initialColumns int
148156 initialLines int
157+ isSetWindowState bool
149158 isSetColumns bool
150159 isSetLines bool
151160 isSetGuiColor bool
@@ -159,6 +168,8 @@ type Editor struct {
159168 isHideMouse bool
160169 isBindNvimSizeToAppwin bool
161170 isUiPrepared bool
171+ firstPaintDone bool
172+ blurUpdateNeeded bool
162173}
163174
164175func (hl * Highlight ) copy () Highlight {
@@ -217,8 +228,15 @@ func InitEditor(options Options, args []string) {
217228 notify : make (chan * Notify , 10 ),
218229 cbChan : make (chan * string , 240 ),
219230 chUiPrepared : make (chan bool , 1 ),
231+ nvimErrCh : make (chan error , 1 ),
220232 }
221233 e := editor
234+ if runtime .GOOS == "darwin" {
235+ e .qAppStartedCh = make (chan bool , 1 )
236+ }
237+ if runtime .GOOS == "darwin" && editor .config .Editor .EnableBackgroundBlur {
238+ e .blurUpdateNeeded = true
239+ }
222240
223241 // Prepare debug log
224242 e .setDebuglog ()
@@ -246,36 +264,35 @@ func InitEditor(options Options, args []string) {
246264 // set application working directory path
247265 e .setAppDirPath (e .homeDir )
248266
249- // create qapplication
250- e .putLog ("start generating the application" )
251- core .QCoreApplication_SetAttribute (core .Qt__AA_EnableHighDpiScaling , true )
252- e .app = widgets .NewQApplication (len (os .Args ), os .Args )
253- setMyApplicationDelegate ()
254-
255- e .app .SetDoubleClickInterval (0 )
256- e .putLog ("finished generating the application" )
257-
258- e .initNotifications ()
259-
260267 var cerr , lerr error
261268 e .initialColumns , cerr , e .initialLines , lerr = parseLinesAndColumns (args )
262- if cerr == nil {
263- editor .isSetColumns = true
264- }
265- if lerr == nil {
266- editor .isSetLines = true
267- }
269+ editor .isSetColumns , editor .isSetLines = cerr == nil , lerr == nil
268270
269271 // new nvim instance
270- signal , redrawUpdates , guiUpdates , nvimCh , uiRCh , errCh : = newNvim (
272+ e . nvimSignal , e . redrawUpdates , e . guiUpdates , e . nvimCh , e . uiRemoteAttachedCh , e . nvimErrCh = newNvim (
271273 e .initialColumns ,
272274 e .initialLines ,
273275 e .ctx ,
274276 )
275277
276- // e.setAppDirPath(home)
278+ // create qapplication
279+ e .putLog ("start generating the application" )
280+
281+ core .QCoreApplication_SetAttribute (core .Qt__AA_EnableHighDpiScaling , true )
282+
283+ e .app = widgets .NewQApplication (len (os .Args ), os .Args )
284+ if runtime .GOOS == "darwin" {
285+ e .qAppStartedCh <- e .app != nil
286+ }
287+
288+ setMyApplicationDelegate ()
289+ e .putLog ("finished generating the application" )
290+
291+ e .app .SetDoubleClickInterval (0 )
292+
293+ e .initNotifications ()
277294
278- e .fontCh = make (chan []* Font , 100 )
295+ e .fontCh = make (chan []* Font , 1 )
279296 go func () {
280297 e .fontCh <- parseFont (
281298 e .config .Editor .FontFamily ,
@@ -296,27 +313,14 @@ func InitEditor(options Options, args []string) {
296313 e .initSpecialKeys ()
297314
298315 // application main window
299- isSetWindowState := e .initAppWindow ()
316+ e .isSetWindowState = e .initAppWindow ()
317+ e .setWindowLayout ()
318+ e .window .SetWindowOpacity (0.0 )
300319 e .window .Show ()
301320
302321 // Apply native title bar customization
303322 e .applyNativeTitlebarCustomization ()
304323
305- // window layout
306- e .setWindowLayout ()
307-
308- // neovim workspaces
309-
310- nvimErr := <- errCh
311- if nvimErr != nil {
312- fmt .Println (nvimErr )
313- os .Exit (1 )
314- }
315-
316- e .initWorkspaces (e .ctx , signal , redrawUpdates , guiUpdates , nvimCh , uiRCh , isSetWindowState )
317-
318- e .connectAppSignals ()
319-
320324 // go e.exitEditor(cancel, f, g)
321325 // go e.exitEditor(cancel, f, fgprofStop)
322326 go e .exitEditor (cancel )
@@ -603,6 +607,12 @@ func (e *Editor) initWorkspaces(ctx context.Context, signal *neovimSignal, redra
603607
604608 ws .initFont ()
605609 e .initAppFont ()
610+
611+ e .nvimErr = <- e .nvimErrCh
612+ if e .nvimErr != nil {
613+ fmt .Println (e .nvimErr )
614+ os .Exit (1 )
615+ }
606616 ws .registerSignal (signal , redrawUpdates , guiUpdates )
607617 ws .updateSize ()
608618
@@ -1056,7 +1066,10 @@ func (e *Editor) updateGUIColor() {
10561066 e .window .SetupTitleColor ((uint16 )(e .colors .fg .R ), (uint16 )(e .colors .fg .G ), (uint16 )(e .colors .fg .B ))
10571067 }
10581068
1059- // e.window.SetWindowOpacity(1.0)
1069+ if ! e .firstPaintDone {
1070+ e .firstPaintDone = true
1071+ e .window .SetWindowOpacity (1.0 )
1072+ }
10601073 e .putLog ("finished updating GUI color" )
10611074}
10621075
@@ -1148,6 +1161,19 @@ func (e *Editor) connectWindowEvents() {
11481161 e .bindResizeEvent ()
11491162 e .window .ConnectShowEvent (func (event * gui.QShowEvent ) {
11501163 editor .putLog ("show application window" )
1164+ e .initWorkspaces (e .ctx , e .nvimSignal , e .redrawUpdates , e .guiUpdates , e .nvimCh , e .uiRemoteAttachedCh , e .isSetWindowState )
1165+ e .connectAppSignals ()
1166+
1167+ // Set Transparent blue effect
1168+ if runtime .GOOS == "darwin" && editor .config .Editor .EnableBackgroundBlur {
1169+ if e .blurUpdateNeeded {
1170+ e .blurUpdateNeeded = false
1171+ ws := e .workspaces [e .active ]
1172+ ws .getBG ()
1173+ isLight := ws .screenbg == "light"
1174+ editor .window .SetBlurEffectForMacOS (isLight )
1175+ }
1176+ }
11511177 })
11521178
11531179 e .window .InstallEventFilter (e .window )
0 commit comments