@@ -26,7 +26,7 @@ function NDI.close_display(::NDI.ElectronDisp; strict)
26
26
end
27
27
28
28
function get_electron_display ()
29
- window = get_electron_window ()
29
+ window = NDI . get_electron_window ()
30
30
# BUG: Electron display cannot be reused
31
31
# if isnothing(ELECTRON_DISP[]) || window != ELECTRON_DISP[].window
32
32
# disp = HTTPServer.ElectronDisplay(window, HTTPServer.BrowserDisplay(; open_browser=false))
@@ -37,23 +37,32 @@ function get_electron_display()
37
37
return HTTPServer. ElectronDisplay (window, HTTPServer. BrowserDisplay (; open_browser= false ))
38
38
end
39
39
40
- function get_electron_window ()
41
- app = get_electron_app ()
40
+ function NDI . get_electron_window ()
41
+ app = NDI . get_electron_app ()
42
42
43
43
any (w -> ! w. exists, windows (app)) && @warn " App contains reference to nonexistent window(s)"
44
44
45
45
window = if isempty (windows (app))
46
- opts = Dict (:width => 1200 , :height => 800 )
46
+ x, y = NDI. CURRENT_DISPLAY[] isa NDI. ElectronDisp ? NDI. CURRENT_DISPLAY[]. resolution : (1200 , 800 )
47
+ opts = Dict (:width => x, :height => y, :webPreferences => Dict (:enableRemoteModule => true ))
48
+ @info " Create new Electron Window with $opts "
47
49
Electron. Window (app, opts)
48
50
else
49
51
length (windows (app)) != 1 && @warn " App contains multiple windows"
50
52
first (windows (app))
51
53
end
54
+ # check window size
55
+ if NDI. CURRENT_DISPLAY[] isa NDI. ElectronDisp
56
+ x, y = NDI. CURRENT_DISPLAY[]. resolution
57
+ run (NDI. get_electron_app (),
58
+ " BrowserWindow.fromId($(window. id) ).setSize($x , $y )" )
59
+ end
60
+
52
61
return window
53
62
end
54
63
haswindow () = hasapp () && ! isempty (windows (ELECTRON_APP[]))
55
64
56
- function get_electron_app ()
65
+ function NDI . get_electron_app ()
57
66
if ! hasapp ()
58
67
ELECTRON_APP[] = Electron. Application (;
59
68
additional_electron_args= [
77
86
78
87
function NDI. toggle_devtools ()
79
88
if haswindow ()
80
- Electron. toggle_devtools (get_electron_window ())
89
+ Electron. toggle_devtools (NDI . get_electron_window ())
81
90
else
82
91
error (" No window to toggle devtools!" )
83
92
end
84
93
end
94
+ NDI. has_electron_window () = haswindow ()
95
+
85
96
86
97
end
0 commit comments