[PATCH weston] ivi-shell: listen compositor wake_signal

2018-06-05 Thread Emre Ucan
If compositor wakes up from sleep state, we have
to trigger repaint for all outputs.

Signed-off-by: Emre Ucan 
---
 ivi-shell/ivi-shell.c | 16 
 ivi-shell/ivi-shell.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index 51e13a0..0235d26 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -361,6 +361,8 @@ shell_destroy(struct wl_listener *listener, void *data)
text_backend_destroy(shell->text_backend);
input_panel_destroy(shell);
 
+   wl_list_remove(>wake_listener.link);
+
wl_list_for_each_safe(ivisurf, next, >ivi_surface_list, link) {
wl_list_remove(>link);
free(ivisurf);
@@ -369,6 +371,17 @@ shell_destroy(struct wl_listener *listener, void *data)
free(shell);
 }
 
+/*
+ * Called through the compositor's wake signal.
+ */
+static void
+wake_handler(struct wl_listener *listener, void *data)
+{
+   struct weston_compositor *compositor = data;
+
+   weston_compositor_damage_all(compositor);
+}
+
 static void
 terminate_binding(struct weston_keyboard *keyboard, const struct timespec 
*time,
  uint32_t key, void *data)
@@ -480,6 +493,9 @@ wet_shell_init(struct weston_compositor *compositor,
shell->destroy_listener.notify = shell_destroy;
wl_signal_add(>destroy_signal, >destroy_listener);
 
+   shell->wake_listener.notify = wake_handler;
+   wl_signal_add(>wake_signal, >wake_listener);
+
if (input_panel_setup(shell) < 0)
goto out;
 
diff --git a/ivi-shell/ivi-shell.h b/ivi-shell/ivi-shell.h
index e35f75f..2c0064d 100644
--- a/ivi-shell/ivi-shell.h
+++ b/ivi-shell/ivi-shell.h
@@ -34,6 +34,7 @@
 struct ivi_shell
 {
struct wl_listener destroy_listener;
+   struct wl_listener wake_listener;
 
struct weston_compositor *compositor;
 
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] ivi-shell: use install paths in example config

2018-05-24 Thread Emre Ucan
The example weston.ini file uses source and build
directory paths. Therefore, it is only useful when
used on the same system that is used to build Weston.

We can use install paths instead of build/source paths
to fix this problem.

v2 changes:
- use $(westondatadir) instead of $(datadir)

Reported-by: Michael Tretter <m.tret...@pengutronix.de>
Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 Makefile.am |  4 +---
 ivi-shell/weston.ini.in | 60 -
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 69ca6cb..819c9c9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,10 +24,8 @@ weston.ini : $(srcdir)/weston.ini.in
 ivi-shell/weston.ini : $(srcdir)/ivi-shell/weston.ini.in
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
-e 's|@bindir[@]|$(bindir)|g' \
-   -e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
-   -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
-e 's|@libexecdir[@]|$(libexecdir)|g' \
-   -e 's|@plugin_prefix[@]||g' \
+   -e 's|@westondatadir[@]|$(westondatadir)|g' \
$< > $@
 
 all-local : weston.ini ivi-shell/weston.ini
diff --git a/ivi-shell/weston.ini.in b/ivi-shell/weston.ini.in
index 3f11e1c..58cba54 100644
--- a/ivi-shell/weston.ini.in
+++ b/ivi-shell/weston.ini.in
@@ -1,9 +1,9 @@
 [core]
-shell=@plugin_pre...@ivi-shell.so
-modules=@plugin_pre...@hmi-controller.so
+shell=ivi-shell.so
+modules=hmi-controller.so
 
 [ivi-shell]
-ivi-shell-user-interface=@abs_top_builddir@/weston-ivi-shell-user-interface
+ivi-shell-user-interface=@libexecdir@/weston-ivi-shell-user-interface
 
 #developermode=true
 
@@ -19,20 +19,20 @@ application-layer-id=4000
 
 transition-duration=300
 
-background-image=@abs_top_srcdir@/data/background.png
+background-image=@westondatadir@/background.png
 background-id=1001
-panel-image=@abs_top_srcdir@/data/panel.png
+panel-image=@westondatadir@/panel.png
 panel-id=1002
 surface-id-offset=10
-tiling-image=@abs_top_srcdir@/data/tiling.png
+tiling-image=@westondatadir@/tiling.png
 tiling-id=1003
-sidebyside-image=@abs_top_srcdir@/data/sidebyside.png
+sidebyside-image=@westondatadir@/sidebyside.png
 sidebyside-id=1004
-fullscreen-image=@abs_top_srcdir@/data/fullscreen.png
+fullscreen-image=@westondatadir@/fullscreen.png
 fullscreen-id=1005
-random-image=@abs_top_srcdir@/data/random.png
+random-image=@westondatadir@/random.png
 random-id=1006
-home-image=@abs_top_srcdir@/data/home.png
+home-image=@westondatadir@/home.png
 home-id=1007
 workspace-background-color=0x9900
 workspace-background-id=2001
@@ -43,59 +43,59 @@ path=@libexecdir@/weston-keyboard
 [ivi-launcher]
 workspace-id=0
 icon-id=4001
-icon=@abs_top_srcdir@/data/icon_ivi_flower.png
-path=@abs_top_builddir@/weston-flower
+icon=@westondatadir@/icon_ivi_flower.png
+path=@bindir@/weston-flower
 
 [ivi-launcher]
 workspace-id=0
 icon-id=4002
-icon=@abs_top_srcdir@/data/icon_ivi_clickdot.png
-path=@abs_top_builddir@/weston-clickdot
+icon=@westondatadir@/icon_ivi_clickdot.png
+path=@bindir@/weston-clickdot
 
 [ivi-launcher]
 workspace-id=1
 icon-id=4003
-icon=@abs_top_srcdir@/data/icon_ivi_simple-egl.png
-path=@abs_top_builddir@/weston-simple-egl
+icon=@westondatadir@/icon_ivi_simple-egl.png
+path=@bindir@/weston-simple-egl
 
 [ivi-launcher]
 workspace-id=1
 icon-id=4004
-icon=@abs_top_srcdir@/data/icon_ivi_simple-shm.png
-path=@abs_top_builddir@/weston-simple-shm
+icon=@westondatadir@/icon_ivi_simple-shm.png
+path=@bindir@/weston-simple-shm
 
 [ivi-launcher]
 workspace-id=2
 icon-id=4005
-icon=@abs_top_srcdir@/data/icon_ivi_smoke.png
-path=@abs_top_builddir@/weston-smoke
+icon=@westondatadir@/icon_ivi_smoke.png
+path=@bindir@/weston-smoke
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4006
-icon=@abs_top_srcdir@/data/icon_ivi_flower.png
-path=@abs_top_builddir@/weston-flower
+icon=@westondatadir@/icon_ivi_flower.png
+path=@bindir@/weston-flower
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4007
-icon=@abs_top_srcdir@/data/icon_ivi_clickdot.png
-path=@abs_top_builddir@/weston-clickdot
+icon=@westondatadir@/icon_ivi_clickdot.png
+path=@bindir@/weston-clickdot
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4008
-icon=@abs_top_srcdir@/data/icon_ivi_simple-egl.png
-path=@abs_top_builddir@/weston-simple-egl
+icon=@westondatadir@/icon_ivi_simple-egl.png
+path=@bindir@/weston-simple-egl
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4009
-icon=@abs_top_srcdir@/data/icon_ivi_simple-shm.png
-path=@abs_top_builddir@/weston-simple-shm
+icon=@westondatadir@/icon_ivi_simple-shm.png
+path=@bindir@/weston-simple-shm
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4010
-icon=@abs_top_srcdir@/data/icon_ivi_smoke.png
-path=@abs_top_builddir@/weston-smoke
+icon=@westondatadir@/icon_ivi_smoke.png
+path=@bindir@/weston-smoke
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@l

[PATCH weston] ivi-shell: use install paths in example config

2018-05-24 Thread Emre Ucan
The example weston.ini file uses source and build
directory paths. Therefore, it is only useful when
used on the same system that is used to build Weston.

We can use install paths instead of build/source paths
to fix this problem.

Reported-by: Michael Tretter <m.tret...@pengutronix.de>
Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 Makefile.am |  4 +---
 ivi-shell/weston.ini.in | 60 -
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 69ca6cb..b5f29bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,10 +24,8 @@ weston.ini : $(srcdir)/weston.ini.in
 ivi-shell/weston.ini : $(srcdir)/ivi-shell/weston.ini.in
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
-e 's|@bindir[@]|$(bindir)|g' \
-   -e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
-   -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
-e 's|@libexecdir[@]|$(libexecdir)|g' \
-   -e 's|@plugin_prefix[@]||g' \
+   -e 's|@datadir[@]|$(datadir)|g' \
$< > $@
 
 all-local : weston.ini ivi-shell/weston.ini
diff --git a/ivi-shell/weston.ini.in b/ivi-shell/weston.ini.in
index 3f11e1c..51238e3 100644
--- a/ivi-shell/weston.ini.in
+++ b/ivi-shell/weston.ini.in
@@ -1,9 +1,9 @@
 [core]
-shell=@plugin_pre...@ivi-shell.so
-modules=@plugin_pre...@hmi-controller.so
+shell=ivi-shell.so
+modules=hmi-controller.so
 
 [ivi-shell]
-ivi-shell-user-interface=@abs_top_builddir@/weston-ivi-shell-user-interface
+ivi-shell-user-interface=@libexecdir@/weston-ivi-shell-user-interface
 
 #developermode=true
 
@@ -19,20 +19,20 @@ application-layer-id=4000
 
 transition-duration=300
 
-background-image=@abs_top_srcdir@/data/background.png
+background-image=@datadir@/weston/background.png
 background-id=1001
-panel-image=@abs_top_srcdir@/data/panel.png
+panel-image=@datadir@/weston/panel.png
 panel-id=1002
 surface-id-offset=10
-tiling-image=@abs_top_srcdir@/data/tiling.png
+tiling-image=@datadir@/weston/tiling.png
 tiling-id=1003
-sidebyside-image=@abs_top_srcdir@/data/sidebyside.png
+sidebyside-image=@datadir@/weston/sidebyside.png
 sidebyside-id=1004
-fullscreen-image=@abs_top_srcdir@/data/fullscreen.png
+fullscreen-image=@datadir@/weston/fullscreen.png
 fullscreen-id=1005
-random-image=@abs_top_srcdir@/data/random.png
+random-image=@datadir@/weston/random.png
 random-id=1006
-home-image=@abs_top_srcdir@/data/home.png
+home-image=@datadir@/weston/home.png
 home-id=1007
 workspace-background-color=0x9900
 workspace-background-id=2001
@@ -43,59 +43,59 @@ path=@libexecdir@/weston-keyboard
 [ivi-launcher]
 workspace-id=0
 icon-id=4001
-icon=@abs_top_srcdir@/data/icon_ivi_flower.png
-path=@abs_top_builddir@/weston-flower
+icon=@datadir@/weston/icon_ivi_flower.png
+path=@bindir@/weston-flower
 
 [ivi-launcher]
 workspace-id=0
 icon-id=4002
-icon=@abs_top_srcdir@/data/icon_ivi_clickdot.png
-path=@abs_top_builddir@/weston-clickdot
+icon=@datadir@/weston/icon_ivi_clickdot.png
+path=@bindir@/weston-clickdot
 
 [ivi-launcher]
 workspace-id=1
 icon-id=4003
-icon=@abs_top_srcdir@/data/icon_ivi_simple-egl.png
-path=@abs_top_builddir@/weston-simple-egl
+icon=@datadir@/weston/icon_ivi_simple-egl.png
+path=@bindir@/weston-simple-egl
 
 [ivi-launcher]
 workspace-id=1
 icon-id=4004
-icon=@abs_top_srcdir@/data/icon_ivi_simple-shm.png
-path=@abs_top_builddir@/weston-simple-shm
+icon=@datadir@/weston/icon_ivi_simple-shm.png
+path=@bindir@/weston-simple-shm
 
 [ivi-launcher]
 workspace-id=2
 icon-id=4005
-icon=@abs_top_srcdir@/data/icon_ivi_smoke.png
-path=@abs_top_builddir@/weston-smoke
+icon=@datadir@/weston/icon_ivi_smoke.png
+path=@bindir@/weston-smoke
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4006
-icon=@abs_top_srcdir@/data/icon_ivi_flower.png
-path=@abs_top_builddir@/weston-flower
+icon=@datadir@/weston/icon_ivi_flower.png
+path=@bindir@/weston-flower
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4007
-icon=@abs_top_srcdir@/data/icon_ivi_clickdot.png
-path=@abs_top_builddir@/weston-clickdot
+icon=@datadir@/weston/icon_ivi_clickdot.png
+path=@bindir@/weston-clickdot
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4008
-icon=@abs_top_srcdir@/data/icon_ivi_simple-egl.png
-path=@abs_top_builddir@/weston-simple-egl
+icon=@datadir@/weston/icon_ivi_simple-egl.png
+path=@bindir@/weston-simple-egl
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4009
-icon=@abs_top_srcdir@/data/icon_ivi_simple-shm.png
-path=@abs_top_builddir@/weston-simple-shm
+icon=@datadir@/weston/icon_ivi_simple-shm.png
+path=@bindir@/weston-simple-shm
 
 [ivi-launcher]
 workspace-id=3
 icon-id=4010
-icon=@abs_top_srcdir@/data/icon_ivi_smoke.png
-path=@abs_top_builddir@/weston-smoke
+icon=@datadir@/weston/icon_ivi_smoke.png
+path=@bindir@/weston-smoke
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 7/9] ivi-shell: allow to set transitions only once

2018-05-23 Thread Emre Ucan
Transitions are only atomically set during commit_changes.
Therefore, it should not be possible to set same type of
transition to same surface/layer more than once.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout-transition.c | 74 +--
 1 file changed, 9 insertions(+), 65 deletions(-)

diff --git a/ivi-shell/ivi-layout-transition.c 
b/ivi-shell/ivi-layout-transition.c
index cb11a01..13c35f1 100644
--- a/ivi-shell/ivi-layout-transition.c
+++ b/ivi-shell/ivi-layout-transition.c
@@ -416,22 +416,7 @@ ivi_layout_transition_move_resize_view(struct 
ivi_layout_surface *surface,
transition = get_transition_from_type_and_id(
IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE,
surface);
-   if (transition) {
-   struct move_resize_view_data *data = transition->private_data;
-   transition->time_start = 0;
-   transition->time_duration = duration;
-
-   data->start_x = start_pos[0];
-   data->start_y = start_pos[1];
-   data->end_x   = dest_x;
-   data->end_y   = dest_y;
-
-   data->start_width  = start_size[0];
-   data->start_height = start_size[1];
-   data->end_width= dest_width;
-   data->end_height   = dest_height;
-   return;
-   }
+   assert(!transition);
 
transition = create_move_resize_view_transition(
surface,
@@ -567,25 +552,11 @@ ivi_layout_transition_visibility_on(struct 
ivi_layout_surface *surface,
bool is_visible = surface->prop.visibility;
wl_fixed_t dest_alpha = surface->prop.opacity;
struct store_alpha *user_data = NULL;
-   wl_fixed_t start_alpha = 0.0;
-   struct fade_view_data *data = NULL;
 
transition = get_transition_from_type_and_id(
IVI_LAYOUT_TRANSITION_VIEW_FADE,
surface);
-   if (transition) {
-   start_alpha = surface->prop.opacity;
-   user_data = transition->user_data;
-   data = transition->private_data;
-
-   transition->time_start = 0;
-   transition->time_duration = duration;
-   transition->destroy_func = visibility_on_transition_destroy;
-
-   data->start_alpha = wl_fixed_to_double(start_alpha);
-   data->end_alpha = user_data->alpha;
-   return;
-   }
+   assert(!transition);
 
if (is_visible)
return;
@@ -631,22 +602,11 @@ ivi_layout_transition_visibility_off(struct 
ivi_layout_surface *surface,
struct ivi_layout_transition *transition;
wl_fixed_t start_alpha = surface->prop.opacity;
struct store_alpha* user_data = NULL;
-   struct fade_view_data* data = NULL;
 
transition =
get_transition_from_type_and_id(IVI_LAYOUT_TRANSITION_VIEW_FADE,
surface);
-   if (transition) {
-   data = transition->private_data;
-
-   transition->time_start = 0;
-   transition->time_duration = duration;
-   transition->destroy_func = visibility_off_transition_destroy;
-
-   data->start_alpha = wl_fixed_to_double(start_alpha);
-   data->end_alpha = 0;
-   return;
-   }
+   assert(!transition);
 
user_data = malloc(sizeof(*user_data));
if (user_data == NULL) {
@@ -766,6 +726,11 @@ ivi_layout_transition_move_layer(struct ivi_layout_layer 
*layer,
int32_t start_pos_y = layer->prop.dest_y;
struct ivi_layout_transition *transition = NULL;
 
+   transition = get_transition_from_type_and_id(
+   IVI_LAYOUT_TRANSITION_LAYER_MOVE,
+   layer);
+   assert(!transition);
+
transition = create_move_layer_transition(
layer,
start_pos_x, start_pos_y,
@@ -843,32 +808,11 @@ ivi_layout_transition_fade_layer(
 {
struct ivi_layout_transition *transition;
struct fade_layer_data *data;
-   wl_fixed_t fixed_opacity;
-   double now_opacity;
-   double remain;
 
transition = get_transition_from_type_and_id(
IVI_LAYOUT_TRANSITION_LAYER_FADE,
layer);
-   if (transition) {
-   /* transition update */
-   data = transition->private_data;
-
-   /* FIXME */
-   fixed_opacity = layer->prop.opacity;
-   now_opacity = wl_fixed_to_double(fixed_opacity);
-
-   data->is_fade_in = is_fade_in;
-   data->start_

[PATCH weston 8/9] ivi-shell: remove surface_set_transition_duration

2018-05-23 Thread Emre Ucan
it is not used

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout-export.h |  9 +
 ivi-shell/ivi-layout.c| 17 -
 2 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index 834b906..fee7adb 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -133,7 +133,7 @@ enum ivi_layout_transition_type{
IVI_LAYOUT_TRANSITION_MAX,
 };
 
-#define IVI_LAYOUT_API_NAME "ivi_layout_api_v1"
+#define IVI_LAYOUT_API_NAME "ivi_layout_api_v2"
 
 struct ivi_layout_interface {
 
@@ -298,13 +298,6 @@ struct ivi_layout_interface {
  uint32_t duration);
 
/**
-* \brief set duration of transition animation
-*/
-   int32_t (*surface_set_transition_duration)(
-   struct ivi_layout_surface *ivisurf,
-   uint32_t duration);
-
-   /**
 * layer controller interface
 */
 
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index b9c21bb..2b6985b 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -1753,22 +1753,6 @@ ivi_layout_layer_set_fade_info(struct ivi_layout_layer* 
ivilayer,
 }
 
 static int32_t
-ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
-  uint32_t duration)
-{
-   struct ivi_layout_surface_properties *prop;
-
-   if (ivisurf == NULL) {
-   weston_log("%s: invalid argument\n", __func__);
-   return -1;
-   }
-
-   prop = >pending.prop;
-   prop->transition_duration = duration*10;
-   return 0;
-}
-
-static int32_t
 ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
  enum ivi_layout_transition_type type,
  uint32_t duration)
@@ -1929,7 +1913,6 @@ static struct ivi_layout_interface ivi_layout_interface = 
{
.surface_add_listener   = 
ivi_layout_surface_add_listener,
.surface_get_weston_surface = 
ivi_layout_surface_get_weston_surface,
.surface_set_transition = 
ivi_layout_surface_set_transition,
-   .surface_set_transition_duration= 
ivi_layout_surface_set_transition_duration,
 
/**
 * layer controller interfaces
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 6/9] ivi-shell: remove start rectangle from ivi_layout_surface

2018-05-23 Thread Emre Ucan
it is always equal to destination rectangle.
Therefore, we can remove it

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout-export.h | 4 
 ivi-shell/ivi-layout-transition.c | 8 
 ivi-shell/ivi-layout.c| 4 
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index 06535bf..834b906 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -75,10 +75,6 @@ struct ivi_layout_surface_properties
int32_t source_y;
int32_t source_width;
int32_t source_height;
-   int32_t start_x;
-   int32_t start_y;
-   int32_t start_width;
-   int32_t start_height;
int32_t dest_x;
int32_t dest_y;
int32_t dest_width;
diff --git a/ivi-shell/ivi-layout-transition.c 
b/ivi-shell/ivi-layout-transition.c
index f700f74..cb11a01 100644
--- a/ivi-shell/ivi-layout-transition.c
+++ b/ivi-shell/ivi-layout-transition.c
@@ -404,13 +404,13 @@ ivi_layout_transition_move_resize_view(struct 
ivi_layout_surface *surface,
 {
struct ivi_layout_transition *transition;
int32_t start_pos[2] = {
-   surface->pending.prop.start_x,
-   surface->pending.prop.start_y
+   surface->prop.dest_x,
+   surface->prop.dest_y
};
 
int32_t start_size[2] = {
-   surface->pending.prop.start_width,
-   surface->pending.prop.start_height
+   surface->prop.dest_width,
+   surface->prop.dest_height
};
 
transition = get_transition_from_type_and_id(
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 548b3a3..b9c21bb 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -1469,12 +1469,8 @@ ivi_layout_surface_set_destination_rectangle(struct 
ivi_layout_surface *ivisurf,
}
 
prop = >pending.prop;
-   prop->start_x = prop->dest_x;
-   prop->start_y = prop->dest_y;
prop->dest_x = x;
prop->dest_y = y;
-   prop->start_width = prop->dest_width;
-   prop->start_height = prop->dest_height;
prop->dest_width = width;
prop->dest_height = height;
 
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/9] ivi-shell: remove redundant code in commit_surface_list

2018-05-23 Thread Emre Ucan
Move out the statements out of if statement, which are
the same in every branch. Furthermore, *_move_resize_view()
function does not modify destination rectangle of the
surface. Therefore, we don't need to store the destination
rectangle locally and set it again.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout.c | 45 -
 1 file changed, 4 insertions(+), 41 deletions(-)

diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 57c4f3b..548b3a3 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -632,19 +632,10 @@ static void
 commit_surface_list(struct ivi_layout *layout)
 {
struct ivi_layout_surface *ivisurf = NULL;
-   int32_t dest_x = 0;
-   int32_t dest_y = 0;
-   int32_t dest_width = 0;
-   int32_t dest_height = 0;
int32_t configured = 0;
 
wl_list_for_each(ivisurf, >surface_list, link) {
if (ivisurf->pending.prop.transition_type == 
IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
-   dest_x = ivisurf->prop.dest_x;
-   dest_y = ivisurf->prop.dest_y;
-   dest_width = ivisurf->prop.dest_width;
-   dest_height = ivisurf->prop.dest_height;
-
ivi_layout_transition_move_resize_view(ivisurf,
   
ivisurf->pending.prop.dest_x,
   
ivisurf->pending.prop.dest_y,
@@ -657,37 +648,13 @@ commit_surface_list(struct ivi_layout *layout)
} else {
ivi_layout_transition_visibility_off(ivisurf, 
ivisurf->pending.prop.transition_duration);
}
-
-   ivisurf->prop = ivisurf->pending.prop;
-   ivisurf->prop.dest_x = dest_x;
-   ivisurf->prop.dest_y = dest_y;
-   ivisurf->prop.dest_width = dest_width;
-   ivisurf->prop.dest_height = dest_height;
-   ivisurf->prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
-   ivisurf->pending.prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
-
} else if (ivisurf->pending.prop.transition_type == 
IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE) {
-   dest_x = ivisurf->prop.dest_x;
-   dest_y = ivisurf->prop.dest_y;
-   dest_width = ivisurf->prop.dest_width;
-   dest_height = ivisurf->prop.dest_height;
-
ivi_layout_transition_move_resize_view(ivisurf,
   
ivisurf->pending.prop.dest_x,
   
ivisurf->pending.prop.dest_y,
   
ivisurf->pending.prop.dest_width,
   
ivisurf->pending.prop.dest_height,
   
ivisurf->pending.prop.transition_duration);
-
-   ivisurf->prop = ivisurf->pending.prop;
-   ivisurf->prop.dest_x = dest_x;
-   ivisurf->prop.dest_y = dest_y;
-   ivisurf->prop.dest_width = dest_width;
-   ivisurf->prop.dest_height = dest_height;
-
-   ivisurf->prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
-   ivisurf->pending.prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
-
} else if (ivisurf->pending.prop.transition_type == 
IVI_LAYOUT_TRANSITION_VIEW_FADE) {
configured = 0;
if (ivisurf->pending.prop.visibility) {
@@ -701,10 +668,6 @@ commit_surface_list(struct ivi_layout *layout)
configured = 1;
}
 
-   ivisurf->prop = ivisurf->pending.prop;
-   ivisurf->prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
-   ivisurf->pending.prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
-
if (configured && !is_surface_transition(ivisurf)) {
shell_surface_send_configure(ivisurf->surface,
 
ivisurf->prop.dest_width,
@@ -717,16 +680,16 @@ commit_surface_list(struct ivi_layout *layout)
configured = 1;
}
 
-   ivisurf->prop = ivisurf->pending.prop;
-   ivisurf->prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
-  

[PATCH weston 9/9] ivi-shell: remove move_layer_cancel API

2018-05-23 Thread Emre Ucan
Transitions are committed during commit_changes.
If we want to remove previously set transitions,
we need to call layer_set_transition with
IVI_LAYOUT_TRANSITION_NONE.

Therefore, this API is redundant.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/hmi-controller.c|  4 +++-
 ivi-shell/ivi-layout-export.h |  1 -
 ivi-shell/ivi-layout-transition.c | 12 
 ivi-shell/ivi-layout.c|  1 -
 4 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index ed2ddb2..4880bc8 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -1783,7 +1783,9 @@ ivi_hmi_controller_workspace_control(struct wl_client 
*client,
 
layer = hmi_ctrl->workspace_layer.ivilayer;
 
-   hmi_ctrl->interface->transition_move_layer_cancel(layer);
+   hmi_ctrl->interface->layer_set_transition(layer,
+ IVI_LAYOUT_TRANSITION_NONE,
+ 0);
 
switch (device) {
case HMI_GRAB_DEVICE_POINTER:
diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index fee7adb..eb4247d 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -523,7 +523,6 @@ struct ivi_layout_interface {
/**
 * transision animation for layer
 */
-   void (*transition_move_layer_cancel)(struct ivi_layout_layer *layer);
int32_t (*layer_set_fade_info)(struct ivi_layout_layer* ivilayer,
   uint32_t is_fade_in,
   double start_alpha, double end_alpha);
diff --git a/ivi-shell/ivi-layout-transition.c 
b/ivi-shell/ivi-layout-transition.c
index 13c35f1..4124c03 100644
--- a/ivi-shell/ivi-layout-transition.c
+++ b/ivi-shell/ivi-layout-transition.c
@@ -744,18 +744,6 @@ ivi_layout_transition_move_layer(struct ivi_layout_layer 
*layer,
free(transition);
 }
 
-void
-ivi_layout_transition_move_layer_cancel(struct ivi_layout_layer *layer)
-{
-   struct ivi_layout_transition *transition =
-   get_transition_from_type_and_id(
-   IVI_LAYOUT_TRANSITION_LAYER_MOVE,
-   layer);
-   if (transition) {
-   layout_transition_destroy(transition);
-   }
-}
-
 /* fade layer transition */
 struct fade_layer_data {
struct ivi_layout_layer *layer;
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 2b6985b..448ef17 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -1948,7 +1948,6 @@ static struct ivi_layout_interface ivi_layout_interface = 
{
/**
 * animation
 */
-   .transition_move_layer_cancel   = 
ivi_layout_transition_move_layer_cancel,
.layer_set_fade_info= ivi_layout_layer_set_fade_info,
 
/**
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 2/9] ivi-shell: remove unused VIEW_RESIZE transition

2018-05-23 Thread Emre Ucan
we can use VIEW_MOVE_RESIZE instead

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout-export.h | 1 -
 ivi-shell/ivi-layout-transition.c | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index b6291f1..b3f5beb 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -135,7 +135,6 @@ enum ivi_layout_transition_type{
IVI_LAYOUT_TRANSITION_LAYER_FADE,
IVI_LAYOUT_TRANSITION_LAYER_MOVE,
IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE,
-   IVI_LAYOUT_TRANSITION_VIEW_RESIZE,
IVI_LAYOUT_TRANSITION_VIEW_FADE,
IVI_LAYOUT_TRANSITION_MAX,
 };
diff --git a/ivi-shell/ivi-layout-transition.c 
b/ivi-shell/ivi-layout-transition.c
index a223b58..f700f74 100644
--- a/ivi-shell/ivi-layout-transition.c
+++ b/ivi-shell/ivi-layout-transition.c
@@ -98,8 +98,7 @@ is_surface_transition(struct ivi_layout_surface *surface)
wl_list_for_each(node, >transitions->transition_list, link) {
tran = node->transition;
 
-   if ((tran->type == IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE ||
-tran->type == IVI_LAYOUT_TRANSITION_VIEW_RESIZE) &&
+   if ((tran->type == IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE) &&
tran->is_transition_func(tran->private_data, surface))
return 1;
}
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/9] ivi-shell: remove VIEW_FADE_ONLY transition

2018-05-23 Thread Emre Ucan
we can use VIEW_FADE transition instead

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/hmi-controller.c| 2 +-
 ivi-shell/ivi-layout-export.h | 1 -
 ivi-shell/ivi-layout.c| 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index f8858c5..ed2ddb2 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -333,7 +333,7 @@ mode_divided_into_sidebyside(struct hmi_controller 
*hmi_ctrl,
 
for (i = idx; i < surf_num; i++) {
hmi_ctrl->interface->surface_set_transition(surfaces[i],
-   
IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY,
+   IVI_LAYOUT_TRANSITION_VIEW_FADE,
duration);
hmi_ctrl->interface->surface_set_visibility(surfaces[i], false);
}
diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index f84c967..06535bf 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -130,7 +130,6 @@ enum ivi_layout_notification_mask {
 enum ivi_layout_transition_type{
IVI_LAYOUT_TRANSITION_NONE,
IVI_LAYOUT_TRANSITION_VIEW_DEFAULT,
-   IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY,
IVI_LAYOUT_TRANSITION_LAYER_FADE,
IVI_LAYOUT_TRANSITION_LAYER_MOVE,
IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE,
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 8ff33e7..57c4f3b 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -688,7 +688,7 @@ commit_surface_list(struct ivi_layout *layout)
ivisurf->prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
ivisurf->pending.prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
 
-   } else if (ivisurf->pending.prop.transition_type == 
IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) {
+   } else if (ivisurf->pending.prop.transition_type == 
IVI_LAYOUT_TRANSITION_VIEW_FADE) {
configured = 0;
if (ivisurf->pending.prop.visibility) {
ivi_layout_transition_visibility_on(ivisurf, 
ivisurf->pending.prop.transition_duration);
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/9] ivi-shell: remove unused VIEW_ORDER transition

2018-05-23 Thread Emre Ucan
it is not possible to make transition of z-order changes

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/hmi-controller.c| 3 ---
 ivi-shell/ivi-layout-export.h | 1 -
 2 files changed, 4 deletions(-)

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 0e44df8..f8858c5 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -265,9 +265,6 @@ mode_divided_into_tiling(struct hmi_controller *hmi_ctrl,
}
hmi_ctrl->interface->layer_set_render_order(ivilayer, 
new_order, i);
 
-   hmi_ctrl->interface->layer_set_transition(ivilayer,
-   IVI_LAYOUT_TRANSITION_LAYER_VIEW_ORDER,
-   duration);
}
for (i = idx; i < surf_num; i++)
hmi_ctrl->interface->surface_set_visibility(surfaces[i], false);
diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index 016d8b5..b6291f1 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -134,7 +134,6 @@ enum ivi_layout_transition_type{
IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY,
IVI_LAYOUT_TRANSITION_LAYER_FADE,
IVI_LAYOUT_TRANSITION_LAYER_MOVE,
-   IVI_LAYOUT_TRANSITION_LAYER_VIEW_ORDER,
IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE,
IVI_LAYOUT_TRANSITION_VIEW_RESIZE,
IVI_LAYOUT_TRANSITION_VIEW_FADE,
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/9] ivi-shell: remove DEST_RECT_ONLY transition

2018-05-23 Thread Emre Ucan
we can use VIEW_MOVE_RESIZE tranisition instead

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout-export.h | 1 -
 ivi-shell/ivi-layout.c| 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index b3f5beb..f84c967 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -130,7 +130,6 @@ enum ivi_layout_notification_mask {
 enum ivi_layout_transition_type{
IVI_LAYOUT_TRANSITION_NONE,
IVI_LAYOUT_TRANSITION_VIEW_DEFAULT,
-   IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY,
IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY,
IVI_LAYOUT_TRANSITION_LAYER_FADE,
IVI_LAYOUT_TRANSITION_LAYER_MOVE,
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index d9a0c2d..8ff33e7 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -666,7 +666,7 @@ commit_surface_list(struct ivi_layout *layout)
ivisurf->prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
ivisurf->pending.prop.transition_type = 
IVI_LAYOUT_TRANSITION_NONE;
 
-   } else if (ivisurf->pending.prop.transition_type == 
IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) {
+   } else if (ivisurf->pending.prop.transition_type == 
IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE) {
dest_x = ivisurf->prop.dest_x;
dest_y = ivisurf->prop.dest_y;
dest_width = ivisurf->prop.dest_width;
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 0/9] Transition rework part 1

2018-05-23 Thread Emre Ucan
I am planning to rework ivi transition implementation.
I want to use weston animation implementation instead of
ivi-shell specific transition implementation.

These patches are some cleanup patches, which can be applied
now. I want to send them now instead of sending a bigger
complete rework patch series.

- First 4 patches remove unused or duplicated transition modes.
- 5th patch simplifies commit_surface_list implementation regarding
  transitions.
- 6th patch removes redundant start rectangle from
  ivi_layout_surface_properties
- 7th patch adds some asserts in transition implementation
  to ensure same type of transition is only set once for a
  ivilayer/ivisurface
- 8th and 9th patch remove unused, unnecessary APIs from
  ivi_layout_interface

Emre Ucan (9):
  ivi-shell: remove unused VIEW_ORDER transition
  ivi-shell: remove unused VIEW_RESIZE transition
  ivi-shell: remove DEST_RECT_ONLY transition
  ivi-shell: remove VIEW_FADE_ONLY transition
  ivi-shell: remove redundant code in commit_surface_list
  ivi-shell: remove start rectangle from ivi_layout_surface
  ivi-shell: allow to set transitions only once
  ivi-shell: remove surface_set_transition_duration
  ivi-shell: remove move_layer_cancel API

 ivi-shell/hmi-controller.c|  9 ++--
 ivi-shell/ivi-layout-export.h | 18 +---
 ivi-shell/ivi-layout-transition.c | 97 ++-
 ivi-shell/ivi-layout.c| 71 +++-
 4 files changed, 25 insertions(+), 170 deletions(-)

-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] libweston: don't accumulate damage from transparent views

2018-04-18 Thread Emre Ucan
If view is set to be entirely transparent,
there is no need to accumulate its damage.

This is an important optimization for
using view transparency. Because otherwise
transparent views are rendered like an
opaque view, and their pixel values
are set to 0 in fragment shader.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 libweston/compositor.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index a9de4ac..4bcf120 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -2122,7 +2122,10 @@ compositor_accumulate_damage(struct weston_compositor 
*ec)
pixman_region32_init();
 
wl_list_for_each(ev, >view_list, link) {
-   if (ev->plane != plane)
+   /* If view is set to be entirely transparent,
+* there is no need to accumulate its damage.
+*/
+   if (ev->plane != plane || ev->alpha == 0.0f)
continue;
 
view_accumulate_damage(ev, );
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 6/7] compositor: initialize ret in repaint_timer_handler

2018-03-20 Thread Emre Ucan
If output_list of compositor is empty, value of
ret is read without initialization.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 libweston/compositor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 67b5d28..4816f33 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -2457,7 +2457,7 @@ output_repaint_timer_handler(void *data)
struct weston_output *output;
struct timespec now;
void *repaint_data = NULL;
-   int ret;
+   int ret = 0;
 
weston_compositor_read_presentation_clock(compositor, );
 
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/7] gl-renderer: set num_images after import_simple_dmabuf

2018-03-20 Thread Emre Ucan
we have to set num_images after import_simple_dmabuf
call. Otherwise, egl_images will not be correctly
referenced in gl_renderer_attach_dmabuf.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 libweston/gl-renderer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index a6b29a9..2c50d2d 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -2216,6 +2216,7 @@ import_known_dmabuf(struct gl_renderer *gr,
image->images[0] = import_simple_dmabuf(gr, 
>dmabuf->attributes);
if (!image->images[0])
return false;
+   image->num_images = 1;
break;
 
case IMPORT_TYPE_GL_CONVERSION:
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 7/7] ivi-shell: remove dead assignments in layer transition

2018-03-20 Thread Emre Ucan
Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout-transition.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/ivi-shell/ivi-layout-transition.c 
b/ivi-shell/ivi-layout-transition.c
index b887ff6..a223b58 100644
--- a/ivi-shell/ivi-layout-transition.c
+++ b/ivi-shell/ivi-layout-transition.c
@@ -843,10 +843,10 @@ ivi_layout_transition_fade_layer(
uint32_t duration)
 {
struct ivi_layout_transition *transition;
-   struct fade_layer_data *data = NULL;
-   wl_fixed_t fixed_opacity = 0.0;
-   double now_opacity = 0.0;
-   double remain = 0.0;
+   struct fade_layer_data *data;
+   wl_fixed_t fixed_opacity;
+   double now_opacity;
+   double remain;
 
transition = get_transition_from_type_and_id(
IVI_LAYOUT_TRANSITION_LAYER_FADE,
@@ -858,7 +858,6 @@ ivi_layout_transition_fade_layer(
/* FIXME */
fixed_opacity = layer->prop.opacity;
now_opacity = wl_fixed_to_double(fixed_opacity);
-   remain = 0.0;
 
data->is_fade_in = is_fade_in;
data->start_alpha = now_opacity;
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 0/7] Fix source code analyzer findings

2018-03-20 Thread Emre Ucan
These patches fix some of the findings which are found by
clang source code analyzer.

Emre Ucan (7):
  compositor-drm: remove superfluos get_disable_state call
  compositor-drm: remove dead assigment in drm_fb_create_dumb
  hmi-controller: remove dead assignments in add_launchers
  input: fix use-after-free issue at pointer_cancel
  gl-renderer: set num_images after import_simple_dmabuf
  compositor: initialize ret in repaint_timer_handler
  ivi-shell: remove dead assignments in layer transition

 ivi-shell/hmi-controller.c|  4 
 ivi-shell/ivi-layout-transition.c |  9 -
 libweston/compositor-drm.c|  3 ---
 libweston/compositor.c|  2 +-
 libweston/gl-renderer.c   |  1 +
 libweston/input.c | 12 
 6 files changed, 6 insertions(+), 25 deletions(-)

-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/7] input: fix use-after-free issue at pointer_cancel

2018-03-20 Thread Emre Ucan
If the constraint is an one-shot constraint, constraint
is freed in disable_pointer_constraint function.
Therefore, we should not try to read freed memory at
"switch (constraint->lifetime)" statement.

The removed code is anyway superfluous. Because
surface destroy signal is only removed, when constraint
is an one-shot constraint.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 libweston/input.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/libweston/input.c b/libweston/input.c
index 3e91c26..a9d21cb 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -4577,18 +4577,6 @@ confined_pointer_grab_pointer_cancel(struct 
weston_pointer_grab *grab)
container_of(grab, struct weston_pointer_constraint, grab);
 
disable_pointer_constraint(constraint);
-
-   /* If this is a persistent constraint, re-add the surface destroy signal
-* listener only if we are currently not destroying the surface. */
-   switch (constraint->lifetime) {
-   case ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT:
-   if (constraint->surface->resource)
-   wl_signal_add(>surface->destroy_signal,
- >surface_destroy_listener);
-   break;
-   case ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT:
-   break;
-   }
 }
 
 static const struct weston_pointer_grab_interface
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/7] hmi-controller: remove dead assignments in add_launchers

2018-03-20 Thread Emre Ucan
assigned values of x, y, ret and layout_surface are
never read.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/hmi-controller.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index b13936f..0e44df8 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -1184,10 +1184,6 @@ ivi_hmi_controller_add_launchers(struct hmi_controller 
*hmi_ctrl,
  compare_launcher_info);
 
wl_array_for_each(data, ) {
-   x = 0;
-   y = 0;
-   ret = 0;
-   layout_surface = NULL;
add_surface_id = wl_array_add(_ctrl->ui_widgets,
  sizeof(*add_surface_id));
 
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/7] compositor-drm: remove superfluos get_disable_state call

2018-03-20 Thread Emre Ucan
drm_output_get_disable_state function returns
a duplicated output_state object.

Here we are creating the object, but we are
never using it. Therefore, it is safe to remove.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 libweston/compositor-drm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 81ca67d..f8c13ee 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -3860,7 +3860,6 @@ drm_set_dpms(struct weston_output *output_base, enum 
dpms_enum level)
state = drm_pending_state_get_output(pending_state, output);
if (state)
drm_output_state_free(state);
-   state = drm_output_get_disable_state(pending_state, output);
return;
}
 
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 2/7] compositor-drm: remove dead assigment in drm_fb_create_dumb

2018-03-20 Thread Emre Ucan
ret is overwritten by drmModeAddFB2 call

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 libweston/compositor-drm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index f8c13ee..506ded5 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -891,8 +891,6 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int 
height,
fb->height = height;
fb->fd = b->drm.fd;
 
-   ret = -1;
-
handles[0] = fb->handle;
pitches[0] = fb->stride;
offsets[0] = 0;
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] tests: fix a race condition in ivi-shell tests

2018-02-14 Thread Emre Ucan
ivi-shell tests load their own controller plugin
for testing purposes. Tests also uses the generated
weston-ivi.in config file, which causes weston to
load hmi-controller and its helper client.
Existence of hmi-controller and its helper client
confuses test plugins. Because they are creating
surfaces and layers which are not expected by
test plugins.

We can start ivi-shell tests without config file
to solve this problem. Then, weston will not load
hmi-controller plugin.

Reported-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 Makefile.am| 16 +---
 tests/weston-tests-env |  4 ++--
 2 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 32c9a0f..c534c56 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,15 +30,6 @@ ivi-shell/weston.ini : $(srcdir)/ivi-shell/weston.ini.in
-e 's|@plugin_prefix[@]||g' \
$< > $@
 
-tests/weston-ivi.ini : $(srcdir)/ivi-shell/weston.ini.in
-   $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
-   -e 's|@bindir[@]|$(bindir)|g' \
-   -e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
-   -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
-   -e 's|@libexecdir[@]|$(abs_builddir)|g' \
-   -e 's|@plugin_prefix[@]|$(abs_top_builddir)/.libs/|g' \
-   $< > $@
-
 all-local : weston.ini ivi-shell/weston.ini
 
 AM_CFLAGS = $(GCC_CFLAGS)
@@ -56,7 +47,6 @@ AM_CPPFLAGS = \
 
 CLEANFILES = weston.ini\
ivi-shell/weston.ini\
-   tests/weston-ivi.ini\
internal-screenshot-00.png  \
$(BUILT_SOURCES)
 
@@ -1238,10 +1228,6 @@ weston_tests =   \
devices.weston  \
touch.weston
 
-ivi_tests =
-
-$(ivi_tests) : $(builddir)/tests/weston-ivi.ini
-
 AM_TESTS_ENVIRONMENT = \
abs_builddir='$(abs_builddir)'; export abs_builddir; \
abs_top_srcdir='$(abs_top_srcdir)'; export abs_top_srcdir;
@@ -1472,7 +1458,7 @@ nodist_ivi_layout_test_la_SOURCES =   \
protocol/weston-test-protocol.c \
protocol/weston-test-server-protocol.h
 
-ivi_tests +=   \
+ivi_tests =\
ivi-shell-app.weston
 
 ivi_shell_app_weston_SOURCES = tests/ivi-shell-app-test.c
diff --git a/tests/weston-tests-env b/tests/weston-tests-env
index f08270e..ac2473f 100755
--- a/tests/weston-tests-env
+++ b/tests/weston-tests-env
@@ -44,7 +44,7 @@ case $TEST_FILE in
WESTON_BUILD_DIR=$abs_builddir \
WESTON_TEST_REFERENCE_PATH=$abs_top_srcdir/tests/reference \
$WESTON --backend=$MODDIR/$BACKEND \
-   --config=$abs_builddir/tests/weston-ivi.ini \
+   --no-config \
--shell=$SHELL_PLUGIN \
--socket=test-${TEST_NAME} \
--modules=$TEST_PLUGIN,$MODDIR/${TEST_FILE/.la/.so}\
@@ -74,7 +74,7 @@ case $TEST_FILE in
WESTON_TEST_REFERENCE_PATH=$abs_top_srcdir/tests/reference \
WESTON_TEST_CLIENT_PATH=$abs_builddir/$TEST_FILE \
$WESTON --backend=$MODDIR/$BACKEND \
-   --config=$abs_builddir/tests/weston-ivi.ini \
+   --no-config \
--shell=$SHELL_PLUGIN \
--socket=test-${TEST_NAME} \
--modules=$TEST_PLUGIN \
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/4] ivi-shell: fix the layer assignment change from one screen to another

2018-01-26 Thread Emre Ucan
if the layer is in order of some screen we need to remove it
from there and mark the screen order as dirty so it will be removed
in commit_screen_list call later
layer should only be assigned to one screen at a time

Signed-off-by: Eugen Friedrich <efriedr...@de.adit-jv.com>
Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 4799c25..976a426 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -1535,6 +1535,11 @@ ivi_layout_screen_add_layer(struct weston_output *output,
 
iviscrn = get_screen_from_output(output);
 
+   /*if layer is already assigned to screen make order of it dirty
+* we are going to remove it (in commit_screen_list)*/
+   if (addlayer->on_screen)
+   addlayer->on_screen->order.dirty = 1;
+
wl_list_remove(>pending.link);
wl_list_insert(>pending.layer_list, >pending.link);
 
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/4] ivi-shell: don't expilicitly assign outputs to views

2018-01-26 Thread Emre Ucan
it is assigned in weston_view_assign_outputs

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 3c52ce1..4799c25 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -821,10 +821,6 @@ commit_screen_list(struct ivi_layout *layout)
 

weston_layer_entry_insert(>layout_layer.view_list,
  
_view->view->layer_link);
-
-   ivi_view->view->output = iviscrn->output;
-   ivi_view->ivisurf->surface->is_mapped = true;
-   ivi_view->view->is_mapped = true;
}
}
}
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/4] ivi-shell: change layer visibility to bool

2018-01-26 Thread Emre Ucan
ivi_layout_layer_set_visibility has bool
as argument.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout-export.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index 277ac59..f656602 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -101,7 +101,7 @@ struct ivi_layout_layer_properties
int32_t dest_width;
int32_t dest_height;
enum wl_output_transform orientation;
-   uint32_t visibility;
+   bool visibility;
int32_t transition_type;
uint32_t transition_duration;
double start_alpha;
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 6/6] ivi-shell: remove ivi_shell_setting

2018-01-25 Thread Emre Ucan
it has only developermode option parameter.
The parameter is only used in init_ivi_shell.
Therefore, we can basically remove the struct,
and check the option locally in the function.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
---
 ivi-shell/ivi-shell.c | 42 --
 1 file changed, 12 insertions(+), 30 deletions(-)

diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index ebca2fc..51e13a0 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -67,11 +67,6 @@ struct ivi_shell_surface
struct wl_list link;
 };
 
-struct ivi_shell_setting
-{
-   int developermode;
-};
-
 /*
  * Implementation of ivi_surface
  */
@@ -384,16 +379,24 @@ terminate_binding(struct weston_keyboard *keyboard, const 
struct timespec *time,
 }
 
 static void
-init_ivi_shell(struct weston_compositor *compositor, struct ivi_shell *shell,
-  const struct ivi_shell_setting *setting)
+init_ivi_shell(struct weston_compositor *compositor, struct ivi_shell *shell)
 {
+   struct weston_config *config = wet_get_config(compositor);
+   struct weston_config_section *section;
+   int developermode;
+
shell->compositor = compositor;
 
wl_list_init(>ivi_surface_list);
 
weston_layer_init(>input_panel_layer, compositor);
 
-   if (setting->developermode) {
+   section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
+
+   weston_config_section_get_bool(section, "developermode",
+  , 0);
+
+   if (developermode) {
weston_install_debug_key_binding(compositor, MODIFIER_SUPER);
 
weston_compositor_add_key_binding(compositor, KEY_BACKSPACE,
@@ -403,23 +406,6 @@ init_ivi_shell(struct weston_compositor *compositor, 
struct ivi_shell *shell,
}
 }
 
-static int
-ivi_shell_setting_create(struct ivi_shell_setting *dest,
-struct weston_compositor *compositor,
-int *argc, char *argv[])
-{
-   int result = 0;
-   struct weston_config *config = wet_get_config(compositor);
-   struct weston_config_section *section;
-
-   section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
-
-   weston_config_section_get_bool(section, "developermode",
-  >developermode, 0);
-
-   return result;
-}
-
 static void
 activate_binding(struct weston_seat *seat,
 struct weston_view *focus_view)
@@ -483,17 +469,13 @@ wet_shell_init(struct weston_compositor *compositor,
   int *argc, char *argv[])
 {
struct ivi_shell *shell;
-   struct ivi_shell_setting setting = { };
int retval = -1;
 
shell = zalloc(sizeof *shell);
if (shell == NULL)
return -1;
 
-   if (ivi_shell_setting_create(, compositor, argc, argv) != 0)
-   return -1;
-
-   init_ivi_shell(compositor, shell, );
+   init_ivi_shell(compositor, shell);
 
shell->destroy_listener.notify = shell_destroy;
wl_signal_add(>destroy_signal, >destroy_listener);
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 1/6] ivi-shell: register ivi_layout_interface

2018-01-25 Thread Emre Ucan
Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
Acked-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
---
 ivi-shell/ivi-layout-export.h | 13 +
 ivi-shell/ivi-layout.c|  6 ++
 ivi-shell/ivi-shell.c |  2 --
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index 277ac59..c15c7f8 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -59,6 +59,7 @@ extern "C" {
 
 #include "stdbool.h"
 #include "compositor.h"
+#include "plugin-registry.h"
 
 #define IVI_SUCCEEDED (0)
 #define IVI_FAILED (-1)
@@ -140,6 +141,8 @@ enum ivi_layout_transition_type{
IVI_LAYOUT_TRANSITION_MAX,
 };
 
+#define IVI_LAYOUT_API_NAME "ivi_layout_api_v1"
+
 struct ivi_layout_interface {
 
/**
@@ -572,6 +575,16 @@ struct ivi_layout_interface {
   struct ivi_layout_layer *removelayer);
 };
 
+static inline const struct ivi_layout_interface *
+ivi_layout_get_api(struct weston_compositor *compositor)
+{
+   const void *api;
+   api = weston_plugin_api_get(compositor, IVI_LAYOUT_API_NAME,
+   sizeof(struct ivi_layout_interface));
+
+   return (const struct ivi_layout_interface *)api;
+}
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 394179b..a11b658 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -1906,6 +1906,8 @@ ivi_layout_surface_create(struct weston_surface 
*wl_surface,
return ivisurf;
 }
 
+static struct ivi_layout_interface ivi_layout_interface;
+
 void
 ivi_layout_init_with_compositor(struct weston_compositor *ec)
 {
@@ -1934,6 +1936,10 @@ ivi_layout_init_with_compositor(struct weston_compositor 
*ec)
 
layout->transitions = ivi_layout_transition_set_create(ec);
wl_list_init(>pending_transition_list);
+
+   weston_plugin_api_register(ec, IVI_LAYOUT_API_NAME,
+  _layout_interface,
+  sizeof(struct ivi_layout_interface));
 }
 
 static struct ivi_layout_interface ivi_layout_interface = {
diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index 766a1fd..c096954 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -425,8 +425,6 @@ ivi_shell_setting_create(struct ivi_shell_setting *dest,
if (!dest->ivi_module &&
weston_config_section_get_string(section, "ivi-module",
 >ivi_module, NULL) < 0) {
-   weston_log("Error: ivi-shell: No ivi-module set\n");
-   result = -1;
}
 
weston_config_section_get_bool(section, "developermode",
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 5/6] ivi-shell: don't load controller modules

2018-01-25 Thread Emre Ucan
controller modules can be loaded as weston modules
from the main function of weston.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
---
 ivi-shell/ivi-layout.c | 40 
 ivi-shell/ivi-shell.c  | 28 
 2 files changed, 4 insertions(+), 64 deletions(-)

diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index a11b658..f9a83ab 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -2012,43 +2012,3 @@ static struct ivi_layout_interface ivi_layout_interface 
= {
.surface_get_size   = ivi_layout_surface_get_size,
.surface_dump   = ivi_layout_surface_dump,
 };
-
-int
-load_controller_modules(struct weston_compositor *compositor, const char 
*modules,
-   int *argc, char *argv[])
-{
-   const char *p, *end;
-   char buffer[256];
-   int (*controller_module_init)(struct weston_compositor *compositor,
- int *argc, char *argv[],
- const struct ivi_layout_interface 
*interface,
- size_t interface_version);
-
-   if (modules == NULL)
-   return 0;
-
-   p = modules;
-   while (*p) {
-   end = strchrnul(p, ',');
-   snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
-
-   controller_module_init =
-   wet_load_module_entrypoint(buffer,
-  "controller_module_init");
-   if (!controller_module_init)
-   return -1;
-
-   if (controller_module_init(compositor, argc, argv,
-  _layout_interface,
-   sizeof(struct ivi_layout_interface)) != 0) {
-   weston_log("ivi-shell: Initialization of controller 
module fails");
-   return -1;
-   }
-
-   p = end;
-   while (*p == ',')
-   p++;
-   }
-
-   return 0;
-}
diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index c096954..ebca2fc 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -69,7 +69,6 @@ struct ivi_shell_surface
 
 struct ivi_shell_setting
 {
-   char *ivi_module;
int developermode;
 };
 
@@ -413,20 +412,8 @@ ivi_shell_setting_create(struct ivi_shell_setting *dest,
struct weston_config *config = wet_get_config(compositor);
struct weston_config_section *section;
 
-   const struct weston_option ivi_shell_options[] = {
-   { WESTON_OPTION_STRING, "ivi-module", 0, >ivi_module },
-   };
-
-   parse_options(ivi_shell_options, ARRAY_LENGTH(ivi_shell_options),
- argc, argv);
-
section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
 
-   if (!dest->ivi_module &&
-   weston_config_section_get_string(section, "ivi-module",
->ivi_module, NULL) < 0) {
-   }
-
weston_config_section_get_bool(section, "developermode",
   >developermode, 0);
 
@@ -512,29 +499,22 @@ wet_shell_init(struct weston_compositor *compositor,
wl_signal_add(>destroy_signal, >destroy_listener);
 
if (input_panel_setup(shell) < 0)
-   goto out_settings;
+   goto out;
 
shell->text_backend = text_backend_init(compositor);
if (!shell->text_backend)
-   goto out_settings;
+   goto out;
 
if (wl_global_create(compositor->wl_display,
 _application_interface, 1,
 shell, bind_ivi_application) == NULL)
-   goto out_settings;
+   goto out;
 
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,
-   argc, argv) < 0)
-   goto out_settings;
-
retval = 0;
 
-out_settings:
-   free(setting.ivi_module);
-
+out:
return retval;
 }
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 4/6] tests: load ivi-shell test plugins as weston module

2018-01-25 Thread Emre Ucan
It is better to load ivi controller modules as a
generic weston module. Then, we do not need to
have a specific ivi way of loading modules.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 tests/ivi_layout-internal-test.c | 21 -
 tests/ivi_layout-test-plugin.c   | 20 +++-
 tests/weston-tests-env   |  3 +--
 3 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/tests/ivi_layout-internal-test.c b/tests/ivi_layout-internal-test.c
index 4d73eff..1054d97 100644
--- a/tests/ivi_layout-internal-test.c
+++ b/tests/ivi_layout-internal-test.c
@@ -33,6 +33,7 @@
 #include 
 
 #include "compositor.h"
+#include "compositor/weston.h"
 #include "ivi-shell/ivi-layout-export.h"
 #include "ivi-shell/ivi-layout-private.h"
 #include "ivi-test.h"
@@ -991,24 +992,18 @@ run_internal_tests(void *data)
free(ctx);
 }
 
-int
-controller_module_init(struct weston_compositor *compositor,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *iface,
-  size_t iface_version);
-
 WL_EXPORT int
-controller_module_init(struct weston_compositor *compositor,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *iface,
-  size_t iface_version)
+wet_module_init(struct weston_compositor *compositor,
+  int *argc, char *argv[])
 {
struct wl_event_loop *loop;
struct test_context *ctx;
+   const struct ivi_layout_interface *iface;
+
+   iface = ivi_layout_get_api(compositor);
 
-   /* strict check, since this is an internal test module */
-   if (iface_version != sizeof(*iface)) {
-   weston_log("fatal: controller interface mismatch\n");
+   if (!iface) {
+   weston_log("fatal: cannot use ivi_layout_interface.\n");
return -1;
}
 
diff --git a/tests/ivi_layout-test-plugin.c b/tests/ivi_layout-test-plugin.c
index 19eab81..1f19c55 100644
--- a/tests/ivi_layout-test-plugin.c
+++ b/tests/ivi_layout-test-plugin.c
@@ -217,25 +217,19 @@ idle_launch_client(void *data)
weston_watch_process(>process);
 }
 
-int
-controller_module_init(struct weston_compositor *compositor,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *iface,
-  size_t iface_version);
-
 WL_EXPORT int
-controller_module_init(struct weston_compositor *compositor,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *iface,
-  size_t iface_version)
+wet_module_init(struct weston_compositor *compositor,
+  int *argc, char *argv[])
 {
struct wl_event_loop *loop;
struct test_launcher *launcher;
const char *path;
+   const struct ivi_layout_interface *iface;
+
+   iface = ivi_layout_get_api(compositor);
 
-   /* strict check, since this is an internal test module */
-   if (iface_version != sizeof(*iface)) {
-   weston_log("fatal: controller interface mismatch\n");
+   if (!iface) {
+   weston_log("fatal: cannot use ivi_layout_interface.\n");
return -1;
}
 
diff --git a/tests/weston-tests-env b/tests/weston-tests-env
index 6da0696..9c321a1 100755
--- a/tests/weston-tests-env
+++ b/tests/weston-tests-env
@@ -46,8 +46,7 @@ case $TEST_FILE in
--config=$abs_builddir/tests/weston-ivi.ini \
--shell=$SHELL_PLUGIN \
--socket=test-${TEST_NAME} \
-   --modules=$TEST_PLUGIN \
-   --ivi-module=$MODDIR/${TEST_FILE/.la/.so} \
+   --modules=$TEST_PLUGIN,$MODDIR/${TEST_FILE/.la/.so}\
--log="$SERVERLOG" \
&> "$OUTLOG"
;;
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 3/6] hmi-controller: load as weston module

2018-01-25 Thread Emre Ucan
weston loads hmi-controller as a weston module.
IVI-shell does not need to load it explicitly.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
---
 ivi-shell/hmi-controller.c | 36 
 ivi-shell/weston.ini.in|  2 +-
 2 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 34abc11..b13936f 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -148,12 +148,6 @@ struct launcher_info {
int32_t index;
 };
 
-int
-controller_module_init(struct weston_compositor *ec,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *interface,
-  size_t interface_version);
-
 /*
  *  local functions
  /
@@ -766,17 +760,26 @@ hmi_controller_destroy(struct wl_listener *listener, void 
*data)
  * ivi_hmi_controller_home is requested.
  */
 static struct hmi_controller *
-hmi_controller_create(struct weston_compositor *ec,
- const struct ivi_layout_interface *interface)
+hmi_controller_create(struct weston_compositor *ec)
 {
struct link_layer *tmp_link_layer = NULL;
int32_t panel_height = 0;
-   struct hmi_controller *hmi_ctrl = MEM_ALLOC(sizeof(*hmi_ctrl));
+   struct hmi_controller *hmi_ctrl;
+   const struct ivi_layout_interface *interface;
struct hmi_controller_layer *base_layer = NULL;
struct hmi_controller_layer *application_layer = NULL;
struct weston_output *output;
+   int32_t i;
 
-   int32_t i = 0;
+   interface = ivi_layout_get_api(ec);
+
+   if (!interface) {
+   weston_log("Cannot use ivi_layout_interface.\n");
+   return NULL;
+   }
+
+   hmi_ctrl = MEM_ALLOC(sizeof(*hmi_ctrl));
+   i = 0;
 
wl_array_init(_ctrl->ui_widgets);
hmi_ctrl->layout_mode = IVI_HMI_CONTROLLER_LAYOUT_MODE_TILING;
@@ -1954,20 +1957,13 @@ launch_hmi_client_process(void *data)
  *  exported functions
  /
 WL_EXPORT int
-controller_module_init(struct weston_compositor *ec,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *interface,
-  size_t interface_version)
+wet_module_init(struct weston_compositor *ec,
+  int *argc, char *argv[])
 {
struct hmi_controller *hmi_ctrl = NULL;
struct wl_event_loop *loop = NULL;
 
-   if (interface_version < sizeof(struct ivi_layout_interface)) {
-   weston_log("ivi-shell: version mismatch of controller 
interface\n");
-   return -1;
-   }
-
-   hmi_ctrl = hmi_controller_create(ec, interface);
+   hmi_ctrl = hmi_controller_create(ec);
if (hmi_ctrl == NULL)
return -1;
 
diff --git a/ivi-shell/weston.ini.in b/ivi-shell/weston.ini.in
index 9b53691..3f11e1c 100644
--- a/ivi-shell/weston.ini.in
+++ b/ivi-shell/weston.ini.in
@@ -1,8 +1,8 @@
 [core]
 shell=@plugin_pre...@ivi-shell.so
+modules=@plugin_pre...@hmi-controller.so
 
 [ivi-shell]
-ivi-module=@plugin_pre...@hmi-controller.so
 ivi-shell-user-interface=@abs_top_builddir@/weston-ivi-shell-user-interface
 
 #developermode=true
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 2/6] hmi-controller: remove ivi_layout_interface global

2018-01-25 Thread Emre Ucan
Put the interface into hmi_controller struct.
It is better to have it in an object.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
---
 ivi-shell/hmi-controller.c | 194 +++--
 1 file changed, 100 insertions(+), 94 deletions(-)

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 5a2ff78..34abc11 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -138,6 +138,8 @@ struct hmi_controller {
 
struct weston_output * workspace_background_output;
int32_t screen_num;
+
+   const struct ivi_layout_interface *interface;
 };
 
 struct launcher_info {
@@ -146,8 +148,6 @@ struct launcher_info {
int32_t index;
 };
 
-const struct ivi_layout_interface *ivi_layout_interface;
-
 int
 controller_module_init(struct weston_compositor *ec,
   int *argc, char *argv[],
@@ -169,7 +169,7 @@ static int32_t
 is_surf_in_ui_widget(struct hmi_controller *hmi_ctrl,
 struct ivi_layout_surface *ivisurf)
 {
-   uint32_t id = ivi_layout_interface->get_id_of_surface(ivisurf);
+   uint32_t id = hmi_ctrl->interface->get_id_of_surface(ivisurf);
 
uint32_t *ui_widget_id = NULL;
wl_array_for_each(ui_widget_id, _ctrl->ui_widgets) {
@@ -259,24 +259,24 @@ mode_divided_into_tiling(struct hmi_controller *hmi_ctrl,
surface_y = (int32_t)surface_height;
}
 
-   ivi_layout_interface->surface_set_transition(ivisurf,
+   hmi_ctrl->interface->surface_set_transition(ivisurf,
IVI_LAYOUT_TRANSITION_VIEW_DEFAULT,
duration);
-   ivi_layout_interface->surface_set_visibility(ivisurf, 
true);
-   
ivi_layout_interface->surface_set_destination_rectangle(ivisurf,
+   hmi_ctrl->interface->surface_set_visibility(ivisurf, 
true);
+   
hmi_ctrl->interface->surface_set_destination_rectangle(ivisurf,
surface_x, surface_y,
(int32_t)surface_width,
(int32_t)surface_height);
 
}
-   ivi_layout_interface->layer_set_render_order(ivilayer, 
new_order, i);
+   hmi_ctrl->interface->layer_set_render_order(ivilayer, 
new_order, i);
 
-   ivi_layout_interface->layer_set_transition(ivilayer,
+   hmi_ctrl->interface->layer_set_transition(ivilayer,
IVI_LAYOUT_TRANSITION_LAYER_VIEW_ORDER,
duration);
}
for (i = idx; i < surf_num; i++)
-   ivi_layout_interface->surface_set_visibility(surfaces[i], 
false);
+   hmi_ctrl->interface->surface_set_visibility(surfaces[i], false);
 
free(surfaces);
free(new_order);
@@ -327,24 +327,24 @@ mode_divided_into_sidebyside(struct hmi_controller 
*hmi_ctrl,
ivisurf = surfaces[idx];
new_order[i] = ivisurf;
 
-   ivi_layout_interface->surface_set_transition(ivisurf,
+   hmi_ctrl->interface->surface_set_transition(ivisurf,
IVI_LAYOUT_TRANSITION_VIEW_DEFAULT,
duration);
-   ivi_layout_interface->surface_set_visibility(ivisurf, 
true);
+   hmi_ctrl->interface->surface_set_visibility(ivisurf, 
true);
 
-   
ivi_layout_interface->surface_set_destination_rectangle(ivisurf,
+   
hmi_ctrl->interface->surface_set_destination_rectangle(ivisurf,
i * 
surface_width, 0,
surface_width,
surface_height);
}
-   ivi_layout_interface->layer_set_render_order(ivilayer, 
new_order, i);
+   hmi_ctrl->interface->layer_set_render_order(ivilayer, 
new_order, i);
}
 
for (i = idx; i < surf_num; i++) {
-   ivi_layout_interface->surface_set_transition(surfaces[i],
+   hmi_ctrl->interface->surface_set_transition(surfaces[i],

IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY,
duration);
-   ivi_layout_interface->surface_set_visibility(surfaces[i], 
false);
+   hmi_ctrl->interface->surface_set_visibil

[PATCH] dmabuf: set modifier to invalid for not supporting clients

2018-01-09 Thread Emre Ucan
modifier_hi and modifier_lo are set to 0 by clients,
which are not supporting modifiers. Modifier attributes
of buffers of these clients set to 0 too in linux-dmabuf.c

import_simple_dmabuf function in gl-renderer.c compares
modifier attribute of the buffer with DRM_FORMAT_MOD_INVALID.
DRM_FORMAT_MOD_INVALID is equal to ((1ULL<<56) - 1).
Therefore, modifer 0 is accepted as valid. Then, the function
checks support for eglQueryDmaBufModifiersEXT.
If it is not supported import_simple_dmabuf function is returning
NULL.

This patch sets the modifier attribute to DRM_FORMAT_MOD_INVALID
for clients which are not supporting modifiers. Without this patch
linux-dmabuf protocol is not working for not supporting clients.

Fixes: b138d7afb3a2a7d51dccb12f08d70c2d86766901 ("gl-renderer: Ignore INVALID 
modifier")
Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 libweston/gl-renderer.c  | 2 +-
 libweston/linux-dmabuf.c | 9 +++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index abf556f..84a2cda 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -2156,7 +2156,7 @@ gl_renderer_import_dmabuf(struct weston_compositor *ec,
 
for (i = 0; i < dmabuf->attributes.n_planes; i++) {
/* return if EGL doesn't support import modifiers */
-   if (dmabuf->attributes.modifier[i] != 0)
+   if (dmabuf->attributes.modifier[i] != DRM_FORMAT_MOD_INVALID)
if (!gr->has_dmabuf_import_modifiers)
return false;
 
diff --git a/libweston/linux-dmabuf.c b/libweston/linux-dmabuf.c
index d81b63d..5970584 100644
--- a/libweston/linux-dmabuf.c
+++ b/libweston/linux-dmabuf.c
@@ -111,8 +111,13 @@ params_add(struct wl_client *client,
buffer->attributes.fd[plane_idx] = name_fd;
buffer->attributes.offset[plane_idx] = offset;
buffer->attributes.stride[plane_idx] = stride;
-   buffer->attributes.modifier[plane_idx] = ((uint64_t)modifier_hi << 32) |
-modifier_lo;
+
+   if (wl_resource_get_version(params_resource) < 
ZWP_LINUX_DMABUF_V1_MODIFIER_SINCE_VERSION)
+   buffer->attributes.modifier[plane_idx] = DRM_FORMAT_MOD_INVALID;
+   else
+   buffer->attributes.modifier[plane_idx] = ((uint64_t)modifier_hi 
<< 32) |
+modifier_lo;
+
buffer->attributes.n_planes++;
 }
 
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 6/6] ivi-shell: remove ivi_shell_setting

2018-01-03 Thread Emre Ucan
it has only developermode option parameter.
The parameter is only used in init_ivi_shell.
Therefore, we can basically remove the struct,
and check the option locally in the function.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-shell.c | 42 --
 1 file changed, 12 insertions(+), 30 deletions(-)

diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index ebca2fc..51e13a0 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -67,11 +67,6 @@ struct ivi_shell_surface
struct wl_list link;
 };
 
-struct ivi_shell_setting
-{
-   int developermode;
-};
-
 /*
  * Implementation of ivi_surface
  */
@@ -384,16 +379,24 @@ terminate_binding(struct weston_keyboard *keyboard, const 
struct timespec *time,
 }
 
 static void
-init_ivi_shell(struct weston_compositor *compositor, struct ivi_shell *shell,
-  const struct ivi_shell_setting *setting)
+init_ivi_shell(struct weston_compositor *compositor, struct ivi_shell *shell)
 {
+   struct weston_config *config = wet_get_config(compositor);
+   struct weston_config_section *section;
+   int developermode;
+
shell->compositor = compositor;
 
wl_list_init(>ivi_surface_list);
 
weston_layer_init(>input_panel_layer, compositor);
 
-   if (setting->developermode) {
+   section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
+
+   weston_config_section_get_bool(section, "developermode",
+  , 0);
+
+   if (developermode) {
weston_install_debug_key_binding(compositor, MODIFIER_SUPER);
 
weston_compositor_add_key_binding(compositor, KEY_BACKSPACE,
@@ -403,23 +406,6 @@ init_ivi_shell(struct weston_compositor *compositor, 
struct ivi_shell *shell,
}
 }
 
-static int
-ivi_shell_setting_create(struct ivi_shell_setting *dest,
-struct weston_compositor *compositor,
-int *argc, char *argv[])
-{
-   int result = 0;
-   struct weston_config *config = wet_get_config(compositor);
-   struct weston_config_section *section;
-
-   section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
-
-   weston_config_section_get_bool(section, "developermode",
-  >developermode, 0);
-
-   return result;
-}
-
 static void
 activate_binding(struct weston_seat *seat,
 struct weston_view *focus_view)
@@ -483,17 +469,13 @@ wet_shell_init(struct weston_compositor *compositor,
   int *argc, char *argv[])
 {
struct ivi_shell *shell;
-   struct ivi_shell_setting setting = { };
int retval = -1;
 
shell = zalloc(sizeof *shell);
if (shell == NULL)
return -1;
 
-   if (ivi_shell_setting_create(, compositor, argc, argv) != 0)
-   return -1;
-
-   init_ivi_shell(compositor, shell, );
+   init_ivi_shell(compositor, shell);
 
shell->destroy_listener.notify = shell_destroy;
wl_signal_add(>destroy_signal, >destroy_listener);
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/6] ivi-shell: don't load controller modules

2018-01-03 Thread Emre Ucan
controller modules can be loaded as weston modules
from the main function of weston.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout.c | 40 
 ivi-shell/ivi-shell.c  | 28 
 2 files changed, 4 insertions(+), 64 deletions(-)

diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index a11b658..f9a83ab 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -2012,43 +2012,3 @@ static struct ivi_layout_interface ivi_layout_interface 
= {
.surface_get_size   = ivi_layout_surface_get_size,
.surface_dump   = ivi_layout_surface_dump,
 };
-
-int
-load_controller_modules(struct weston_compositor *compositor, const char 
*modules,
-   int *argc, char *argv[])
-{
-   const char *p, *end;
-   char buffer[256];
-   int (*controller_module_init)(struct weston_compositor *compositor,
- int *argc, char *argv[],
- const struct ivi_layout_interface 
*interface,
- size_t interface_version);
-
-   if (modules == NULL)
-   return 0;
-
-   p = modules;
-   while (*p) {
-   end = strchrnul(p, ',');
-   snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
-
-   controller_module_init =
-   wet_load_module_entrypoint(buffer,
-  "controller_module_init");
-   if (!controller_module_init)
-   return -1;
-
-   if (controller_module_init(compositor, argc, argv,
-  _layout_interface,
-   sizeof(struct ivi_layout_interface)) != 0) {
-   weston_log("ivi-shell: Initialization of controller 
module fails");
-   return -1;
-   }
-
-   p = end;
-   while (*p == ',')
-   p++;
-   }
-
-   return 0;
-}
diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index c096954..ebca2fc 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -69,7 +69,6 @@ struct ivi_shell_surface
 
 struct ivi_shell_setting
 {
-   char *ivi_module;
int developermode;
 };
 
@@ -413,20 +412,8 @@ ivi_shell_setting_create(struct ivi_shell_setting *dest,
struct weston_config *config = wet_get_config(compositor);
struct weston_config_section *section;
 
-   const struct weston_option ivi_shell_options[] = {
-   { WESTON_OPTION_STRING, "ivi-module", 0, >ivi_module },
-   };
-
-   parse_options(ivi_shell_options, ARRAY_LENGTH(ivi_shell_options),
- argc, argv);
-
section = weston_config_get_section(config, "ivi-shell", NULL, NULL);
 
-   if (!dest->ivi_module &&
-   weston_config_section_get_string(section, "ivi-module",
->ivi_module, NULL) < 0) {
-   }
-
weston_config_section_get_bool(section, "developermode",
   >developermode, 0);
 
@@ -512,29 +499,22 @@ wet_shell_init(struct weston_compositor *compositor,
wl_signal_add(>destroy_signal, >destroy_listener);
 
if (input_panel_setup(shell) < 0)
-   goto out_settings;
+   goto out;
 
shell->text_backend = text_backend_init(compositor);
if (!shell->text_backend)
-   goto out_settings;
+   goto out;
 
if (wl_global_create(compositor->wl_display,
 _application_interface, 1,
 shell, bind_ivi_application) == NULL)
-   goto out_settings;
+   goto out;
 
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,
-   argc, argv) < 0)
-   goto out_settings;
-
retval = 0;
 
-out_settings:
-   free(setting.ivi_module);
-
+out:
return retval;
 }
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/6] hmi-controller: load as weston module

2018-01-03 Thread Emre Ucan
weston loads hmi-controller as a weston module.
IVI-shell does not need to load it explicitly.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/hmi-controller.c | 33 ++---
 ivi-shell/weston.ini.in|  2 +-
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 34abc11..e6dd174 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -148,12 +148,6 @@ struct launcher_info {
int32_t index;
 };
 
-int
-controller_module_init(struct weston_compositor *ec,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *interface,
-  size_t interface_version);
-
 /*
  *  local functions
  /
@@ -766,16 +760,24 @@ hmi_controller_destroy(struct wl_listener *listener, void 
*data)
  * ivi_hmi_controller_home is requested.
  */
 static struct hmi_controller *
-hmi_controller_create(struct weston_compositor *ec,
- const struct ivi_layout_interface *interface)
+hmi_controller_create(struct weston_compositor *ec)
 {
struct link_layer *tmp_link_layer = NULL;
int32_t panel_height = 0;
-   struct hmi_controller *hmi_ctrl = MEM_ALLOC(sizeof(*hmi_ctrl));
+   struct hmi_controller *hmi_ctrl;
+   const struct ivi_layout_interface *interface;
struct hmi_controller_layer *base_layer = NULL;
struct hmi_controller_layer *application_layer = NULL;
struct weston_output *output;
 
+   interface = ivi_layout_get_api(ec);
+
+   if (!interface) {
+   weston_log("Cannot use ivi_layout_interface.\n");
+   return NULL;
+   }
+
+   hmi_ctrl = MEM_ALLOC(sizeof(*hmi_ctrl));
int32_t i = 0;
 
wl_array_init(_ctrl->ui_widgets);
@@ -1954,20 +1956,13 @@ launch_hmi_client_process(void *data)
  *  exported functions
  /
 WL_EXPORT int
-controller_module_init(struct weston_compositor *ec,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *interface,
-  size_t interface_version)
+wet_module_init(struct weston_compositor *ec,
+  int *argc, char *argv[])
 {
struct hmi_controller *hmi_ctrl = NULL;
struct wl_event_loop *loop = NULL;
 
-   if (interface_version < sizeof(struct ivi_layout_interface)) {
-   weston_log("ivi-shell: version mismatch of controller 
interface\n");
-   return -1;
-   }
-
-   hmi_ctrl = hmi_controller_create(ec, interface);
+   hmi_ctrl = hmi_controller_create(ec);
if (hmi_ctrl == NULL)
return -1;
 
diff --git a/ivi-shell/weston.ini.in b/ivi-shell/weston.ini.in
index 9b53691..3f11e1c 100644
--- a/ivi-shell/weston.ini.in
+++ b/ivi-shell/weston.ini.in
@@ -1,8 +1,8 @@
 [core]
 shell=@plugin_pre...@ivi-shell.so
+modules=@plugin_pre...@hmi-controller.so
 
 [ivi-shell]
-ivi-module=@plugin_pre...@hmi-controller.so
 ivi-shell-user-interface=@abs_top_builddir@/weston-ivi-shell-user-interface
 
 #developermode=true
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 0/6] Register ivi_layout_interface to Weston Plugin Registry

2018-01-03 Thread Emre Ucan
Main motivation of these patches is to be able to load controller modules
from the main function of weston as any other weston module.
The controller modules require ivi_layout_interface to interact
with ivi-shell. Therefore, the API has to be registered to
weston plugin registry.

I made also some minor clean-ups in hmi-controller and ivi-shell.

Emre Ucan (6):
  ivi-shell: register ivi_layout_interface
  hmi-controller: remove ivi_layout_interface global
  hmi-controller: load as weston module
  tests: load ivi-shell test plugins as weston module
  ivi-shell: don't load controller modules
  ivi-shell: remove ivi_shell_setting

 ivi-shell/hmi-controller.c   | 217 ---
 ivi-shell/ivi-layout-export.h|  13 +++
 ivi-shell/ivi-layout.c   |  46 ++---
 ivi-shell/ivi-shell.c|  72 +++--
 ivi-shell/weston.ini.in  |   2 +-
 tests/ivi_layout-internal-test.c |  21 ++--
 tests/ivi_layout-test-plugin.c   |  20 ++--
 7 files changed, 160 insertions(+), 231 deletions(-)

-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/6] ivi-shell: register ivi_layout_interface

2018-01-03 Thread Emre Ucan
controller modules can be loaded from the main function of weston.
They will get the ivi_layout_interface via weston plugin registry.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/ivi-layout-export.h | 13 +
 ivi-shell/ivi-layout.c|  6 ++
 ivi-shell/ivi-shell.c |  2 --
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h
index 277ac59..c15c7f8 100644
--- a/ivi-shell/ivi-layout-export.h
+++ b/ivi-shell/ivi-layout-export.h
@@ -59,6 +59,7 @@ extern "C" {
 
 #include "stdbool.h"
 #include "compositor.h"
+#include "plugin-registry.h"
 
 #define IVI_SUCCEEDED (0)
 #define IVI_FAILED (-1)
@@ -140,6 +141,8 @@ enum ivi_layout_transition_type{
IVI_LAYOUT_TRANSITION_MAX,
 };
 
+#define IVI_LAYOUT_API_NAME "ivi_layout_api_v1"
+
 struct ivi_layout_interface {
 
/**
@@ -572,6 +575,16 @@ struct ivi_layout_interface {
   struct ivi_layout_layer *removelayer);
 };
 
+static inline const struct ivi_layout_interface *
+ivi_layout_get_api(struct weston_compositor *compositor)
+{
+   const void *api;
+   api = weston_plugin_api_get(compositor, IVI_LAYOUT_API_NAME,
+   sizeof(struct ivi_layout_interface));
+
+   return (const struct ivi_layout_interface *)api;
+}
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 394179b..a11b658 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -1906,6 +1906,8 @@ ivi_layout_surface_create(struct weston_surface 
*wl_surface,
return ivisurf;
 }
 
+static struct ivi_layout_interface ivi_layout_interface;
+
 void
 ivi_layout_init_with_compositor(struct weston_compositor *ec)
 {
@@ -1934,6 +1936,10 @@ ivi_layout_init_with_compositor(struct weston_compositor 
*ec)
 
layout->transitions = ivi_layout_transition_set_create(ec);
wl_list_init(>pending_transition_list);
+
+   weston_plugin_api_register(ec, IVI_LAYOUT_API_NAME,
+  _layout_interface,
+  sizeof(struct ivi_layout_interface));
 }
 
 static struct ivi_layout_interface ivi_layout_interface = {
diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index 766a1fd..c096954 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -425,8 +425,6 @@ ivi_shell_setting_create(struct ivi_shell_setting *dest,
if (!dest->ivi_module &&
weston_config_section_get_string(section, "ivi-module",
 >ivi_module, NULL) < 0) {
-   weston_log("Error: ivi-shell: No ivi-module set\n");
-   result = -1;
}
 
weston_config_section_get_bool(section, "developermode",
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/6] tests: load ivi-shell test plugins as weston module

2018-01-03 Thread Emre Ucan
Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 tests/ivi_layout-internal-test.c | 21 -
 tests/ivi_layout-test-plugin.c   | 20 +++-
 2 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/tests/ivi_layout-internal-test.c b/tests/ivi_layout-internal-test.c
index 4d73eff..1054d97 100644
--- a/tests/ivi_layout-internal-test.c
+++ b/tests/ivi_layout-internal-test.c
@@ -33,6 +33,7 @@
 #include 
 
 #include "compositor.h"
+#include "compositor/weston.h"
 #include "ivi-shell/ivi-layout-export.h"
 #include "ivi-shell/ivi-layout-private.h"
 #include "ivi-test.h"
@@ -991,24 +992,18 @@ run_internal_tests(void *data)
free(ctx);
 }
 
-int
-controller_module_init(struct weston_compositor *compositor,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *iface,
-  size_t iface_version);
-
 WL_EXPORT int
-controller_module_init(struct weston_compositor *compositor,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *iface,
-  size_t iface_version)
+wet_module_init(struct weston_compositor *compositor,
+  int *argc, char *argv[])
 {
struct wl_event_loop *loop;
struct test_context *ctx;
+   const struct ivi_layout_interface *iface;
+
+   iface = ivi_layout_get_api(compositor);
 
-   /* strict check, since this is an internal test module */
-   if (iface_version != sizeof(*iface)) {
-   weston_log("fatal: controller interface mismatch\n");
+   if (!iface) {
+   weston_log("fatal: cannot use ivi_layout_interface.\n");
return -1;
}
 
diff --git a/tests/ivi_layout-test-plugin.c b/tests/ivi_layout-test-plugin.c
index 19eab81..1f19c55 100644
--- a/tests/ivi_layout-test-plugin.c
+++ b/tests/ivi_layout-test-plugin.c
@@ -217,25 +217,19 @@ idle_launch_client(void *data)
weston_watch_process(>process);
 }
 
-int
-controller_module_init(struct weston_compositor *compositor,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *iface,
-  size_t iface_version);
-
 WL_EXPORT int
-controller_module_init(struct weston_compositor *compositor,
-  int *argc, char *argv[],
-  const struct ivi_layout_interface *iface,
-  size_t iface_version)
+wet_module_init(struct weston_compositor *compositor,
+  int *argc, char *argv[])
 {
struct wl_event_loop *loop;
struct test_launcher *launcher;
const char *path;
+   const struct ivi_layout_interface *iface;
+
+   iface = ivi_layout_get_api(compositor);
 
-   /* strict check, since this is an internal test module */
-   if (iface_version != sizeof(*iface)) {
-   weston_log("fatal: controller interface mismatch\n");
+   if (!iface) {
+   weston_log("fatal: cannot use ivi_layout_interface.\n");
return -1;
}
 
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 2/6] hmi-controller: remove ivi_layout_interface global

2018-01-03 Thread Emre Ucan
Put the interface into hmi_controller struct.
It is better to have it in an object.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 ivi-shell/hmi-controller.c | 194 +++--
 1 file changed, 100 insertions(+), 94 deletions(-)

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 5a2ff78..34abc11 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -138,6 +138,8 @@ struct hmi_controller {
 
struct weston_output * workspace_background_output;
int32_t screen_num;
+
+   const struct ivi_layout_interface *interface;
 };
 
 struct launcher_info {
@@ -146,8 +148,6 @@ struct launcher_info {
int32_t index;
 };
 
-const struct ivi_layout_interface *ivi_layout_interface;
-
 int
 controller_module_init(struct weston_compositor *ec,
   int *argc, char *argv[],
@@ -169,7 +169,7 @@ static int32_t
 is_surf_in_ui_widget(struct hmi_controller *hmi_ctrl,
 struct ivi_layout_surface *ivisurf)
 {
-   uint32_t id = ivi_layout_interface->get_id_of_surface(ivisurf);
+   uint32_t id = hmi_ctrl->interface->get_id_of_surface(ivisurf);
 
uint32_t *ui_widget_id = NULL;
wl_array_for_each(ui_widget_id, _ctrl->ui_widgets) {
@@ -259,24 +259,24 @@ mode_divided_into_tiling(struct hmi_controller *hmi_ctrl,
surface_y = (int32_t)surface_height;
}
 
-   ivi_layout_interface->surface_set_transition(ivisurf,
+   hmi_ctrl->interface->surface_set_transition(ivisurf,
IVI_LAYOUT_TRANSITION_VIEW_DEFAULT,
duration);
-   ivi_layout_interface->surface_set_visibility(ivisurf, 
true);
-   
ivi_layout_interface->surface_set_destination_rectangle(ivisurf,
+   hmi_ctrl->interface->surface_set_visibility(ivisurf, 
true);
+   
hmi_ctrl->interface->surface_set_destination_rectangle(ivisurf,
surface_x, surface_y,
(int32_t)surface_width,
(int32_t)surface_height);
 
}
-   ivi_layout_interface->layer_set_render_order(ivilayer, 
new_order, i);
+   hmi_ctrl->interface->layer_set_render_order(ivilayer, 
new_order, i);
 
-   ivi_layout_interface->layer_set_transition(ivilayer,
+   hmi_ctrl->interface->layer_set_transition(ivilayer,
IVI_LAYOUT_TRANSITION_LAYER_VIEW_ORDER,
duration);
}
for (i = idx; i < surf_num; i++)
-   ivi_layout_interface->surface_set_visibility(surfaces[i], 
false);
+   hmi_ctrl->interface->surface_set_visibility(surfaces[i], false);
 
free(surfaces);
free(new_order);
@@ -327,24 +327,24 @@ mode_divided_into_sidebyside(struct hmi_controller 
*hmi_ctrl,
ivisurf = surfaces[idx];
new_order[i] = ivisurf;
 
-   ivi_layout_interface->surface_set_transition(ivisurf,
+   hmi_ctrl->interface->surface_set_transition(ivisurf,
IVI_LAYOUT_TRANSITION_VIEW_DEFAULT,
duration);
-   ivi_layout_interface->surface_set_visibility(ivisurf, 
true);
+   hmi_ctrl->interface->surface_set_visibility(ivisurf, 
true);
 
-   
ivi_layout_interface->surface_set_destination_rectangle(ivisurf,
+   
hmi_ctrl->interface->surface_set_destination_rectangle(ivisurf,
i * 
surface_width, 0,
surface_width,
surface_height);
}
-   ivi_layout_interface->layer_set_render_order(ivilayer, 
new_order, i);
+   hmi_ctrl->interface->layer_set_render_order(ivilayer, 
new_order, i);
}
 
for (i = idx; i < surf_num; i++) {
-   ivi_layout_interface->surface_set_transition(surfaces[i],
+   hmi_ctrl->interface->surface_set_transition(surfaces[i],

IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY,
duration);
-   ivi_layout_interface->surface_set_visibility(surfaces[i], 
false);
+   hmi_ctrl->interface->surface_set_visibility(surfaces[i], false);
}
 
free(surfac

[PATCH weston] launcher: don't exit when user is not root

2017-10-30 Thread Emre Ucan
weston does not need to be root.
It requires adjusting ownership on the given tty device.

If weston does not have proper rights, it will get
an error at startup anyway.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 libweston/launcher-direct.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c
index a5d3ee5..b05d214 100644
--- a/libweston/launcher-direct.c
+++ b/libweston/launcher-direct.c
@@ -276,9 +276,6 @@ launcher_direct_connect(struct weston_launcher **out, 
struct weston_compositor *
 {
struct launcher_direct *launcher;
 
-   if (geteuid() != 0)
-   return -EINVAL;
-
launcher = zalloc(sizeof(*launcher));
if (launcher == NULL)
return -ENOMEM;
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v4 6/9] xwm: dump_property() to use FILE internally

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

Write the output of dump_property() out in one log call. When multiple
processes (weston and Xwayland) are writing to the same file, this will
keep the property dump uninterrupted by Xwayland debug prints.

This is also preparation for more development in the same direction.

Signed-off-by: Pekka Paalanen 
Signed-off-by: Maniraj Devadoss 
---
 xwayland/window-manager.c | 42 +++---
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 3e8c4c7..b66b787 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -384,22 +384,29 @@ dump_property(struct weston_wm *wm,
xcb_atom_t *atom_value;
int width, len;
uint32_t i;
+   FILE *fp;
+   char *logstr;
+   size_t logsize;
 
-   width = wm_log_continue("%s: ", get_atom_name(wm->conn, property));
-   if (reply == NULL) {
-   wm_log_continue("(no reply)\n");
+   fp = open_memstream(, );
+   if (!fp)
return;
+
+   width = fprintf(fp, "%s: ", get_atom_name(wm->conn, property));
+   if (reply == NULL) {
+   fprintf(fp, "(no reply)\n");
+   goto out;
}
 
-   width += wm_log_continue("%s/%d, length %d (value_len %d): ",
-get_atom_name(wm->conn, reply->type),
-reply->format,
-xcb_get_property_value_length(reply),
-reply->value_len);
+   width += fprintf(fp, "%s/%d, length %d (value_len %d): ",
+get_atom_name(wm->conn, reply->type),
+reply->format,
+xcb_get_property_value_length(reply),
+reply->value_len);
 
if (reply->type == wm->atom.incr) {
incr_value = xcb_get_property_value(reply);
-   wm_log_continue("%d\n", *incr_value);
+   fprintf(fp, "%d\n", *incr_value);
} else if (reply->type == wm->atom.utf8_string ||
  reply->type == wm->atom.string) {
text_value = xcb_get_property_value(reply);
@@ -407,24 +414,29 @@ dump_property(struct weston_wm *wm,
len = 40;
else
len = reply->value_len;
-   wm_log_continue("\"%.*s\"\n", len, text_value);
+   fprintf(fp, "\"%.*s\"\n", len, text_value);
} else if (reply->type == XCB_ATOM_ATOM) {
atom_value = xcb_get_property_value(reply);
for (i = 0; i < reply->value_len; i++) {
name = get_atom_name(wm->conn, atom_value[i]);
if (width + strlen(name) + 2 > 78) {
-   wm_log_continue("\n");
+   fprintf(fp, "\n");
width = 4;
} else if (i > 0) {
-   width +=  wm_log_continue(", ");
+   width +=  fprintf(fp, ", ");
}
 
-   width +=  wm_log_continue("%s", name);
+   width +=  fprintf(fp, "%s", name);
}
-   wm_log_continue("\n");
+   fprintf(fp, "\n");
} else {
-   wm_log_continue("huh?\n");
+   fprintf(fp, "huh?\n");
}
+
+out:
+   if (fclose(fp) == 0)
+   wm_log_continue("%s", logstr);
+   free(logstr);
 }
 
 static void
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v4 5/9] compositor: offer logs via weston-debug

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

This registers a new weston-debug scope "log" through which one can get
live log output interspersed with possible other debugging prints.

Signed-off-by: Pekka Paalanen 

pass the log_scope to weston_debug_scope_timestamp API to append
the scope name to the timestamp

Signed-off-by: Maniraj Devadoss 
---
 compositor/main.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 03e05e4..f864e42 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -83,6 +83,7 @@ struct wet_compositor {
 };
 
 static FILE *weston_logfile = NULL;
+static struct weston_debug_scope *log_scope;
 
 static int cached_tm_mday = -1;
 
@@ -113,9 +114,16 @@ static int weston_log_timestamp(void)
 static void
 custom_handler(const char *fmt, va_list arg)
 {
+   char timestr[128];
+
weston_log_timestamp();
fprintf(weston_logfile, "libwayland: ");
vfprintf(weston_logfile, fmt, arg);
+
+   weston_debug_scope_printf(log_scope, "%s libwayland: ",
+   weston_debug_scope_timestamp(log_scope,
+   timestr, sizeof timestr));
+   weston_debug_scope_vprintf(log_scope, fmt, arg);
 }
 
 static void
@@ -147,6 +155,14 @@ static int
 vlog(const char *fmt, va_list ap)
 {
int l;
+   char timestr[128];
+
+   if (weston_debug_scope_is_enabled(log_scope)) {
+   weston_debug_scope_printf(log_scope, "%s ",
+   weston_debug_scope_timestamp(log_scope,
+   timestr, sizeof timestr));
+   weston_debug_scope_vprintf(log_scope, fmt, ap);
+   }
 
l = weston_log_timestamp();
l += vfprintf(weston_logfile, fmt, ap);
@@ -157,6 +173,8 @@ vlog(const char *fmt, va_list ap)
 static int
 vlog_continue(const char *fmt, va_list argp)
 {
+   weston_debug_scope_vprintf(log_scope, fmt, argp);
+
return vfprintf(weston_logfile, fmt, argp);
 }
 
@@ -646,6 +664,9 @@ static int on_term_signal(int signal_number, void *data)
 static void
 on_caught_signal(int s, siginfo_t *siginfo, void *context)
 {
+   /* Leak it, try to avoid more fallout. */
+   log_scope = NULL;
+
/* This signal handler will do a best-effort backtrace, and
 * then call the backend restore function, which will switch
 * back to the vt we launched from or ungrab X etc and then
@@ -1888,6 +1909,9 @@ int main(int argc, char *argv[])
goto out;
}
 
+   log_scope = weston_compositor_add_debug_scope(ec, "log",
+   "Weston and Wayland log\n", NULL, NULL);
+
if (debug_protocol)
weston_compositor_enable_debug_protocol(ec);
 
@@ -1999,6 +2023,7 @@ out:
/* free(NULL) is valid, and it won't be NULL if it's used */
free(user_data.parsed_options);
 
+   weston_debug_scope_destroy(log_scope);
weston_compositor_destroy(ec);
 
 out_signals:
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v4 8/9] xwm: convert WM_DEBUG into a weston-debug scope

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

Instead of a compile time choice, offer the XWM debugging messages
through the weston-debug protocol and tool on demand. Users will not
need to recompile weston to get XWM debugging, and it won't flood the
weston log.

The debug scope needs to be initialized in launcher.c for it be
available from start, before the first X11 client tries to connect and
initializes XWM.

Signed-off-by: Pekka Paalanen 

pass the wm_debug scope to weston_debug_scope_printf API to append
the scopename to the timestr

Signed-off-by: Maniraj Devadoss 
---
 xwayland/launcher.c   |   7 ++
 xwayland/window-manager.c | 166 +-
 xwayland/xwayland.h   |   3 +
 3 files changed, 99 insertions(+), 77 deletions(-)

diff --git a/xwayland/launcher.c b/xwayland/launcher.c
index 0ecdb20..c5b9938 100644
--- a/xwayland/launcher.c
+++ b/xwayland/launcher.c
@@ -229,6 +229,8 @@ weston_xserver_destroy(struct wl_listener *l, void *data)
if (wxs->loop)
weston_xserver_shutdown(wxs);
 
+   weston_debug_scope_destroy(wxs->wm_debug);
+
free(wxs);
 }
 
@@ -391,5 +393,10 @@ weston_module_init(struct weston_compositor *compositor)
wxs->destroy_listener.notify = weston_xserver_destroy;
wl_signal_add(>destroy_signal, >destroy_listener);
 
+   wxs->wm_debug = weston_compositor_add_debug_scope(wxs->compositor,
+   "xwm-wm-x11",
+   "XWM's window management X11 events\n",
+   NULL, NULL);
+
return 0;
 }
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 9659c2a..48fa57d 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -190,23 +190,27 @@ static void
 xserver_map_shell_surface(struct weston_wm_window *window,
  struct weston_surface *surface);
 
-static int __attribute__ ((format (printf, 1, 2)))
-wm_log(const char *fmt, ...)
+static bool
+wm_debug_is_enabled(struct weston_wm *wm)
 {
-#ifdef WM_DEBUG
-   int l;
-   va_list argp;
+   return weston_debug_scope_is_enabled(wm->server->wm_debug);
+}
 
-   va_start(argp, fmt);
-   l = weston_vlog(fmt, argp);
-   va_end(argp);
+static void __attribute__ ((format (printf, 2, 3)))
+wm_printf(struct weston_wm *wm, const char *fmt, ...)
+{
+   va_list ap;
+   char timestr[128];
 
-   return l;
-#else
-   return 0;
-#endif
-}
+   if (wm_debug_is_enabled(wm))
+   weston_debug_scope_printf(wm->server->wm_debug, "%s ",
+   
weston_debug_scope_timestamp(wm->server->wm_debug,
+   timestr, sizeof timestr));
 
+   va_start(ap, fmt);
+   weston_debug_scope_vprintf(wm->server->wm_debug, fmt, ap);
+   va_end(ap);
+}
 static void
 weston_output_weak_ref_init(struct weston_output_weak_ref *ref)
 {
@@ -657,10 +661,10 @@ weston_wm_handle_configure_request(struct weston_wm *wm, 
xcb_generic_event_t *ev
uint32_t mask, values[16];
int x, y, width, height, i = 0;
 
-   wm_log("XCB_CONFIGURE_REQUEST (window %d) %d,%d @ %dx%d\n",
-  configure_request->window,
-  configure_request->x, configure_request->y,
-  configure_request->width, configure_request->height);
+   wm_printf(wm, "XCB_CONFIGURE_REQUEST (window %d) %d,%d @ %dx%d\n",
+ configure_request->window,
+ configure_request->x, configure_request->y,
+ configure_request->width, configure_request->height);
 
if (!wm_lookup_window(wm, configure_request->window, ))
return;
@@ -726,11 +730,11 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, 
xcb_generic_event_t *eve
wm->server->compositor->xwayland_interface;
struct weston_wm_window *window;
 
-   wm_log("XCB_CONFIGURE_NOTIFY (window %d) %d,%d @ %dx%d%s\n",
-  configure_notify->window,
-  configure_notify->x, configure_notify->y,
-  configure_notify->width, configure_notify->height,
-  configure_notify->override_redirect ? ", override" : "");
+   wm_printf(wm, "XCB_CONFIGURE_NOTIFY (window %d) %d,%d @ %dx%d%s\n",
+ configure_notify->window,
+ configure_notify->x, configure_notify->y,
+ configure_notify->width, configure_notify->height,
+ configure_notify->override_redirect ? ", override" : "");
 
if (!wm_lookup_window(wm, configure_notify->window, ))
return;
@@ -779,7 +783,7 @@ weston_wm_create_surface(struct wl_listener *listener, void 
*data)
if (wl_resource_get_client(surface->resource) != wm->server->client)
return;
 
-   wm_log("XWM: create weston_surface %p\n", surface);
+   wm_printf(wm, "XWM: create weston_surface %p\n", surface);
 
wl_list_for_each(window, 

[PATCH weston v4 9/9] compositor: protocol logger

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

This is better than running Weston with WAYLAND_DEBUG=server:
- It is enabled on demand, no unnecessary flooding and no need to
  restart the compositor if debug was enabled.
- It prints client pointers so that messages with different clients can
  be seen apart.

Signed-off-by: Pekka Paalanen 

parse and print message arguments in protocol_log_fn

Signed-off-by: Maniraj Devadoss 
---
 compositor/main.c | 127 +-
 1 file changed, 125 insertions(+), 2 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index f864e42..11d52f6 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -84,6 +84,7 @@ struct wet_compositor {
 
 static FILE *weston_logfile = NULL;
 static struct weston_debug_scope *log_scope;
+static struct weston_debug_scope *protocol_scope;
 
 static int cached_tm_mday = -1;
 
@@ -178,6 +179,116 @@ vlog_continue(const char *fmt, va_list argp)
return vfprintf(weston_logfile, fmt, argp);
 }
 
+static const char *
+get_next_argument(const char *signature, char* type)
+{
+   for(; *signature; ++signature) {
+   switch(*signature) {
+   case 'i':
+   case 'u':
+   case 'f':
+   case 's':
+   case 'o':
+   case 'n':
+   case 'a':
+   case 'h':
+   *type = *signature;
+   return signature + 1;
+   }
+   }
+   *type = '\0';
+   return signature;
+}
+
+static void
+protocol_log_fn(void *user_data,
+   enum wl_protocol_logger_type direction,
+   const struct wl_protocol_logger_message *message)
+{
+   FILE *fp;
+   char *logstr;
+   size_t logsize;
+   char timestr[128];
+   struct wl_resource *res = message->resource;
+   const char *signature = message->message->signature;
+   int i;
+   char type;
+
+   if (!weston_debug_scope_is_enabled(protocol_scope))
+   return;
+
+   fp = open_memstream(, );
+   if (!fp)
+   return;
+
+   weston_debug_scope_timestamp(protocol_scope,
+   timestr, sizeof timestr);
+   fprintf(fp, "%s ", timestr);
+   fprintf(fp, "client %p %s ", wl_resource_get_client(res),
+   direction == WL_PROTOCOL_LOGGER_REQUEST ? "rq" : "ev");
+   fprintf(fp, "%s@%u.%s(",
+   wl_resource_get_class(res),
+   wl_resource_get_id(res),
+   message->message->name);
+
+   for (i = 0; i < message->arguments_count; i++) {
+   signature = get_next_argument(signature, );
+
+   if (i > 0)
+   fprintf(fp, ", ");
+
+   switch (type) {
+   case 'u':
+   fprintf(fp, "%u", message->arguments[i].u);
+   break;
+   case 'i':
+   fprintf(fp, "%d", message->arguments[i].i);
+   break;
+   case 'f':
+   fprintf(fp, "%f",
+   wl_fixed_to_double(message->arguments[i].f));
+   break;
+   case 's':
+   fprintf(fp, "\"%s\"", message->arguments[i].s);
+   break;
+   case 'o':
+   if (message->arguments[i].o) {
+   struct wl_resource* resource;
+   resource = (struct wl_resource*) 
message->arguments[i].o;
+   fprintf(fp, "%s@%u",
+   wl_resource_get_class(resource),
+   wl_resource_get_id(resource));
+   }
+   else
+   fprintf(fp, "nil");
+   break;
+   case 'n':
+   fprintf(fp, "new id %s@",
+   (message->message->types[i]) ?
+   message->message->types[i]->name :
+   "[unknown]");
+   if (message->arguments[i].n != 0)
+   fprintf(fp, "%u", message->arguments[i].n);
+   else
+   fprintf(fp, "nil");
+   break;
+   case 'a':
+   fprintf(fp, "array");
+   break;
+   case 'h':
+   fprintf(fp, "fd %d", message->arguments[i].h);
+   break;
+   }
+   }
+
+   fprintf(fp, ")\n");
+
+   if (fclose(fp) == 0)
+   weston_debug_scope_write(protocol_scope, logstr, logsize);
+
+   free(logstr);
+}
+
 static struct wl_list child_process_list;
 static struct weston_compositor *segv_compositor;
 
@@ -1821,6 +1932,7 @@ int 

[PATCH weston v4 7/9] xwm: move FILE to the callers of dump_property()

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

This is preparation for using the weston-debug infrastructure for
WM_DEBUG. dump_property() may be called from different debugging
contexts and often needs to be prefixed with more information.

An alternative to this patch would be to pass in the weston_debug_scope
as an argument to dump_property(), but then all callers would need to be
converted to weston-debug infra in a single commit.

Therefore require the callers to provide the FILE* to print to.

Signed-off-by: Pekka Paalanen 
Signed-off-by: Maniraj Devadoss 
---
 xwayland/selection.c  | 39 ---
 xwayland/window-manager.c | 67 +++
 xwayland/xwayland.h   |  3 ++-
 3 files changed, 65 insertions(+), 44 deletions(-)

diff --git a/xwayland/selection.c b/xwayland/selection.c
index 19a24d2..922f2ca 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -34,6 +34,12 @@
 #include "xwayland.h"
 #include "shared/helpers.h"
 
+#ifdef WM_DEBUG
+#define wm_log(...) weston_log(__VA_ARGS__)
+#else
+#define wm_log(...) do {} while (0)
+#endif
+
 static int
 writable_callback(int fd, uint32_t mask, void *data)
 {
@@ -102,6 +108,9 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
 {
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply;
+   FILE *fp;
+   char *logstr;
+   size_t logsize;
 
cookie = xcb_get_property(wm->conn,
  0, /* delete */
@@ -115,7 +124,13 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
if (reply == NULL)
return;
 
-   dump_property(wm, wm->atom.wl_selection, reply);
+   fp = open_memstream(, );
+   if (fp) {
+   dump_property(fp, wm, wm->atom.wl_selection, reply);
+   if (fclose(fp) == 0)
+   wm_log("%s", logstr);
+   free(logstr);
+   }
 
if (xcb_get_property_value_length(reply) > 0) {
/* reply's ownership is transferred to wm, which is responsible
@@ -178,6 +193,9 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
xcb_atom_t *value;
char **p;
uint32_t i;
+   FILE *fp;
+   char *logstr;
+   size_t logsize;
 
cookie = xcb_get_property(wm->conn,
  1, /* delete */
@@ -191,7 +209,13 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
if (reply == NULL)
return;
 
-   dump_property(wm, wm->atom.wl_selection, reply);
+   fp = open_memstream(, );
+   if (fp) {
+   dump_property(fp, wm, wm->atom.wl_selection, reply);
+   if (fclose(fp) == 0)
+   wm_log("%s", logstr);
+   free(logstr);
+   }
 
if (reply->type != XCB_ATOM_ATOM) {
free(reply);
@@ -232,6 +256,9 @@ weston_wm_get_selection_data(struct weston_wm *wm)
 {
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply;
+   FILE *fp;
+   char *logstr;
+   size_t logsize;
 
cookie = xcb_get_property(wm->conn,
  1, /* delete */
@@ -243,7 +270,13 @@ weston_wm_get_selection_data(struct weston_wm *wm)
 
reply = xcb_get_property_reply(wm->conn, cookie, NULL);
 
-   dump_property(wm, wm->atom.wl_selection, reply);
+   fp = open_memstream(, );
+   if (fp) {
+   dump_property(fp, wm, wm->atom.wl_selection, reply);
+   if (fclose(fp) == 0)
+   wm_log("%s", logstr);
+   free(logstr);
+   }
 
if (reply == NULL) {
return;
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index b66b787..9659c2a 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -207,23 +207,6 @@ wm_log(const char *fmt, ...)
 #endif
 }
 
-static int __attribute__ ((format (printf, 1, 2)))
-wm_log_continue(const char *fmt, ...)
-{
-#ifdef WM_DEBUG
-   int l;
-   va_list argp;
-
-   va_start(argp, fmt);
-   l = weston_vlog_continue(fmt, argp);
-   va_end(argp);
-
-   return l;
-#else
-   return 0;
-#endif
-}
-
 static void
 weston_output_weak_ref_init(struct weston_output_weak_ref *ref)
 {
@@ -376,7 +359,7 @@ xcb_cursor_library_load_cursor(struct weston_wm *wm, const 
char *file)
 }
 
 void
-dump_property(struct weston_wm *wm,
+dump_property(FILE *fp, struct weston_wm *wm,
  xcb_atom_t property, xcb_get_property_reply_t *reply)
 {
int32_t *incr_value;
@@ -384,18 +367,11 @@ dump_property(struct weston_wm *wm,
xcb_atom_t *atom_value;
int width, len;
uint32_t i;
-   FILE *fp;
-   char *logstr;
-   size_t logsize;
-
-   fp = open_memstream(, );
-   if (!fp)
-   return;
 
width = fprintf(fp, "%s: ", get_atom_name(wm->conn, property));
if (reply == NULL) {

[PATCH weston v4 1/9] protocol: add weston-debug.xml

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

This is a new debugging extension for non-production environments. The
aim is to replace all build-time choosable debug prints in the
compositor with runtime subscribable debug streams.

Signed-off-by: Pekka Paalanen 

Added new libweston-$MAJOR-protocols.pc file and install that
for external projects to find the XML files installed by libweston.

Signed-off-by: Maniraj Devadoss 
---
 Makefile.am |   8 +++
 configure.ac|   1 +
 libweston/libweston-protocols.pc.in |   7 ++
 protocol/weston-debug.xml   | 128 
 4 files changed, 144 insertions(+)
 create mode 100644 libweston/libweston-protocols.pc.in
 create mode 100644 protocol/weston-debug.xml

diff --git a/Makefile.am b/Makefile.am
index 1d3eedb..026cc58 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -116,6 +116,10 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES =   
\
shared/platform.h   \
shared/weston-egl-ext.h
 
+libweston_@LIBWESTON_MAJOR@_datadir = $(datadir)/weston/protocols
+dist_libweston_@LIBWESTON_MAJOR@_data_DATA =   \
+   protocol/weston-debug.xml
+
 lib_LTLIBRARIES += libweston-desktop-@LIBWESTON_MAJOR@.la
 libweston_desktop_@LIBWESTON_MAJOR@_la_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
 libweston_desktop_@LIBWESTON_MAJOR@_la_CFLAGS = $(AM_CFLAGS) 
$(COMPOSITOR_CFLAGS)
@@ -166,6 +170,8 @@ endif
 nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES =
\
protocol/weston-screenshooter-protocol.c\
protocol/weston-screenshooter-server-protocol.h \
+   protocol/weston-debug-protocol.c\
+   protocol/weston-debug-server-protocol.h \
protocol/text-cursor-position-protocol.c\
protocol/text-cursor-position-server-protocol.h \
protocol/text-input-unstable-v1-protocol.c  \
@@ -283,6 +289,7 @@ endif # BUILD_WESTON_LAUNCH
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = \
libweston/libweston-${LIBWESTON_MAJOR}.pc \
+   libweston/libweston-${LIBWESTON_MAJOR}-protocols.pc \
libweston-desktop/libweston-desktop-${LIBWESTON_MAJOR}.pc \
compositor/weston.pc
 
@@ -1528,6 +1535,7 @@ BUILT_SOURCES +=  \
protocol/text-input-unstable-v1-client-protocol.h
 
 EXTRA_DIST +=  \
+   protocol/weston-debug.xml   \
protocol/weston-desktop-shell.xml   \
protocol/weston-screenshooter.xml   \
protocol/text-cursor-position.xml   \
diff --git a/configure.ac b/configure.ac
index 21e3a41..e514944 100644
--- a/configure.ac
+++ b/configure.ac
@@ -687,6 +687,7 @@ AC_CONFIG_FILES([Makefile libweston/version.h 
compositor/weston.pc])
 # AC_CONFIG_FILES needs the full name when running autoconf, so we need to use
 # libweston_abi_version here, and outside [] because of m4 quoting rules
 
AC_CONFIG_FILES([libweston/libweston-]libweston_major_version[.pc:libweston/libweston.pc.in])
+AC_CONFIG_FILES([libweston/libweston-]libweston_major_version[-protocols.pc:libweston/libweston-protocols.pc.in])
 
AC_CONFIG_FILES([libweston-desktop/libweston-desktop-]libweston_major_version[.pc:libweston-desktop/libweston-desktop.pc.in])
 
 AM_CONDITIONAL([HAVE_GIT_REPO], [test -f $srcdir/.git/logs/HEAD])
diff --git a/libweston/libweston-protocols.pc.in 
b/libweston/libweston-protocols.pc.in
new file mode 100644
index 000..46fd586
--- /dev/null
+++ b/libweston/libweston-protocols.pc.in
@@ -0,0 +1,7 @@
+prefix=@prefix@
+datarootdir=@datarootdir@
+pkgdatadir=@datadir@/@PACKAGE@/protocols
+
+Name: libWeston Protocols
+Description: libWeston protocol files
+Version: @WESTON_VERSION@
diff --git a/protocol/weston-debug.xml b/protocol/weston-debug.xml
new file mode 100644
index 000..fa8d21d
--- /dev/null
+++ b/protocol/weston-debug.xml
@@ -0,0 +1,128 @@
+
+
+
+  
+Copyright © 2017 Pekka Paalanen pq at iki.fi
+
+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 

[PATCH weston v4 2/9] libweston: add weston_debug API and implementation

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

weston_debug is both a libweston API for relaying debugging messages,
and the compositor-debug wayland protocol implementation for accessing those
debug messages from a Wayland client.

weston_debug_compositor_{create,destroy}() are private API, hence not
exported.

Signed-off-by: Pekka Paalanen 

append the debug scope name along with the timestamp in
weston_debug_scope_timestamp API

Signed-off-by: Maniraj Devadoss 
---
 Makefile.am  |   2 +
 libweston/compositor.c   |   5 +
 libweston/compositor.h   |   8 +
 libweston/weston-debug.c | 755 +++
 libweston/weston-debug.h | 107 +++
 5 files changed, 877 insertions(+)
 create mode 100644 libweston/weston-debug.c
 create mode 100644 libweston/weston-debug.h

diff --git a/Makefile.am b/Makefile.am
index 026cc58..ac57d66 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -108,6 +108,8 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES =
\
libweston/linux-dmabuf.h\
libweston/pixel-formats.c   \
libweston/pixel-formats.h   \
+   libweston/weston-debug.c\
+   libweston/weston-debug.h\
shared/helpers.h\
shared/matrix.c \
shared/matrix.h \
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 62b4457..251bc92 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -5280,6 +5280,9 @@ weston_compositor_create(struct wl_display *display, void 
*user_data)
  ec, bind_presentation))
goto fail;
 
+   if (weston_debug_compositor_create(ec) < 0)
+   goto fail;
+
if (weston_input_init(ec) != 0)
goto fail;
 
@@ -5601,6 +5604,8 @@ weston_compositor_destroy(struct weston_compositor 
*compositor)
 
weston_plugin_api_destroy_list(compositor);
 
+   weston_debug_compositor_destroy(compositor);
+
free(compositor);
 }
 
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 8d288ad..5b1b168 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -849,6 +849,7 @@ struct weston_backend {
 
 struct weston_desktop_xwayland;
 struct weston_desktop_xwayland_interface;
+struct weston_debug_compositor;
 
 struct weston_compositor {
struct wl_signal destroy_signal;
@@ -944,6 +945,7 @@ struct weston_compositor {
/* Whether to let the compositor run without any input device. */
bool require_input;
 
+   struct weston_debug_compositor *weston_debug;
 };
 
 struct weston_buffer {
@@ -1947,6 +1949,12 @@ weston_pending_output_coldplug(struct weston_compositor 
*compositor);
 struct weston_output *
 weston_output_from_resource(struct wl_resource *resource);
 
+int
+weston_debug_compositor_create(struct weston_compositor *compositor);
+
+void
+weston_debug_compositor_destroy(struct weston_compositor *compositor);
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/libweston/weston-debug.c b/libweston/weston-debug.c
new file mode 100644
index 000..65fa652
--- /dev/null
+++ b/libweston/weston-debug.c
@@ -0,0 +1,755 @@
+/*
+ * Copyright © 2017 Pekka Paalanen 
+ *
+ * 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.
+ */
+
+#include "config.h"
+
+#include "weston-debug.h"
+#include "helpers.h"
+#include "compositor.h"
+
+#include "weston-debug-server-protocol.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** Main weston-debug context
+ *
+ * One per weston_compositor.
+ *
+ * \internal
+ */
+struct weston_debug_compositor {
+   struct weston_compositor *compositor;
+   struct wl_listener compositor_destroy_listener;
+   struct wl_global *global;
+   

[PATCH weston v4 3/9] compositor: add option to enable weston_debug

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

Let users enable the compositor debug protocol on the compositor command
line. This allows weston-debug tool to work.

Signed-off-by: Pekka Paalanen 
Signed-off-by: Maniraj Devadoss 
---
 compositor/main.c |  7 +++
 man/weston.man| 15 +--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 4200acd..03e05e4 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -64,6 +64,7 @@
 #include "compositor-x11.h"
 #include "compositor-wayland.h"
 #include "windowed-output-api.h"
+#include "weston-debug.h"
 
 #define WINDOW_TITLE "Weston Compositor"
 
@@ -557,6 +558,7 @@ usage(int error_code)
"  --log=FILE\t\tLog to the given file\n"
"  -c, --config=FILE\tConfig file to load, defaults to 
weston.ini\n"
"  --no-config\t\tDo not read weston.ini\n"
+   "  --debug\t\tEnable debug extension\n"
"  -h, --help\t\tThis help message\n\n");
 
 #if defined(BUILD_DRM_COMPOSITOR)
@@ -1788,6 +1790,7 @@ int main(int argc, char *argv[])
char *socket_name = NULL;
int32_t version = 0;
int32_t noconfig = 0;
+   int32_t debug_protocol = 0;
int32_t numlock_on;
char *config_file = NULL;
struct weston_config *config = NULL;
@@ -1810,6 +1813,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_BOOLEAN, "version", 0,  },
{ WESTON_OPTION_BOOLEAN, "no-config", 0,  },
{ WESTON_OPTION_STRING, "config", 'c', _file },
+   { WESTON_OPTION_BOOLEAN, "debug", 0, _protocol },
};
 
if (os_fd_set_cloexec(fileno(stdin))) {
@@ -1884,6 +1888,9 @@ int main(int argc, char *argv[])
goto out;
}
 
+   if (debug_protocol)
+   weston_compositor_enable_debug_protocol(ec);
+
if (weston_compositor_init_config(ec, config) < 0)
goto out;
 
diff --git a/man/weston.man b/man/weston.man
index face229..a506895 100644
--- a/man/weston.man
+++ b/man/weston.man
@@ -22,7 +22,7 @@ under another Wayland server), it should be done with the 
command
 .B weston-launch
 to set up proper privileged access to devices.
 
-Weston also supports X clients via 
+Weston also supports X clients via
 .BR XWayland ", see below."
 .
 .\" ***
@@ -106,7 +106,7 @@ Load
 .I backend.so
 instead of the default backend. The file is searched for in
 .IR "__weston_modules_dir__" ,
-or you can pass an absolute path. The default backend is 
+or you can pass an absolute path. The default backend is
 .I __weston_native_backend__
 unless the environment suggests otherwise, see
 .IR DISPLAY " and " WAYLAND_DISPLAY .
@@ -123,6 +123,17 @@ If also
 .B --no-config
 is given, no configuration file will be read.
 .TP
+.BR \-\-debug
+Enable debug protocol extension
+.I weston_debug_v1
+which any client can use to receive debugging messages from the compositor.
+
+.B WARNING:
+This is risky for two reasons. First, a client may cause a denial-of-service
+blocking the compositor by providing an unsuitable file descriptor, and
+second, the debug messages may expose sensitive information. This option
+should not be used in production.
+.TP
 .BR \-\-version
 Print the program version.
 .TP
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v4 4/9] clients: add weston-debug

2017-10-12 Thread Emre Ucan
From: Pekka Paalanen 

A tool for accessing the zcompositor_debug_v1 interface features.

Installed along weston-info, because it should be potentially useful for
people running libweston-based compositors.

Signed-off-by: Pekka Paalanen 

Added a man page for weston-debug client

Signed-off-by: Maniraj Devadoss 
---
 Makefile.am|  18 ++-
 clients/weston-debug.c | 378 +
 man/weston-debug.man   |  46 ++
 3 files changed, 439 insertions(+), 3 deletions(-)
 create mode 100644 clients/weston-debug.c
 create mode 100644 man/weston-debug.man

diff --git a/Makefile.am b/Makefile.am
index ac57d66..8472161 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -534,7 +534,7 @@ spring_tool_SOURCES =   \
 
 if BUILD_CLIENTS
 
-bin_PROGRAMS += weston-terminal weston-info
+bin_PROGRAMS += weston-terminal weston-info weston-debug
 
 libexec_PROGRAMS +=\
weston-desktop-shell\
@@ -847,6 +847,15 @@ nodist_weston_info_SOURCES =   
\
 weston_info_LDADD = $(WESTON_INFO_LIBS) libshared.la
 weston_info_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
 
+weston_debug_SOURCES = \
+   clients/weston-debug.c  \
+   shared/helpers.h
+nodist_weston_debug_SOURCES =  \
+   protocol/weston-debug-protocol.c\
+   protocol/weston-debug-client-protocol.h
+weston_debug_LDADD = $(WESTON_INFO_LIBS) libshared.la
+weston_debug_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
+
 weston_desktop_shell_SOURCES = \
clients/desktop-shell.c \
shared/helpers.h
@@ -881,6 +890,8 @@ endif
 BUILT_SOURCES +=   \
protocol/weston-screenshooter-protocol.c\
protocol/weston-screenshooter-client-protocol.h \
+   protocol/weston-debug-protocol.c\
+   protocol/weston-debug-client-protocol.h \
protocol/text-cursor-position-client-protocol.h \
protocol/text-cursor-position-protocol.c\
protocol/text-input-unstable-v1-protocol.c  \
@@ -1562,7 +1573,7 @@ surface_screenshot_la_SOURCES = tests/surface-screenshot.c
 # Documentation
 #
 
-man_MANS = weston.1 weston.ini.5
+man_MANS = weston.1 weston.ini.5 weston-debug.1
 
 if ENABLE_DRM_COMPOSITOR
 man_MANS += weston-drm.7
@@ -1582,7 +1593,8 @@ SUFFIXES = .1 .5 .7 .man
 EXTRA_DIST +=  \
man/weston.man  \
man/weston-drm.man  \
-   man/weston.ini.man
+   man/weston.ini.man  \
+   man/weston-debug.man
 
 CLEANFILES += $(man_MANS)
 
diff --git a/clients/weston-debug.c b/clients/weston-debug.c
new file mode 100644
index 000..fe2fb1c
--- /dev/null
+++ b/clients/weston-debug.c
@@ -0,0 +1,378 @@
+/*
+ * Copyright © 2017 Pekka Paalanen 
+ *
+ * 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.
+ */
+
+#include "config.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "shared/helpers.h"
+#include "shared/zalloc.h"
+#include "weston-debug-client-protocol.h"
+
+struct debug_app {
+   struct {
+   bool help;
+   char *output;
+   char *outfd;
+   } opt;
+
+   int out_fd;
+   struct wl_display *dpy;
+   struct wl_registry *registry;
+   struct weston_debug_v1 *debug_iface;
+   struct wl_list stream_list;
+};
+
+struct debug_stream {
+   struct wl_list link;
+   char *name;
+   struct 

[PATCH weston v4 0/9] weston-debug API and tool

2017-10-12 Thread Emre Ucan
This series of patches are from weston debug protocol RFC posted by Pekka 
Paalanen 
along with the modifications done by Maniraj Devadoss .

https://lists.freedesktop.org/archives/wayland-devel/2017-June/034227.html
v3:
1. protocol is renamed to weston-debug.xml
2. libweston-3-protocols-pc is installed to sysroot

Pekka Paalanen (9):
  protocol: add weston-debug.xml
  libweston: add weston_debug API and implementation
  compositor: add option to enable weston_debug
  clients: add weston-debug
  compositor: offer logs via weston-debug
  xwm: dump_property() to use FILE internally
  xwm: move FILE to the callers of dump_property()
  xwm: convert WM_DEBUG into a weston-debug scope
  compositor: protocol logger

 Makefile.am |  28 +-
 clients/weston-debug.c  | 378 ++
 compositor/main.c   | 155 
 configure.ac|   1 +
 libweston/compositor.c  |   5 +
 libweston/compositor.h  |   8 +
 libweston/libweston-protocols.pc.in |   7 +
 libweston/weston-debug.c| 755 
 libweston/weston-debug.h| 107 +
 man/weston-debug.man|  46 +++
 man/weston.man  |  15 +-
 protocol/weston-debug.xml   | 128 ++
 xwayland/launcher.c |   7 +
 xwayland/selection.c|  39 +-
 xwayland/window-manager.c   | 233 +--
 xwayland/xwayland.h |   6 +-
 16 files changed, 1798 insertions(+), 120 deletions(-)
 create mode 100644 clients/weston-debug.c
 create mode 100644 libweston/libweston-protocols.pc.in
 create mode 100644 libweston/weston-debug.c
 create mode 100644 libweston/weston-debug.h
 create mode 100644 man/weston-debug.man
 create mode 100644 protocol/weston-debug.xml

-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel