summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTran Ba Khang(MS/EMC31-XC) <Khang.TranBa@vn.bosch.com>2023-03-20 18:00:41 +0700
committerTran Ba Khang(MS/EMC31-XC) <Khang.TranBa@vn.bosch.com>2023-04-28 15:12:06 +0700
commit765e844c296f5db8ecd0b29e539698c82dceaf22 (patch)
tree6908519b5598a311570be4efce44893900861d01
parent8a735a3ee6695778c9907f6bd044e9be7db1ef37 (diff)
downloadwayland-ivi-extension-765e844c296f5db8ecd0b29e539698c82dceaf22.tar.gz
ilmInput: support ilm_getDefaultSeat api to return default seat name
Sometimes the client need to know the default seat is available or not, or it wants to know which seat is default among multi seats. The seat_create_event should add more an argument for identification of default seat. The ilm_getDefaultSeat is going to query the list of seats to find the default seat name. Signed-off-by: Tran Ba Khang(MS/EMC31-XC) <Khang.TranBa@vn.bosch.com>
-rw-r--r--ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c12
-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--protocol/ivi-input.xml4
6 files changed, 53 insertions, 7 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 a3c0ea5..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
@@ -971,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__);
@@ -991,10 +992,12 @@ 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
@@ -1211,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,
@@ -1220,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) {
@@ -1402,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 b4fdfbf..533c053 100644
--- a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c
+++ b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c
@@ -754,7 +754,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;
@@ -771,6 +772,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);
}
@@ -900,7 +902,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);
@@ -913,7 +914,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/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">