@ -35,12 +35,14 @@
# include <wayland-client.h>
# include <wayland-client.h>
# include "../shared/os-compatibility.h"
# include "../shared/os-compatibility.h"
# include "xdg-shell-client-protocol.h"
# include "xdg-shell-client-protocol.h"
# include "fullscreen-shell-client-protocol.h"
struct display {
struct display {
struct wl_display * display ;
struct wl_display * display ;
struct wl_registry * registry ;
struct wl_registry * registry ;
struct wl_compositor * compositor ;
struct wl_compositor * compositor ;
struct xdg_shell * shell ;
struct xdg_shell * shell ;
struct _wl_fullscreen_shell * fshell ;
struct wl_shm * shm ;
struct wl_shm * shm ;
uint32_t formats ;
uint32_t formats ;
} ;
} ;
@ -165,14 +167,26 @@ create_window(struct display *display, int width, int height)
window - > width = width ;
window - > width = width ;
window - > height = height ;
window - > height = height ;
window - > surface = wl_compositor_create_surface ( display - > compositor ) ;
window - > surface = wl_compositor_create_surface ( display - > compositor ) ;
window - > xdg_surface = xdg_shell_get_xdg_surface ( display - > shell ,
window - > surface ) ;
if ( window - > xdg_surface )
if ( display - > shell ) {
window - > xdg_surface =
xdg_shell_get_xdg_surface ( display - > shell ,
window - > surface ) ;
assert ( window - > xdg_surface ) ;
xdg_surface_add_listener ( window - > xdg_surface ,
xdg_surface_add_listener ( window - > xdg_surface ,
& xdg_surface_listener , window ) ;
& xdg_surface_listener , window ) ;
xdg_surface_set_title ( window - > xdg_surface , " simple-shm " ) ;
xdg_surface_set_title ( window - > xdg_surface , " simple-shm " ) ;
} else if ( display - > fshell ) {
_wl_fullscreen_shell_present_surface ( display - > fshell ,
window - > surface ,
_WL_FULLSCREEN_SHELL_PRESENT_METHOD_DEFAULT ,
NULL ) ;
} else {
assert ( 0 ) ;
}
return window ;
return window ;
}
}
@ -188,7 +202,8 @@ destroy_window(struct window *window)
if ( window - > buffers [ 1 ] . buffer )
if ( window - > buffers [ 1 ] . buffer )
wl_buffer_destroy ( window - > buffers [ 1 ] . buffer ) ;
wl_buffer_destroy ( window - > buffers [ 1 ] . buffer ) ;
xdg_surface_destroy ( window - > xdg_surface ) ;
if ( window - > xdg_surface )
xdg_surface_destroy ( window - > xdg_surface ) ;
wl_surface_destroy ( window - > surface ) ;
wl_surface_destroy ( window - > surface ) ;
free ( window ) ;
free ( window ) ;
}
}
@ -346,6 +361,9 @@ registry_handle_global(void *data, struct wl_registry *registry,
id , & xdg_shell_interface , 1 ) ;
id , & xdg_shell_interface , 1 ) ;
xdg_shell_use_unstable_version ( d - > shell , XDG_VERSION ) ;
xdg_shell_use_unstable_version ( d - > shell , XDG_VERSION ) ;
xdg_shell_add_listener ( d - > shell , & xdg_shell_listener , d ) ;
xdg_shell_add_listener ( d - > shell , & xdg_shell_listener , d ) ;
} else if ( strcmp ( interface , " _wl_fullscreen_shell " ) = = 0 ) {
d - > fshell = wl_registry_bind ( registry ,
id , & _wl_fullscreen_shell_interface , 1 ) ;
} else if ( strcmp ( interface , " wl_shm " ) = = 0 ) {
} else if ( strcmp ( interface , " wl_shm " ) = = 0 ) {
d - > shm = wl_registry_bind ( registry ,
d - > shm = wl_registry_bind ( registry ,
id , & wl_shm_interface , 1 ) ;
id , & wl_shm_interface , 1 ) ;
@ -408,6 +426,9 @@ destroy_display(struct display *display)
if ( display - > shell )
if ( display - > shell )
xdg_shell_destroy ( display - > shell ) ;
xdg_shell_destroy ( display - > shell ) ;
if ( display - > fshell )
_wl_fullscreen_shell_release ( display - > fshell ) ;
if ( display - > compositor )
if ( display - > compositor )
wl_compositor_destroy ( display - > compositor ) ;
wl_compositor_destroy ( display - > compositor ) ;