mirror of
https://github.com/wizbright/waybox.git
synced 2025-10-29 05:40:20 -04:00
Support for ext-foreign-toplevel-list
This commit is contained in:
parent
c9b187afc8
commit
77652741b5
5 changed files with 57 additions and 1 deletions
|
|
@ -12,6 +12,9 @@
|
|||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#if WLR_CHECK_VERSION(0, 18, 0)
|
||||
#include <wlr/types/wlr_ext_foreign_toplevel_list_v1.h>
|
||||
#endif
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
#include <wlr/types/wlr_idle_notify_v1.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
|
|
@ -68,6 +71,9 @@ struct wb_server {
|
|||
struct wlr_box grab_geo_box;
|
||||
double grab_x, grab_y;
|
||||
uint32_t resize_edges;
|
||||
#if WLR_CHECK_VERSION(0, 18, 0)
|
||||
struct wlr_ext_foreign_toplevel_list_v1 *foreign_toplevel_list;
|
||||
#endif
|
||||
struct wl_list toplevels;
|
||||
|
||||
struct wlr_layer_shell_v1 *layer_shell;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ struct wb_toplevel {
|
|||
|
||||
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
||||
|
||||
#if WLR_CHECK_VERSION(0, 18, 0)
|
||||
struct wlr_ext_foreign_toplevel_handle_v1 *foreign_toplevel_handle;
|
||||
struct wlr_ext_foreign_toplevel_handle_v1_state foreign_toplevel_state;
|
||||
#endif
|
||||
|
||||
struct wl_listener map;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener commit;
|
||||
|
|
@ -28,6 +33,8 @@ struct wb_toplevel {
|
|||
struct wl_listener request_minimize;
|
||||
struct wl_listener request_move;
|
||||
struct wl_listener request_resize;
|
||||
struct wl_listener set_app_id;
|
||||
struct wl_listener set_title;
|
||||
|
||||
struct wlr_box geometry;
|
||||
struct wlr_box previous_geometry;
|
||||
|
|
|
|||
|
|
@ -184,7 +184,9 @@ static void wb_layer_surface_destroy(struct wb_layer_surface *surface) {
|
|||
return;
|
||||
}
|
||||
|
||||
wlr_fractional_scale_v1_notify_scale(surface->scene->layer_surface->surface, surface->output->wlr_output->scale);
|
||||
if (surface->scene->layer_surface->surface != NULL)
|
||||
wlr_fractional_scale_v1_notify_scale(surface->scene->layer_surface->surface,
|
||||
surface->output->wlr_output->scale);
|
||||
|
||||
wl_list_remove(&surface->map.link);
|
||||
wl_list_remove(&surface->unmap.link);
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ bool wb_start_server(struct wb_server* server) {
|
|||
wlr_data_control_manager_v1_create(server->wl_display);
|
||||
wlr_data_device_manager_create(server->wl_display);
|
||||
|
||||
#if WLR_CHECK_VERSION(0, 18, 0)
|
||||
server->foreign_toplevel_list =
|
||||
wlr_ext_foreign_toplevel_list_v1_create(server->wl_display, 1);
|
||||
#endif
|
||||
|
||||
server->gamma_control_manager =
|
||||
wlr_gamma_control_manager_v1_create(server->wl_display);
|
||||
server->gamma_control_set_gamma.notify = handle_gamma_control_set_gamma;
|
||||
|
|
|
|||
|
|
@ -178,6 +178,9 @@ static void xdg_toplevel_destroy(struct wl_listener *listener, void *data) {
|
|||
struct wlr_xdg_surface *base = toplevel->xdg_toplevel->base;
|
||||
wlr_surface_send_leave(base->surface, output);
|
||||
update_fractional_scale(base->surface);
|
||||
#if WLR_CHECK_VERSION(0, 18, 0)
|
||||
wlr_ext_foreign_toplevel_handle_v1_destroy(toplevel->foreign_toplevel_handle);
|
||||
#endif
|
||||
|
||||
wl_list_remove(&toplevel->map.link);
|
||||
wl_list_remove(&toplevel->unmap.link);
|
||||
|
|
@ -190,11 +193,35 @@ static void xdg_toplevel_destroy(struct wl_listener *listener, void *data) {
|
|||
wl_list_remove(&toplevel->request_maximize.link);
|
||||
wl_list_remove(&toplevel->request_move.link);
|
||||
wl_list_remove(&toplevel->request_resize.link);
|
||||
wl_list_remove(&toplevel->set_app_id.link);
|
||||
wl_list_remove(&toplevel->set_title.link);
|
||||
|
||||
wl_list_remove(&toplevel->link);
|
||||
free(toplevel);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_set_app_id(
|
||||
struct wl_listener *listener, void *data) {
|
||||
struct wb_toplevel *toplevel =
|
||||
wl_container_of(listener, toplevel, set_app_id);
|
||||
#if WLR_CHECK_VERSION(0, 18, 0)
|
||||
toplevel->foreign_toplevel_state.app_id = toplevel->xdg_toplevel->app_id;
|
||||
wlr_ext_foreign_toplevel_handle_v1_update_state(
|
||||
toplevel->foreign_toplevel_handle, &toplevel->foreign_toplevel_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void xdg_toplevel_set_title(
|
||||
struct wl_listener *listener, void *data) {
|
||||
struct wb_toplevel *toplevel =
|
||||
wl_container_of(listener, toplevel, set_title);
|
||||
#if WLR_CHECK_VERSION(0, 18, 0)
|
||||
toplevel->foreign_toplevel_state.title = toplevel->xdg_toplevel->title;
|
||||
wlr_ext_foreign_toplevel_handle_v1_update_state(
|
||||
toplevel->foreign_toplevel_handle, &toplevel->foreign_toplevel_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void xdg_toplevel_request_fullscreen(
|
||||
struct wl_listener *listener, void *data) {
|
||||
/* This event is raised when a client would like to set itself to
|
||||
|
|
@ -416,6 +443,11 @@ static void handle_new_xdg_toplevel(struct wl_listener *listener, void *data) {
|
|||
toplevel->server = server;
|
||||
toplevel->xdg_toplevel = xdg_toplevel;
|
||||
|
||||
#if WLR_CHECK_VERSION(0, 18, 0)
|
||||
toplevel->foreign_toplevel_handle = wlr_ext_foreign_toplevel_handle_v1_create(
|
||||
server->foreign_toplevel_list, &toplevel->foreign_toplevel_state);
|
||||
#endif
|
||||
|
||||
/* Listen to the various events it can emit */
|
||||
toplevel->map.notify = xdg_toplevel_map;
|
||||
wl_signal_add(&xdg_toplevel->base->surface->events.map, &toplevel->map);
|
||||
|
|
@ -447,6 +479,10 @@ static void handle_new_xdg_toplevel(struct wl_listener *listener, void *data) {
|
|||
wl_signal_add(&xdg_toplevel->events.request_move, &toplevel->request_move);
|
||||
toplevel->request_resize.notify = xdg_toplevel_request_resize;
|
||||
wl_signal_add(&xdg_toplevel->events.request_resize, &toplevel->request_resize);
|
||||
toplevel->set_app_id.notify = xdg_toplevel_set_app_id;
|
||||
wl_signal_add(&xdg_toplevel->events.set_app_id, &toplevel->set_app_id);
|
||||
toplevel->set_title.notify = xdg_toplevel_set_title;
|
||||
wl_signal_add(&xdg_toplevel->events.set_title, &toplevel->set_title);
|
||||
|
||||
wl_list_insert(&toplevel->server->toplevels, &toplevel->link);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue