@@ -21,6 +21,11 @@ fn is_wayland(glfw: &Glfw) -> bool {
2121 cfg ! ( target_os = "linux" ) && glfw. get_platform ( ) == glfw:: Platform :: Wayland
2222}
2323
24+ /// Capture runs keep windows unmapped, except on Wayland where an unmapped surface never presents.
25+ fn offscreen ( glfw : & Glfw ) -> bool {
26+ processing_render:: ci:: enabled ( ) && !is_wayland ( glfw)
27+ }
28+
2429/// A single GLFW instance drives every window (GLFW's event pump is global). The
2530/// main window is `windows[0]`; `create_window` appends more.
2631pub struct GlfwContext {
@@ -70,6 +75,10 @@ impl Default for AppliedWindow {
7075
7176impl GlfwContext {
7277 pub fn new ( width : u32 , height : u32 , transparent : bool ) -> Result < Self > {
78+ if processing_render:: ci:: enabled ( ) {
79+ // Without the menubar GLFW never becomes a foreground (Dock, focus-taking) app on macOS.
80+ glfw:: init_hint ( glfw:: InitHint :: CocoaMenubar ( false ) ) ;
81+ }
7382 let mut glfw = glfw:: init ( glfw:: fail_on_errors) . unwrap ( ) ;
7483 let main = Self :: spawn_window ( & mut glfw, width, height, transparent, "Processing" ) ;
7584 Ok ( Self {
@@ -129,7 +138,9 @@ impl GlfwContext {
129138 }
130139 }
131140
132- window. show ( ) ;
141+ if !offscreen ( glfw) {
142+ window. show ( ) ;
143+ }
133144
134145 ManagedWindow {
135146 window,
@@ -467,7 +478,7 @@ impl ManagedWindow {
467478 if desired. maximize {
468479 self . window . maximize ( ) ;
469480 }
470- if desired. focus && !is_wayland ( glfw) {
481+ if desired. focus && !is_wayland ( glfw) && ! offscreen ( glfw ) {
471482 self . window . focus ( ) ;
472483 }
473484
@@ -521,7 +532,7 @@ impl ManagedWindow {
521532 last. size = desired. size ;
522533 }
523534 if desired. visible != last. visible {
524- if desired. visible {
535+ if desired. visible && ! offscreen ( glfw ) {
525536 self . window . show ( ) ;
526537 } else {
527538 self . window . hide ( ) ;
0 commit comments