grpc-proxy: Add dynamic scale of floating windows 69/29069/2
authorMarius Vlad <marius.vlad@collabora.com>
Mon, 31 Jul 2023 11:41:48 +0000 (14:41 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Tue, 29 Aug 2023 13:31:20 +0000 (13:31 +0000)
This adds basic scaling for floating windows, sending new dimensions to
the clients to resize itself.

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

grpc-proxy/agl_shell.proto
grpc-proxy/grpc-async-cb.cpp
grpc-proxy/grpc-async-cb.h
grpc-proxy/main-grpc.cpp
grpc-proxy/shell.cpp
grpc-proxy/shell.h
protocol/agl-shell.xml
src/shell.c

index 74ea958..c4f3dfe 100644 (file)
@@ -4,16 +4,17 @@ syntax = "proto3";
 package agl_shell_ipc;
 
 service AglShellManagerService {
-       rpc ActivateApp(ActivateRequest)                                returns (ActivateResponse) {}
-       rpc DeactivateApp(DeactivateRequest)                    returns (DeactivateResponse) {}
-       rpc SetAppSplit(SplitRequest)                           returns (SplitResponse) {}
-       rpc SetAppFloat(FloatRequest)                           returns (FloatResponse) {}
-       rpc SetAppFullscreen(FullscreenRequest)                 returns (FullscreenResponse) {}
-       rpc AppStatusState(AppStateRequest)                     returns (stream AppStateResponse) {}
-       rpc GetOutputs(OutputRequest)                           returns (ListOutputResponse) {}
-       rpc SetAppNormal(NormalRequest)                         returns (NormalResponse) {}
-       rpc SetAppOnOutput(AppOnOutputRequest)                  returns (AppOnOutputResponse) {}
-       rpc SetAppPosition(AppPositionRequest)                  returns (AppPositionResponse) {}
+       rpc ActivateApp(ActivateRequest)                        returns (ActivateResponse) {}
+       rpc DeactivateApp(DeactivateRequest)            returns (DeactivateResponse) {}
+       rpc SetAppSplit(SplitRequest)                   returns (SplitResponse) {}
+       rpc SetAppFloat(FloatRequest)                   returns (FloatResponse) {}
+       rpc SetAppFullscreen(FullscreenRequest)         returns (FullscreenResponse) {}
+       rpc AppStatusState(AppStateRequest)             returns (stream AppStateResponse) {}
+       rpc GetOutputs(OutputRequest)                   returns (ListOutputResponse) {}
+       rpc SetAppNormal(NormalRequest)                 returns (NormalResponse) {}
+       rpc SetAppOnOutput(AppOnOutputRequest)          returns (AppOnOutputResponse) {}
+       rpc SetAppPosition(AppPositionRequest)          returns (AppPositionResponse) {}
+       rpc SetAppScale(AppScaleRequest)                        returns (AppScaleResponse) {}
 }
 
 message ActivateRequest {
@@ -98,3 +99,12 @@ message AppPositionRequest {
 
 message AppPositionResponse {
 };
+
+message AppScaleRequest {
+       string app_id = 1;
+       int32 width = 2;
+       int32 height = 3;
+};
+
+message AppScaleResponse {
+};
index 92aaa3c..9cbbb4d 100644 (file)
@@ -170,6 +170,19 @@ GrpcServiceImpl::SetAppPosition(grpc::CallbackServerContext *context,
        return reactor;
 }
 
+grpc::ServerUnaryReactor *
+GrpcServiceImpl::SetAppScale(grpc::CallbackServerContext *context,
+                            const ::agl_shell_ipc::AppScaleRequest* request,
+                            ::agl_shell_ipc::AppScaleResponse* /* response */)
+{
+       m_aglShell->SetAppScale(request->app_id(),
+                               request->width(), request->height());
+
+       grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
+       reactor->Finish(grpc::Status::OK);
+       return reactor;
+}
+
 grpc::ServerUnaryReactor *
 GrpcServiceImpl::SetAppSplit(grpc::CallbackServerContext *context,
            const ::agl_shell_ipc::SplitRequest* request,
index 21a4e4d..cb8adcb 100644 (file)
@@ -100,6 +100,10 @@ public:
                        const ::agl_shell_ipc::AppPositionRequest* request,
                        ::agl_shell_ipc::AppPositionResponse* /*response*/) override;
 
+       grpc::ServerUnaryReactor *SetAppScale(grpc::CallbackServerContext *context,
+                       const ::agl_shell_ipc::AppScaleRequest* request,
+                       ::agl_shell_ipc::AppScaleResponse* /*response*/) override;
+
        grpc::ServerWriteReactor< ::agl_shell_ipc::AppStateResponse>* AppStatusState(
              ::grpc::CallbackServerContext* /*context*/,
              const ::agl_shell_ipc::AppStateRequest* /*request*/)  override;
index 740594f..b2eca84 100644 (file)
@@ -275,7 +275,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>(9), version)));
+                               std::min(static_cast<uint32_t>(10), version)));
                agl_shell_add_listener(sh->shell, &shell_listener, data);
                sh->version = version;
        } else if (strcmp(interface, "wl_output") == 0) {
@@ -299,7 +299,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>(9), version)));
+                               std::min(static_cast<uint32_t>(10), version)));
                agl_shell_add_listener(sh->shell, &shell_listener_init, data);
                sh->version = version;
        }
index 44f2117..bc2df23 100644 (file)
@@ -129,6 +129,16 @@ Shell::SetAppPosition(const std::string &app_id, const int32_t x, const int32_t
        wl_display_flush(m_shell_data->wl_display);
 }
 
+void
+Shell::SetAppScale(const std::string &app_id,
+               const int32_t width, const int32_t height)
+{
+       struct agl_shell *shell = this->m_shell.get();
+
+       agl_shell_set_app_scale(shell, app_id.c_str(), width, height);
+       wl_display_flush(m_shell_data->wl_display);
+}
+
 void
 Shell::SetAppSplit(const std::string &app_id, uint32_t orientation)
 {
index b9a818c..95aae79 100644 (file)
@@ -47,4 +47,5 @@ public:
        void SetAppFullscreen(const std::string &app_id);
        void SetAppOnOutput(const std::string &app_id, const std::string &output);
        void SetAppPosition(const std::string &app_id, int32_t x, int32_t y);
+       void SetAppScale(const std::string &app_id, int32_t width, int32_t height);
 };
index b85cf01..b11beb6 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="9">
+  <interface name="agl_shell" version="10">
     <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="x" type="int"/>
       <arg name="y" type="int"/>
     </request>
+
+    <request name="set_app_scale" since="10">
+      <description summary="scale window to a specific rectangle">
+        Clients can inform the compositor to scale a floating type of window
+        to the values specified in width and height. If the window is
+        not a floating type, the request will be discarded. If the window
+        doesn't exist the compositor will ignore the request. For this request
+        to function properly the window would first to be set as floating
+        and then it can be moved using this request.
+
+
+        see xdg_toplevel.set_app_id from the xdg-shell protocol for a
+        description of app_id.
+      </description>
+      <arg name="app_id" type="string"/>
+      <arg name="width" type="int"/>
+      <arg name="height" type="int"/>
+    </request>
   </interface>
 
   <interface name="agl_shell_ext" version="1">
index 2ce6ac4..f5dc3e3 100644 (file)
@@ -1678,6 +1678,21 @@ shell_set_app_position(struct wl_client *client, struct wl_resource *res,
        weston_compositor_schedule_repaint(ivi->compositor);
 }
 
+static void
+shell_set_app_scale(struct wl_client *client, struct wl_resource *res,
+                   const char *app_id, int32_t width, int32_t height)
+{
+
+       struct ivi_compositor *ivi = wl_resource_get_user_data(res);
+       struct ivi_surface *surf = ivi_find_app(ivi, app_id);
+
+       if (!surf || !app_id || surf->role != IVI_SURFACE_ROLE_POPUP)
+               return;
+
+       weston_desktop_surface_set_size(surf->dsurface, width, height);
+       weston_compositor_schedule_repaint(ivi->compositor);
+}
+
 static void
 shell_ext_destroy(struct wl_client *client, struct wl_resource *res)
 {
@@ -1707,6 +1722,7 @@ static const struct agl_shell_interface agl_shell_implementation = {
        .set_app_fullscreen = shell_set_app_fullscreen,
        .set_app_output = shell_set_app_output,
        .set_app_position = shell_set_app_position,
+       .set_app_scale = shell_set_app_scale,
 };
 
 static const struct agl_shell_ext_interface agl_shell_ext_implementation = {
@@ -2008,7 +2024,7 @@ int
 ivi_shell_create_global(struct ivi_compositor *ivi)
 {
        ivi->agl_shell = wl_global_create(ivi->compositor->wl_display,
-                                         &agl_shell_interface, 9,
+                                         &agl_shell_interface, 10,
                                          ivi, bind_agl_shell);
        if (!ivi->agl_shell) {
                weston_log("Failed to create wayland global.\n");