[PATCH 3/3] desktop-shell: resize background and panel surfaces on output resize

2016-05-27 Thread David Fort
When an output is resized (permanent mode switch), we should also notify the
shell client so that the panel and background fits to the new screen dimensions.

Signed-off-by: David Fort 
---
 desktop-shell/shell.c | 93 +++
 desktop-shell/shell.h |  8 -
 2 files changed, 86 insertions(+), 15 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 7d5bca9..42c0757 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -4364,6 +4364,20 @@ configure_static_view(struct weston_view *ev, struct 
weston_layer *layer)
}
 }
 
+
+static struct shell_output *
+find_shell_output_from_weston_output(struct desktop_shell *shell, struct 
weston_output *output)
+{
+   struct shell_output *shell_output;
+
+   wl_list_for_each(shell_output, >output_list, link) {
+   if (shell_output->output == output)
+   return shell_output;
+   }
+
+   return NULL;
+}
+
 static int
 background_get_label(struct weston_surface *surface, char *buf, size_t len)
 {
@@ -4383,6 +4397,16 @@ background_configure(struct weston_surface *es, int32_t 
sx, int32_t sy)
 }
 
 static void
+handle_background_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct shell_output *output =
+   container_of(listener, struct shell_output, 
background_surface_listener);
+
+   weston_log("background surface gone\n");
+   output->background_surface = NULL;
+}
+
+static void
 desktop_shell_set_background(struct wl_client *client,
 struct wl_resource *resource,
 struct wl_resource *output_resource,
@@ -4391,6 +4415,7 @@ desktop_shell_set_background(struct wl_client *client,
struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
+   struct shell_output *sh_output;
struct weston_view *view, *next;
 
if (surface->configure) {
@@ -4413,6 +4438,12 @@ desktop_shell_set_background(struct wl_client *client,
surface_resource,
surface->output->width,
surface->output->height);
+
+   sh_output = find_shell_output_from_weston_output(shell, 
surface->output);
+   sh_output->background_surface = surface;
+
+   sh_output->background_surface_listener.notify = 
handle_background_surface_destroy;
+   wl_signal_add(>destroy_signal, 
_output->background_surface_listener);
 }
 
 static int
@@ -4434,6 +4465,17 @@ panel_configure(struct weston_surface *es, int32_t sx, 
int32_t sy)
 }
 
 static void
+handle_panel_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct shell_output *output =
+   container_of(listener, struct shell_output, panel_surface_listener);
+
+   weston_log("panel surface gone\n");
+   output->panel_surface = NULL;
+}
+
+
+static void
 desktop_shell_set_panel(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *output_resource,
@@ -4443,6 +4485,7 @@ desktop_shell_set_panel(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct weston_view *view, *next;
+   struct shell_output *sh_output;
 
if (surface->configure) {
wl_resource_post_error(surface_resource,
@@ -4464,6 +4507,12 @@ desktop_shell_set_panel(struct wl_client *client,
surface_resource,
surface->output->width,
surface->output->height);
+
+   sh_output = find_shell_output_from_weston_output(shell, 
surface->output);
+   sh_output->panel_surface = surface;
+
+   sh_output->panel_surface_listener.notify = handle_panel_surface_destroy;
+   wl_signal_add(>destroy_signal, 
_output->panel_surface_listener);
 }
 
 static int
@@ -4494,16 +4543,6 @@ lock_surface_configure(struct weston_surface *surface, 
int32_t sx, int32_t sy)
 }
 
 static void
-handle_lock_surface_destroy(struct wl_listener *listener, void *data)
-{
-   struct desktop_shell *shell =
-   container_of(listener, struct desktop_shell, lock_surface_listener);
-
-   weston_log("lock surface gone\n");
-   shell->lock_surface = NULL;
-}
-
-static void
 desktop_shell_set_lock_surface(struct wl_client *client,
   struct wl_resource *resource,
   struct wl_resource *surface_resource)
@@ -4519,10 +4558,6 @@ desktop_shell_set_lock_surface(struct wl_client *client,
 
shell->lock_surface = surface;
 
-   shell->lock_surface_listener.notify = handle_lock_surface_destroy;
-  

Re: [PATCH 1/5] scanner: Fixed doxygen group name for _add_listener

2016-05-27 Thread Yong Bakos
Hi Bill,

> On May 17, 2016, at 1:18 AM, spit...@gmail.com wrote:
> 
> From: Bill Spitzak 
> 
> Signed-off-by: Bill Spitzak 
> ---
> src/scanner.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 037ebdb..33271bc 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -1350,7 +1350,7 @@ emit_structs(struct wl_list *message_list, struct 
> interface *interface, enum sid
> 
>   if (side == CLIENT) {
>   printf("/**\n"
> -" * @ingroup %s_iface\n"
> +" * @ingroup iface_%s\n"
>  " */\n", interface->name);
>   printf("static inline int\n"
>  "%s_add_listener(struct %s *%s,\n"
> -- 
> 1.9.1

This was on my list, but I didn't test it yet, so
Acked-by: Yong Bakos 

However, IMHO it would be best to see this as a standalone patch rather than
as the first in this series.

yong


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


Re: [PATCH] xdg-shell: add draw states for xdg_surface

2016-05-27 Thread Mike Blumenkrantz
I've inlined some replies below.

On Fri, May 27, 2016 at 1:13 PM Yong Bakos  wrote:

> On May 27, 2016, at 10:29 AM, Mike Blumenkrantz 
> wrote:
> >
> > this adds a method for compositors to change various draw attributes
> > for a surface
> >
> > Signed-off-by: Mike Blumenkrantz 
> > Signed-off-by: Jonas Ådahl 
>
> Hi Mike & Jonas,
> A question about communicating default state, and some
> minor nits you can certainly ignore, inline below.
>
>
> > ---
> > unstable/xdg-shell/xdg-shell-unstable-v6.xml | 69
> 
> > 1 file changed, 69 insertions(+)
> >
> > diff --git a/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > index dfd7e84..0fa76d4 100644
> > --- a/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > +++ b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > @@ -843,6 +843,75 @@
> >   
> > 
> >
> > +
> > +  
> > +The draw state enum defines optional states which describe how
>
> nit: that describe
>

"which" is correct and intended in this case.


>
> > +a client should draw a surface. A client must at least support
> the
> > +default state, and support for optional draw states is
> explicitly
> > +advertised using xdg_toplevel.set_available_draw_states.
> > +
> > +The default draw state implies that the client draws the surface
> > +with complete window decorations.
>
> nit: Same paragraph, so remove line break
>

Line break was intentional: documentation will not generate a line break,
but anyone reading the protocol file will see it.


>
> > +This may include, e.g., window frame and drop shadow.
> > +
> > +Each draw state defines an alteration to the default. Some draw
> > +states may be combined, while some are mutually exclusive. See
> > +each draw state for details.
> > +
> > +Desktop environments may extend this enum by taking up a range
> of
> > +values and documenting the range they chose in this description.
> > +They are not required to document the values for the range that
> they
> > +chose. Ideally, any good extensions from a desktop environment
> should
>
> nit: extension (singular)


> > +make its way into standardization into this enum.
> > +
> > +The current reserved ranges are:
> > +
> > +0x - 0x0FFF: xdg-shell core values, documented below.
> > +0x1000 - 0x1FFF: EFL
> > +  
>
> should there be a 0 entry in the enum for default?
> (see my comment re: empty array below)
>

Other state enums begin at 1.


>
> > +  
> > +
> > +  The "no_shadow" draw state implies that the client must not
> draw
>
> nit: not draw a
>

Using "a" would imply that the drop shadow is a singular unit instead of a
combination of multiple shadow regions--a possible case.


>
> > +  drop shadow around the surface. This may have side effects
> > +  on usability, e.g., the inability to activate client-initiated
> > +  interactive resize.
> > +
> > +  
> > +
> > +
> > +
> > +  
> > +Set the draw state(s) which the client should use to draw a
> given
>
> nit: that the client should
>

"which" is correct and intended in this case.


>
> > +surface. The absence of this event prior to an
> xdg_surface.configure
> > +event indicates that no change has occurred in the draw state
> since the
> > +previous xdg_surface.configure.
> > +
> > +Sending an empty array of states with this method resets a
> surface to the
> > +default draw state.
>
> Would it not be more explicit for compositors to pass a "default" enum
> value rather
> than an empty array? (Assuming there is a default in the draw_state enum,
> per my
> comment above.)
> But, you will definitely know better than I!
>

This was discussed, and the resulting decision was that implementations
would be simplified if the default value never got passed here.


>
> > +
> > +This event is not sent by itself but as a latched state sent
> prior to
> > +the xdg_surface.configure event. When received, a client should
> adapt
> > +the drawing of the surface according to the state and respond
> to the
> > +configure event accordingly. See xdg_surface.ack_configure for
> > +details.
> > +
> > +A compositor will only configure a client to draw with optional
> states on a
> > +given surface using the states which were advertised by that
> surface using
>
> nit: that were advertised
>

"which" is correct and intended in this case.


>
> > +xdg_toplevel.set_available_draw_states.
> > +  
> > +  
> > +
> > +
> > +
> > +  
>
> nit: advertise available draw states
> Seems clearer, as there's no separation between "available" and
> "optional," since
> all draw states are 

Re: [PATCH] xdg-shell: add draw states for xdg_surface

2016-05-27 Thread Yong Bakos
On May 27, 2016, at 10:29 AM, Mike Blumenkrantz  wrote:
> 
> this adds a method for compositors to change various draw attributes
> for a surface
> 
> Signed-off-by: Mike Blumenkrantz 
> Signed-off-by: Jonas Ådahl 

Hi Mike & Jonas,
A question about communicating default state, and some
minor nits you can certainly ignore, inline below.


> ---
> unstable/xdg-shell/xdg-shell-unstable-v6.xml | 69 
> 1 file changed, 69 insertions(+)
> 
> diff --git a/unstable/xdg-shell/xdg-shell-unstable-v6.xml 
> b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> index dfd7e84..0fa76d4 100644
> --- a/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> +++ b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> @@ -843,6 +843,75 @@
>   
> 
> 
> +
> +  
> +The draw state enum defines optional states which describe how

nit: that describe

> +a client should draw a surface. A client must at least support the
> +default state, and support for optional draw states is explicitly
> +advertised using xdg_toplevel.set_available_draw_states.
> +
> +The default draw state implies that the client draws the surface
> +with complete window decorations.

nit: Same paragraph, so remove line break

> +This may include, e.g., window frame and drop shadow.
> +
> +Each draw state defines an alteration to the default. Some draw
> +states may be combined, while some are mutually exclusive. See
> +each draw state for details.
> +
> +Desktop environments may extend this enum by taking up a range of
> +values and documenting the range they chose in this description.
> +They are not required to document the values for the range that they
> +chose. Ideally, any good extensions from a desktop environment should

nit: extension (singular)

> +make its way into standardization into this enum.
> +
> +The current reserved ranges are:
> +
> +0x - 0x0FFF: xdg-shell core values, documented below.
> +0x1000 - 0x1FFF: EFL
> +  

should there be a 0 entry in the enum for default?
(see my comment re: empty array below)

> +  
> +
> +  The "no_shadow" draw state implies that the client must not draw

nit: not draw a

> +  drop shadow around the surface. This may have side effects
> +  on usability, e.g., the inability to activate client-initiated
> +  interactive resize.
> +
> +  
> +
> +
> +
> +  
> +Set the draw state(s) which the client should use to draw a given

nit: that the client should

> +surface. The absence of this event prior to an xdg_surface.configure
> +event indicates that no change has occurred in the draw state since 
> the
> +previous xdg_surface.configure.
> +
> +Sending an empty array of states with this method resets a surface 
> to the
> +default draw state.

Would it not be more explicit for compositors to pass a "default" enum value 
rather
than an empty array? (Assuming there is a default in the draw_state enum, per my
comment above.)
But, you will definitely know better than I!

> +
> +This event is not sent by itself but as a latched state sent prior to
> +the xdg_surface.configure event. When received, a client should adapt
> +the drawing of the surface according to the state and respond to the
> +configure event accordingly. See xdg_surface.ack_configure for
> +details.
> +
> +A compositor will only configure a client to draw with optional 
> states on a
> +given surface using the states which were advertised by that surface 
> using

nit: that were advertised

> +xdg_toplevel.set_available_draw_states.
> +  
> +  
> +
> +
> +
> +  

nit: advertise available draw states
Seems clearer, as there's no separation between "available" and "optional," 
since
all draw states are optional. (Not being consistent here makes the reader 
second-
guess, "are there available ones and optional ones?")

> +Inform the compositor of optional draw states which are available
> +for the xdg_toplevel.

nit: of available draw states for the xdg_toplevel.
(same as previous reason)

> +
> +Calling this after an xdg_toplevel's first commit will raise a 
> client error.
> +  
> +  

Just a sanity check, since I haven't seen it in a protocol spec yet. Does 
scanner handle
this combination of array and enum correctly?

> +
> +
> 
>   
>   This configure event asks the client to resize its toplevel surface or
> -- 
> 2.5.5

yong


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


Create cross wayland-scanner for toolchain or cross-development environment

2016-05-27 Thread Andrew Kosteltsev
Hi guys,

Currently during cross compilation of the wayland library the
wayland-scanner utility is built by cross-gcc and then used on the
developer machine which lead build error.

I suggest to build development version, for example,
$(top_builddir)/build-wayland-scanner and to use this utility during
cross-buildin the wayland package.

When build is done the user can copy this release of scanner utility into
his toolchain or into his SDK for example wit $(host-triplet) preffix

cp $(top_builddir)/build-wayland-scanner
SDK/bin/$(host_triplet)-wayland-scanner

Then the user can make use this cross-wayland-scanner in his SDK, for
example, like follow:

$ ../MesaLib-10.3.4/configure
WAILAND_SCANNER=$(SDK_DIR)/bin/$(target)-wayland-scanner

I have attached the patch for you. Please look at this patch and please
make decision related to cross building the wayland.

Of course after applying attached patch we have to reconfigure src package;

$ autoreconf -i


Best Regards,
Andrey K.
diff -b --unified -Nr wayland-1.10.0-orig/Makefile.am wayland-1.10.0/Makefile.am
--- wayland-1.10.0-orig/Makefile.am	2015-11-23 23:06:44.0 +0300
+++ wayland-1.10.0/Makefile.am	2016-05-18 15:15:08.399576274 +0300
@@ -2,6 +2,10 @@
 SUBDIRS = doc
 endif
 
+CC_FOR_BUILD = gcc
+LD_FOR_BUILD = $(CC_FOR_BUILD)
+COMPILE_FOR_BUILD = $(CC_FOR_BUILD)
+
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
 AM_CPPFLAGS =	\
@@ -33,7 +37,7 @@
 if USE_HOST_SCANNER
 wayland_scanner = wayland-scanner
 else
-$(BUILT_SOURCES) : wayland-scanner
+$(BUILT_SOURCES) : wayland-scanner build-wayland-scanner
 wayland_scanner = $(top_builddir)/wayland-scanner
 endif
 
@@ -93,20 +97,44 @@
 
 pkgconfig_DATA += src/wayland-client.pc src/wayland-server.pc
 
+build-wayland-util.c: $(top_srcdir)/src/wayland-util.c
+	cp $< $@
+
+build-scanner.c: $(top_srcdir)/src/scanner.c
+	cp $< $@
+
+build-dtddata.S: $(top_srcdir)/src/dtddata.S
+	cp $< $@
+
+build_wayland_scanner = $(top_builddir)/build-wayland-scanner
+build_wayland_scanner_SOURCES = build-scanner.c build-wayland-util.c build-dtddata.S
+build_wayland_scanner_LDADD = -lexpat -lxml2
+build_wayland_scanner_LINK = $(LD_FOR_BUILD) -o $@
+
+build-%.o : build-%.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -I$(top_srcdir)/src -I/usr/include/libxml2 -MT $@ -MD -MP -MF $(DEPDIR)/build-$*.Tpo -c -o $@ $<
+	$(AM_V_at)$(am__mv) $(DEPDIR)/build-$*.Tpo $(DEPDIR)/build-$*.Po
+
+build-%.o : build-%.S
+	$(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+	$(AM_V_CPPAS)$(COMPILE_FOR_BUILD) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+	$(am__mv) $$depbase.Tpo $$depbase.Po
+
+
 protocol/%-protocol.c : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) code < $< > $@
+	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(build_wayland_scanner) code < $< > $@
 
 protocol/%-server-protocol.h : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) server-header < $< > $@
+	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(build_wayland_scanner) server-header < $< > $@
 
 protocol/%-client-protocol.h : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@
+	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(build_wayland_scanner) client-header < $< > $@
 
 protocol/%-server-protocol-core.h : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) server-header -c < $< > $@
+	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(build_wayland_scanner) server-header -c < $< > $@
 
 protocol/%-client-protocol-core.h : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header -c < $< > $@
+	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(build_wayland_scanner) client-header -c < $< > $@
 
 BUILT_SOURCES =	\
 	$(nodist_libwayland_server_la_SOURCES)	\
@@ -168,7 +196,7 @@
 	exec-fd-leak-checker
 
 noinst_PROGRAMS =\
-	fixed-benchmark
+	fixed-benchmark build-wayland-scanner
 
 check_LTLIBRARIES = libtest-runner.la
 
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 1/5] scanner: Fixed doxygen group name for _add_listener

2016-05-27 Thread spitzak
From: Bill Spitzak 

Signed-off-by: Bill Spitzak 
---
 src/scanner.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/scanner.c b/src/scanner.c
index 037ebdb..33271bc 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1350,7 +1350,7 @@ emit_structs(struct wl_list *message_list, struct 
interface *interface, enum sid
 
if (side == CLIENT) {
printf("/**\n"
-  " * @ingroup %s_iface\n"
+  " * @ingroup iface_%s\n"
   " */\n", interface->name);
printf("static inline int\n"
   "%s_add_listener(struct %s *%s,\n"
-- 
1.9.1

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


[PATCH 2/5] client: Cleanup to hold lock for less time

2016-05-27 Thread spitzak
From: Bill Spitzak 

Splits the allocation of wl_proxy from the assignment of the id. This removes
some code such as the malloc from the lock, possibly improving multithreaded
performance.

Removes unnecessary lock in wl_proxy_create_wrapper.

This does not change the public api.

Signed-off-by: Bill Spitzak 
---
 src/wayland-client.c | 157 +--
 1 file changed, 77 insertions(+), 80 deletions(-)

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 03c087a..9934cd2 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -325,24 +325,13 @@ wl_display_create_queue(struct wl_display *display)
 }
 
 static struct wl_proxy *
-proxy_create(struct wl_proxy *factory, const struct wl_interface *interface,
-uint32_t version)
+proxy_new(const struct wl_interface *interface)
 {
-   struct wl_proxy *proxy;
-   struct wl_display *display = factory->display;
-
-   proxy = zalloc(sizeof *proxy);
-   if (proxy == NULL)
-   return NULL;
-
-   proxy->object.interface = interface;
-   proxy->display = display;
-   proxy->queue = factory->queue;
-   proxy->refcount = 1;
-   proxy->version = version;
-
-   proxy->object.id = wl_map_insert_new(>objects, 0, proxy);
-
+   struct wl_proxy *proxy = zalloc(sizeof *proxy);
+   if (proxy) {
+   proxy->object.interface = interface;
+   proxy->refcount = 1;
+   }
return proxy;
 }
 
@@ -369,10 +358,16 @@ WL_EXPORT struct wl_proxy *
 wl_proxy_create(struct wl_proxy *factory, const struct wl_interface *interface)
 {
struct wl_display *display = factory->display;
-   struct wl_proxy *proxy;
+   struct wl_proxy *proxy = proxy_new(interface);
+   if (proxy == NULL)
+   return NULL;
+
+   proxy->display = display;
+   proxy->queue = factory->queue;
+   proxy->version = factory->version;
 
pthread_mutex_lock(>mutex);
-   proxy = proxy_create(factory, interface, factory->version);
+   proxy->object.id = wl_map_insert_new(>objects, 0, proxy);
pthread_mutex_unlock(>mutex);
 
return proxy;
@@ -383,19 +378,15 @@ static struct wl_proxy *
 wl_proxy_create_for_id(struct wl_proxy *factory,
   uint32_t id, const struct wl_interface *interface)
 {
-   struct wl_proxy *proxy;
struct wl_display *display = factory->display;
-
-   proxy = zalloc(sizeof *proxy);
+   struct wl_proxy *proxy = proxy_new(interface);
if (proxy == NULL)
return NULL;
 
-   proxy->object.interface = interface;
-   proxy->object.id = id;
proxy->display = display;
proxy->queue = factory->queue;
-   proxy->refcount = 1;
proxy->version = factory->version;
+   proxy->object.id = id;
 
wl_map_insert_at(>objects, 0, id, proxy);
 
@@ -539,33 +530,63 @@ wl_proxy_add_dispatcher(struct wl_proxy *proxy,
return 0;
 }
 
-static struct wl_proxy *
-create_outgoing_proxy(struct wl_proxy *proxy, const struct wl_message *message,
- union wl_argument *args,
- const struct wl_interface *interface, uint32_t version)
+/* Return index of the new_id argument */
+static int
+new_id_index(struct wl_proxy *proxy, uint32_t opcode)
 {
-   int i, count;
-   const char *signature;
-   struct argument_details arg;
-   struct wl_proxy *new_proxy = NULL;
-
-   signature = message->signature;
-   count = arg_count_for_signature(signature);
-   for (i = 0; i < count; i++) {
+   int i;
+   const struct wl_message *message =
+   >object.interface->methods[opcode];
+   const char *signature = message->signature;
+   int count = arg_count_for_signature(signature);
+   for (i = 0; ; i++) {
+   struct argument_details arg;
+   if (i >= count)
+   wl_abort("Missing new_id argument");
signature = get_next_argument(signature, );
+   if (arg.type == 'n')
+   break;
+   }
+   return i;
+}
 
-   switch (arg.type) {
-   case 'n':
-   new_proxy = proxy_create(proxy, interface, version);
-   if (new_proxy == NULL)
-   return NULL;
+/* Does wl_proxy_marshal_array, but also allocates an id for new_proxy
+ * if it is not null before sending the message (which requires the
+ * lock that this holds).
+ */
+static void
+proxy_marshal_array(struct wl_proxy *proxy,
+   uint32_t opcode,
+   union wl_argument *args,
+   struct wl_proxy *new_proxy)
+{
+   struct wl_closure *closure;
+   const struct wl_message *message;
 
-   args[i].o = _proxy->object;
-   break;
-   }
+   

[PATCH 5/5] client: Added wl_registry_bind_id

2016-05-27 Thread spitzak
From: Bill Spitzak 

This function assigns the id into an existing wl_proxy structure. Allows
setting of the queue before binding so that events are sent to the correct
thread.

The arguments are purposely swapped around so that just changing 
wl_registry_bind
to wl_registry_bind_id will not compile.

The display-test modified to test this and show the usage.

Signed-off-by: Bill Spitzak 
---
 src/scanner.c | 29 +++--
 src/wayland-client-core.h |  4 
 src/wayland-client.c  | 15 ++-
 tests/display-test.c  |  4 
 4 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index fbe8193..3c0db01 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1184,14 +1184,13 @@ emit_stubs(struct wl_list *message_list, struct 
interface *interface)
 */
if (!ret)
continue;
-   if (!ret->interface_name)
-   continue; /* wl_registry_bind_id nyi */
printf("/**\n"
   " * @ingroup iface_%s\n", interface->name);
printf(" *\n"
   " * Same as %s_%s() except it uses an existing proxy 
created by\n"
   " * %s_new().\n"
-  " */\n", interface->name, m->name, ret->interface_name);
+  " */\n", interface->name, m->name,
+  ret->interface_name ? ret->interface_name : "wl_proxy");
printf("static inline void\n");
 
printf("%s_%s_id(struct %s *%s",
@@ -1200,23 +1199,33 @@ emit_stubs(struct wl_list *message_list, struct 
interface *interface)
 
wl_list_for_each(a, >arg_list, link) {
printf(", ");
-   if (a->type != NEW_ID)
+   if (a->type != NEW_ID) {
emit_type(a);
-   else
-   printf("struct %s *", ret->interface_name);
-   printf("%s", a->name);
+   printf("%s", a->name);
+   } else if (ret->interface_name) {
+   printf("struct %s *proxy", ret->interface_name);
+   } else {
+   printf("uint32_t version, void *proxy");
+   }
}
 
printf(")\n"
   "{\n"
-  "\twl_proxy_marshal_id((struct wl_proxy *) %s,\n"
+  "\twl_proxy_marshal_%s((struct wl_proxy *) %s,\n"
   "\t\t\t %s_%s",
+  ret->interface_name ? "id" : "bind",
   interface->name,
   interface->uppercase_name,
   m->uppercase_name);
 
wl_list_for_each(a, >arg_list, link) {
-   printf(", %s", a->name);
+   if (a->type != NEW_ID) {
+   printf(", %s", a->name);
+   } else if (ret->interface_name) {
+   printf(", proxy");
+   } else {
+   printf(", version, (struct wl_proxy *) proxy");
+   }
}
printf(");\n");
 
@@ -1398,7 +1407,7 @@ emit_structs(struct wl_list *message_list, struct 
interface *interface, enum sid
printf("/**\n"
   " * @ingroup iface_%s\n"
   " *\n"
-  " * Create a %s and allocate an id.\n"
+  " * Allocate a new %s.\n"
   " */\n"
   "static inline struct %s *\n"
   "%s_new(void)\n"
diff --git a/src/wayland-client-core.h b/src/wayland-client-core.h
index 8e48cab..84ceb70 100644
--- a/src/wayland-client-core.h
+++ b/src/wayland-client-core.h
@@ -128,6 +128,10 @@ void
 wl_proxy_marshal_id(struct wl_proxy *proxy, uint32_t opcode, ...);
 
 void
+wl_proxy_marshal_bind(struct wl_proxy *factory, uint32_t opcode,
+ uint32_t name, uint32_t version, struct wl_proxy 
*new_proxy);
+
+void
 wl_proxy_marshal_array(struct wl_proxy *p, uint32_t opcode,
   union wl_argument *args);
 
diff --git a/src/wayland-client.c b/src/wayland-client.c
index d539bf7..326ca14 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -741,11 +741,24 @@ wl_proxy_marshal_id(struct wl_proxy *factory, uint32_t 
opcode, ...)
new_proxy->display = factory->display;
if (new_proxy->queue == NULL)
new_proxy->queue = factory->queue;
-   new_proxy->version = factory->version;
+   if (new_proxy->version == 0)
+   new_proxy->version = factory->version;
 
proxy_marshal_array(factory, opcode, args, new_proxy);
 }
 
+/** Same as wl_proxy_marshal_id() except 

[PATCH] xdg-shell: add draw states for xdg_surface

2016-05-27 Thread Mike Blumenkrantz
this adds a method for compositors to change various draw attributes
for a surface

Signed-off-by: Mike Blumenkrantz 
Signed-off-by: Jonas Ådahl 
---
 unstable/xdg-shell/xdg-shell-unstable-v6.xml | 69 
 1 file changed, 69 insertions(+)

diff --git a/unstable/xdg-shell/xdg-shell-unstable-v6.xml 
b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
index dfd7e84..0fa76d4 100644
--- a/unstable/xdg-shell/xdg-shell-unstable-v6.xml
+++ b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
@@ -843,6 +843,75 @@
   
 
 
+
+  
+The draw state enum defines optional states which describe how
+a client should draw a surface. A client must at least support the
+default state, and support for optional draw states is explicitly
+advertised using xdg_toplevel.set_available_draw_states.
+
+The default draw state implies that the client draws the surface
+with complete window decorations.
+This may include, e.g., window frame and drop shadow.
+
+Each draw state defines an alteration to the default. Some draw
+states may be combined, while some are mutually exclusive. See
+each draw state for details.
+
+Desktop environments may extend this enum by taking up a range of
+values and documenting the range they chose in this description.
+They are not required to document the values for the range that they
+chose. Ideally, any good extensions from a desktop environment should
+make its way into standardization into this enum.
+
+The current reserved ranges are:
+
+0x - 0x0FFF: xdg-shell core values, documented below.
+0x1000 - 0x1FFF: EFL
+  
+  
+
+  The "no_shadow" draw state implies that the client must not draw
+  drop shadow around the surface. This may have side effects
+  on usability, e.g., the inability to activate client-initiated
+  interactive resize.
+
+  
+
+
+
+  
+Set the draw state(s) which the client should use to draw a given
+surface. The absence of this event prior to an xdg_surface.configure
+event indicates that no change has occurred in the draw state since the
+previous xdg_surface.configure.
+
+Sending an empty array of states with this method resets a surface to 
the
+default draw state.
+
+This event is not sent by itself but as a latched state sent prior to
+the xdg_surface.configure event. When received, a client should adapt
+the drawing of the surface according to the state and respond to the
+configure event accordingly. See xdg_surface.ack_configure for
+details.
+
+A compositor will only configure a client to draw with optional states 
on a
+given surface using the states which were advertised by that surface 
using
+xdg_toplevel.set_available_draw_states.
+  
+  
+
+
+
+  
+Inform the compositor of optional draw states which are available
+for the xdg_toplevel.
+
+Calling this after an xdg_toplevel's first commit will raise a client 
error.
+  
+  
+
+
 
   
This configure event asks the client to resize its toplevel surface or
-- 
2.5.5

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


[PATCH 3/5] client: Changed argument name from "proxy" to "factory" in constructors

2016-05-27 Thread spitzak
From: Bill Spitzak 

I think this makes it less confusing. "factory" was already used for internal
functions.

Signed-off-by: Bill Spitzak 
---
 src/wayland-client-core.h | 10 +-
 src/wayland-client.c  | 48 +++
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/wayland-client-core.h b/src/wayland-client-core.h
index b1d6515..52bb553 100644
--- a/src/wayland-client-core.h
+++ b/src/wayland-client-core.h
@@ -133,29 +133,29 @@ wl_proxy_create(struct wl_proxy *factory,
const struct wl_interface *interface);
 
 void *
-wl_proxy_create_wrapper(void *proxy);
+wl_proxy_create_wrapper(void *factory);
 
 void
 wl_proxy_wrapper_destroy(void *proxy_wrapper);
 
 struct wl_proxy *
-wl_proxy_marshal_constructor(struct wl_proxy *proxy,
+wl_proxy_marshal_constructor(struct wl_proxy *factory,
 uint32_t opcode,
 const struct wl_interface *interface,
 ...);
 
 struct wl_proxy *
-wl_proxy_marshal_constructor_versioned(struct wl_proxy *proxy,
+wl_proxy_marshal_constructor_versioned(struct wl_proxy *factory,
   uint32_t opcode,
   const struct wl_interface *interface,
   uint32_t version,
   ...);
 struct wl_proxy *
-wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
+wl_proxy_marshal_array_constructor(struct wl_proxy *factory,
   uint32_t opcode, union wl_argument *args,
   const struct wl_interface *interface);
 struct wl_proxy *
-wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy,
+wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *factory,
 uint32_t opcode,
 union wl_argument *args,
 const struct wl_interface 
*interface,
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 9934cd2..f67678b 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -532,11 +532,11 @@ wl_proxy_add_dispatcher(struct wl_proxy *proxy,
 
 /* Return index of the new_id argument */
 static int
-new_id_index(struct wl_proxy *proxy, uint32_t opcode)
+new_id_index(struct wl_proxy *factory, uint32_t opcode)
 {
int i;
const struct wl_message *message =
-   >object.interface->methods[opcode];
+   >object.interface->methods[opcode];
const char *signature = message->signature;
int count = arg_count_for_signature(signature);
for (i = 0; ; i++) {
@@ -591,7 +591,7 @@ proxy_marshal_array(struct wl_proxy *proxy,
 
 /** Prepare a request to be sent to the compositor
  *
- * \param proxy The proxy object
+ * \param factory The proxy object
  * \param opcode Opcode of the request to be sent
  * \param args Extra arguments for the given request
  * \param interface The interface to use for the new proxy
@@ -613,19 +613,19 @@ proxy_marshal_array(struct wl_proxy *proxy,
  * \memberof wl_proxy
  */
 WL_EXPORT struct wl_proxy *
-wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
+wl_proxy_marshal_array_constructor(struct wl_proxy *factory,
   uint32_t opcode, union wl_argument *args,
   const struct wl_interface *interface)
 {
-   return wl_proxy_marshal_array_constructor_versioned(proxy, opcode,
+   return wl_proxy_marshal_array_constructor_versioned(factory, opcode,
args, interface,
-   proxy->version);
+   factory->version);
 }
 
 
 /** Prepare a request to be sent to the compositor
  *
- * \param proxy The proxy object
+ * \param factory The proxy object
  * \param opcode Opcode of the request to be sent
  * \param args Extra arguments for the given request
  * \param interface The interface to use for the new proxy
@@ -648,7 +648,7 @@ wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
  * \memberof wl_proxy
  */
 WL_EXPORT struct wl_proxy *
-wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy,
+wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *factory,
 uint32_t opcode,
 union wl_argument *args,
 const struct wl_interface 
*interface,
@@ -660,13 +660,13 @@ wl_proxy_marshal_array_constructor_versioned(struct 
wl_proxy *proxy,
new_proxy = proxy_new(interface);
if (new_proxy == NULL)
return NULL;
-   new_proxy->display = 

[PATCH 4/5] client: "_id" versions of constructors, alternative to proxy_wrapper

2016-05-27 Thread spitzak
From: Bill Spitzak 

Scanner produces a wl_xyz_new() for each object, and for each constructor
request it produces an "_id" version that takes one of these, instead of
creating one. This allows the queue and listener to be set before creation of
the object so events always go to the correct queue.

Existing code using proxy_wrapper changed to use this.

To implement this two new api's were added to wayland-client-core.h:

wl_proxy_new(interface)

wl_proxy_marshal_id(...): Same as wl_proxy_marshal except it handles 'n' 
arguments
and assigns an id to them. wl_proxy_marshal could do this but it would add 
overhead
to search for the 'n' to non-constructor requests.

v2: Moved definition of wl_proxy back out of header file
v3: _new api and named request _id.

Signed-off-by: Bill Spitzak 
---
 src/scanner.c | 59 ++
 src/wayland-client-core.h |  6 
 src/wayland-client.c  | 72 ---
 tests/queue-test.c| 15 +-
 4 files changed, 127 insertions(+), 25 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index 33271bc..fbe8193 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1176,6 +1176,51 @@ emit_stubs(struct wl_list *message_list, struct 
interface *interface)
   ret->interface_name, ret->name);
 
printf("}\n\n");
+
+   /* Produce the _id version of constructor calls.
+* FIXME: this is a cut + paste patch, it would be better
+* to reuse the above code and/or make the old constructor
+* be the special case.
+*/
+   if (!ret)
+   continue;
+   if (!ret->interface_name)
+   continue; /* wl_registry_bind_id nyi */
+   printf("/**\n"
+  " * @ingroup iface_%s\n", interface->name);
+   printf(" *\n"
+  " * Same as %s_%s() except it uses an existing proxy 
created by\n"
+  " * %s_new().\n"
+  " */\n", interface->name, m->name, ret->interface_name);
+   printf("static inline void\n");
+
+   printf("%s_%s_id(struct %s *%s",
+  interface->name, m->name,
+  interface->name, interface->name);
+
+   wl_list_for_each(a, >arg_list, link) {
+   printf(", ");
+   if (a->type != NEW_ID)
+   emit_type(a);
+   else
+   printf("struct %s *", ret->interface_name);
+   printf("%s", a->name);
+   }
+
+   printf(")\n"
+  "{\n"
+  "\twl_proxy_marshal_id((struct wl_proxy *) %s,\n"
+  "\t\t\t %s_%s",
+  interface->name,
+  interface->uppercase_name,
+  m->uppercase_name);
+
+   wl_list_for_each(a, >arg_list, link) {
+   printf(", %s", a->name);
+   }
+   printf(");\n");
+
+   printf("}\n\n");
}
 }
 
@@ -1349,6 +1394,20 @@ emit_structs(struct wl_list *message_list, struct 
interface *interface, enum sid
printf("};\n\n");
 
if (side == CLIENT) {
+   if (strcmp(interface->name, "wl_display"))
+   printf("/**\n"
+  " * @ingroup iface_%s\n"
+  " *\n"
+  " * Create a %s and allocate an id.\n"
+  " */\n"
+  "static inline struct %s *\n"
+  "%s_new(void)\n"
+  "{\n"
+  "\treturn (struct %s *) wl_proxy_new(&%s_interface);\n"
+  "}\n\n",
+  interface->name, interface->name, interface->name,
+  interface->name, interface->name, interface->name);
+
printf("/**\n"
   " * @ingroup iface_%s\n"
   " */\n", interface->name);
diff --git a/src/wayland-client-core.h b/src/wayland-client-core.h
index 52bb553..8e48cab 100644
--- a/src/wayland-client-core.h
+++ b/src/wayland-client-core.h
@@ -125,10 +125,16 @@ void
 wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);
 
 void
+wl_proxy_marshal_id(struct wl_proxy *proxy, uint32_t opcode, ...);
+
+void
 wl_proxy_marshal_array(struct wl_proxy *p, uint32_t opcode,
   union wl_argument *args);
 
 struct wl_proxy *
+wl_proxy_new(const struct wl_interface *interface);
+
+struct wl_proxy *
 wl_proxy_create(struct wl_proxy *factory,
const struct wl_interface *interface);
 
diff --git a/src/wayland-client.c b/src/wayland-client.c
index f67678b..d539bf7 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -324,8 +324,17 @@ wl_display_create_queue(struct 

Re: [systemd-devel] [ANNOUNCE] systemd v230

2016-05-27 Thread Zbigniew Jędrzejewski-Szmek
On Sun, May 22, 2016 at 02:02:57PM +0500, Alexander E. Patrakov wrote:
> 22.05.2016 13:33, Alexander E. Patrakov пишет:
> >22.05.2016 03:51, Zbigniew Jędrzejewski-Szmek пишет:
> >>Hi,
> >>
> >>systemd v230 has been tagged. Enjoy!
> >>
> >>CHANGES WITH 230:
> >
> >
> >
> >>* Framebuffer devices (/dev/fb*) and 3D printers and scanners
> >>  (devices tagged with ID_MAKER_TOOL) are now tagged with
> >>  "uaccess" and are available to logged in users.
> >
> >Has this been discussed with Wayland developers? Framebuffer device
> >access can possibly be abused to take screenshots and draw on top of the
> >compositor in a Wayland-based environment. Impossibility for arbitrary
> >applications to take screenshots was one of the design goals of Wayland,
> >and this change breaks it.
> >
> >So, unless one of Wayland developers confirms that they are OK with it,
> >please revert it and ask for a CVE.
> >
> 
> Sorry, I have to take this back. Attempting to grab video from
> /dev/fb0 here on Intel hardware, both under X and Weston, shows only
> an image from the first virtual console - i.e. not the actual
> session. Still, I would like someone else to confirm that this
> behaviour is not Intel-specific and cannot be circumvented by, say,
> ioctls on /dev/fb0.

Hi,

that change makes /dev/fb* behave the same as /dev/dri/card* and
/dev/dri/render*. You are right that the user can control the device,
this is by design: the processes of the same user are not isolated
from one another and can do pretty much anything. To achieve
isolation between processes running using the same uid some other
mechanism must be used (selinux, seccomp, etc). Wayland offers
separation between clients, but only when using the Wayland protocol,
and not through side channels.

>> Has this been discussed with Wayland developers? Framebuffer device

A few Wayland developers commented on the bugs where this was discussed.

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


Re: [PATCH] weston-launch: Handle invalid command line options

2016-05-27 Thread Otavio Salvador
On Mon, May 16, 2016 at 3:43 PM, Yong Bakos  wrote:
> On May 7, 2016, at 5:57 AM, Otavio Salvador  wrote:
>>
>> From: Tom Hochstein 
>>
>> Exit the program if an unrecognized command line option is found.
>>
>> Signed-off-by; Tom Hochstein 
>> Signed-off-by: Otavio Salvador 
>
> Simple enough of a review, and I did test this. But the question is
> whether we want weston-launch to ignore invalid options or to quit in the
> event of their presence. I'm not experienced enough to judge, so others
> will have to chime in. So fwiw,
>
> Reviewed-by: Yong Bakos 
> Tested-by: Yong Bakos 

I believe it ought to fail so we know we are giving it invalid
arguments otherwise it is very hard to identify why it is not behaving
as expected. We had this problem when implementing the XWayland
handling in OpenEmbedded.

-- 
Otavio Salvador O.S. Systems
http://www.ossystems.com.brhttp://code.ossystems.com.br
Mobile: +55 (53) 9981-7854Mobile: +1 (347) 903-9750
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v3] client: Some cleanup and new _id versions of constructors

2016-05-27 Thread spitzak
The first three patches are cleanup that does not change the api. In particular
this change moves the malloc of wl_proxy outside the lock.

Patch 4 adds an "_id" version of all the constructors that takes an existing
wl_proxy, and a "_new" function to create these proxies. This is an alternative
to wl_proxy_wrapper which I think is simpler to use, though it adds to the
header files.

Patch 5 adds an "_id" version of wl_registry_bind. 

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


Re: [PATCH weston 3/6] Move the functions launching clients to main.c

2016-05-27 Thread Benoit Gschwind
Hello Giulio,

With this patch, and mine to fix MODULEDIR of patch #2, this patch does
not build due to incomplete type:

src/screenshooter.c:46:24: error: field 'process' has incomplete type
  struct weston_process process;

The patch look fine, if I ignore this building error, I also saw a lot
of change about screenshoter in the following patch, that I can imagine
resolve the issue. I do not know the policy of weston, but I guess you
must fix this issue.

Best regards.

On 24/05/2016 18:59, Giulio Camuffo wrote:
> They belong in the compositor rather than libweston since they
> set signals handlers, and a library should not do that behind its
> user's back. Besides, they were using functions in main.c already
> so they were not usable by other compositors.
> 
> Signed-off-by: Giulio Camuffo 
> ---
>  ivi-shell/hmi-controller.c |   1 +
>  src/compositor.c   | 144 
>  src/compositor.h   |  22 ---
>  src/main.c | 145 
> +
>  src/text-backend.c |   1 +
>  src/weston.h   |  24 +++
>  tests/ivi_layout-test-plugin.c |   1 +
>  tests/weston-test.c|   1 +
>  xwayland/xwayland.h|   1 +
>  9 files changed, 174 insertions(+), 166 deletions(-)
> 
> diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
> index 97f78af..094682c 100644
> --- a/ivi-shell/hmi-controller.c
> +++ b/ivi-shell/hmi-controller.c
> @@ -62,6 +62,7 @@
>  #include "ivi-hmi-controller-server-protocol.h"
>  #include "shared/helpers.h"
>  #include "shared/xalloc.h"
> +#include "src/weston.h"
>  
>  
> /*
>   *  structure, globals
> diff --git a/src/compositor.c b/src/compositor.c
> index 5a52d86..3904ef0 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -236,150 +236,6 @@ weston_output_mode_switch_to_temporary(struct 
> weston_output *output,
>  }
>  
>  static void
> -child_client_exec(int sockfd, const char *path)
> -{
> - int clientfd;
> - char s[32];
> - sigset_t allsigs;
> -
> - /* do not give our signal mask to the new process */
> - sigfillset();
> - sigprocmask(SIG_UNBLOCK, , NULL);
> -
> - /* Launch clients as the user. Do not lauch clients with wrong euid.*/
> - if (seteuid(getuid()) == -1) {
> - weston_log("compositor: failed seteuid\n");
> - return;
> - }
> -
> - /* SOCK_CLOEXEC closes both ends, so we dup the fd to get a
> -  * non-CLOEXEC fd to pass through exec. */
> - clientfd = dup(sockfd);
> - if (clientfd == -1) {
> - weston_log("compositor: dup failed: %m\n");
> - return;
> - }
> -
> - snprintf(s, sizeof s, "%d", clientfd);
> - setenv("WAYLAND_SOCKET", s, 1);
> -
> - if (execl(path, path, NULL) < 0)
> - weston_log("compositor: executing '%s' failed: %m\n",
> - path);
> -}
> -
> -WL_EXPORT struct wl_client *
> -weston_client_launch(struct weston_compositor *compositor,
> -  struct weston_process *proc,
> -  const char *path,
> -  weston_process_cleanup_func_t cleanup)
> -{
> - int sv[2];
> - pid_t pid;
> - struct wl_client *client;
> -
> - weston_log("launching '%s'\n", path);
> -
> - if (os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0, sv) < 0) {
> - weston_log("weston_client_launch: "
> - "socketpair failed while launching '%s': %m\n",
> - path);
> - return NULL;
> - }
> -
> - pid = fork();
> - if (pid == -1) {
> - close(sv[0]);
> - close(sv[1]);
> - weston_log("weston_client_launch: "
> - "fork failed while launching '%s': %m\n", path);
> - return NULL;
> - }
> -
> - if (pid == 0) {
> - child_client_exec(sv[1], path);
> - _exit(-1);
> - }
> -
> - close(sv[1]);
> -
> - client = wl_client_create(compositor->wl_display, sv[0]);
> - if (!client) {
> - close(sv[0]);
> - weston_log("weston_client_launch: "
> - "wl_client_create failed while launching '%s'.\n",
> - path);
> - return NULL;
> - }
> -
> - proc->pid = pid;
> - proc->cleanup = cleanup;
> - weston_watch_process(proc);
> -
> - return client;
> -}
> -
> -struct process_info {
> - struct weston_process proc;
> - char *path;
> -};
> -
> -static void
> -process_handle_sigchld(struct weston_process *process, int status)
> -{
> - struct process_info *pinfo =
> - container_of(process, struct process_info, proc);
> -
> - /*
> -  * There are no guarantees whether this runs before or after
> -  * the wl_client destructor.
> -  */
> -
> - if 

Re: [PATCH 0/6] RDP compositor needs love v2

2016-05-27 Thread Sam Spilsbury
Hi David,

On Fri, May 27, 2016 at 6:48 AM, Hardening  wrote:
> Le 26/04/2016 23:34, David Fort a écrit :
>> Compared to the first version:
>>   compositor: recompute output position on mode switch
>>   desktop-shell: resize background, panel and lock surface on output
>> resize
>>

I checked my mails and it seems like these two have been reviewed with
comments by Pekka.


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


Re: [PATCH weston 2/6] Split the modules and include files between weston and libweston

2016-05-27 Thread Benoit Gschwind
Hello Giulio,

The idea of the patch is fine, but the patch doesn't work. See following
comments. (@Quentin: no it's does not work as it is ;) )

On 24/05/2016 18:59, Giulio Camuffo wrote:
> The backends are now installed in lib/libweston-0, and the include
> files that will be used by libweston in include/libweston-0. The other
> modules and weston-specific include files are kept in the old paths.
> A new load_weston_module() is added to load plugins in the old path,
> which is not part of libweston, but weston only and defined in main.c.
> To allow that to be used by out of tree weston plugins, the function
> is declared in a new weston.h, installed in include/weston.
> 
> The -0 in the paths is the abi version of libweston, and it will be
> used by the libweston .so too. When the abi change the number will
> be increased.
> 
> Signed-off-by: Giulio Camuffo 
> ---
>  Makefile.am| 28 +---
>  configure.ac   |  2 ++
>  ivi-shell/ivi-layout.c |  3 ++-
>  src/compositor.c   |  2 +-
>  src/main.c | 47 ++-
>  src/weston.h   | 40 
>  src/weston.pc.in   |  2 +-
>  7 files changed, 109 insertions(+), 15 deletions(-)
>  create mode 100644 src/weston.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index 00b74e5..da37526 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -5,6 +5,8 @@ noinst_PROGRAMS =
>  libexec_PROGRAMS =
>  moduledir = $(libdir)/weston
>  module_LTLIBRARIES =
> +libweston_moduledir = $(libdir)/libweston-${LIBWESTON_ABI_VERSION}
> +libweston_module_LTLIBRARIES =
>  noinst_LTLIBRARIES =
>  BUILT_SOURCES =
>  
> @@ -49,7 +51,7 @@ AM_CPPFLAGS =   \
>   -I$(top_srcdir)/shared  \
>   -I$(top_builddir)/protocol  \
>   -DDATADIR='"$(datadir)"'\
> - -DMODULEDIR='"$(moduledir)"'\

Here you replace MODULESDIR as already commented by Quentin. But you
need MODULEDIR to build weston-compositor. I fixed the build issue by
adding MODULEDIR to weston-compositor C(PP)FLAGS as follow:

diff --git a/Makefile.am b/Makefile.am
index da37526..2554e1f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -64,8 +64,10 @@ CLEANFILES = weston.ini  \
 bin_PROGRAMS += weston

 weston_LDFLAGS = -export-dynamic
-weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
-weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
+weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON \
+   -DMODULEDIR='"$(moduledir)"'
+weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS) \
+   -DMODULEDIR='"$(moduledir)"'
 weston_LDADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
$(DLOPEN_LIBS) -lm $(CLOCK_GETTIME_LIBS) libshared.la

After this change weston build and run.

> + -DLIBWESTON_MODULEDIR='"$(libweston_moduledir)"' \
>   -DLIBEXECDIR='"$(libexecdir)"'  \
>   -DBINDIR='"$(bindir)"'
>  
> @@ -95,6 +97,7 @@ weston_SOURCES =\
>   src/main.c  \
>   src/linux-dmabuf.c  \
>   src/linux-dmabuf.h  \
> + src/weston.h\
>   shared/helpers.h\
>   shared/matrix.c \
>   shared/matrix.h \
> @@ -104,7 +107,7 @@ weston_SOURCES =  \
>   src/weston-egl-ext.h
>  
>  if SYSTEMD_NOTIFY_SUPPORT
> -module_LTLIBRARIES += systemd-notify.la
> +libweston_module_LTLIBRARIES += systemd-notify.la
>  systemd_notify_la_LDFLAGS = -module -avoid-version
>  systemd_notify_la_LIBADD = $(SYSTEMD_DAEMON_LIBS)
>  systemd_notify_la_CFLAGS =   \
> @@ -210,8 +213,8 @@ pkgconfig_DATA = src/weston.pc
>  wayland_sessiondir = $(datadir)/wayland-sessions
>  dist_wayland_session_DATA = src/weston.desktop
>  
> -westonincludedir = $(includedir)/weston
> -westoninclude_HEADERS =  \
> +libwestonincludedir = $(includedir)/libweston-${LIBWESTON_ABI_VERSION}
> +libwestoninclude_HEADERS =   \
>   src/version.h   \
>   src/compositor.h\
>   src/compositor-drm.h\
> @@ -226,13 +229,16 @@ westoninclude_HEADERS = \
>   shared/zalloc.h \
>   shared/platform.h
>  
> +westonincludedir = $(includedir)/weston
> +westoninclude_HEADERS = src/weston.h
> +
>  if ENABLE_IVI_SHELL
>  westoninclude_HEADERS += \
>   ivi-shell/ivi-layout-export.h
>  endif
>  
>  if ENABLE_EGL
> -module_LTLIBRARIES += gl-renderer.la
> +libweston_module_LTLIBRARIES += gl-renderer.la
>  gl_renderer_la_LDFLAGS = -module -avoid-version
>  

[PATCH weston 0/2] compositor: Support linux_dmabuf multiplanar formats for scanout/sprite planes

2016-05-27 Thread Tomohito Esaki
These patches add support multiplanar formats by using linux_dmabuf instead of
gbm for scanout/sprite plane importing.

When rendering linux_dmabuf buffers, gbm isn't required, and multiplanar
formats can be supported by using drmModeAddFB2() instead of gbm_import().

The first patch adapts the functions that create and destroy the drm_fb struct
to add support for linux_dmabuf.

Tomohito Esaki (2):
  compositor-drm: Add scanout support for linux_dmabuf buffers
  compositor-drm: Support linux_dmabuf output for sprite planes without
gbm

 src/compositor-drm.c | 175 +--
 1 file changed, 127 insertions(+), 48 deletions(-)

-- 
2.7.4

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


Re: [PATCH 5/6] compositor: recompute output position on mode switch

2016-05-27 Thread Pekka Paalanen
On Tue, 26 Apr 2016 23:34:07 +0200
David Fort  wrote:

> When an output permanently changes its resolution, the output on the right
> should be moved accordingly. We also add an event for output resizing so that
> plugins can react when an output is resized.
> 
> Signed-off-by: David Fort 
> ---
>  src/compositor.c | 34 --
>  src/compositor.h |  1 +
>  2 files changed, 25 insertions(+), 10 deletions(-)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index b88936b..6653bb2 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -143,6 +143,11 @@ static void weston_mode_switch_finish(struct 
> weston_output *output,
>   }
>  }
>  
> +
> +static void
> +weston_compositor_reflow_outputs(struct weston_compositor *compositor,
> + struct weston_output *resized_output, int 
> delta_width);
> +
>  WL_EXPORT int
>  weston_output_mode_set_native(struct weston_output *output,
> struct weston_mode *mode,
> @@ -150,6 +155,7 @@ weston_output_mode_set_native(struct weston_output 
> *output,
>  {
>   int ret;
>   int mode_changed = 0, scale_changed = 0;
> + struct weston_mode *old_mode;
>  
>   if (!output->switch_mode)
>   return -1;
> @@ -165,11 +171,16 @@ weston_output_mode_set_native(struct weston_output 
> *output,
>   }
>   }
>  
> + old_mode = output->native_mode;
>   output->native_mode = mode;
>   output->native_scale = scale;
>  
>   weston_mode_switch_finish(output, mode_changed, scale_changed);
>  
> + if (old_mode)
> + weston_compositor_reflow_outputs(output->compositor, output, 
> mode->width - old_mode->width);

Hi,

I think you have to account for the scale here, too. Output position
and size are in global units, while mode width and height are in output
pixels, and the difference between those is the output scale.

Since weston_mode_switch_finish() is already called, you could just
inspect output->width instead of mode, and you should get the units
right directly.

> +
> + wl_signal_emit(>compositor->output_resized_signal, output);
>   return 0;
>  }
>  
> @@ -4047,23 +4058,25 @@ bind_output(struct wl_client *client,
>   wl_output_send_done(resource);
>  }
>  
> -/* Move other outputs when one is removed so the space remains contiguos. */
> +/* Move other outputs when one is resized so the space remains contiguous. */
>  static void
> -weston_compositor_remove_output(struct weston_compositor *compositor,
> - struct weston_output *remove_output)
> +weston_compositor_reflow_outputs(struct weston_compositor *compositor,
> + struct weston_output *resized_output, int 
> delta_width)
>  {
>   struct weston_output *output;
> - int offset = 0;
> + bool start_resizing = false;
> +
> + if (!delta_width)
> + return;
>  
>   wl_list_for_each(output, >output_list, link) {
> - if (output == remove_output) {
> - offset = output->width;
> + if (output == resized_output) {
> + start_resizing = true;
>   continue;
>   }
>  
> - if (offset > 0) {
> - weston_output_move(output,
> -output->x - offset, output->y);
> + if (start_resizing) {
> + weston_output_move(output, output->x + delta_width, 
> output->y);
>   output->dirty = 1;
>   }
>   }
> @@ -4086,7 +4099,7 @@ weston_output_destroy(struct weston_output *output)
>  
>   weston_presentation_feedback_discard_list(>feedback_list);
>  
> - weston_compositor_remove_output(output->compositor, output);
> + weston_compositor_reflow_outputs(output->compositor, output, 
> output->width);
>   wl_list_remove(>link);
>  
>   wl_signal_emit(>compositor->output_destroyed_signal, output);
> @@ -4706,6 +4719,7 @@ weston_compositor_create(struct wl_display *display, 
> void *user_data)
>   wl_signal_init(>output_created_signal);
>   wl_signal_init(>output_destroyed_signal);
>   wl_signal_init(>output_moved_signal);
> + wl_signal_init(>output_resized_signal);
>   wl_signal_init(>session_signal);
>   ec->session_active = 1;
>  
> diff --git a/src/compositor.h b/src/compositor.h
> index cb9df00..b71ade0 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -743,6 +743,7 @@ struct weston_compositor {
>   struct wl_signal output_created_signal;
>   struct wl_signal output_destroyed_signal;
>   struct wl_signal output_moved_signal;
> + struct wl_signal output_resized_signal;

Please add a comment explaining what the callback data argument is.

>  
>   struct wl_signal session_signal;
>   int session_active;

With those two fixed:
Reviewed-by: Pekka 

Re: [PATCH 6/6] desktop-shell: resize background, panel and lock surface on output resize

2016-05-27 Thread Pekka Paalanen
On Tue, 26 Apr 2016 23:34:08 +0200
David Fort  wrote:

> When an output is resized (permanent mode switch), we should also notify the
> shell client so that the panel, background and the lock screen fits to the
> new screen dimensions.
> 
> Signed-off-by: David Fort 
> ---
>  desktop-shell/shell.c | 60 
> +++
>  desktop-shell/shell.h |  7 ++
>  2 files changed, 67 insertions(+)
> 
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index cd269a8..99dcd3e 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -4375,6 +4375,16 @@ background_configure(struct weston_surface *es, 
> int32_t sx, int32_t sy)
>  }
>  
>  static void
> +handle_background_surface_destroy(struct wl_listener *listener, void *data)
> +{
> + struct desktop_shell *shell =
> + container_of(listener, struct desktop_shell, 
> background_surface_listener);
> +
> + weston_log("background surface gone\n");
> + shell->background_surface = NULL;
> +}
> +
> +static void
>  desktop_shell_set_background(struct wl_client *client,
>struct wl_resource *resource,
>struct wl_resource *output_resource,
> @@ -4405,6 +4415,10 @@ desktop_shell_set_background(struct wl_client *client,
>   surface_resource,
>   surface->output->width,
>   surface->output->height);
> + shell->background_surface = surface;
> +
> + shell->background_surface_listener.notify = 
> handle_background_surface_destroy;
> + wl_signal_add(>destroy_signal, 
> >background_surface_listener);

This will cause list corruption with multiple outputs.

>  }
>  
>  static int
> @@ -4426,6 +4440,17 @@ panel_configure(struct weston_surface *es, int32_t sx, 
> int32_t sy)
>  }
>  
>  static void
> +handle_panel_surface_destroy(struct wl_listener *listener, void *data)
> +{
> + struct desktop_shell *shell =
> + container_of(listener, struct desktop_shell, 
> panel_surface_listener);
> +
> + weston_log("panel surface gone\n");
> + shell->panel_surface = NULL;
> +}
> +
> +
> +static void
>  desktop_shell_set_panel(struct wl_client *client,
>   struct wl_resource *resource,
>   struct wl_resource *output_resource,
> @@ -4456,6 +4481,10 @@ desktop_shell_set_panel(struct wl_client *client,
>   surface_resource,
>   surface->output->width,
>   surface->output->height);
> +
> + shell->panel_surface_listener.notify = handle_panel_surface_destroy;
> + wl_signal_add(>destroy_signal, >panel_surface_listener);
> + shell->panel_surface = surface;

This will cause list corruption with multiple outputs.

>  }
>  
>  static int
> @@ -6368,11 +6397,40 @@ handle_output_destroy(struct wl_listener *listener, 
> void *data)
>   shell_for_each_layer(shell, shell_output_destroy_move_layer, output);
>  
>   wl_list_remove(_listener->destroy_listener.link);
> + wl_list_remove(_listener->resized_listener.link);
>   wl_list_remove(_listener->link);
>   free(output_listener);
>  }
>  
>  static void
> +shell_resize_surface_to_output(struct desktop_shell *shell,
> + struct weston_surface *surface,
> + const struct weston_output *output)
> +{
> + if (!surface)
> + return;
> +
> + weston_desktop_shell_send_configure(shell->child.desktop_shell, 0,
> + surface->resource,
> + output->width,
> + output->height);
> +}
> +
> +
> +static void
> +handle_output_resized(struct wl_listener *listener, void *data)
> +{
> + struct shell_output *output_listener =

That is not a listener, that is a shell_output. You probably looked at
a place that actually had a struct myfoo_listener for an example, but
here it is not like that.

> + container_of(listener, struct shell_output, resized_listener);
> + struct weston_output *output = output_listener->output;
> + struct desktop_shell *shell = output_listener->shell;
> +
> + shell_resize_surface_to_output(shell, shell->background_surface, 
> output);
> + shell_resize_surface_to_output(shell, shell->panel_surface, output);
> + shell_resize_surface_to_output(shell, shell->lock_surface, output);

I don't think we ever had the lock surface resized to fill the whole
output. The lock surface is not per-output anyway, there is only one
even with multiple outputs.

Handling the lock surface correctly will need more work. Not only you
need to ensure it stays centered, one should also tell it to resize
only as necessary. We currently do not send any 

Re: [PATCH] rdp: don't release the seat until it is safe v2

2016-05-27 Thread Pekka Paalanen
On Fri, 20 May 2016 15:02:02 +0200
Hardening  wrote:

> Le 20/05/2016 11:58, Sam Spilsbury a écrit :
> > On Fri, May 20, 2016 at 5:33 PM, David Fort  wrote:  
> >> Releasing a seat is not safe, so let's just announce it without keyboard
> >> and mouse until this is fixed. Without this patch we just can't reconnect 
> >> on
> >> the RDP compositor as it crashes.
> >>
> >> v2: fixed the leak of the xkb_keymap
> >>
> >> Signed-off-by: David Fort 
> >> ---
> >>  src/compositor-rdp.c | 33 -
> >>  1 file changed, 20 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> >> index 4fc7c74..52cf426 100644
> >> --- a/src/compositor-rdp.c
> >> +++ b/src/compositor-rdp.c
> >> @@ -109,7 +109,7 @@ enum peer_item_flags {
> >>  struct rdp_peers_item {
> >> int flags;
> >> freerdp_peer *peer;
> >> -   struct weston_seat seat;
> >> +   struct weston_seat *seat;
> >>
> >> struct wl_list link;
> >>  };
> >> @@ -640,9 +640,9 @@ rdp_peer_context_free(freerdp_peer* client, 
> >> RdpPeerContext* context)
> >> }
> >>
> >> if (context->item.flags & RDP_PEER_ACTIVATED) {
> >> -   weston_seat_release_keyboard(>item.seat);
> >> -   weston_seat_release_pointer(>item.seat);
> >> -   weston_seat_release(>item.seat);
> >> +   weston_seat_release_keyboard(context->item.seat);
> >> +   weston_seat_release_pointer(context->item.seat);
> >> +   /*weston_seat_release(context->item.seat);*/
> >> }  
> > 
> > I think instead of just having commented out code, put the reasons why
> > the seat cannot be released safely at the moment. Just having it
> > commented out will confuse future maintainers.
> >   
> 
> Well, future maintainers actually means me. The explanation is quite
> long, I don't think a comment in the code is the right place for this.
> And BTW it's not something that is RDP compositor specific, all the
> weston compositors have it.

That is even more reason to add a comment there. Please do so, gather
review tags, and re-send. The future you is not the same as today's you.

You don't have to make comment exhaustive, even though that would be
good. As long as there is /* XXX: should weston_seat_release() here,
but it will crash on reconnect */ or something like that would be
enough.

> >>
> >> Stream_Free(context->encode_stream, TRUE);
> >> @@ -911,9 +911,16 @@ xf_peer_activate(freerdp_peer* client)
> >> else
> >> snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
> >> settings->ClientAddress);
> >>
> >> -   weston_seat_init(>seat, b->compositor, seat_name);
> >> -   weston_seat_init_keyboard(>seat, keymap);
> >> -   weston_seat_init_pointer(>seat);
> >> +   peersItem->seat = zalloc(sizeof(*peersItem->seat));
> >> +   if (!peersItem->seat) {
> >> +   xkb_keymap_unref(keymap);
> >> +   weston_log("unable to create a weston_seat\n");
> >> +   return FALSE;
> >> +   }
> >> +
> >> +   weston_seat_init(peersItem->seat, b->compositor, seat_name);
> >> +   weston_seat_init_keyboard(peersItem->seat, keymap);
> >> +   weston_seat_init_pointer(peersItem->seat);  
> > 
> > Any reason to make this dynamically allocated memory? It seems to me
> > like it is adding an additional point of failure for little added
> > benefit. If it needs to be dynamically allocated, I think such a
> > change should come in a separate patch, since it seems unrelated to
> > this one.
> >   
> 
> I have already answered this in a previous mail to Bryce. To do it
> short, it's because the seat has to live longer than the RdpPeerContext.
> So when the RDP peer disconnects, the RdpPeerContext will be destroyed
> immediately, while the seat is supposed to live until all wayland client
> have released it.
> 
> 
> > Reviewed-by: Sam Spilsbury 
> >   

Yeah, it indeed seems no other backend dynamically destroys and
re-creates whole seats, they only do it with the specific device
capabilities, so the idea of this patch is good to me.

However, I think you really should store the weston_seat pointer
somewhere where it does not get lost, so you can re-use it, and destroy
it on compositor shutdown.

Anyway, leaking seems better than crashing, so:
Acked-by: Pekka Paalanen 


Thanks,
pq


pgpmxxkvxjQ86.pgp
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland] scanner: Replace #define tab with space

2016-05-27 Thread Quentin Glidic

On 24/05/2016 21:55, Yong Bakos wrote:

From: Yong Bakos 

wayland-client-protocol.h and wayland-server-protocol.h use a tab
between the identifier and token of generated #defines for request/event
opcodes and versions. While this sometimes enables vertical alignment,
it more frequently doesn't, and leads to awkward spacing.

Replace the tab with a space, for consistency and readability.

Signed-off-by: Yong Bakos 



Reviewed-by: Quentin Glidic 
Tested-by: Quentin Glidic 

Cheers,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel