From 4af44df30c1784a69b96d310f152133a507bc2e1 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Fri, 20 Jan 2023 16:32:35 +0200 Subject: protocol, grpc-proxy: Add support for set_app_float Add support for setting a window as float/popup. This allows either the application itself be set-up as float, or from other gRPC clients. Bug-AGL: SPEC-4673 Signed-off-by: Marius Vlad Change-Id: Ic7ee8203cd9c4dfcc51b7fc9709f35be504ae9d0 --- grpc-proxy/agl_shell.proto | 2 ++ grpc-proxy/grpc-async-cb.cpp | 3 ++- grpc-proxy/main-grpc.cpp | 4 +-- grpc-proxy/shell.cpp | 7 ++++-- grpc-proxy/shell.h | 3 ++- protocol/agl-shell.xml | 28 ++++++++++++++++++++- src/ivi-compositor.h | 6 +++++ src/layout.c | 17 +++++++++++++ src/shell.c | 60 +++++++++++++++++++++++++++++++++++++++++++- 9 files changed, 122 insertions(+), 8 deletions(-) diff --git a/grpc-proxy/agl_shell.proto b/grpc-proxy/agl_shell.proto index 22fad1c..8e81750 100644 --- a/grpc-proxy/agl_shell.proto +++ b/grpc-proxy/agl_shell.proto @@ -37,6 +37,8 @@ message SplitResponse { message FloatRequest { string app_id = 1; + int32 x_pos = 2; + int32 y_pos = 3; } message FloatResponse { diff --git a/grpc-proxy/grpc-async-cb.cpp b/grpc-proxy/grpc-async-cb.cpp index d0fd88d..3754b3c 100644 --- a/grpc-proxy/grpc-async-cb.cpp +++ b/grpc-proxy/grpc-async-cb.cpp @@ -114,7 +114,8 @@ GrpcServiceImpl::SetAppFloat(grpc::CallbackServerContext *context, const ::agl_shell_ipc::FloatRequest* request, ::agl_shell_ipc::FloatResponse* /* response */) { - m_aglShell->SetAppFloat(request->app_id()); + m_aglShell->SetAppFloat(request->app_id(), + request->x_pos(), request->y_pos()); grpc::ServerUnaryReactor* reactor = context->DefaultReactor(); reactor->Finish(grpc::Status::OK); diff --git a/grpc-proxy/main-grpc.cpp b/grpc-proxy/main-grpc.cpp index d094be5..ea609f0 100644 --- a/grpc-proxy/main-grpc.cpp +++ b/grpc-proxy/main-grpc.cpp @@ -260,7 +260,7 @@ global_add(void *data, struct wl_registry *reg, uint32_t id, sh->shell = static_cast(wl_registry_bind(reg, id, &agl_shell_interface, - std::min(static_cast(5), version))); + std::min(static_cast(6), 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(wl_registry_bind(reg, id, &agl_shell_interface, - std::min(static_cast(5), version))); + std::min(static_cast(6), version))); agl_shell_add_listener(sh->shell, &shell_listener_init, data); sh->version = version; } diff --git a/grpc-proxy/shell.cpp b/grpc-proxy/shell.cpp index b96ac39..83032b1 100644 --- a/grpc-proxy/shell.cpp +++ b/grpc-proxy/shell.cpp @@ -68,9 +68,12 @@ Shell::DeactivateApp(const std::string &app_id) } void -Shell::SetAppFloat(const std::string &app_id) +Shell::SetAppFloat(const std::string &app_id, int32_t x_pos, int32_t y_pos) { - (void) app_id; + struct agl_shell *shell = this->m_shell.get(); + + agl_shell_set_app_float(shell, app_id.c_str(), x_pos, y_pos); + wl_display_flush(m_shell_data->wl_display); } void diff --git a/grpc-proxy/shell.h b/grpc-proxy/shell.h index 03a4a87..4059e0b 100644 --- a/grpc-proxy/shell.h +++ b/grpc-proxy/shell.h @@ -41,5 +41,6 @@ public: void ActivateApp(const std::string &app_id, const std::string &output_name); void DeactivateApp(const std::string &app_id); void SetAppSplit(const std::string &app_id, uint32_t orientation); - void SetAppFloat(const std::string &app_id); + void SetAppFloat(const std::string &app_id, + int32_t x_pos, int32_t y_pos); }; diff --git a/protocol/agl-shell.xml b/protocol/agl-shell.xml index d3640f6..140910c 100644 --- a/protocol/agl-shell.xml +++ b/protocol/agl-shell.xml @@ -22,7 +22,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + 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. @@ -217,6 +217,32 @@ + + + + Makes the application identified by app_id as floating. If the + application's window is already mapped, in a maximized, normal state, + it would transition to the float state. + + For applications that want to modify their own state, this request + must be done before the initial surface commit in order to take effect. + + If the application is already in floating state, this request wouldn't + do anything. + + There's no persistence of this request, once the application terminated + you'll to issue this request again for that particular app_id. + + The x, and y values would be initial position of the window where the + window surface will be placed. + + See xdg_toplevel.set_app_id from the xdg-shell protocol for a + description of app_id. + + + + + diff --git a/src/ivi-compositor.h b/src/ivi-compositor.h index ed56c7f..f755e67 100644 --- a/src/ivi-compositor.h +++ b/src/ivi-compositor.h @@ -507,4 +507,10 @@ shell_send_app_state(struct ivi_compositor *ivi, const char *app_id, void ivi_layout_destroy_saved_outputs(struct ivi_compositor *ivi); +struct weston_output * +get_default_output(struct weston_compositor *compositor); + +struct weston_output * +get_focused_output(struct weston_compositor *compositor); + #endif diff --git a/src/layout.c b/src/layout.c index 028ff4a..bc489b2 100644 --- a/src/layout.c +++ b/src/layout.c @@ -788,6 +788,19 @@ ivi_compute_popup_position(const struct weston_output *output, struct weston_vie } +static bool +ivi_surf_in_hidden_layer(struct ivi_compositor *ivi, struct ivi_surface *surface) +{ + struct weston_view *ev; + + wl_list_for_each(ev, &ivi->hidden.view_list.link, layer_link.link) { + if (ev == surface->view) + return true; + } + + return false; +} + void ivi_layout_popup_committed(struct ivi_surface *surface) { @@ -819,6 +832,10 @@ ivi_layout_popup_committed(struct ivi_surface *surface) assert(surface->role == IVI_SURFACE_ROLE_POPUP); + /* remove it from hidden layer if present */ + if (ivi_surf_in_hidden_layer(ivi, surface)) + weston_layer_entry_remove(&view->layer_link); + weston_view_set_output(view, woutput); ivi_compute_popup_position(woutput, view, diff --git a/src/shell.c b/src/shell.c index b1ef59b..4a1a954 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1447,6 +1447,63 @@ shell_new_deactivate_app(struct wl_client *client, struct wl_resource *shell_res ivi_layout_deactivate(ivi, app_id); } +static void +shell_set_app_float(struct wl_client *client, struct wl_resource *shell_res, + const char *app_id, int32_t x_pos, int32_t y_pos) +{ + struct ivi_compositor *ivi = wl_resource_get_user_data(shell_res); + struct weston_output *output = get_focused_output(ivi->compositor); + struct ivi_output *ivi_output; + struct ivi_surface *surf = ivi_find_app(ivi, app_id); + + if (!output) + output = get_default_output(ivi->compositor); + + ivi_output = to_ivi_output(output); + + /* verify if already mapped as desktop role, regular, unmap it, so we + * can make it float */ + if (surf && surf->role == IVI_SURFACE_ROLE_DESKTOP) { + struct weston_view *ev = surf->view; + struct weston_desktop_surface *dsurf = surf->dsurface; + struct ivi_bounding_box bb = {}; + + /* XXX: if this is useful we could bring it as active then make + * it float, but avoid doing it for the moment */ + if (surf != ivi_output->active) + return; + + ivi_layout_deactivate(ivi, app_id); + surf->hidden_layer_output = ivi_output; + + /* set attributes */ + surf->popup.output = ivi_output; + + surf->popup.x = x_pos; + surf->popup.y = y_pos; + surf->popup.bb = bb; + + /* change the role */ + surf->role = IVI_SURFACE_ROLE_NONE; + + wl_list_remove(&surf->link); + wl_list_init(&surf->link); + + ivi_set_desktop_surface_popup(surf); + + weston_desktop_surface_set_maximized(dsurf, false); + weston_desktop_surface_set_size(dsurf, 0, 0); + + /* add to hidden layer */ + weston_layer_entry_insert(&ivi->hidden.view_list, &ev->layer_link); + weston_compositor_schedule_repaint(ivi->compositor); + + } else if (!surf || (surf && surf->role != IVI_SURFACE_ROLE_POPUP)) { + ivi_set_pending_desktop_surface_popup(ivi_output, x_pos, y_pos, + 0, 0, 0, 0, app_id); + } +} + static void shell_desktop_activate_app(struct wl_client *client, struct wl_resource *shell_res, @@ -1529,6 +1586,7 @@ static const struct agl_shell_interface agl_shell_implementation = { .destroy = shell_destroy, .set_activate_region = shell_set_activate_region, .deactivate_app = shell_new_deactivate_app, + .set_app_float = shell_set_app_float, }; static const struct agl_shell_ext_interface agl_shell_ext_implementation = { @@ -1828,7 +1886,7 @@ int ivi_shell_create_global(struct ivi_compositor *ivi) { ivi->agl_shell = wl_global_create(ivi->compositor->wl_display, - &agl_shell_interface, 5, + &agl_shell_interface, 6, ivi, bind_agl_shell); if (!ivi->agl_shell) { weston_log("Failed to create wayland global.\n"); -- cgit 1.2.3-korg