protocol/grpc-proxy: Add deactivate_app request 63/28463/2
authorMarius Vlad <marius.vlad@collabora.com>
Fri, 20 Jan 2023 11:34:00 +0000 (13:34 +0200)
committerMarius Vlad <marius.vlad@collabora.com>
Wed, 1 Mar 2023 10:38:14 +0000 (12:38 +0200)
This request will hide the currently active window, and activate
either the background or the previously active window.

This request mimics the agl-shell-desktop request, actually using the
same code path. It only handles regular windows and float/pop-up. Once
we add other roles like fullscreen/split we can improve on this.

Bug-AGL: SPEC-4673
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I593cda5d008dfc32fe5e3b079fad9450dc1a490d

grpc-proxy/main-grpc.cpp
grpc-proxy/shell.cpp
protocol/agl-shell.xml
src/shell.c

index a59c282..d094be5 100644 (file)
@@ -260,7 +260,7 @@ global_add(void *data, struct wl_registry *reg, uint32_t id,
                sh->shell =
                        static_cast<struct agl_shell *>(wl_registry_bind(reg, id,
                                &agl_shell_interface,
-                               std::min(static_cast<uint32_t>(3), version)));
+                               std::min(static_cast<uint32_t>(5), version)));
                agl_shell_add_listener(sh->shell, &shell_listener, data);
                sh->version = version;
        } else if (strcmp(interface, "wl_output") == 0) {
@@ -284,7 +284,7 @@ global_add_init(void *data, struct wl_registry *reg, uint32_t id,
                sh->shell =
                        static_cast<struct agl_shell *>(wl_registry_bind(reg, id,
                                &agl_shell_interface,
-                               std::min(static_cast<uint32_t>(3), version)));
+                               std::min(static_cast<uint32_t>(5), version)));
                agl_shell_add_listener(sh->shell, &shell_listener_init, data);
                sh->version = version;
        }
index cc6ead6..b96ac39 100644 (file)
@@ -61,7 +61,10 @@ Shell::ActivateApp(const std::string &app_id, const std::string &output_name)
 void
 Shell::DeactivateApp(const std::string &app_id)
 {
-       (void) app_id;
+       struct agl_shell *shell = this->m_shell.get();
+
+       agl_shell_deactivate_app(shell, app_id.c_str());
+       wl_display_flush(m_shell_data->wl_display);
 }
 
 void
index b8f219e..d3640f6 100644 (file)
@@ -22,7 +22,7 @@
     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     DEALINGS IN THE SOFTWARE.
   </copyright>
-  <interface name="agl_shell" version="4">
+  <interface name="agl_shell" version="5">
     <description summary="user interface for Automotive Grade Linux platform">
       Starting with version 2 of the protocol, the client is required to wait
       for the 'bound_ok' or 'bound_fail' events in order to proceed further.
       <arg name="width" type="int" summary="width of rectangle"/>
       <arg name="height" type="int" summary="height of rectangle"/>
     </request>
+
+    <request name="deactivate_app" since="5">
+      <description summary="de-activate/hide window identified by app_id">
+        Ask the compositor to hide the toplevel window for window
+        management purposes. Depending on the window role, this request
+        will either display the previously active window (or the background
+        in case there's no previously active surface) or temporarily (or
+        until a 'activate_app' is called upon) hide the surface.
+
+        All the surfaces are identifiable by using the app_id, and no actions
+        are taken in case the app_id is not/was not present.
+
+        See xdg_toplevel.set_app_id from the xdg-shell protocol for a
+        description of app_id.
+      </description>
+      <arg name="app_id" type="string"/>
+    </request>
   </interface>
 
   <interface name="agl_shell_ext" version="1">
index bcfb673..b1ef59b 100644 (file)
@@ -1438,6 +1438,15 @@ shell_activate_app(struct wl_client *client,
        ivi_layout_activate(output, app_id);
 }
 
+static void
+shell_new_deactivate_app(struct wl_client *client, struct wl_resource *shell_res,
+                        const char *app_id)
+{
+       struct ivi_compositor *ivi = wl_resource_get_user_data(shell_res);
+
+       ivi_layout_deactivate(ivi, app_id);
+}
+
 static void
 shell_desktop_activate_app(struct wl_client *client,
                           struct wl_resource *shell_res,
@@ -1518,7 +1527,8 @@ static const struct agl_shell_interface agl_shell_implementation = {
        .set_panel = shell_set_panel,
        .activate_app = shell_activate_app,
        .destroy = shell_destroy,
-       .set_activate_region = shell_set_activate_region
+       .set_activate_region = shell_set_activate_region,
+       .deactivate_app = shell_new_deactivate_app,
 };
 
 static const struct agl_shell_ext_interface agl_shell_ext_implementation = {
@@ -1818,7 +1828,7 @@ int
 ivi_shell_create_global(struct ivi_compositor *ivi)
 {
        ivi->agl_shell = wl_global_create(ivi->compositor->wl_display,
-                                         &agl_shell_interface, 4,
+                                         &agl_shell_interface, 5,
                                          ivi, bind_agl_shell);
        if (!ivi->agl_shell) {
                weston_log("Failed to create wayland global.\n");