sync from std to master

Change-Id: Ia07e75deafe5eef8c088889758a2ffa89089026c
Signed-off-by: lizheng <lizheng2@huawei.com>
This commit is contained in:
lizheng
2021-08-03 14:22:01 +08:00
parent 2cfca0dc8f
commit 8802b5a6f5
5 changed files with 187 additions and 10 deletions
@@ -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;
}
@@ -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 <stdint.h>
#include <limits.h>
#include "stdbool.h"
#include <libweston/libweston.h>
#include <libweston/plugin-registry.h>
#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_ */
@@ -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)
+8
View File
@@ -175,6 +175,14 @@
<arg name="id" type="new_id" interface="ivi_wm_screen" summary="the new ivi-screen"/>
</request>
<request name="create_screen2">
<description summary="create a screen in ivi-compositor">
Ask the ivi-wm to create a ivi-screen for given wl_output.
</description>
<arg name="screen_id" type="uint"/>
<arg name="id" type="new_id" interface="ivi_wm_screen" summary="the new ivi-screen"/>
</request>
<request name="set_surface_visibility">
<description summary="set the visibility of a surface in ivi compositor">
If visibility argument is 0, the surface in the ivi compositor is set to invisible.
+46
View File
@@ -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) {