@ -3418,86 +3418,73 @@ xdg_surface_resize(struct wl_client *client, struct wl_resource *resource,
}
}
static void
static void
xdg_surface_set_output ( struct wl_client * client ,
xdg_surface_ack_configure ( struct wl_client * client ,
struct wl_resource * resource ,
struct wl_resource * resource ,
struct wl_resource * output_resource )
uint32_t serial )
{
{
struct shell_surface * shsurf = wl_resource_get_user_data ( resource ) ;
struct shell_surface * shsurf = wl_resource_get_user_data ( resource ) ;
struct weston_output * output ;
if ( output_resource )
output = wl_resource_get_user_data ( output_resource ) ;
else
output = NULL ;
shsurf - > recommended_output = output ;
if ( shsurf - > state_requested ) {
shsurf - > next_state = shsurf - > requested_state ;
shsurf - > state_changed = true ;
shsurf - > state_requested = false ;
}
}
}
static void
static void
xdg_surface_change_state ( struct shell_surface * shsurf ,
xdg_surface_set_maximized ( struct wl_client * client ,
uint32_t state , uint32_t value , uint32_t serial )
struct wl_resource * resource )
{
{
xdg_surface_send_change_state ( shsurf - > resource , state , value , serial ) ;
struct shell_surface * shsurf = wl_resource_get_user_data ( resource ) ;
shsurf - > state_requested = true ;
shsurf - > state_requested = true ;
shsurf - > requested_state . maximized = true ;
set_maximized ( shsurf , NULL ) ;
}
switch ( state ) {
static void
case XDG_SURFACE_STATE_MAXIMIZED :
xdg_surface_unset_maximized ( struct wl_client * client ,
shsurf - > requested_state . maximized = value ;
struct wl_resource * resource )
if ( value )
{
set_maximized ( shsurf , NULL ) ;
struct shell_surface * shsurf = wl_resource_get_user_data ( resource ) ;
break ;
case XDG_SURFACE_STATE_FULLSCREEN :
shsurf - > requested_state . fullscreen = value ;
if ( value )
shsurf - > state_requested = true ;
set_fullscreen ( shsurf ,
shsurf - > requested_state . maximized = false ;
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT ,
shsurf - > client - > send_configure ( shsurf - > surface , 0 , 0 ) ;
0 , shsurf - > recommended_output ) ;
break ;
}
}
}
static void
static void
xdg_surface_request_change_state ( struct wl_client * client ,
xdg_surface_set_fullscreen ( struct wl_client * client ,
struct wl_resource * resource ,
struct wl_resource * resource ,
uint32_t state ,
struct wl_resource * output_resource )
uint32_t value ,
uint32_t serial )
{
{
struct shell_surface * shsurf = wl_resource_get_user_data ( resource ) ;
struct shell_surface * shsurf = wl_resource_get_user_data ( resource ) ;
struct weston_output * output ;
/* The client can't know what the current state is, so we need
shsurf - > state_requested = true ;
to always send a state change in response . */
shsurf - > requested_state . fullscreen = true ;
if ( shsurf - > type ! = SHELL_SURFACE_TOPLEVEL )
if ( output_resource )
return ;
output = wl_resource_get_user_data ( output_resource ) ;
else
output = NULL ;
switch ( state ) {
shsurf - > recommended_output = output ;
case XDG_SURFACE_STATE_MAXIMIZED :
case XDG_SURFACE_STATE_FULLSCREEN :
break ;
default :
/* send error? ignore? send change state with value 0? */
return ;
}
xdg_surface_change_state ( shsurf , state , value , serial ) ;
set_fullscreen ( shsurf ,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT ,
0 , shsurf - > recommended_output ) ;
}
}
static void
static void
xdg_surface_ack_change_state ( struct wl_client * client ,
xdg_surface_unset_fullscreen ( struct wl_client * client ,
struct wl_resource * resource ,
struct wl_resource * resource )
uint32_t state ,
uint32_t value ,
uint32_t serial )
{
{
struct shell_surface * shsurf = wl_resource_get_user_data ( resource ) ;
struct shell_surface * shsurf = wl_resource_get_user_data ( resource ) ;
if ( shsurf - > state_requested ) {
shsurf - > state_requested = true ;
shsurf - > next_state = shsurf - > requested_state ;
shsurf - > requested_state . fullscreen = false ;
shsurf - > state_changed = true ;
shsurf - > client - > send_configure ( shsurf - > surface , 0 , 0 ) ;
shsurf - > state_requested = false ;
}
}
}
static void
static void
@ -3521,10 +3508,12 @@ static const struct xdg_surface_interface xdg_surface_implementation = {
xdg_surface_set_app_id ,
xdg_surface_set_app_id ,
xdg_surface_move ,
xdg_surface_move ,
xdg_surface_resize ,
xdg_surface_resize ,
xdg_surface_set_output ,
xdg_surface_ack_configure ,
xdg_surface_request_change_state ,
xdg_surface_set_maximized ,
xdg_surface_ack_change_state ,
xdg_surface_unset_maximized ,
xdg_surface_set_minimized
xdg_surface_set_fullscreen ,
xdg_surface_unset_fullscreen ,
xdg_surface_set_minimized ,
} ;
} ;
static void
static void
@ -3532,11 +3521,28 @@ xdg_send_configure(struct weston_surface *surface,
int32_t width , int32_t height )
int32_t width , int32_t height )
{
{
struct shell_surface * shsurf = get_shell_surface ( surface ) ;
struct shell_surface * shsurf = get_shell_surface ( surface ) ;
uint32_t * s ;
struct wl_array states ;
uint32_t serial ;
assert ( shsurf ) ;
assert ( shsurf ) ;
if ( shsurf - > resource )
if ( ! shsurf - > resource )
xdg_surface_send_configure ( shsurf - > resource , width , height ) ;
return ;
wl_array_init ( & states ) ;
if ( shsurf - > requested_state . fullscreen ) {
s = wl_array_add ( & states , sizeof * s ) ;
* s = XDG_SURFACE_STATE_FULLSCREEN ;
} else if ( shsurf - > requested_state . maximized ) {
s = wl_array_add ( & states , sizeof * s ) ;
* s = XDG_SURFACE_STATE_MAXIMIZED ;
}
serial = wl_display_next_serial ( shsurf - > surface - > compositor - > wl_display ) ;
xdg_surface_send_configure ( shsurf - > resource , width , height , & states , serial ) ;
wl_array_release ( & states ) ;
}
}
static const struct weston_shell_client xdg_client = {
static const struct weston_shell_client xdg_client = {
@ -4107,7 +4113,6 @@ maximize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void
struct weston_surface * focus = seat - > keyboard - > focus ;
struct weston_surface * focus = seat - > keyboard - > focus ;
struct weston_surface * surface ;
struct weston_surface * surface ;
struct shell_surface * shsurf ;
struct shell_surface * shsurf ;
uint32_t serial ;
surface = weston_surface_get_main_surface ( focus ) ;
surface = weston_surface_get_main_surface ( focus ) ;
if ( surface = = NULL )
if ( surface = = NULL )
@ -4120,9 +4125,10 @@ maximize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void
if ( ! shell_surface_is_xdg_surface ( shsurf ) )
if ( ! shell_surface_is_xdg_surface ( shsurf ) )
return ;
return ;
serial = wl_display_next_serial ( seat - > compositor - > wl_display ) ;
shsurf - > state_requested = true ;
xdg_surface_change_state ( shsurf , XDG_SURFACE_STATE_MAXIMIZED ,
shsurf - > requested_state . maximized = ! shsurf - > state . maximized ;
! shsurf - > state . maximized , serial ) ;
if ( shsurf - > requested_state . maximized )
set_maximized ( shsurf , NULL ) ;
}
}
static void
static void
@ -4131,7 +4137,6 @@ fullscreen_binding(struct weston_seat *seat, uint32_t time, uint32_t button, voi
struct weston_surface * focus = seat - > keyboard - > focus ;
struct weston_surface * focus = seat - > keyboard - > focus ;
struct weston_surface * surface ;
struct weston_surface * surface ;
struct shell_surface * shsurf ;
struct shell_surface * shsurf ;
uint32_t serial ;
surface = weston_surface_get_main_surface ( focus ) ;
surface = weston_surface_get_main_surface ( focus ) ;
if ( surface = = NULL )
if ( surface = = NULL )
@ -4144,9 +4149,12 @@ fullscreen_binding(struct weston_seat *seat, uint32_t time, uint32_t button, voi
if ( ! shell_surface_is_xdg_surface ( shsurf ) )
if ( ! shell_surface_is_xdg_surface ( shsurf ) )
return ;
return ;
serial = wl_display_next_serial ( seat - > compositor - > wl_display ) ;
shsurf - > state_requested = true ;
xdg_surface_change_state ( shsurf , XDG_SURFACE_STATE_FULLSCREEN ,
shsurf - > requested_state . fullscreen = ! shsurf - > state . fullscreen ;
! shsurf - > state . fullscreen , serial ) ;
if ( shsurf - > requested_state . fullscreen )
set_fullscreen ( shsurf ,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT ,
0 , shsurf - > recommended_output ) ;
}
}
static void
static void