diff --git a/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c b/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c index 19c192e4a7b46077539f5edad704dbf77980df17..6e608b80e700000b792c158c9845d5944d60884c 100644 --- a/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c +++ b/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c @@ -35,6 +35,7 @@ #include "ivi-input-server-protocol.h" #include "ivi-controller.h" #include "libweston-internal.h" +#include "ivi-input-export.h" struct seat_ctx { struct input_context *input_ctx; @@ -93,6 +94,13 @@ struct wl_keyboard_data { uint32_t serial; }; +static struct input_context *g_ctx = {0}; +struct input_context * +get_instance(void) +{ + return &g_ctx; +} + static struct seat_focus * get_accepted_seat(struct ivisurface *surface, struct seat_ctx *seat_ctx) { @@ -1086,6 +1094,15 @@ setup_input_focus(struct input_context *ctx, uint32_t surface, } } +static void +set_focus(uint32_t surface, uint32_t device, int32_t enabled) +{ + weston_log("%{public}s surface: %{public}d device: %{public}d enabled: %{public}d", + __FUNCTION__, surface, device, enabled); + setup_input_focus(get_instance(), surface, device, enabled); + weston_log("%{public}s end.", __FUNCTION__); +} + static void input_set_input_focus(struct wl_client *client, struct wl_resource *resource, @@ -1300,14 +1317,8 @@ input_controller_destroy(struct wl_listener *listener, void *data) static struct input_context * create_input_context(struct ivishell *shell) { - struct input_context *ctx = NULL; + struct input_context *ctx = get_instance(); struct weston_seat *seat; - ctx = calloc(1, sizeof *ctx); - if (ctx == NULL) { - weston_log("%s: Failed to allocate memory for input context\n", - __FUNCTION__); - return NULL; - } ctx->ivishell = shell; wl_list_init(&ctx->resource_list); @@ -1333,7 +1344,6 @@ create_input_context(struct ivishell *shell) return ctx; } - static int input_controller_init(struct ivishell *shell) { @@ -1377,6 +1387,10 @@ input_controller_init(struct ivishell *shell) return ret; } +static struct ivi_input_interface_for_wms ivi_input_interface_for_wms = { + .set_focus = set_focus, +}; + WL_EXPORT int input_controller_module_init(struct ivishell *shell) { @@ -1388,6 +1402,11 @@ input_controller_module_init(struct ivishell *shell) if (ret >= 0) weston_log("ivi-input-controller module loaded successfully!\n"); } + + weston_plugin_api_register(shell->compositor, + IVI_INPUT_API_NAME_FOR_WMS, + &ivi_input_interface_for_wms, + sizeof(struct ivi_input_interface_for_wms)); return ret; } diff --git a/ivi-input-modules/ivi-input-controller/src/ivi-input-export.h b/ivi-input-modules/ivi-input-controller/src/ivi-input-export.h new file mode 100644 index 0000000000000000000000000000000000000000..cb0a9faa014d62108a0876035277178e2d831547 --- /dev/null +++ b/ivi-input-modules/ivi-input-controller/src/ivi-input-export.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _IVI_INPUT_EXPORT_H_ +#define _IVI_INPUT_EXPORT_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include + +#include "stdbool.h" +#include +#include + +#define IVI_INPUT_API_NAME_FOR_WMS "ivi_input_api_for_wms" + +#define INPUT_DEVICE_KEYBOARD ((unsigned int) 1 << 0) +#define INPUT_DEVICE_POINTER ((unsigned int) 1 << 1) +#define INPUT_DEVICE_TOUCH ((unsigned int) 1 << 2) +#define INPUT_DEVICE_ALL ((unsigned int) ~0) + +struct ivi_input_interface_for_wms { + void (*set_focus)(uint32_t surface, uint32_t device, int32_t enabled); +}; + +static inline const struct ivi_input_interface_for_wms * +ivi_input_get_api_for_wms(struct weston_compositor *compositor) +{ + const void *api; + api = weston_plugin_api_get(compositor, IVI_INPUT_API_NAME_FOR_WMS, + sizeof(struct ivi_input_interface_for_wms)); + + return (const struct ivi_input_interface_for_wms *)api; +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _IVI_INPUT_EXPORT_H_ */ diff --git a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c index cce5dde8fd176f937708eb9a40343dd1852787a6..146f6e92c79f1e805e9002dd4b056b183eeaf5a9 100644 --- a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c +++ b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c @@ -38,6 +38,8 @@ #include "ivi-wm-client-protocol.h" #include "ivi-input-client-protocol.h" +// #define USE_DUMMY_SCREEN + struct layer_context { struct wl_list link; @@ -1337,13 +1339,50 @@ init_control(void) return -1; } +#ifdef USE_DUMMY_SCREEN + ctx_scrn = calloc(1, sizeof *ctx_scrn); + if (ctx_scrn == NULL) { + fprintf(stderr, "Failed to allocate memory for screen_context\n"); + return -1; + } + ctx_scrn->ctx = wl; + wl_list_insert(&wl->list_screen, &ctx_scrn->link); + wl_list_for_each(ctx_scrn, &ctx->wl.list_screen, link) { if (!ctx_scrn->controller) { - ctx_scrn->controller = ivi_wm_create_screen(wl->controller, ctx_scrn->output); - ivi_wm_screen_add_listener(ctx_scrn->controller, &wm_screen_listener, + if (ctx_scrn->output) { + printf("for dummy output screen, output = !NULL\n"); + ctx_scrn->controller = ivi_wm_create_screen(wl->controller, ctx_scrn->output); + ivi_wm_screen_add_listener(ctx_scrn->controller, &wm_screen_listener, ctx_scrn); + } + else { + printf("for dummy output screen, output = NULL\n"); + //for dummy output screen. + ctx_scrn->controller = ivi_wm_create_screen2(wl->controller, 1); + ivi_wm_screen_add_listener(ctx_scrn->controller, &wm_screen_listener, + ctx_scrn); + ctx_scrn->prop.screenWidth = 240; + ctx_scrn->prop.screenHeight = 480; + } + } + + // get screen-ids + if (wl_display_roundtrip_queue(wl->display, wl->queue) == -1) + { + fprintf(stderr, "Failed to do roundtrip queue: %s\n", strerror(errno)); + return -1; } } +#else + wl_list_for_each(ctx_scrn, &ctx->wl.list_screen, link) { + if (!ctx_scrn->controller) { + ctx_scrn->controller = ivi_wm_create_screen(wl->controller, ctx_scrn->output); + ivi_wm_screen_add_listener(ctx_scrn->controller, &wm_screen_listener, + ctx_scrn); + } + } +#endif // get screen-ids if (wl_display_roundtrip_queue(wl->display, wl->queue) == -1) diff --git a/protocol/ivi-wm.xml b/protocol/ivi-wm.xml index da45c7ed81206fecd3abca2325a1709caf09005b..32b77cc0f5cdac29bc372b58c34bc6f83c67f858 100644 --- a/protocol/ivi-wm.xml +++ b/protocol/ivi-wm.xml @@ -175,6 +175,14 @@ + + + Ask the ivi-wm to create a ivi-screen for given wl_output. + + + + + If visibility argument is 0, the surface in the ivi compositor is set to invisible. diff --git a/weston-ivi-shell/src/ivi-controller.c b/weston-ivi-shell/src/ivi-controller.c index b16b3d22c6a2bc7bd4b87d1a6a0583de8dd6efce..98b801ddc2d379c6a9b4cacbbc36b3edfaf3a3d7 100644 --- a/weston-ivi-shell/src/ivi-controller.c +++ b/weston-ivi-shell/src/ivi-controller.c @@ -101,6 +101,11 @@ screen_listener_t screen_info_property_change_callback_listener = NULL; static int check_surface_id(struct wl_client *client, uint32_t surface_id) { + //for dummy output screen debug(USE_DUMMY_SCREEN) +#ifdef USE_DUMMY_SCREEN + return 0; +#endif + pid_t pid; const int windowIdBitNum = 5; @@ -1504,9 +1509,46 @@ controller_create_screen(struct wl_client *client, } } +//for dummy output screen(USE_DUMMY_SCREEN) +static void +controller_create_screen2(struct wl_client *client, + struct wl_resource *resource, + uint32_t screen_id, + uint32_t id) +{ + struct wl_resource *screen_resource; + struct ivicontroller *ctrl = wl_resource_get_user_data(resource); + struct iviscreen* iviscrn = NULL; + weston_log("######controller_create_screen2: screen_id = %d\n", screen_id); + + wl_list_for_each(iviscrn, &ctrl->shell->list_screen, link) { + weston_log("######controller_create_screen2: iviscrn->id_screen = %d\n", iviscrn->id_screen); + if (screen_id != iviscrn->id_screen) { + continue; + } + + screen_resource = wl_resource_create(client, &ivi_wm_screen_interface, 1, id); + if (screen_resource == NULL) { + wl_resource_post_no_memory(resource); + return; + } + + wl_resource_set_implementation(screen_resource, + &controller_screen_implementation, + iviscrn, destroy_ivicontroller_screen); + + wl_list_insert(&iviscrn->resource_list, wl_resource_get_link(screen_resource)); + + ivi_wm_screen_send_screen_id(screen_resource, iviscrn->id_screen); + ivi_wm_screen_send_connector_name(screen_resource, iviscrn->output->name); + } +} + static const struct ivi_wm_interface controller_implementation = { controller_commit_changes, controller_create_screen, + //for dummy output screen(USE_DUMMY_SCREEN) + controller_create_screen2, controller_set_surface_visibility, controller_set_layer_visibility, controller_set_surface_opacity, @@ -2159,6 +2201,10 @@ init_ivi_shell(struct weston_compositor *ec, struct ivishell *shell) wl_list_for_each(output, &ec->output_list, link) create_screen(shell, output); +#ifdef USE_DUMMY_SCREEN + output = lyt->get_dummy_output(); + create_screen(shell, output); +#endif /* USE_DUMMY_SCREEN */ ret = check_layout_layers(shell); if (ret != 0) {