@@ -568,6 +568,86 @@ static bool createXdgSurface(_GLFWwindow* window)
568568 return true;
569569}
570570
571+ static void layerSurfaceHandleConfigure (void * data ,
572+ struct zwlr_layer_surface_v1 * surface ,
573+ uint32_t serial ,
574+ uint32_t width ,
575+ uint32_t height ) {
576+ _GLFWwindow * window = data ;
577+ dispatchChangesAfterConfigure (window , width , height );
578+ zwlr_layer_surface_v1_ack_configure (surface , serial );
579+ }
580+
581+
582+ static void layerSurfaceHandleClosed (void * data ,
583+ struct zwlr_layer_surface_v1 * surface UNUSED ) {
584+ _GLFWwindow * window = data ;
585+ _glfwInputWindowCloseRequest (window );
586+ }
587+
588+ static const struct zwlr_layer_surface_v1_listener layerSurfaceListener = {
589+ layerSurfaceHandleConfigure ,
590+ layerSurfaceHandleClosed ,
591+ };
592+
593+ static struct wl_output * findWlOutput (const char * name )
594+ {
595+ int count ;
596+ GLFWmonitor * * monitors = glfwGetMonitors (& count );
597+
598+ for (int i = 0 ; i < count ; ++ i )
599+ {
600+ if (strcmp (glfwGetMonitorName (monitors [i ]), name ) == 0 )
601+ {
602+ return glfwGetWaylandMonitor (monitors [i ]);
603+ }
604+ }
605+ return NULL ;
606+ }
607+
608+ static bool createLayerSurface (_GLFWwindow * window ,
609+ const _GLFWwndconfig * wndconfig )
610+ {
611+ if (!_glfw .wl .layer_shell )
612+ {
613+ _glfwInputError (GLFW_PLATFORM_ERROR ,
614+ "Wayland: layer-shell protocol unsupported" );
615+ return false;
616+ }
617+
618+ struct wl_output * output = findWlOutput (wndconfig -> wl .backgroundMonitor );
619+ window -> wl .layer .surface =
620+ zwlr_layer_shell_v1_get_layer_surface (_glfw .wl .layer_shell ,
621+ window -> wl .surface , output , ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM ,
622+ "kitty" );
623+
624+ if (!window -> wl .layer .surface )
625+ {
626+ _glfwInputError (GLFW_PLATFORM_ERROR ,
627+ "Wayland: layer-surface creation failed" );
628+ return false;
629+ }
630+
631+ zwlr_layer_surface_v1_set_size (window -> wl .layer .surface , 0 , 0 );
632+ zwlr_layer_surface_v1_set_anchor (window -> wl .layer .surface ,
633+ ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
634+ ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
635+ ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
636+ ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT );
637+ zwlr_layer_surface_v1_set_exclusive_zone (window -> wl .layer .surface , -1 );
638+ zwlr_layer_surface_v1_set_margin (window -> wl .layer .surface , 0 , 0 , 0 , 0 );
639+ zwlr_layer_surface_v1_set_keyboard_interactivity (window -> wl .layer .surface , 0 );
640+
641+ zwlr_layer_surface_v1_add_listener (window -> wl .layer .surface ,
642+ & layerSurfaceListener ,
643+ window );
644+
645+ wl_surface_commit (window -> wl .surface );
646+ wl_display_roundtrip (_glfw .wl .display );
647+
648+ return true;
649+ }
650+
571651static void incrementCursorImage (_GLFWwindow * window )
572652{
573653 if (window && window -> wl .decorations .focus == CENTRAL_WINDOW && window -> cursorMode != GLFW_CURSOR_HIDDEN ) {
@@ -746,8 +826,16 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
746826
747827 if (wndconfig -> visible )
748828 {
749- if (!createXdgSurface (window ))
750- return false;
829+ if (wndconfig -> wl .background )
830+ {
831+ if (!createLayerSurface (window , wndconfig ))
832+ return false;
833+ }
834+ else
835+ {
836+ if (!createXdgSurface (window ))
837+ return false;
838+ }
751839
752840 window -> wl .visible = true;
753841 }
0 commit comments