@@ -738,6 +738,87 @@ static bool createXdgSurface(_GLFWwindow* window)
738738 return true;
739739}
740740
741+ static void layerSurfaceHandleConfigure (void * data ,
742+ struct zwlr_layer_surface_v1 * surface ,
743+ uint32_t serial ,
744+ uint32_t width ,
745+ uint32_t height ) {
746+ _GLFWwindow * window = data ;
747+ window -> wl .fullscreened = true;
748+ dispatchChangesAfterConfigure (window , width , height );
749+ zwlr_layer_surface_v1_ack_configure (surface , serial );
750+ }
751+
752+
753+ static void layerSurfaceHandleClosed (void * data ,
754+ struct zwlr_layer_surface_v1 * surface UNUSED ) {
755+ _GLFWwindow * window = data ;
756+ _glfwInputWindowCloseRequest (window );
757+ }
758+
759+ static const struct zwlr_layer_surface_v1_listener layerSurfaceListener = {
760+ layerSurfaceHandleConfigure ,
761+ layerSurfaceHandleClosed ,
762+ };
763+
764+ static struct wl_output * findWlOutput (const char * name )
765+ {
766+ int count ;
767+ GLFWmonitor * * monitors = glfwGetMonitors (& count );
768+
769+ for (int i = 0 ; i < count ; ++ i )
770+ {
771+ if (strcmp (glfwGetMonitorName (monitors [i ]), name ) == 0 )
772+ {
773+ return glfwGetWaylandMonitor (monitors [i ]);
774+ }
775+ }
776+ return NULL ;
777+ }
778+
779+ static bool createLayerSurface (_GLFWwindow * window ,
780+ const _GLFWwndconfig * wndconfig )
781+ {
782+ if (!_glfw .wl .layer_shell )
783+ {
784+ _glfwInputError (GLFW_PLATFORM_ERROR ,
785+ "Wayland: layer-shell protocol unsupported" );
786+ return false;
787+ }
788+
789+ struct wl_output * output = findWlOutput (wndconfig -> wl .backgroundMonitor );
790+ window -> wl .layer .surface =
791+ zwlr_layer_shell_v1_get_layer_surface (_glfw .wl .layer_shell ,
792+ window -> wl .surface , output , ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM ,
793+ "kitty" );
794+
795+ if (!window -> wl .layer .surface )
796+ {
797+ _glfwInputError (GLFW_PLATFORM_ERROR ,
798+ "Wayland: layer-surface creation failed" );
799+ return false;
800+ }
801+
802+ zwlr_layer_surface_v1_set_size (window -> wl .layer .surface , 0 , 0 );
803+ zwlr_layer_surface_v1_set_anchor (window -> wl .layer .surface ,
804+ ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
805+ ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
806+ ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
807+ ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT );
808+ zwlr_layer_surface_v1_set_exclusive_zone (window -> wl .layer .surface , -1 );
809+ zwlr_layer_surface_v1_set_margin (window -> wl .layer .surface , 0 , 0 , 0 , 0 );
810+ zwlr_layer_surface_v1_set_keyboard_interactivity (window -> wl .layer .surface , 0 );
811+
812+ zwlr_layer_surface_v1_add_listener (window -> wl .layer .surface ,
813+ & layerSurfaceListener ,
814+ window );
815+
816+ wl_surface_commit (window -> wl .surface );
817+ wl_display_roundtrip (_glfw .wl .display );
818+
819+ return true;
820+ }
821+
741822static void incrementCursorImage (_GLFWwindow * window )
742823{
743824 if (window && window -> wl .decorations .focus == mainWindow && window -> cursorMode != GLFW_CURSOR_HIDDEN ) {
@@ -913,8 +994,16 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
913994
914995 if (wndconfig -> visible )
915996 {
916- if (!createXdgSurface (window ))
917- return false;
997+ if (wndconfig -> wl .background )
998+ {
999+ if (!createLayerSurface (window , wndconfig ))
1000+ return false;
1001+ }
1002+ else
1003+ {
1004+ if (!createXdgSurface (window ))
1005+ return false;
1006+ }
9181007
9191008 window -> wl .visible = true;
9201009 }
0 commit comments