@ -12,31 +12,22 @@ static void xdg_decoration_handle_destroy(struct wl_listener *listener,
wl_container_of ( listener , deco , destroy ) ;
wl_container_of ( listener , deco , destroy ) ;
deco - > view - > xdg_decoration = NULL ;
deco - > view - > xdg_decoration = NULL ;
wl_list_remove ( & deco - > destroy . link ) ;
wl_list_remove ( & deco - > destroy . link ) ;
wl_list_remove ( & deco - > surface_commit . link ) ;
wl_list_remove ( & deco - > request_mode . link ) ;
wl_list_remove ( & deco - > link ) ;
wl_list_remove ( & deco - > link ) ;
free ( deco ) ;
free ( deco ) ;
}
}
static void xdg_decoration_handle_ surface_commit ( struct wl_listener * listener ,
static void xdg_decoration_handle_ request_mode ( struct wl_listener * listener ,
void * data ) {
void * data ) {
struct sway_xdg_decoration * decoration =
struct sway_xdg_decoration * deco =
wl_container_of ( listener , decoration , surface_commit ) ;
wl_container_of ( listener , deco , request_mode ) ;
wlr_xdg_toplevel_decoration_v1_set_mode ( deco - > wlr_xdg_decoration ,
bool csd = decoration - > wlr_xdg_decoration - > current_mode = =
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE ) ;
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE ;
struct sway_view * view = decoration - > view ;
view_update_csd_from_client ( view , csd ) ;
arrange_container ( view - > container ) ;
transaction_commit_dirty ( ) ;
}
}
void handle_xdg_decoration ( struct wl_listener * listener , void * data ) {
void handle_xdg_decoration ( struct wl_listener * listener , void * data ) {
struct wlr_xdg_toplevel_decoration_v1 * wlr_deco = data ;
struct wlr_xdg_toplevel_decoration_v1 * wlr_deco = data ;
struct sway_xdg_shell_view * xdg_shell_view = wlr_deco - > surface - > data ;
struct sway_xdg_shell_view * xdg_shell_view = wlr_deco - > surface - > data ;
struct wlr_xdg_surface * wlr_xdg_surface =
xdg_shell_view - > view . wlr_xdg_surface ;
struct sway_xdg_decoration * deco = calloc ( 1 , sizeof ( * deco ) ) ;
struct sway_xdg_decoration * deco = calloc ( 1 , sizeof ( * deco ) ) ;
if ( deco = = NULL ) {
if ( deco = = NULL ) {
@ -50,13 +41,8 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data) {
wl_signal_add ( & wlr_deco - > events . destroy , & deco - > destroy ) ;
wl_signal_add ( & wlr_deco - > events . destroy , & deco - > destroy ) ;
deco - > destroy . notify = xdg_decoration_handle_destroy ;
deco - > destroy . notify = xdg_decoration_handle_destroy ;
// Note: We don't listen to the request_mode signal here, effectively
wl_signal_add ( & wlr_deco - > events . request_mode , & deco - > request_mode ) ;
// ignoring any modes the client asks to set. The client can still force a
deco - > request_mode . notify = xdg_decoration_handle_request_mode ;
// mode upon us, in which case we get upset but live with it.
deco - > surface_commit . notify = xdg_decoration_handle_surface_commit ;
wl_signal_add ( & wlr_xdg_surface - > surface - > events . commit ,
& deco - > surface_commit ) ;
wl_list_insert ( & server . xdg_decorations , & deco - > link ) ;
wl_list_insert ( & server . xdg_decorations , & deco - > link ) ;
}
}