summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Friedrich <efriedrich@de.adit-jv.com>2023-05-05 10:11:51 +0200
committerEugen Friedrich <efriedrich@de.adit-jv.com>2023-05-05 10:11:51 +0200
commit641a541c15785c004c61065a5044a8db3fe4255c (patch)
tree2ebbdc49ed7ed874e17331bc6dc5439c50c2326a
parent6405590f6a8786b986e1cf153e369bc3791f067a (diff)
parentb986ce06bf7552c3ee5fe8d7ec80531d3e2aa85f (diff)
downloadwayland-ivi-extension-641a541c15785c004c61065a5044a8db3fe4255c.tar.gz
Merge remote-tracking branch 'upstream/pull/148'HEADmaster
* upstream/pull/148 ilm_input_test: update tests with default seat ilmInput: support ilm_getDefaultSeat api to return default seat name ivi-input-modules: read default seat name from weston.ini file Reviewed-by: Eugen Friedrich <efriedrich@de.adit-jv.com> Reviewed-by: Harsha M M <harsha.manjulamallikarjun@in.bosch.com> Tested-by: Doan Ngoc Au <au.doanngoc@vn.bosch.com>
-rw-r--r--ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c63
-rw-r--r--ivi-layermanagement-api/ilmControl/include/ilm_control_platform.h1
-rw-r--r--ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c7
-rw-r--r--ivi-layermanagement-api/ilmInput/include/ilm_input.h12
-rw-r--r--ivi-layermanagement-api/ilmInput/src/ilm_input.c24
-rw-r--r--ivi-layermanagement-api/test/ilm_input_test.cpp26
-rw-r--r--protocol/ivi-input.xml4
7 files changed, 118 insertions, 19 deletions
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 82900dc..661215e 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
@@ -73,6 +73,8 @@ struct input_context {
struct wl_listener surface_destroyed;
struct wl_listener compositor_destroy_listener;
struct wl_listener seat_create_listener;
+
+ char *seat_default_name;
};
enum kbd_events {
@@ -969,6 +971,7 @@ handle_seat_create(struct wl_listener *listener, void *data)
struct ivisurface *surf;
const struct ivi_layout_interface *interface =
input_ctx->ivishell->interface;
+ int32_t is_default_seat = ILM_FALSE;
struct seat_ctx *ctx = calloc(1, sizeof *ctx);
if (ctx == NULL) {
weston_log("%s: Failed to allocate memory\n", __FUNCTION__);
@@ -989,20 +992,22 @@ handle_seat_create(struct wl_listener *listener, void *data)
ctx->updated_caps_listener.notify = &handle_seat_updated_caps;
wl_signal_add(&seat->updated_caps_signal, &ctx->updated_caps_listener);
+ is_default_seat = (strcmp(input_ctx->seat_default_name, seat->seat_name))
+ ? ILM_FALSE : ILM_TRUE;
wl_resource_for_each(resource, &input_ctx->resource_list) {
ivi_input_send_seat_created(resource,
seat->seat_name,
- get_seat_capabilities(seat));
+ get_seat_capabilities(seat), is_default_seat);
}
/* If default seat is created, we have to add it to the accepted_seat_list
* of all surfaces. Also we have to send an acceptance event to all clients */
- if (!strcmp(ctx->west_seat->seat_name, "default")) {
+ if (!strcmp(ctx->west_seat->seat_name, input_ctx->seat_default_name)) {
wl_list_for_each(surf, &input_ctx->ivishell->list_surface, link) {
add_accepted_seat(surf, ctx);
send_input_acceptance(input_ctx,
interface->get_id_of_surface(surf->layout_surface),
- "default", ILM_TRUE);
+ input_ctx->seat_default_name, ILM_TRUE);
}
}
}
@@ -1049,12 +1054,12 @@ handle_surface_create(struct wl_listener *listener, void *data)
wl_list_init(&ivisurface->accepted_seat_list);
- seat_ctx = input_ctrl_get_seat_ctx(input_ctx, "default");
+ seat_ctx = input_ctrl_get_seat_ctx(input_ctx, input_ctx->seat_default_name);
if (seat_ctx) {
add_accepted_seat(ivisurface, seat_ctx);
send_input_acceptance(input_ctx,
interface->get_id_of_surface(ivisurface->layout_surface),
- "default", ILM_TRUE);
+ input_ctx->seat_default_name, ILM_TRUE);
}
}
@@ -1209,6 +1214,7 @@ bind_ivi_input(struct wl_client *client, void *data,
ctx->ivishell->interface;
struct seat_focus *st_focus;
uint32_t ivi_surf_id;
+ int32_t is_default_seat = ILM_FALSE;
resource = wl_resource_create(client, &ivi_input_interface, 1, id);
wl_resource_set_implementation(resource, &input_implementation,
@@ -1218,8 +1224,10 @@ bind_ivi_input(struct wl_client *client, void *data,
/* Send seat events for all known seats to the client */
wl_list_for_each(seat, &ctx->ivishell->compositor->seat_list, link) {
+ is_default_seat = (strcmp(ctx->seat_default_name, seat->seat_name))
+ ? ILM_FALSE : ILM_TRUE;
ivi_input_send_seat_created(resource, seat->seat_name,
- get_seat_capabilities(seat));
+ get_seat_capabilities(seat), is_default_seat);
}
/* Send focus and acceptance events for all known surfaces to the client */
wl_list_for_each(ivisurface, &ctx->ivishell->list_surface, link) {
@@ -1263,6 +1271,10 @@ destroy_input_context(struct input_context *ctx)
* free up the controller structure*/
wl_resource_destroy(resource);
}
+
+ if (ctx->seat_default_name) {
+ free(ctx->seat_default_name);
+ }
free(ctx);
}
@@ -1304,6 +1316,36 @@ input_controller_destroy(struct wl_listener *listener, void *data)
}
}
+static int
+get_config( struct input_context *ctx)
+{
+ int ret = 0;
+ struct weston_config *config = NULL;
+ struct weston_config_section *section = NULL;
+ ctx->seat_default_name = NULL;
+
+ config = wet_get_config(ctx->ivishell->compositor);
+ if (!config)
+ goto exit;
+
+ section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
+ if (!section)
+ goto exit;
+
+ weston_config_section_get_string(section,
+ "default-seat",
+ &ctx->seat_default_name, "default");
+exit:
+ if (!ctx->seat_default_name) {
+ ctx->seat_default_name = strdup("default");
+ if (!ctx->seat_default_name) {
+ weston_log("%s: Failed to allocate memory for seat default name\n", __FUNCTION__);
+ ret = -1;
+ }
+ }
+
+ return ret;
+}
static struct input_context *
create_input_context(struct ivishell *shell)
@@ -1321,6 +1363,12 @@ create_input_context(struct ivishell *shell)
wl_list_init(&ctx->resource_list);
wl_list_init(&ctx->seat_list);
+ /* get the default seat*/
+ if (get_config(ctx) != 0) {
+ free(ctx);
+ return NULL;
+ }
+
/* Add signal handlers for ivi surfaces. */
ctx->surface_created.notify = handle_surface_create;
ctx->surface_destroyed.notify = handle_surface_destroy;
@@ -1341,7 +1389,6 @@ create_input_context(struct ivishell *shell)
return ctx;
}
-
static int
input_controller_init(struct ivishell *shell)
{
@@ -1361,7 +1408,7 @@ input_controller_init(struct ivishell *shell)
successful_init_stage++;
break;
case 1:
- if (wl_global_create(shell->compositor->wl_display, &ivi_input_interface, 1,
+ if (wl_global_create(shell->compositor->wl_display, &ivi_input_interface, 2,
ctx, bind_ivi_input) != NULL) {
successful_init_stage++;
}
diff --git a/ivi-layermanagement-api/ilmControl/include/ilm_control_platform.h b/ivi-layermanagement-api/ilmControl/include/ilm_control_platform.h
index db672cc..5053b19 100644
--- a/ivi-layermanagement-api/ilmControl/include/ilm_control_platform.h
+++ b/ivi-layermanagement-api/ilmControl/include/ilm_control_platform.h
@@ -66,6 +66,7 @@ struct ilm_control_context {
struct seat_context {
struct wl_list link;
char *seat_name;
+ bool is_default;
ilmInputDevice capabilities;
};
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 97e4e6d..bed3c8d 100644
--- a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c
+++ b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c
@@ -757,7 +757,8 @@ static void
input_listener_seat_created(void *data,
struct ivi_input *ivi_input,
const char *name,
- uint32_t capabilities)
+ uint32_t capabilities,
+ int32_t is_default)
{
struct wayland_context *ctx = data;
struct seat_context *seat;
@@ -774,6 +775,7 @@ input_listener_seat_created(void *data,
}
seat->seat_name = strdup(name);
seat->capabilities = capabilities;
+ seat->is_default = (is_default == ILM_TRUE) ? true : false;
wl_list_insert(&ctx->list_seat, &seat->link);
}
@@ -903,7 +905,6 @@ registry_handle_control(void *data,
{
struct wayland_context *ctx = data;
(void)version;
-
if (strcmp(interface, "ivi_wm") == 0) {
ctx->controller = wl_registry_bind(registry, name,
&ivi_wm_interface, 1);
@@ -916,7 +917,7 @@ registry_handle_control(void *data,
} else if (strcmp(interface, "ivi_input") == 0) {
ctx->input_controller =
- wl_registry_bind(registry, name, &ivi_input_interface, 1);
+ wl_registry_bind(registry, name, &ivi_input_interface, 2);
if (ctx->input_controller == NULL) {
fprintf(stderr, "Failed to registry bind input controller\n");
diff --git a/ivi-layermanagement-api/ilmInput/include/ilm_input.h b/ivi-layermanagement-api/ilmInput/include/ilm_input.h
index 7c0008e..fd1fa91 100644
--- a/ivi-layermanagement-api/ilmInput/include/ilm_input.h
+++ b/ivi-layermanagement-api/ilmInput/include/ilm_input.h
@@ -117,6 +117,18 @@ ilmErrorTypes
ilm_getInputFocus(t_ilm_surface **surfaceIDs, ilmInputDevice** bitmasks,
t_ilm_uint *num_ids);
+/**
+ * \brief get the name of default seat
+ * \ingroup ilmControl
+ * \param[out] seat_name A pointer to the memory where the seat name is
+ * stored. It is the caller's responsibility to free
+ * this memory after use.
+ * \return ILM_SUCCESS if the default seat is available
+ * \return ILM_FAILED if the default seat isn't available
+ */
+ilmErrorTypes
+ilm_getDefaultSeat(t_ilm_string *seat_name);
+
#ifdef __cplusplus
} /**/
#endif /* __cplusplus */
diff --git a/ivi-layermanagement-api/ilmInput/src/ilm_input.c b/ivi-layermanagement-api/ilmInput/src/ilm_input.c
index eae9b61..979bf56 100644
--- a/ivi-layermanagement-api/ilmInput/src/ilm_input.c
+++ b/ivi-layermanagement-api/ilmInput/src/ilm_input.c
@@ -333,3 +333,27 @@ ilm_getInputFocus(t_ilm_surface **surfaceIDs, ilmInputDevice **bitmasks,
return ILM_SUCCESS;
}
+
+ILM_EXPORT ilmErrorTypes
+ilm_getDefaultSeat(t_ilm_string *seat_name)
+{
+ struct ilm_control_context *ctx = NULL;
+ struct seat_context *seat = NULL;
+
+ if (seat_name == NULL) {
+ fprintf(stderr, "Invalid Argument\n");
+ return ILM_FAILED;
+ }
+
+ *seat_name = NULL;
+ ctx = sync_and_acquire_instance();
+ wl_list_for_each(seat, &ctx->wl.list_seat, link) {
+ if (seat->is_default) {
+ *seat_name = strdup(seat->seat_name);
+ break;
+ }
+ }
+
+ release_instance();
+ return (*seat_name) ? ILM_SUCCESS : ILM_FAILED;
+}
diff --git a/ivi-layermanagement-api/test/ilm_input_test.cpp b/ivi-layermanagement-api/test/ilm_input_test.cpp
index 032a7e3..2edb301 100644
--- a/ivi-layermanagement-api/test/ilm_input_test.cpp
+++ b/ivi-layermanagement-api/test/ilm_input_test.cpp
@@ -96,6 +96,13 @@ TEST_F(IlmInputTest, ilm_input_focus) {
ilmInputDevice *bitmasks;
t_ilm_uint num_ids;
t_ilm_uint layer = 0xbeef;
+ t_ilm_string set_seats = NULL;
+
+ /*ilm_set/get_input_focus test only work if default seat is avaiable*/
+ if (ilm_getDefaultSeat(&set_seats) == ILM_FAILED) {
+ GTEST_SKIP() << "Skipping input focus, there isn't a default seat";
+ }
+ free(set_seats);
/* We have to add surfaces to a layer. Otherwise, they would not have a view.
We need a view to be able to set pointer focus. */
@@ -120,7 +127,6 @@ TEST_F(IlmInputTest, ilm_input_focus) {
/* Can set all focus to keyboard */
ASSERT_EQ(ILM_SUCCESS, ilm_setInputFocus(&surfaces[0], surfaceCount, ILM_INPUT_DEVICE_KEYBOARD, ILM_TRUE));
-
ASSERT_EQ(ILM_SUCCESS, ilm_getInputFocus(&surfaceIDs, &bitmasks, &num_ids));
for (unsigned int i = 0; i < num_ids; i++) {
/* All surfaces now have keyboard focus */
@@ -174,16 +180,20 @@ TEST_F(IlmInputTest, ilm_input_event_acceptance) {
t_ilm_surface surface1 = iviSurfaces[0].surface_id;
t_ilm_uint num_seats = 0;
t_ilm_string *seats = NULL;
- char const *set_seats = "default";
+ t_ilm_string set_seats = NULL;
t_ilm_uint set_seats_count = 1;
+ /*ilm_input_event_acceptance test only work if default seat is available*/
+ if (ilm_getDefaultSeat(&set_seats) == ILM_FAILED) {
+ GTEST_SKIP() << "Skipping input event acceptace, there isn't a default seat";
+ }
/* All seats accept the "default" seat when created */
ASSERT_EQ(ILM_SUCCESS, ilm_getInputAcceptanceOn(surface1, &num_seats,
&seats));
EXPECT_EQ(1, num_seats);
/* googletest doesn't like comparing to null pointers */
ASSERT_FALSE(seats == NULL);
- EXPECT_STREQ("default", seats[0]);
+ EXPECT_STREQ(set_seats, seats[0]);
free(seats[0]);
free(seats);
@@ -196,12 +206,12 @@ TEST_F(IlmInputTest, ilm_input_event_acceptance) {
/* Can add a seat to acceptance */
ASSERT_EQ(ILM_SUCCESS, ilm_setInputAcceptanceOn(surface1, set_seats_count,
- (t_ilm_string*)&set_seats));
+ &set_seats));
ASSERT_EQ(ILM_SUCCESS, ilm_getInputAcceptanceOn(surface1, &num_seats,
&seats));
EXPECT_EQ(set_seats_count, num_seats);
bool found = false;
- if (!strcmp(*seats, (t_ilm_string)set_seats))
+ if (!strcmp(*seats, set_seats))
found = true;
EXPECT_EQ(true, found) << set_seats[0] << " not found in returned seats";
@@ -209,7 +219,9 @@ TEST_F(IlmInputTest, ilm_input_event_acceptance) {
free(seats);
/* Seats can be set, unset, then reset */
- ASSERT_EQ(ILM_SUCCESS, ilm_setInputAcceptanceOn(surface1, 1, (t_ilm_string*)&set_seats));
+ ASSERT_EQ(ILM_SUCCESS, ilm_setInputAcceptanceOn(surface1, 1, &set_seats));
ASSERT_EQ(ILM_SUCCESS, ilm_setInputAcceptanceOn(surface1, 0, NULL));
- ASSERT_EQ(ILM_SUCCESS, ilm_setInputAcceptanceOn(surface1, 1, (t_ilm_string*)&set_seats));
+ ASSERT_EQ(ILM_SUCCESS, ilm_setInputAcceptanceOn(surface1, 1, &set_seats));
+
+ free(set_seats);
}
diff --git a/protocol/ivi-input.xml b/protocol/ivi-input.xml
index f8ca77e..50eb19d 100644
--- a/protocol/ivi-input.xml
+++ b/protocol/ivi-input.xml
@@ -21,7 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</copyright>
- <interface name="ivi_input" version="1">
+ <interface name="ivi_input" version="2">
<description summary="controller interface to the input system">
This includes handling the existence of seats, seat capabilities,
seat acceptance and input focus.
@@ -31,6 +31,8 @@
</description>
<arg name="name" type="string"/>
<arg name="capabilities" type="uint"/>
+ <!-- Version 2 additions -->
+ <arg name="is_default" type="int"/>
</event>
<event name="seat_capabilities">
<description summary="A seat's capabilities have changed">