From 5b1b9657bfde8dd254744533c3c826aacd1f7df1 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Sat, 25 Aug 2018 22:27:11 +0300 Subject: types: implement wlr_foreign_toplevel_management_v1 --- include/wlr/types/meson.build | 1 + .../wlr/types/wlr_foreign_toplevel_management_v1.h | 120 +++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 include/wlr/types/wlr_foreign_toplevel_management_v1.h (limited to 'include') diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build index 72debcf3..e2ce86e3 100644 --- a/include/wlr/types/meson.build +++ b/include/wlr/types/meson.build @@ -5,6 +5,7 @@ install_headers( 'wlr_cursor.h', 'wlr_data_device.h', 'wlr_export_dmabuf_v1.h', + 'wlr_foreign_toplevel_management_v1.h', 'wlr_gamma_control_v1.h', 'wlr_gamma_control.h', 'wlr_gtk_primary_selection.h', diff --git a/include/wlr/types/wlr_foreign_toplevel_management_v1.h b/include/wlr/types/wlr_foreign_toplevel_management_v1.h new file mode 100644 index 00000000..75ae0e64 --- /dev/null +++ b/include/wlr/types/wlr_foreign_toplevel_management_v1.h @@ -0,0 +1,120 @@ +/* + * This an unstable interface of wlroots. No guarantees are made regarding the + * future consistency of this API. + */ +#ifndef WLR_USE_UNSTABLE +#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" +#endif + +#ifndef WLR_TYPES_WLR_FOREIGN_TOPLEVEL_MANAGEMENT_V1_H +#define WLR_TYPES_WLR_FOREIGN_TOPLEVEL_MANAGEMENT_V1_H + +#include +#include + +struct wlr_foreign_toplevel_manager_v1 { + struct wl_event_loop *event_loop; + struct wl_global *global; + struct wl_list resources; + struct wl_list toplevels; // wlr_foreign_toplevel_handle_v1::link + + struct wl_listener display_destroy; + + struct { + struct wl_signal destroy; + } events; + + void *data; +}; + +enum wlr_foreign_toplevel_handle_v1_state { + WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED = 1, + WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED = 2, + WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED = 4, +}; + +struct wlr_foreign_toplevel_handle_v1_output { + struct wl_list link; // wlr_foreign_toplevel_handle_v1::outputs + struct wl_listener output_destroy; + struct wlr_output *output; + + struct wlr_foreign_toplevel_handle_v1 *toplevel; +}; + +struct wlr_foreign_toplevel_handle_v1 { + struct wlr_foreign_toplevel_manager_v1 *manager; + struct wl_list resources; + struct wl_list link; + struct wl_event_source *idle_source; + + char *title; + char *app_id; + struct wl_list outputs; // wlr_foreign_toplevel_v1_output + uint32_t state; // wlr_foreign_toplevel_v1_state + + struct { + // wlr_foreign_toplevel_handle_v1_maximized_event + struct wl_signal request_maximize; + //wlr_foreign_toplevel_handle_v1_minimized_event + struct wl_signal request_minimize; + //wlr_foreign_toplevel_handle_v1_activated_event + struct wl_signal request_activate; + struct wl_signal request_close; + + //wlr_foreign_toplevel_handle_v1_set_rectangle_event + struct wl_signal set_rectangle; + struct wl_signal destroy; + } events; + + void *data; +}; + +struct wlr_foreign_toplevel_handle_v1_maximized_event { + struct wlr_foreign_toplevel_handle_v1 *toplevel; + bool maximized; +}; + +struct wlr_foreign_toplevel_handle_v1_minimized_event { + struct wlr_foreign_toplevel_handle_v1 *toplevel; + bool minimized; +}; + +struct wlr_foreign_toplevel_handle_v1_activated_event { + struct wlr_foreign_toplevel_handle_v1 *toplevel; + struct wlr_seat *seat; +}; + +struct wlr_foreign_toplevel_handle_v1_set_rectangle_event { + struct wlr_foreign_toplevel_handle_v1 *toplevel; + struct wlr_surface *surface; + int32_t x, y, width, height; +}; + +struct wlr_foreign_toplevel_manager_v1 *wlr_foreign_toplevel_manager_v1_create( + struct wl_display *display); +void wlr_foreign_toplevel_manager_v1_destroy( + struct wlr_foreign_toplevel_manager_v1 *manager); + +struct wlr_foreign_toplevel_handle_v1 *wlr_foreign_toplevel_handle_v1_create( + struct wlr_foreign_toplevel_manager_v1 *manager); +void wlr_foreign_toplevel_handle_v1_destroy( + struct wlr_foreign_toplevel_handle_v1 *toplevel); + +void wlr_foreign_toplevel_handle_v1_set_title( + struct wlr_foreign_toplevel_handle_v1 *toplevel, const char *title); +void wlr_foreign_toplevel_handle_v1_set_app_id( + struct wlr_foreign_toplevel_handle_v1 *toplevel, const char *app_id); + +void wlr_foreign_toplevel_handle_v1_output_enter( + struct wlr_foreign_toplevel_handle_v1 *toplevel, struct wlr_output *output); +void wlr_foreign_toplevel_handle_v1_output_leave( + struct wlr_foreign_toplevel_handle_v1 *toplevel, struct wlr_output *output); + +void wlr_foreign_toplevel_handle_v1_set_maximized( + struct wlr_foreign_toplevel_handle_v1 *toplevel, bool maximized); +void wlr_foreign_toplevel_handle_v1_set_minimized( + struct wlr_foreign_toplevel_handle_v1 *toplevel, bool minimized); +void wlr_foreign_toplevel_handle_v1_set_activated( + struct wlr_foreign_toplevel_handle_v1 *toplevel, bool activated); + +#endif -- cgit v1.2.3 From f387a840d89f8040fdea57a1e9e159d79fa0e7ff Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Sat, 25 Aug 2018 22:46:55 +0300 Subject: rootston: add title/app_id/class listeners --- include/rootston/view.h | 7 +++++++ rootston/xdg_shell.c | 19 +++++++++++++++++++ rootston/xdg_shell_v6.c | 17 +++++++++++++++++ rootston/xwayland.c | 17 +++++++++++++++++ 4 files changed, 60 insertions(+) (limited to 'include') diff --git a/include/rootston/view.h b/include/rootston/view.h index e67aaf36..a514bc4f 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -33,6 +33,8 @@ struct roots_xdg_surface_v6 { struct wl_listener request_resize; struct wl_listener request_maximize; struct wl_listener request_fullscreen; + struct wl_listener set_title; + struct wl_listener set_app_id; struct wl_listener surface_commit; @@ -52,6 +54,9 @@ struct roots_xdg_surface { struct wl_listener request_resize; struct wl_listener request_maximize; struct wl_listener request_fullscreen; + struct wl_listener set_title; + struct wl_listener set_app_id; + struct wl_listener surface_commit; @@ -71,6 +76,8 @@ struct roots_xwayland_surface { struct wl_listener request_fullscreen; struct wl_listener map; struct wl_listener unmap; + struct wl_listener set_title; + struct wl_listener set_class; struct wl_listener surface_commit; }; diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c index d3fc5372..8d8a1479 100644 --- a/rootston/xdg_shell.c +++ b/rootston/xdg_shell.c @@ -265,6 +265,8 @@ static void destroy(struct roots_view *view) { wl_list_remove(&roots_xdg_surface->request_resize.link); wl_list_remove(&roots_xdg_surface->request_maximize.link); wl_list_remove(&roots_xdg_surface->request_fullscreen.link); + wl_list_remove(&roots_xdg_surface->set_title.link); + wl_list_remove(&roots_xdg_surface->set_app_id.link); roots_xdg_surface->view->xdg_surface->data = NULL; free(roots_xdg_surface); } @@ -326,6 +328,18 @@ static void handle_request_fullscreen(struct wl_listener *listener, view_set_fullscreen(view, e->fullscreen, e->output); } +static void handle_set_title(struct wl_listener *listener, void *data) { + struct roots_xdg_surface *roots_xdg_surface = + wl_container_of(listener, roots_xdg_surface, set_title); +} + +static void handle_set_app_id(struct wl_listener *listener, void *data) { + struct roots_xdg_surface *roots_xdg_surface = + wl_container_of(listener, roots_xdg_surface, set_title); + wlr_log(WLR_INFO, "surface title %s", + roots_xdg_surface->view->xdg_surface->toplevel->title); +} + static void handle_surface_commit(struct wl_listener *listener, void *data) { struct roots_xdg_surface *roots_surface = wl_container_of(listener, roots_surface, surface_commit); @@ -438,6 +452,11 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { roots_surface->request_fullscreen.notify = handle_request_fullscreen; wl_signal_add(&surface->toplevel->events.request_fullscreen, &roots_surface->request_fullscreen); + roots_surface->set_title.notify = handle_set_title; + wl_signal_add(&surface->toplevel->events.set_title, &roots_surface->set_title); + roots_surface->set_app_id.notify = handle_set_app_id; + wl_signal_add(&surface->toplevel->events.set_app_id, + &roots_surface->set_app_id); roots_surface->new_popup.notify = handle_new_popup; wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup); surface->data = roots_surface; diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 6bdf749f..e7b55039 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -265,6 +265,8 @@ static void destroy(struct roots_view *view) { wl_list_remove(&roots_xdg_surface->request_resize.link); wl_list_remove(&roots_xdg_surface->request_maximize.link); wl_list_remove(&roots_xdg_surface->request_fullscreen.link); + wl_list_remove(&roots_xdg_surface->set_title.link); + wl_list_remove(&roots_xdg_surface->set_app_id.link); free(roots_xdg_surface); } @@ -325,6 +327,16 @@ static void handle_request_fullscreen(struct wl_listener *listener, view_set_fullscreen(view, e->fullscreen, e->output); } +static void handle_set_title(struct wl_listener *listener, void *data) { + struct roots_xdg_surface_v6 *roots_xdg_surface = + wl_container_of(listener, roots_xdg_surface, set_title); +} + +static void handle_set_app_id(struct wl_listener *listener, void *data) { + struct roots_xdg_surface_v6 *roots_xdg_surface = + wl_container_of(listener, roots_xdg_surface, set_title); +} + static void handle_surface_commit(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_surface = wl_container_of(listener, roots_surface, surface_commit); @@ -437,6 +449,11 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { roots_surface->request_fullscreen.notify = handle_request_fullscreen; wl_signal_add(&surface->toplevel->events.request_fullscreen, &roots_surface->request_fullscreen); + roots_surface->set_title.notify = handle_set_title; + wl_signal_add(&surface->toplevel->events.set_title, &roots_surface->set_title); + roots_surface->set_app_id.notify = handle_set_app_id; + wl_signal_add(&surface->toplevel->events.set_app_id, + &roots_surface->set_app_id); roots_surface->new_popup.notify = handle_new_popup; wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup); diff --git a/rootston/xwayland.c b/rootston/xwayland.c index d98f808b..f887ed40 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -114,6 +114,8 @@ static void destroy(struct roots_view *view) { wl_list_remove(&roots_surface->request_move.link); wl_list_remove(&roots_surface->request_resize.link); wl_list_remove(&roots_surface->request_maximize.link); + wl_list_remove(&roots_surface->set_title.link); + wl_list_remove(&roots_surface->set_class.link); wl_list_remove(&roots_surface->map.link); wl_list_remove(&roots_surface->unmap.link); free(roots_surface); @@ -198,6 +200,16 @@ static void handle_request_fullscreen(struct wl_listener *listener, view_set_fullscreen(view, xwayland_surface->fullscreen, NULL); } +static void handle_set_title(struct wl_listener *listener, void *data) { + struct roots_xwayland_surface *roots_surface = + wl_container_of(listener, roots_surface, set_title); +} + +static void handle_set_class(struct wl_listener *listener, void *data) { + struct roots_xwayland_surface *roots_surface = + wl_container_of(listener, roots_surface, set_title); +} + static void handle_surface_commit(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, surface_commit); @@ -300,6 +312,11 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { roots_surface->request_fullscreen.notify = handle_request_fullscreen; wl_signal_add(&surface->events.request_fullscreen, &roots_surface->request_fullscreen); + roots_surface->set_title.notify = handle_set_title; + wl_signal_add(&surface->events.set_title, &roots_surface->set_title); + roots_surface->set_class.notify = handle_set_class; + wl_signal_add(&surface->events.set_class, + &roots_surface->set_class); struct roots_view *view = view_create(desktop); if (view == NULL) { -- cgit v1.2.3 From 8cce2d75a9a9241ca5083d99e3ef827238b8f471 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Tue, 2 Oct 2018 13:08:23 +0200 Subject: rootston: add support for wlr_foreign_toplevel_management_v1 --- include/rootston/desktop.h | 2 ++ include/rootston/view.h | 12 +++++++ rootston/desktop.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++ rootston/wl_shell.c | 26 ++++++++++++++ rootston/xdg_shell.c | 15 ++++++-- rootston/xdg_shell_v6.c | 13 ++++++- rootston/xwayland.c | 14 ++++++-- 7 files changed, 162 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index cd85e794..b1fcaca0 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +64,7 @@ struct roots_desktop { struct wlr_tablet_manager_v2 *tablet_v2; struct wlr_pointer_constraints_v1 *pointer_constraints; struct wlr_presentation *presentation; + struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager_v1; struct wl_listener new_output; struct wl_listener layout_change; diff --git a/include/rootston/view.h b/include/rootston/view.h index a514bc4f..b1feb5ce 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,8 @@ struct roots_wl_shell_surface { struct wl_listener request_maximize; struct wl_listener request_fullscreen; struct wl_listener set_state; + struct wl_listener set_title; + struct wl_listener set_class; struct wl_listener surface_commit; }; @@ -139,6 +142,11 @@ struct roots_view { struct wlr_surface *wlr_surface; struct wl_list children; // roots_view_child::link + struct wlr_foreign_toplevel_handle_v1 *toplevel_handle; + struct wl_listener toplevel_handle_request_maximize; + struct wl_listener toplevel_handle_request_activate; + struct wl_listener toplevel_handle_request_close; + struct wl_listener new_subsurface; struct { @@ -225,6 +233,10 @@ bool view_center(struct roots_view *view); void view_setup(struct roots_view *view); void view_teardown(struct roots_view *view); +void view_set_title(struct roots_view *view, const char *title); +void view_set_app_id(struct roots_view *view, const char *app_id); +void view_create_foreign_toplevel_handle(struct roots_view *view); + void view_get_deco_box(const struct roots_view *view, struct wlr_box *box); enum roots_deco_part { diff --git a/rootston/desktop.c b/rootston/desktop.c index 69f025e1..b41a3079 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -123,9 +123,17 @@ static void view_update_output(const struct roots_view *view, output->wlr_output, &box); if (intersected && !intersects) { wlr_surface_send_leave(view->wlr_surface, output->wlr_output); + if (view->toplevel_handle) { + wlr_foreign_toplevel_handle_v1_output_leave( + view->toplevel_handle, output->wlr_output); + } } if (!intersected && intersects) { wlr_surface_send_enter(view->wlr_surface, output->wlr_output); + if (view->toplevel_handle) { + wlr_foreign_toplevel_handle_v1_output_enter( + view->toplevel_handle, output->wlr_output); + } } } } @@ -149,6 +157,11 @@ void view_activate(struct roots_view *view, bool activate) { if (view->activate) { view->activate(view, activate); } + + if (view->toplevel_handle) { + wlr_foreign_toplevel_handle_v1_set_activated(view->toplevel_handle, + activate); + } } void view_resize(struct roots_view *view, uint32_t width, uint32_t height) { @@ -225,6 +238,11 @@ void view_maximize(struct roots_view *view, bool maximized) { view->maximize(view, maximized); } + if (view->toplevel_handle) { + wlr_foreign_toplevel_handle_v1_set_maximized(view->toplevel_handle, + maximized); + } + if (!view->maximized && maximized) { view->maximized = true; view->saved.x = view->box.x; @@ -501,6 +519,11 @@ void view_unmap(struct roots_view *view) { view->wlr_surface = NULL; view->box.width = view->box.height = 0; + + if (view->toplevel_handle) { + wlr_foreign_toplevel_handle_v1_destroy(view->toplevel_handle); + view->toplevel_handle = NULL; + } } void view_initial_focus(struct roots_view *view) { @@ -520,6 +543,7 @@ void view_setup(struct roots_view *view) { } view_update_output(view, NULL); + view_create_foreign_toplevel_handle(view); } void view_apply_damage(struct roots_view *view) { @@ -575,6 +599,66 @@ void view_update_decorated(struct roots_view *view, bool decorated) { view_damage_whole(view); } +void view_set_title(struct roots_view *view, const char *title) { + if (view->toplevel_handle) { + wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle, title); + } +} + +void view_set_app_id(struct roots_view *view, const char *app_id) { + if (view->toplevel_handle) { + wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle, app_id); + } +} + +static void handle_toplevel_handle_request_maximize(struct wl_listener *listener, + void *data) { + struct roots_view *view = wl_container_of(listener, view, + toplevel_handle_request_maximize); + struct wlr_foreign_toplevel_handle_v1_maximized_event *event = data; + view_maximize(view, event->maximized); +} + +static void handle_toplevel_handle_request_activate(struct wl_listener *listener, + void *data) { + struct roots_view *view = + wl_container_of(listener, view, toplevel_handle_request_activate); + struct wlr_foreign_toplevel_handle_v1_activated_event *event = data; + + struct roots_seat *seat; + wl_list_for_each(seat, &view->desktop->server->input->seats, link) { + if (event->seat == seat->seat) { + roots_seat_set_focus(seat, view); + } + } +} + +static void handle_toplevel_handle_request_close(struct wl_listener *listener, + void *data) { + struct roots_view *view = + wl_container_of(listener, view, toplevel_handle_request_close); + view_close(view); +} + +void view_create_foreign_toplevel_handle(struct roots_view *view) { + view->toplevel_handle = + wlr_foreign_toplevel_handle_v1_create( + view->desktop->foreign_toplevel_manager_v1); + + view->toplevel_handle_request_maximize.notify = + handle_toplevel_handle_request_maximize; + wl_signal_add(&view->toplevel_handle->events.request_maximize, + &view->toplevel_handle_request_maximize); + view->toplevel_handle_request_activate.notify = + handle_toplevel_handle_request_activate; + wl_signal_add(&view->toplevel_handle->events.request_activate, + &view->toplevel_handle_request_activate); + view->toplevel_handle_request_close.notify = + handle_toplevel_handle_request_close; + wl_signal_add(&view->toplevel_handle->events.request_close, + &view->toplevel_handle_request_close); +} + static bool view_at(struct roots_view *view, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { if (view->type == ROOTS_WL_SHELL_VIEW && @@ -995,6 +1079,8 @@ struct roots_desktop *desktop_create(struct roots_server *server, desktop->presentation = wlr_presentation_create(server->wl_display, server->backend); + desktop->foreign_toplevel_manager_v1 = + wlr_foreign_toplevel_manager_v1_create(server->wl_display); return desktop; } diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 0f7228bb..2bf4f4c2 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -87,6 +87,8 @@ static void destroy(struct roots_view *view) { wl_list_remove(&roots_surface->request_maximize.link); wl_list_remove(&roots_surface->request_fullscreen.link); wl_list_remove(&roots_surface->set_state.link); + wl_list_remove(&roots_surface->set_title.link); + wl_list_remove(&roots_surface->set_class.link); wl_list_remove(&roots_surface->surface_commit.link); free(roots_surface); } @@ -150,6 +152,20 @@ static void handle_set_state(struct wl_listener *listener, void *data) { } } +static void handle_set_title(struct wl_listener *listener, void *data) { + struct roots_wl_shell_surface *roots_surface = + wl_container_of(listener, roots_surface, set_state); + view_set_title(roots_surface->view, + roots_surface->view->wl_shell_surface->title); +} + +static void handle_set_class(struct wl_listener *listener, void *data) { + struct roots_wl_shell_surface *roots_surface = + wl_container_of(listener, roots_surface, set_state); + view_set_app_id(roots_surface->view, + roots_surface->view->wl_shell_surface->class); +} + static void handle_surface_commit(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = wl_container_of(listener, roots_surface, surface_commit); @@ -225,8 +241,13 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { handle_request_fullscreen; wl_signal_add(&surface->events.request_fullscreen, &roots_surface->request_fullscreen); + roots_surface->set_state.notify = handle_set_state; wl_signal_add(&surface->events.set_state, &roots_surface->set_state); + roots_surface->set_title.notify = handle_set_title; + wl_signal_add(&surface->events.set_title, &roots_surface->set_title); + roots_surface->set_class.notify = handle_set_class; + wl_signal_add(&surface->events.set_class, &roots_surface->set_class); roots_surface->surface_commit.notify = handle_surface_commit; wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit); @@ -249,6 +270,11 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { view_map(view, surface->surface); view_setup(view); + wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle, + view->wl_shell_surface->title ?: "none"); + wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle, + view->wl_shell_surface->class ?: "none"); + if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) { // We need to map it relative to the parent bool found = false; diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c index 8d8a1479..da8909ba 100644 --- a/rootston/xdg_shell.c +++ b/rootston/xdg_shell.c @@ -331,13 +331,17 @@ static void handle_request_fullscreen(struct wl_listener *listener, static void handle_set_title(struct wl_listener *listener, void *data) { struct roots_xdg_surface *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, set_title); + + view_set_title(roots_xdg_surface->view, + roots_xdg_surface->view->xdg_surface->toplevel->title); } static void handle_set_app_id(struct wl_listener *listener, void *data) { struct roots_xdg_surface *roots_xdg_surface = - wl_container_of(listener, roots_xdg_surface, set_title); - wlr_log(WLR_INFO, "surface title %s", - roots_xdg_surface->view->xdg_surface->toplevel->title); + wl_container_of(listener, roots_xdg_surface, set_app_id); + + view_set_app_id(roots_xdg_surface->view, + roots_xdg_surface->view->xdg_surface->toplevel->app_id); } static void handle_surface_commit(struct wl_listener *listener, void *data) { @@ -396,6 +400,11 @@ static void handle_map(struct wl_listener *listener, void *data) { view_map(view, view->xdg_surface->surface); view_setup(view); + + wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle, + view->xdg_surface->toplevel->title ?: "none"); + wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle, + view->xdg_surface->toplevel->app_id ?: "none"); } static void handle_unmap(struct wl_listener *listener, void *data) { diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index e7b55039..8d989aef 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -330,11 +330,17 @@ static void handle_request_fullscreen(struct wl_listener *listener, static void handle_set_title(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, set_title); + + view_set_title(roots_xdg_surface->view, + roots_xdg_surface->view->xdg_surface_v6->toplevel->title); } static void handle_set_app_id(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_xdg_surface = - wl_container_of(listener, roots_xdg_surface, set_title); + wl_container_of(listener, roots_xdg_surface, set_app_id); + + view_set_app_id(roots_xdg_surface->view, + roots_xdg_surface->view->xdg_surface_v6->toplevel->app_id); } static void handle_surface_commit(struct wl_listener *listener, void *data) { @@ -393,6 +399,11 @@ static void handle_map(struct wl_listener *listener, void *data) { view_map(view, view->xdg_surface_v6->surface); view_setup(view); + + wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle, + view->xdg_surface_v6->toplevel->title ?: "none"); + wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle, + view->xdg_surface_v6->toplevel->app_id ?: "none"); } static void handle_unmap(struct wl_listener *listener, void *data) { diff --git a/rootston/xwayland.c b/rootston/xwayland.c index f887ed40..f3f962e8 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -203,11 +203,17 @@ static void handle_request_fullscreen(struct wl_listener *listener, static void handle_set_title(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, set_title); + + view_set_title(roots_surface->view, + roots_surface->view->xwayland_surface->title); } static void handle_set_class(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = - wl_container_of(listener, roots_surface, set_title); + wl_container_of(listener, roots_surface, set_class); + + view_set_app_id(roots_surface->view, + roots_surface->view->xwayland_surface->class); } static void handle_surface_commit(struct wl_listener *listener, void *data) { @@ -262,6 +268,11 @@ static void handle_map(struct wl_listener *listener, void *data) { } view_setup(view); + + wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle, + view->xwayland_surface->title ?: "none"); + wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle, + view->xwayland_surface->class ?: "none"); } else { view_initial_focus(view); } @@ -273,7 +284,6 @@ static void handle_unmap(struct wl_listener *listener, void *data) { struct roots_view *view = roots_surface->view; wl_list_remove(&roots_surface->surface_commit.link); - view_unmap(view); } -- cgit v1.2.3