diff --git a/include/labwc.h b/include/labwc.h index 80d5e73d..5dfebafb 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -338,6 +338,8 @@ void view_for_each_popup_surface(struct view *view, void view_move_to_edge(struct view *view, const char *direction); void view_update_title(struct view *view); +void view_impl_map(struct view *view); + void foreign_toplevel_handle_create(struct view *view); /* diff --git a/src/meson.build b/src/meson.build index 6d014505..dc183ef1 100644 --- a/src/meson.build +++ b/src/meson.build @@ -17,6 +17,7 @@ labwc_sources = files( 'theme.c', 'view.c', 'view-child.c', + 'view-impl.c', 'xdg.c', 'xdg-deco.c', 'xdg-popup.c', diff --git a/src/view-impl.c b/src/view-impl.c new file mode 100644 index 00000000..f92d5d40 --- /dev/null +++ b/src/view-impl.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* view-impl.c: common code for shell view->impl functions */ +#include +#include +#include "labwc.h" + +void +view_impl_map(struct view *view) +{ + desktop_focus_and_activate_view(&view->server->seat, view); + desktop_raise_view(view); + + const char *app_id = view->impl->get_string_prop(view, "app_id"); + if (app_id) { + wlr_foreign_toplevel_handle_v1_set_app_id( + view->toplevel_handle, app_id); + } + + view_update_title(view); + + damage_all_outputs(view->server); +} diff --git a/src/xdg.c b/src/xdg.c index e8f9400c..18a0e843 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -343,9 +343,7 @@ xdg_toplevel_view_map(struct view *view) wl_signal_add(&view->surface->events.new_subsurface, &view->new_subsurface); - desktop_focus_and_activate_view(&view->server->seat, view); - desktop_raise_view(view); - damage_all_outputs(view->server); + view_impl_map(view); } static void diff --git a/src/xwayland.c b/src/xwayland.c index 22d54859..bd17c55d 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -146,6 +146,10 @@ get_string_prop(struct view *view, const char *prop) if (!strcmp(prop, "class")) { return view->xwayland_surface->class; } + /* We give 'class' for wlr_foreign_toplevel_handle_v1_set_app_id() */ + if (!strcmp(prop, "app_id")) { + return view->xwayland_surface->class; + } return ""; } @@ -208,9 +212,7 @@ map(struct view *view) &view->commit); view->commit.notify = handle_commit; - desktop_focus_and_activate_view(&view->server->seat, view); - desktop_raise_view(view); - damage_all_outputs(view->server); + view_impl_map(view); } static void