ivi-shell: activate weston surface with a seat when left click or touch.

Submitted by Nobuhiko Tanibata on Dec. 9, 2015, 6:03 a.m.

Details

Message ID 1449641027-21741-1-git-send-email-nobuhiko_tanibata@xddp.denso.co.jp
State Accepted
Commit 0627b4a73d323fb65ce7271c5db35fd211f11551
Headers show
Series "ivi-shell: activate weston surface with a seat when left click or touch." ( rev: 1 ) in Wayland (DEPRECATED)

Not browsing as part of any series.

Commit Message

Nobuhiko Tanibata Dec. 9, 2015, 6:03 a.m.
From: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

Similar with Desktop shell, set activate to weston surface which is
left-clicked by pointer or touched. This is needed to focus it with a seat.
Without this, a feature who gets activated weston surface by using
weston_surface_get_main_surface doesn't work correctly because it can
not get correct focused weston surface. For example, input-panel uses
weston_surface_get_main_surface to get a weston surface. With this
weston surface, it get a member: output to decide which output shall
show a input-panel, software keyboard. Without activation,
input-panel-ivi can not find a correct output which shows e.g.
weston-editor who uses input-method.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
---
 ivi-shell/ivi-shell.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

Patch hide | download patch | download mbox

diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index 1720705..a767ccf 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -414,6 +414,59 @@  ivi_shell_setting_create(struct ivi_shell_setting *dest,
 	return result;
 }
 
+static void
+activate_binding(struct weston_seat *seat,
+		 struct weston_view *focus_view)
+{
+	struct weston_surface *focus = focus_view->surface;
+	struct weston_surface *main_surface =
+		weston_surface_get_main_surface(focus);
+
+	if (get_ivi_shell_surface(main_surface) == NULL)
+		return;
+
+	weston_surface_activate(focus, seat);
+}
+
+static void
+click_to_activate_binding(struct weston_pointer *pointer, uint32_t time,
+			  uint32_t button, void *data)
+{
+	if (pointer->grab != &pointer->default_grab)
+		return;
+	if (pointer->focus == NULL)
+		return;
+
+	activate_binding(pointer->seat, pointer->focus);
+}
+
+static void
+touch_to_activate_binding(struct weston_touch *touch, uint32_t time,
+			  void *data)
+{
+	if (touch->grab != &touch->default_grab)
+		return;
+	if (touch->focus == NULL)
+		return;
+
+	activate_binding(touch->seat, touch->focus);
+}
+
+static void
+shell_add_bindings(struct weston_compositor *compositor,
+		   struct ivi_shell *shell)
+{
+	weston_compositor_add_button_binding(compositor, BTN_LEFT, 0,
+					     click_to_activate_binding,
+					     shell);
+	weston_compositor_add_button_binding(compositor, BTN_RIGHT, 0,
+					     click_to_activate_binding,
+					     shell);
+	weston_compositor_add_touch_binding(compositor, 0,
+					    touch_to_activate_binding,
+					    shell);
+}
+
 /*
  * Initialization of ivi-shell.
  */
@@ -450,6 +503,7 @@  module_init(struct weston_compositor *compositor,
 		goto out_settings;
 
 	ivi_layout_init_with_compositor(compositor);
+	shell_add_bindings(compositor, shell);
 
 	/* Call module_init of ivi-modules which are defined in weston.ini */
 	if (load_controller_modules(compositor, setting.ivi_module,

Comments

On Wed,  9 Dec 2015 15:03:47 +0900
Nobuhiko Tanibata <nobuhiko_tanibata@xddp.denso.co.jp> wrote:

> From: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
> 
> Similar with Desktop shell, set activate to weston surface which is
> left-clicked by pointer or touched. This is needed to focus it with a seat.
> Without this, a feature who gets activated weston surface by using
> weston_surface_get_main_surface doesn't work correctly because it can
> not get correct focused weston surface. For example, input-panel uses
> weston_surface_get_main_surface to get a weston surface. With this
> weston surface, it get a member: output to decide which output shall
> show a input-panel, software keyboard. Without activation,
> input-panel-ivi can not find a correct output which shows e.g.
> weston-editor who uses input-method.
> 
> Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
> ---
>  ivi-shell/ivi-shell.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
> 
> diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
> index 1720705..a767ccf 100644
> --- a/ivi-shell/ivi-shell.c
> +++ b/ivi-shell/ivi-shell.c
> @@ -414,6 +414,59 @@ ivi_shell_setting_create(struct ivi_shell_setting *dest,
>  	return result;
>  }
>  
> +static void
> +activate_binding(struct weston_seat *seat,
> +		 struct weston_view *focus_view)
> +{
> +	struct weston_surface *focus = focus_view->surface;
> +	struct weston_surface *main_surface =
> +		weston_surface_get_main_surface(focus);
> +
> +	if (get_ivi_shell_surface(main_surface) == NULL)
> +		return;
> +
> +	weston_surface_activate(focus, seat);
> +}
> +
> +static void
> +click_to_activate_binding(struct weston_pointer *pointer, uint32_t time,
> +			  uint32_t button, void *data)
> +{
> +	if (pointer->grab != &pointer->default_grab)
> +		return;
> +	if (pointer->focus == NULL)
> +		return;
> +
> +	activate_binding(pointer->seat, pointer->focus);
> +}
> +
> +static void
> +touch_to_activate_binding(struct weston_touch *touch, uint32_t time,
> +			  void *data)
> +{
> +	if (touch->grab != &touch->default_grab)
> +		return;
> +	if (touch->focus == NULL)
> +		return;
> +
> +	activate_binding(touch->seat, touch->focus);
> +}
> +
> +static void
> +shell_add_bindings(struct weston_compositor *compositor,
> +		   struct ivi_shell *shell)
> +{
> +	weston_compositor_add_button_binding(compositor, BTN_LEFT, 0,
> +					     click_to_activate_binding,
> +					     shell);
> +	weston_compositor_add_button_binding(compositor, BTN_RIGHT, 0,
> +					     click_to_activate_binding,
> +					     shell);
> +	weston_compositor_add_touch_binding(compositor, 0,
> +					    touch_to_activate_binding,
> +					    shell);
> +}
> +
>  /*
>   * Initialization of ivi-shell.
>   */
> @@ -450,6 +503,7 @@ module_init(struct weston_compositor *compositor,
>  		goto out_settings;
>  
>  	ivi_layout_init_with_compositor(compositor);
> +	shell_add_bindings(compositor, shell);
>  
>  	/* Call module_init of ivi-modules which are defined in weston.ini */
>  	if (load_controller_modules(compositor, setting.ivi_module,

Hi,

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>

With this patch, first clicking weston-editor to bring OSK up and then
clicking another app correctly causes the OSK to hide. Without this
patch it did not happen.

With the ivi-shell multiscreen support series, this patch also causes
the OSK to appear on the correct output while previously the OSK always
appeared on the one output.


Thanks,
pq
On Wed, 9 Dec 2015 12:08:09 +0200
Pekka Paalanen <ppaalanen@gmail.com> wrote:

> On Wed,  9 Dec 2015 15:03:47 +0900
> Nobuhiko Tanibata <nobuhiko_tanibata@xddp.denso.co.jp> wrote:
> 
> > From: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
> > 
> > Similar with Desktop shell, set activate to weston surface which is
> > left-clicked by pointer or touched. This is needed to focus it with a seat.
> > Without this, a feature who gets activated weston surface by using
> > weston_surface_get_main_surface doesn't work correctly because it can
> > not get correct focused weston surface. For example, input-panel uses
> > weston_surface_get_main_surface to get a weston surface. With this
> > weston surface, it get a member: output to decide which output shall
> > show a input-panel, software keyboard. Without activation,
> > input-panel-ivi can not find a correct output which shows e.g.
> > weston-editor who uses input-method.
> > 
> > Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
> > ---
> >  ivi-shell/ivi-shell.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 54 insertions(+)

> Hi,
> 
> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
> Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
> 
> With this patch, first clicking weston-editor to bring OSK up and then
> clicking another app correctly causes the OSK to hide. Without this
> patch it did not happen.
> 
> With the ivi-shell multiscreen support series, this patch also causes
> the OSK to appear on the correct output while previously the OSK always
> appeared on the one output.

Hi,

pushed as part of:
To ssh://git.freedesktop.org/git/wayland/weston
   748c695..1c2201b  master -> master


Thanks,
pq