wlserver: Add wlserver_set_xwayland_server_mode

Sets the current mode and stuff for a specific xwayland server.
This commit is contained in:
Joshua Ashton 2022-02-06 23:09:32 +00:00 committed by Joshie
parent aca867e60f
commit 5ed0753165
2 changed files with 28 additions and 0 deletions

View file

@ -522,6 +522,11 @@ void gamescope_xwayland_server_t::handle_override_window_content( struct wl_clie
content_overrides[ x11_window ] = co; content_overrides[ x11_window ] = co;
} }
struct wl_client *gamescope_xwayland_server_t::get_client()
{
return xwayland_server->client;
}
static void gamescope_xwayland_handle_override_window_content( struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface_resource, uint32_t x11_window ) static void gamescope_xwayland_handle_override_window_content( struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface_resource, uint32_t x11_window )
{ {
// This should ideally use the surface's xwayland, but we don't know it. // This should ideally use the surface's xwayland, but we don't know it.
@ -1060,3 +1065,22 @@ void wlserver_surface_finish( struct wlserver_surface *surf )
wl_list_remove( &surf->pending_link ); wl_list_remove( &surf->pending_link );
wl_list_remove( &surf->destroy.link ); wl_list_remove( &surf->destroy.link );
} }
void wlserver_set_xwayland_server_mode( size_t idx, int w, int h, int refresh )
{
gamescope_xwayland_server_t *server = wlserver_get_xwayland_server( idx );
if ( !server )
return;
wl_client *client = server->get_client();
struct wl_resource *resource;
wl_resource_for_each( resource, &wlserver.wlr.output->resources )
{
if ( wl_resource_get_client( resource ) == client )
{
wl_output_send_mode( resource, WL_OUTPUT_MODE_CURRENT, w, h, refresh * 1000 );
wl_output_send_done( resource );
wl_log.infof( "Updating mode for xwayland server %zu %dx%d@%d - client %p - resource %p", idx, w, h, refresh, client, resource );
}
}
}

View file

@ -47,6 +47,8 @@ public:
void handle_override_window_content( struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface_resource, uint32_t x11_window ); void handle_override_window_content( struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface_resource, uint32_t x11_window );
void destroy_content_override(struct wlserver_content_override *co); void destroy_content_override(struct wlserver_content_override *co);
struct wl_client *get_client();
private: private:
struct wlr_xwayland_server *xwayland_server = NULL; struct wlr_xwayland_server *xwayland_server = NULL;
struct wl_listener xwayland_ready_listener = { .notify = xwayland_ready_callback }; struct wl_listener xwayland_ready_listener = { .notify = xwayland_ready_callback };
@ -167,3 +169,5 @@ struct wlserver_surface
void wlserver_surface_init( struct wlserver_surface *surf, long x11_id ); void wlserver_surface_init( struct wlserver_surface *surf, long x11_id );
void wlserver_surface_finish( struct wlserver_surface *surf ); void wlserver_surface_finish( struct wlserver_surface *surf );
void wlserver_set_xwayland_server_mode( size_t idx, int w, int h, int refresh );