]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: call wlr_foreign_toplevel_handle_v1_set_app_id() on map
authorJohan Malm <jgm323@gmail.com>
Sat, 16 Oct 2021 20:26:57 +0000 (21:26 +0100)
committerJohan Malm <jgm323@gmail.com>
Sat, 16 Oct 2021 20:26:57 +0000 (21:26 +0100)
Fix issue #74

Add view-impl.c with view_impl_map() containing common code for xdg-shell
and xwayland-shell.

include/labwc.h
src/meson.build
src/view-impl.c [new file with mode: 0644]
src/xdg.c
src/xwayland.c

index 80d5e73d25ee0c0a439428a796b45a6c03bdd1fd..5dfebafba9b4b92bcd34e940dcd7b2b98f77b11c 100644 (file)
@@ -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);
 
 /*
index 6d014505855c259f763b9599ce09d20c4d7dc87a..dc183ef10c48b3131b3c66e908e3e3cec87910a7 100644 (file)
@@ -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 (file)
index 0000000..f92d5d4
--- /dev/null
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* view-impl.c: common code for shell view->impl functions */
+#include <stdio.h>
+#include <strings.h>
+#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);
+}
index e8f9400c481ce51f4ca0ee7edae2d1b05953009b..18a0e843cb9ce72a87e73a8957328e1e3eb321bc 100644 (file)
--- 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
index 22d548597993cd16487d07d69d29e160bd9feba1..bd17c55d02c368e1f6e30c5111e5e3e4784b7e78 100644 (file)
@@ -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