Re: [PATCH wayland-protocols v4] Add screensaver idle inhibitor protocol

2016-08-12 Thread Bryce Harrington
On Fri, Aug 12, 2016 at 04:40:15PM +0800, Jonas Ådahl wrote:
> As one probably already noticed, this was pushed earlier and was
> included in wayland-protocols 1.6.
> 
> 
> Jonas

Thanks again Jonas.

Bryce

> On Thu, Jul 14, 2016 at 06:35:31PM -0700, Bryce Harrington wrote:
> > This interface allows disabling of screensaver/screenblanking on a
> > per-surface basis.  As long as the surface remains visible and
> > non-occluded it blocks the screensaver, etc. from activating on the
> > output(s) that the surface is visible on.
> > 
> > To uninhibit, simply destroy the inhibitor object.
> > 
> > Signed-off-by: Bryce Harrington 
> > ---
> >  Makefile.am|  1 +
> >  unstable/idle-inhibit/README   |  4 ++
> >  unstable/idle-inhibit/idle-inhibit-unstable-v1.xml | 83 
> > ++
> >  3 files changed, 88 insertions(+)
> >  create mode 100644 unstable/idle-inhibit/README
> >  create mode 100644 unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
> > 
> > diff --git a/Makefile.am b/Makefile.am
> > index 71d2632..de691db 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -8,6 +8,7 @@ unstable_protocols =
> > \
> > unstable/relative-pointer/relative-pointer-unstable-v1.xml  
> > \
> > unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
> > \
> > unstable/tablet/tablet-unstable-v1.xml  
> > \
> > +   unstable/idle-inhibit/idle-inhibit-unstable-v1.xml  
> > \
> > $(NULL)
> >  
> >  stable_protocols = 
> > \
> > diff --git a/unstable/idle-inhibit/README b/unstable/idle-inhibit/README
> > new file mode 100644
> > index 000..396e871
> > --- /dev/null
> > +++ b/unstable/idle-inhibit/README
> > @@ -0,0 +1,4 @@
> > +Screensaver inhibition protocol
> > +
> > +Maintainers:
> > +Bryce Harrington 
> > diff --git a/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml 
> > b/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
> > new file mode 100644
> > index 000..70372fc
> > --- /dev/null
> > +++ b/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
> > @@ -0,0 +1,83 @@
> > +
> > +
> > +
> > +  
> > +Copyright © 2015 Samsung Electronics Co., Ltd
> > +
> > +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.
> > +  
> > +
> > +  
> > +
> > +  This interface permits inhibiting the idle behavior such as screen
> > +  blanking, locking, and screensaving.  The client binds the idle 
> > manager
> > +  globally, then creates idle-inhibitor objects for each surface.
> > +
> > +  Warning! The protocol described in this file is experimental and
> > +  backward incompatible changes may be made. Backward compatible 
> > changes
> > +  may be added together with the corresponding interface version bump.
> > +  Backward incompatible changes are done by bumping the version number 
> > in
> > +  the protocol and interface names and resetting the interface version.
> > +  Once the protocol is to be declared stable, the 'z' prefix and the
> > +  version number in the protocol and interface names are removed and 
> > the
> > +  interface version number is reset.
> > +
> > +
> > +
> > +  
> > +   This destroys the inhibit manager.
> > +  
> > +
> > +
> > +
> > +  
> > +   Create a new inhibitor object associated with the given surface.
> > +  
> > +  
> > +   > +  summary="the surface that inhibits the idle behavior"/>
> > +
> > +
> > +  
> > +
> > +  
> > +
> > +  An idle inhibitor prevents the output that the 

Re: [PATCH wayland] shm: Make shm_pool_interface static const

2016-08-12 Thread Bryce Harrington
On Fri, Aug 12, 2016 at 12:04:41PM -0700, Yong Bakos wrote:
> From: Yong Bakos 
> 
> Add static const modifiers to the shm_pool_interface definition,
> making it consistent with the other wl_*_interface definitions and
> mundanely safer.
> 
> Note that this does not affect the ABI, according to abi-dumper and
> abi-compliance-checker[1]; and weston and its shm-backed clients still
> run as expected.
> 
> [1]: http://lvc.github.io/abi-compliance-checker/
> 
> Signed-off-by: Yong Bakos 
> Tested-by: Yong Bakos 

Acked-by: Bryce Harrington 
> ---
>  src/wayland-shm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/wayland-shm.c b/src/wayland-shm.c
> index 7fea364..8e2ef77 100644
> --- a/src/wayland-shm.c
> +++ b/src/wayland-shm.c
> @@ -247,7 +247,7 @@ shm_pool_resize(struct wl_client *client, struct 
> wl_resource *resource,
>   shm_pool_finish_resize(pool);
>  }
>  
> -struct wl_shm_pool_interface shm_pool_interface = {
> +static const struct wl_shm_pool_interface shm_pool_interface = {
>   shm_pool_create_buffer,
>   shm_pool_destroy,
>   shm_pool_resize
> -- 
> 2.7.2
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland 0/8] protocol: documentation improvements

2016-08-12 Thread Bryce Harrington
On Thu, Aug 11, 2016 at 02:32:57PM -0700, Yong Bakos wrote:
> From: Yong Bakos 
> 
> This series "fills in the blanks" of all missing summary attributes in
> wayland.xml, and massages some inconsistencies I found along the way.
> 
> Patch 1/8 is the meatiest, and incorporates Pekka's feedback from the RFC[1].
> 
> Patches 2 - 8 Apply changes for consistency, and some minor clarifications I
> chose to add based on #wayland conversations.
> 
> [1] https://patchwork.freedesktop.org/patch/90745/
> 
> Yong Bakos (8):
>   protocol: Add summary attributes to request params and enum entries
>   protocol: Hyphenate subsurface
>   protocol: Capitalize ID for consistency
>   protocol: Add missing line break
>   protocol: Correct description indentation
>   protocol: Remove wl_ prefix from summary descriptions
>   protocol: Describe serial as serial number
>   protocol: Specify upper left corner of damage rectangle
> 
>  protocol/wayland.xml | 388 
> ++-
>  1 file changed, 201 insertions(+), 187 deletions(-)

Pushed the set:
   1c3213a..a285fa9  master -> master
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland] server: Add doxygen comment for wl_client_for_each

2016-08-12 Thread Bryce Harrington
On Thu, Aug 11, 2016 at 01:07:51PM -0700, Bryce Harrington wrote:
> On Thu, Aug 11, 2016 at 12:13:37PM -0700, Yong Bakos wrote:
> > From: Yong Bakos 
> > 
> > Commit 596024f728b0a1292ee69a80dd72a85167870936 includes a doc comment
> > with a link to the wl_client_for_each macro, causing an error when 
> > generating
> > documentation.
> > 
> > Add a doc comment to wl_client_for_each, enabling the hyperlink and removing
> > the error.
> > 
> > Signed-off-by: Yong Bakos 
> 
> Reviewed-by: Bryce Harrington 

Pushed:
   450f06e..1c3213a  master -> master
 
> > ---
> >  src/wayland-server-core.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
> > index 69c09dc..5b5112f 100644
> > --- a/src/wayland-server-core.h
> > +++ b/src/wayland-server-core.h
> > @@ -180,6 +180,7 @@ wl_client_get_link(struct wl_client *client);
> >  struct wl_client *
> >  wl_client_from_link(struct wl_list *link);
> >  
> > +/** Iterate over a list of clients. */
> >  #define wl_client_for_each(client, list)   \
> > for (client = wl_client_from_link((list)->next);\
> >  wl_client_get_link(client) != (list);  \
> > -- 
> > 2.7.2
> > 
> > ___
> > wayland-devel mailing list
> > wayland-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland] shm: Make shm_pool_interface static const

2016-08-12 Thread Yong Bakos
From: Yong Bakos 

Add static const modifiers to the shm_pool_interface definition,
making it consistent with the other wl_*_interface definitions and
mundanely safer.

Note that this does not affect the ABI, according to abi-dumper and
abi-compliance-checker[1]; and weston and its shm-backed clients still
run as expected.

[1]: http://lvc.github.io/abi-compliance-checker/

Signed-off-by: Yong Bakos 
Tested-by: Yong Bakos 
---
 src/wayland-shm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index 7fea364..8e2ef77 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -247,7 +247,7 @@ shm_pool_resize(struct wl_client *client, struct 
wl_resource *resource,
shm_pool_finish_resize(pool);
 }
 
-struct wl_shm_pool_interface shm_pool_interface = {
+static const struct wl_shm_pool_interface shm_pool_interface = {
shm_pool_create_buffer,
shm_pool_destroy,
shm_pool_resize
-- 
2.7.2

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


Re: [PATCH wayland-protocols 1/4 v5] xdg-shell: Introduce xdg_positioner

2016-08-12 Thread Bryce Harrington
On Fri, Aug 12, 2016 at 12:45:33PM +0800, Jonas Ådahl wrote:
> On Thu, Aug 11, 2016 at 09:36:42PM -0700, Bryce Harrington wrote:
> > On Fri, Aug 12, 2016 at 12:33:42PM +0800, Jonas Ådahl wrote:
> > > On Thu, Aug 11, 2016 at 09:08:15PM -0700, Bryce Harrington wrote:
> > > > On Fri, Aug 12, 2016 at 11:51:38AM +0800, Jonas Ådahl wrote:
> > > > > On Thu, Aug 11, 2016 at 08:39:08PM -0700, Bryce Harrington wrote:
> > > > > > On Fri, Jul 29, 2016 at 12:04:53PM +0800, Jonas Ådahl wrote:
> > > > > > > xdg_positioner is a method for declarative positioning of child 
> > > > > > > surfaces
> > > > > > > (currently only xdg_popup surfaces). A client creates a 
> > > > > > > description of a
> > > > > > > positioning logic using the xdg_positioner interface. The 
> > > > > > > xdg_positioner
> > > > > > > object is then used when creating a xdg_popup for describing how 
> > > > > > > the
> > > > > > > child surface should be positioned in relation to the parent 
> > > > > > > surface.
> > > > > > > 
> > > > > > > Signed-off-by: Jonas Ådahl 
> > > > > > > Signed-off-by: Mike Blumenkrantz 
> > > > > > > Acked-by: Yong Bakos 
> > > > > > > Acked-by: Quentin Glidic 
> > > > > > > ---
> > > > > > > 
> > > > > > > Changes since v4:
> > > > > > > 
> > > > > > >  - Changed the description of xdg_positioner.set_anchor and
> > > > > > >xdg_positioner.set_gravity with the intention of clarifying 
> > > > > > > semantics
> > > > > > >(especially when not setting a anchor/gravity on one or more 
> > > > > > > axes).
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > >  unstable/xdg-shell/xdg-shell-unstable-v6.xml | 276 
> > > > > > > ++-
> > > > > > >  1 file changed, 273 insertions(+), 3 deletions(-)
> > > > > > > 
> > > > > > > diff --git a/unstable/xdg-shell/xdg-shell-unstable-v6.xml 
> > > > > > > b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > > > > > > index 0771668..1d59a0e 100644
> > > > > > > --- a/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > > > > > > +++ b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > > > > > > @@ -45,6 +45,8 @@
> > > > > > >summary="the client specified an invalid popup parent 
> > > > > > > surface"/>
> > > > > > > > > > > > >summary="the client provided an invalid surface state"/>
> > > > > > > +   > > > > > > +  summary="the client provided an invalid positioner"/>
> > > > > > >  
> > > > > > >  
> > > > > > >  
> > > > > > > @@ -57,6 +59,15 @@
> > > > > > >
> > > > > > >  
> > > > > > >  
> > > > > > > +
> > > > > > > +  
> > > > > > > + Create a positioner object. A positioner object is used to 
> > > > > > > position
> > > > > > > + surfaces relative to some parent surface. See the interface 
> > > > > > > description
> > > > > > > + and xdg_surface.get_popup for details.
> > > > > > > +  
> > > > > > > +   > > > > > > interface="zxdg_positioner_v6"/>
> > > > > > > +
> > > > > > > +
> > > > > > >  
> > > > > > >
> > > > > > >   This creates an xdg_surface for the given surface. While 
> > > > > > > xdg_surface
> > > > > > > @@ -101,6 +112,250 @@
> > > > > > >  
> > > > > > >
> > > > > > >  
> > > > > > > +  
> > > > > > > +
> > > > > > > +  The xdg_positioner provides an interface for constructing 
> > > > > > > positioning
> > > > > > > +  rules used for positioning a child surface relative to a 
> > > > > > > parent surface
> > > > > > > +  in a certain way. It allows methods for defining a rule 
> > > > > > > that will make
> > > > > > > +  the child surface stay within the border of the visible 
> > > > > > > area of the
> > > > > > > +  screen, with different ways in which the child surface 
> > > > > > > should change
> > > > > > > +  its position, including sliding along an axis, or flipping 
> > > > > > > around a
> > > > > > > +  rectangle.
> > > > > > > +
> > > > > > > +  See the various requests for details about possible rules.
> > > > > > > +
> > > > > > > +  Semantically, an xdg_positioner is a collection of 
> > > > > > > positioning rules. When
> > > > > > > +  used for positioning a surface, for example when passed as 
> > > > > > > an argument to
> > > > > > > +  xdg_surface.get_popup, the compositor copies the rules 
> > > > > > > that were set up at
> > > > > > > +  the time of the request. Making any changes or destroying 
> > > > > > > the object after
> > > > > > > +  it was used has no effect on previous usages.
> > > > > > 
> > > > > > This description is a bit wordy; I took a shot at copyediting it to 
> > > > > > be
> > > > > > slightly more concise:
> > > > > > 
> > > > > >   The xdg_positioner provides a collection of rules for the 
> > > > > > placement of
> > > > > >   a child surface relative to a parent surface.  Rules can be 
> > > > > > defined to
> > > > > >   ensure the child 

Re: [PATCH wayland-protocols 3/4 v2] xdg-shell: Add resize_x/y constrain adjustment to positioner

2016-08-12 Thread Bryce Harrington
On Fri, Aug 12, 2016 at 12:44:49PM +0800, Jonas Ådahl wrote:
> On Thu, Aug 11, 2016 at 09:35:57PM -0700, Bryce Harrington wrote:
> > On Fri, Aug 12, 2016 at 11:56:13AM +0800, Jonas Ådahl wrote:
> > > On Thu, Aug 11, 2016 at 08:49:01PM -0700, Bryce Harrington wrote:
> > > > On Fri, Jul 29, 2016 at 12:04:55PM +0800, Jonas Ådahl wrote:
> > > > > In order to get feedback of available space where a client can create
> > > > > its popup, let it create requset that its popup rectangle being 
> > > > > resized
> > > > > would it not fit the within the work area. This adds two new constrain
> > > > > adjustment values to the adjustment enum, and dimension parameters to
> > > > > the xdg_popup.configure event.
> > > > > 
> > > > > The existing constrain adjustment actions take precedence, and 
> > > > > resizing
> > > > > will only be triggered if all other adjustments requested didn't 
> > > > > manage
> > > > > to make the popup rectangle fully visible.
> > > > > 
> > > > > Signed-off-by: Jonas Ådahl 
> > > > > Acked-by: Quentin Glidic 
> > > > > ---
> > > > > 
> > > > > Chances since v1: none
> > > > > 
> > > > > 
> > > > > 
> > > > >  unstable/xdg-shell/xdg-shell-unstable-v6.xml | 40 
> > > > > +---
> > > > >  1 file changed, 30 insertions(+), 10 deletions(-)
> > > > > 
> > > > > diff --git a/unstable/xdg-shell/xdg-shell-unstable-v6.xml 
> > > > > b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > > > > index 2c8f636..ef45ff4 100644
> > > > > --- a/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > > > > +++ b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> > > > > @@ -249,6 +249,19 @@
> > > > >  
> > > > >  
> > > > >  
> > > > > +  
> > > > > + The constrain adjustment value define ways the compositor will 
> > > > > adjust
> > > > > + the position of the surface, if the unadjusted position would 
> > > > > result
> > > > > + in the surface being partly constrained.
> > > > 
> > > > "constraint adjustment" maybe?
> > > 
> > > Isn't 'constraint' the noun, and 'constrain' the verb? What I mean is
> > > the adjustment done while constraining. I'm not a native speaker, so I
> > > suppose you'd know what to use better.
> > 
> > Yeah I'm not sure, Yong might have a better idea.  But "constrain
> > adjustment" doesn't sound right to my ears.
> > 
> > Googling, I see the phrasing "constraint adjustment" and "constrained
> > adjustment", but not "constrain adjustment".
> > 
> > Poking through the google results, "constraint adjustment" are
> > adjustments that implement different types of constraints.  "Constrained
> > adjustments" are types of adjustments which are constrained (as opposed
> > to "free adjustments" that are not constrained).  So maybe "constraint
> > adjustment" might be the right terminology here, but I'm not certain.
> > 
> > Also I think you can just say, "constraint adjustment" rather than
> > "constraint adjustment value".
> 
> Maybe thats better than. Do you mean the request name or just the
> documentation should be updated, if we decide something other than
> 'constrain adjustment' should be used.

I'm only suggesting the documentation be corrected.  If the request name
also can be updated to be consistent that would be ideal, if it doesn't
break the API.
 
> CC:ing Yong for some grammar input.
> 
> > 
> > > > > + What a constrained surface means is compositor specific, but it 
> > > > > could
> > > > > + for example be partly outside of the work area of a monitor.
> > > > 
> > > > I'm not sure what this sentence means.
> > > 
> > > What I try to communicate is that what a 'constrained' surface is an
> > > implementation detail.  Commonly 'constrained' means to be partly
> > > outside of the work area (monitor region excluding panel etc), while
> > > unconstrained completely within that work area. Do you have a better
> > > suggestion?
> > 
> > Ah, I think I get it now.
> > 
> > Whether a surface is considered 'constrained' is left to the compositor
> > to determine.  For example, the surface may be partly outside the
> > compositor's defined 'work area', thus necessitating the child surface's
> > position be adjusted until it is entirely inside the work area.
> 
> Right. Its meant to be a compositor implementation detail so that we can
> do crazy things like 3D compositors where 'unconstrained' might mean its
> "inside a wall in the 3D space", or "infinite work areas" where nothing is 
> ever
> unconstrained.

Ok, sounds good.  So I'd suggest using the text I wrote there, I think
that might be a bit clearer.

Bryce

> Jonas
> 
> > 
> > > > > + Multiple constrain adjustment values can be combined, in which 
> > > > > case
> > > > > + they have a defined precedence. The order of adjustments is: 
> > > > > flip,
> > > > > + slide then resize.
> > > > 
> > > > The adjustments can be combined, according to a defined
> > > > precedence: 1) Flip, 2) Slide, 3) Resize.
> > > 

Re: [PATCH 1/3 v3] wayland-server: Add API to control globals visibility

2016-08-12 Thread Yong Bakos
Hi Olivier,
I thought you'd say that. :)
Ok, I get it - I did think of those things as well although coming to
a different conclusion. However, just consider this...

> On Aug 11, 2016, at 11:32 PM, Olivier Fourdan  wrote:
> 
> Hi Yong,
> 
> Thanks for your follow-up.
> 
> I don;t necessarily agree with your all of comments though, see below.
> 
>>> @@ -164,6 +165,15 @@ wl_global_create(struct wl_display *display,
>>> void
>>> wl_global_destroy(struct wl_global *global);
>>> 
>>> +typedef bool (*wl_display_filter_global_func_t)(const struct wl_client
>>> *client,
>> 
>> After reading this patch a few times, and writing some sample use cases,
>> I really think this type should be named wl_display_global_filter_func_t,
>> meaning "this is a global filter function."
> 
> Err, nope, I disagree, it's not what is meant, precisely.
> 
> Using something like "global_filter" makes it sound like "global" is an 
> adjective for the filter, i.e. the filter is global, which is not the meaning 
> of global here, global here is a noun for "wl_global" (but 
> "wl_display_filter_wl_global_func_t" would sound awkward).
> 
> I intentionally named it "filter_global" to avoid that confusion.
> 
>> Second, perhaps a short comment is necessary here, before the typedef, that
>> states something like:
>> 
>> "A filter function enables the server to decide which globals to
>> advertise to clients. This function should return true if..."
> 
> Yeap, I agree.
> 
>>> +   const struct wl_global *global,
>>> +   void *data);
>>> +
>>> +void
>>> +wl_display_set_filter_global(struct wl_display *display,
>> 
>> This should be set_global_filter, matching the name of the struct member...
> 
> Nope, for the same reasons as above.

I agree with your reasons above, but this is a setter associated with
a struct member, and the struct member is called global_filter. As such,
it seems congruent to call the setter set_global_filter.
(Or maybe rename the struct member to filter_global? Perhaps that would
bring the naming inline with the reasons that you stated above, plus
it matches the setter name.)

Respectfully,
yong


> 
>>> +wl_display_filter_global_func_t filter,
>>> +void *data);
>>> +
>>> struct wl_client *
>>> wl_client_create(struct wl_display *display, int fd);
>>> 
>>> diff --git a/src/wayland-server.c b/src/wayland-server.c
>>> index 19aa2e8..480af23 100644
>>> --- a/src/wayland-server.c
>>> +++ b/src/wayland-server.c
>>> @@ -98,6 +98,9 @@ struct wl_display {
>>> struct wl_signal destroy_signal;
>>> 
>>> struct wl_array additional_shm_formats;
>>> +
>>> +   wl_display_filter_global_func_t global_filter;
>> 
>> ... Here, where again the type is better described as
>> wl_display_global_filter_func_t.
> 
> Nope, for the same reasons as above.
> 
>>> +   void *global_filter_data;
>>> };
>>> 
>>> struct wl_global {
>>> @@ -714,6 +717,16 @@ wl_client_destroy(struct wl_client *client)
>>> free(client);
>>> }
>>> 
>> 
>> I would add a short comment here for the filter_global function,
>> that at least explains when it returns true. /Better yet/, if you
>> named this function, say, `is_visible`, `is_advertised`, `is_listed`,
>> or perhaps even
>> 
>> wl_global_is_visible(const struct wl_global *global,
>>  const struct wl_client *client)
>> 
>> Then its usage within registry_bind and display_get_registry
>> becomes very clear.
> 
> Yeap, makes sense, agreed.
> 
>>> +static bool
>>> +filter_global(const struct wl_client *client,
>>> + const struct wl_global *global)
>>> +{
>>> +   struct wl_display *display = client->display;
>>> +
>>> +   return (display->global_filter == NULL ||
>>> +   display->global_filter(client, global, 
>>> display->global_filter_data));
>>> +}
>>> +
>>> static void
>>> registry_bind(struct wl_client *client,
>>>   struct wl_resource *resource, uint32_t name,
>>> @@ -740,6 +753,10 @@ registry_bind(struct wl_client *client,
>>>WL_DISPLAY_ERROR_INVALID_OBJECT,
>>>"invalid version for global %s (%d): 
>>> have %d, wanted %d",
>>>interface, name, global->version, 
>>> version);
>>> +   else if (!filter_global(client, global))
>>> +   wl_resource_post_error(resource,
>>> +  WL_DISPLAY_ERROR_INVALID_OBJECT,
>>> +  "invalid global %s (%d)", interface, 
>>> name);
>>> else
>>> global->bind(client, global->data, version, id);
>>> }
>>> @@ -795,11 +812,12 @@ display_get_registry(struct wl_client *client,
>>>_resource->link);
>>> 
>>> wl_list_for_each(global, >global_list, link)
>>> -   wl_resource_post_event(registry_resource,
>>> -  WL_REGISTRY_GLOBAL,
>>> -  

Re: [PATCH wayland-protocols 3/4 v2] xdg-shell: Add resize_x/y constrain adjustment to positioner

2016-08-12 Thread Yong Bakos
Hi Jonas & Bryce,

> On Aug 11, 2016, at 9:44 PM, Jonas Ådahl  wrote:
> 
> On Thu, Aug 11, 2016 at 09:35:57PM -0700, Bryce Harrington wrote:
>> On Fri, Aug 12, 2016 at 11:56:13AM +0800, Jonas Ådahl wrote:
>>> On Thu, Aug 11, 2016 at 08:49:01PM -0700, Bryce Harrington wrote:
 On Fri, Jul 29, 2016 at 12:04:55PM +0800, Jonas Ådahl wrote:
> In order to get feedback of available space where a client can create
> its popup, let it create requset that its popup rectangle being resized
> would it not fit the within the work area. This adds two new constrain
> adjustment values to the adjustment enum, and dimension parameters to
> the xdg_popup.configure event.
> 
> The existing constrain adjustment actions take precedence, and resizing
> will only be triggered if all other adjustments requested didn't manage
> to make the popup rectangle fully visible.
> 
> Signed-off-by: Jonas Ådahl 
> Acked-by: Quentin Glidic 
> ---
> 
> Chances since v1: none
> 
> 
> 
> unstable/xdg-shell/xdg-shell-unstable-v6.xml | 40 
> +---
> 1 file changed, 30 insertions(+), 10 deletions(-)
> 
> diff --git a/unstable/xdg-shell/xdg-shell-unstable-v6.xml 
> b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> index 2c8f636..ef45ff4 100644
> --- a/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> +++ b/unstable/xdg-shell/xdg-shell-unstable-v6.xml
> @@ -249,6 +249,19 @@
> 
> 
> 
> +  
> + The constrain adjustment value define ways the compositor will adjust
> + the position of the surface, if the unadjusted position would result
> + in the surface being partly constrained.
 
 "constraint adjustment" maybe?
>>> 
>>> Isn't 'constraint' the noun, and 'constrain' the verb? What I mean is
>>> the adjustment done while constraining. I'm not a native speaker, so I
>>> suppose you'd know what to use better.
>> 
>> Yeah I'm not sure, Yong might have a better idea.  But "constrain
>> adjustment" doesn't sound right to my ears.
>> 

I thought of this a while back as well, and the 'right' solution, in my
opinion, would be to rename the enum to constraint_adjustment but also
to go with "The constraint adjustment value" - matching the description
summary. For some reason I resisted suggesting renaming the enum, but I
guess I'm doing that now, FWIW.

yong



>> Googling, I see the phrasing "constraint adjustment" and "constrained
>> adjustment", but not "constrain adjustment".
>> 
>> Poking through the google results, "constraint adjustment" are
>> adjustments that implement different types of constraints.  "Constrained
>> adjustments" are types of adjustments which are constrained (as opposed
>> to "free adjustments" that are not constrained).  So maybe "constraint
>> adjustment" might be the right terminology here, but I'm not certain.
>> 
>> Also I think you can just say, "constraint adjustment" rather than
>> "constraint adjustment value".
> 
> Maybe thats better than. Do you mean the request name or just the
> documentation should be updated, if we decide something other than
> 'constrain adjustment' should be used.
> 
> CC:ing Yong for some grammar input.
> 
>> 
> + What a constrained surface means is compositor specific, but it could
> + for example be partly outside of the work area of a monitor.
 
 I'm not sure what this sentence means.
>>> 
>>> What I try to communicate is that what a 'constrained' surface is an
>>> implementation detail.  Commonly 'constrained' means to be partly
>>> outside of the work area (monitor region excluding panel etc), while
>>> unconstrained completely within that work area. Do you have a better
>>> suggestion?
>> 
>> Ah, I think I get it now.
>> 
>> Whether a surface is considered 'constrained' is left to the compositor
>> to determine.  For example, the surface may be partly outside the
>> compositor's defined 'work area', thus necessitating the child surface's
>> position be adjusted until it is entirely inside the work area.
> 
> Right. Its meant to be a compositor implementation detail so that we can
> do crazy things like 3D compositors where 'unconstrained' might mean its
> "inside a wall in the 3D space", or "infinite work areas" where nothing is 
> ever
> unconstrained.
> 
> 
> Jonas
> 
>> 
> + Multiple constrain adjustment values can be combined, in which case
> + they have a defined precedence. The order of adjustments is: flip,
> + slide then resize.
 
The adjustments can be combined, according to a defined
precedence: 1) Flip, 2) Slide, 3) Resize.
>>> 
>>> Thanks, thats better.
>>> 
>>> 
>>> Jonas
>> 
>> Bryce
>> 
 
> +  
> +
>   
>   
> Don't alter the surface position even if it is constrained on some
> @@ -268,8 +281,6 @@
> x axis until either the edge in the direction 

Re: [PATCH 02/10] libweston: Add initial output API for windowed outputs configuration

2016-08-12 Thread Pekka Paalanen
On Thu, 11 Aug 2016 17:33:57 +0200
Armin Krezović  wrote:

> This adds new plugin-specific API for configuring outputs
> on "windowed" backends, such as X11, wayland/non-fullscreen
> and even headless (although, it doesn't have any windows,
> its configuration is very similar). It can be used from
> compositors to configure pending outputs and should be used
> with previously added weston_output_set_{scale,transform}
> to properly configure an output before enabling it.
> 
> It also supports creating additional outputs on the mentioned
> backends.
> 
> Signed-off-by: Armin Krezović 
> ---
>  Makefile.am|  1 +
>  libweston/output-api.h | 88 
> ++

Hi,

the file name should probably be windowed-output-api.h.

>  2 files changed, 89 insertions(+)
>  create mode 100644 libweston/output-api.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index 32627f5..038e4da 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -245,6 +245,7 @@ libwestoninclude_HEADERS =\
>   libweston/compositor-rdp.h  \
>   libweston/compositor-wayland.h  \
>   libweston/compositor-x11.h  \
> + libweston/output-api.h  \
>   libweston/plugin-registry.h \
>   libweston/timeline-object.h \
>   shared/matrix.h \
> diff --git a/libweston/output-api.h b/libweston/output-api.h
> new file mode 100644
> index 000..ef33587
> --- /dev/null
> +++ b/libweston/output-api.h
> @@ -0,0 +1,88 @@
> +/*
> + * Copyright © 2016 Collabora, Ltd.

I think the copyright is not quite right, is it? :-)
I wouldn't consider the boilerplate in this file copyrightable.

> + *
> + * 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.
> + */
> +
> +#ifndef WESTON_OUTPUT_API_H
> +#define WESTON_OUTPUT_API_H
> +
> +#ifdef  __cplusplus
> +extern "C" {
> +#endif
> +
> +#include "plugin-registry.h"
> +
> +struct weston_compositor;
> +struct weston_output;
> +
> +#define WESTON_WINDOWED_OUTPUT_API_NAME "weston_windowed_output_api_v1"
> +
> +struct weston_windowed_output_api {
> + /** Configure an output with given width and height.
> +  *
> +  * \param output An output to be configured.
> +  * \param width  Desired width of the output.
> +  * \param height Desired height of the output.
> +  *
> +  * This configures a windowed output with desired width and
> +  * height. The backend decides what should be done and applies
> +  * the desired configuration. After using this function and
> +  * generic weston_output_set_{scale,transform}, a windowed
> +  * output should be in a state where weston_output_enable()
> +  * can be run.

Return values?

> +  */
> + int (*output_configure)(struct weston_output *output,
> + int width, int height);

What Quentin said. We use the term "configure" already too much.
set_size()?

> +
> + /** Create a new windowed output.
> +  *
> +  * \param compositor The compositor instance.
> +  * \param name   Desired name for a new output.
> +  *
> +  * This creates a new output in the backend using this API.
> +  * After this function is ran, the created output should be
> +  * ready for configuration using the output_configure() and
> +  * weston_output_set_{scale,transform}().
> +  *
> +  * An optional name can be assigned to it, so it can be used
> +  * by compositor to configure it. It can be NULL.

Return values?

Could we require the name to be set easily? I don't like unnamed
outputs much. Or was there a name generated if this is NULL?

> +  */
> + int (*output_create)(struct weston_compositor *compositor,
> +  const char *name);
> 

Re: [PATCH 01/10] libweston: Add more functionality for handling weston_output objects

2016-08-12 Thread Armin Krezović
On 12.08.2016 18:10, Pekka Paalanen wrote:
> On Fri, 12 Aug 2016 15:33:27 +0200
> Armin Krezović  wrote:
> 
>> On 12.08.2016 15:02, Pekka Paalanen wrote:
>>> On Thu, 11 Aug 2016 17:33:56 +0200
>>> Armin Krezović  wrote:
>>>   
 This patch implements additional functionality that will be used
 for configuring, enabling and disabling weston's outputs. Its
 indended use is by the compositors or user programs that want to
 be able to configure, enable or disable an output at any time. An
 output can only be configured while it's disabled.

 The compositor and backend specific functionality is required
 for these functions to be useful, and those will come later in
 this series.

 All the new functions have been documented, so I'll avoid
 describing them here.

 Signed-off-by: Armin Krezović 
 ---
  libweston/compositor.c | 346 
 -
  libweston/compositor.h |  29 +
  2 files changed, 340 insertions(+), 35 deletions(-)  
> 
 +/** Undoes changes to an output done by weston_output_init()
 + *
 + * \param output The weston_output object that needs the changes undone.
 + *
 + * Removes the repaint timer.
 + * Destroys the Wayland global assigned to the output.
 + * Destroys pixman regions allocated to the output.
 + * Deallocates output's ID and updates compositor's output_id_pool.
 + */
 +static void
 +weston_output_deinit(struct weston_output *output)
 +{
 +  if (!output->initialized)
 +  return;
 +
 +  wl_event_source_remove(output->repaint_timer);
 +
 +  wl_global_destroy(output->global);  
>>>
>>> Destroying the global on deinit instead of disable looks odd...
>>> The same goes for repaint_timer too. It is only needed when the output
>>> is enabled.
>>>   
 +
 +  pixman_region32_fini(>region);
 +  pixman_region32_fini(>previous_damage);  
>>>
>>> Finalizing these regions is the opposite of
>>> weston_output_init_geometry() which is called from
>>> weston_output_init(). So far so good, but patch 10 should move these
>>> into weston_output_disable(), so that it matches weston_output_enable()
>>> initializing these regions.
>>>   
 +  output->compositor->output_id_pool &= ~(1u << output->id);  
>>>
>>> I wonder if output id would be needed only while enabled, but that's not
>>> important.
>>>
>>> Hmm. The three comments above are actually misguided. I wrote them
>>> assuming the deinit is the opposite of init, but it's not. Deinit is the
>>> opposite of enable, more or less.
>>>   
>>
>> Without this, the output could be left partially enabled in 
>> weston_output_enable(),
>> see weston_output_enable() call to output->enable().
>>
>> That means that (currently) weston_output_init() called from 
>> weston_output_enable()
>> will create a global, repaint timer and some pixman regions. Still, 
>> output->enable()
>> MAY fail for some reason, and we want to return the output that was passed to
>> weston_output_enable() in a state it was before that. Naturally, the same 
>> code needs
>> to be called on explicit disable, which is why this function has been 
>> introduced.
>>
>> But, as noted in Patch 10 reply, this function won't be doing the thing it 
>> currently
>> is doing (as current weston_output_init() will be gone by then). It can be 
>> renamed,
>> no big deal.
> 
> Right.
> 
> 
 +/** Converts a weston_output object to a pending output state, so it
 + ** can be configured again or destroyed.
 + *
 + * \param output The weston_output object that needs to be disabled.
 + *
 + * See weston_output_init_pending() for more information on the
 + * state output is returned to.
 + *
 + * Calls a backend specific function to disable an output, in case
 + * such function exists.
 + *
 + * If the output is being used by the compositor, the following happens:
 + *
 + * 1. Presentation feedback is discarded.
 + * 2. Compositor is notified that outputs were changed and
 + *applies the necessary changes.
 + * 3. All views assigned to the weston_output object are
 + *moved to a new output if such exists. Otherwise,
 + *they are marked as dirty and are waiting for a new
 + *output to be assigned.
 + * 4. Signal is emited to notify all users of the weston_output
 + *object that the output is being destroyed.
 + * 5. Resources assigned to an output are destroyed.
 + *
 + * Output is returned to a state it was before weston_output_enable()
 + * was ran. See weston_output_deinit() for more information.
 + *
 + * Output is added to pending_output_list so it will get destroyed
 + * if the output does not get configured again when the compositor
 + * shuts down. If an output is to be used 

Re: [PATCH 01/10] libweston: Add more functionality for handling weston_output objects

2016-08-12 Thread Pekka Paalanen
On Fri, 12 Aug 2016 15:33:27 +0200
Armin Krezović  wrote:

> On 12.08.2016 15:02, Pekka Paalanen wrote:
> > On Thu, 11 Aug 2016 17:33:56 +0200
> > Armin Krezović  wrote:
> >   
> >> This patch implements additional functionality that will be used
> >> for configuring, enabling and disabling weston's outputs. Its
> >> indended use is by the compositors or user programs that want to
> >> be able to configure, enable or disable an output at any time. An
> >> output can only be configured while it's disabled.
> >>
> >> The compositor and backend specific functionality is required
> >> for these functions to be useful, and those will come later in
> >> this series.
> >>
> >> All the new functions have been documented, so I'll avoid
> >> describing them here.
> >>
> >> Signed-off-by: Armin Krezović 
> >> ---
> >>  libweston/compositor.c | 346 
> >> -
> >>  libweston/compositor.h |  29 +
> >>  2 files changed, 340 insertions(+), 35 deletions(-)  

> >> +/** Undoes changes to an output done by weston_output_init()
> >> + *
> >> + * \param output The weston_output object that needs the changes undone.
> >> + *
> >> + * Removes the repaint timer.
> >> + * Destroys the Wayland global assigned to the output.
> >> + * Destroys pixman regions allocated to the output.
> >> + * Deallocates output's ID and updates compositor's output_id_pool.
> >> + */
> >> +static void
> >> +weston_output_deinit(struct weston_output *output)
> >> +{
> >> +  if (!output->initialized)
> >> +  return;
> >> +
> >> +  wl_event_source_remove(output->repaint_timer);
> >> +
> >> +  wl_global_destroy(output->global);  
> > 
> > Destroying the global on deinit instead of disable looks odd...
> > The same goes for repaint_timer too. It is only needed when the output
> > is enabled.
> >   
> >> +
> >> +  pixman_region32_fini(>region);
> >> +  pixman_region32_fini(>previous_damage);  
> > 
> > Finalizing these regions is the opposite of
> > weston_output_init_geometry() which is called from
> > weston_output_init(). So far so good, but patch 10 should move these
> > into weston_output_disable(), so that it matches weston_output_enable()
> > initializing these regions.
> >   
> >> +  output->compositor->output_id_pool &= ~(1u << output->id);  
> > 
> > I wonder if output id would be needed only while enabled, but that's not
> > important.
> > 
> > Hmm. The three comments above are actually misguided. I wrote them
> > assuming the deinit is the opposite of init, but it's not. Deinit is the
> > opposite of enable, more or less.
> >   
> 
> Without this, the output could be left partially enabled in 
> weston_output_enable(),
> see weston_output_enable() call to output->enable().
> 
> That means that (currently) weston_output_init() called from 
> weston_output_enable()
> will create a global, repaint timer and some pixman regions. Still, 
> output->enable()
> MAY fail for some reason, and we want to return the output that was passed to
> weston_output_enable() in a state it was before that. Naturally, the same 
> code needs
> to be called on explicit disable, which is why this function has been 
> introduced.
> 
> But, as noted in Patch 10 reply, this function won't be doing the thing it 
> currently
> is doing (as current weston_output_init() will be gone by then). It can be 
> renamed,
> no big deal.

Right.


> >> +/** Converts a weston_output object to a pending output state, so it
> >> + ** can be configured again or destroyed.
> >> + *
> >> + * \param output The weston_output object that needs to be disabled.
> >> + *
> >> + * See weston_output_init_pending() for more information on the
> >> + * state output is returned to.
> >> + *
> >> + * Calls a backend specific function to disable an output, in case
> >> + * such function exists.
> >> + *
> >> + * If the output is being used by the compositor, the following happens:
> >> + *
> >> + * 1. Presentation feedback is discarded.
> >> + * 2. Compositor is notified that outputs were changed and
> >> + *applies the necessary changes.
> >> + * 3. All views assigned to the weston_output object are
> >> + *moved to a new output if such exists. Otherwise,
> >> + *they are marked as dirty and are waiting for a new
> >> + *output to be assigned.
> >> + * 4. Signal is emited to notify all users of the weston_output
> >> + *object that the output is being destroyed.
> >> + * 5. Resources assigned to an output are destroyed.
> >> + *
> >> + * Output is returned to a state it was before weston_output_enable()
> >> + * was ran. See weston_output_deinit() for more information.
> >> + *
> >> + * Output is added to pending_output_list so it will get destroyed
> >> + * if the output does not get configured again when the compositor
> >> + * shuts down. If an output is to be used immediately, it needs to
> >> + * be manually removed from the list.
> >> + *
> >> + 

Re: [PATCH 03/10] compositor: Implement output configuration using windowed_output_api

2016-08-12 Thread Pekka Paalanen
On Thu, 11 Aug 2016 17:33:58 +0200
Armin Krezović  wrote:

> This implements output configuration for outputs which use
> previously added weston_windowed_output_api. The function
> takes an output that's to be configured, default configuration
> that's to be set in case no configuration is specified in
> the config file or on command line and optional third argument,
> parsed_options, which will override defaults and options for
> configuration if they are present.
> 
> This also introduces new compositor specific functions for
> setting output's scale and transform from either hardcoded
> default, config file option or command line option.
> 
> Pending output handling is also wired up in the compositor.

Hi,

I wouldn't say "wired up" because wet_set_pending_output_handler() is
not called yet in this patch. This patch is more like adding helpers
for the windowed backend-cases.

There are a couple details pointed out below, but all in all this patch
looks good to me. With the potential double-free fixed, you can slap a
Reviewed-by: Pekka Paalanen 
on this patch.

> Signed-off-by: Armin Krezović 
> ---
>  compositor/main.c | 171 
> ++
>  1 file changed, 171 insertions(+)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index 0e5af5b..c5d8e81 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -63,11 +63,21 @@
>  #include "compositor-fbdev.h"
>  #include "compositor-x11.h"
>  #include "compositor-wayland.h"
> +#include "output-api.h"
>  
>  #define WINDOW_TITLE "Weston Compositor"
>  
> +struct wet_output_config {
> + int width;
> + int height;
> + int32_t scale;
> + uint32_t transform;
> +};
> +
>  struct wet_compositor {
>   struct weston_config *config;
> + struct wet_output_config *parsed_options;
> + struct wl_listener pending_output_listener;
>  };
>  
>  static FILE *weston_logfile = NULL;
> @@ -425,6 +435,47 @@ to_wet_compositor(struct weston_compositor *compositor)
>   return weston_compositor_get_user_data(compositor);
>  }
>  
> +static void
> +wet_set_pending_output_handler(struct weston_compositor *ec,
> +wl_notify_func_t handler)
> +{
> + struct wet_compositor *compositor = to_wet_compositor(ec);
> +
> + compositor->pending_output_listener.notify = handler;
> + wl_signal_add(>output_pending_signal, 
> >pending_output_listener);
> +}
> +
> +static struct wet_output_config *
> +wet_get_parsed_options(struct weston_compositor *ec)
> +{
> + struct wet_compositor *compositor = to_wet_compositor(ec);
> +
> + return compositor->parsed_options;
> +}
> +
> +static struct wet_output_config *
> +wet_init_parsed_options(struct weston_compositor *ec)
> +{
> + struct wet_compositor *compositor = to_wet_compositor(ec);
> + struct wet_output_config *config = NULL;
> +
> + config = zalloc(sizeof *config);
> +
> + if (!config) {
> + perror("out of memory");
> + return NULL;
> + }
> +
> + config->width = 0;
> + config->height = 0;
> + config->scale = 0;
> + config->transform = UINT32_MAX;
> +
> + compositor->parsed_options = config;
> +
> + return config;
> +}
> +
>  WL_EXPORT struct weston_config *
>  wet_get_config(struct weston_compositor *ec)
>  {
> @@ -940,6 +991,120 @@ handle_exit(struct weston_compositor *c)
>   wl_display_terminate(c->wl_display);
>  }
>  
> +static void
> +wet_output_set_scale(struct weston_output *output,
> +  struct weston_config_section *section,
> +  int32_t default_scale,
> +  int32_t parsed_scale)
> +{
> + int32_t scale = default_scale;
> +
> + if (section)
> + weston_config_section_get_int(section, "scale", , 
> default_scale);
> +
> + if (parsed_scale)
> + scale = parsed_scale;
> +
> + weston_output_set_scale(output, scale);
> +}
> +
> +/* UINT32_MAX is treated as invalid because 0 is a valid
> + * enumeration value and the parameter is unsigned
> + */
> +static void
> +wet_output_set_transform(struct weston_output *output,
> +  struct weston_config_section *section,
> +  uint32_t default_transform,
> +  uint32_t parsed_transform)
> +{
> + char *t;
> + uint32_t transform = default_transform;
> +
> + if (section) {
> + weston_config_section_get_string(section,
> +  "transform", , "normal");
> +
> + if (weston_parse_transform(t, ) < 0) {
> + weston_log("Invalid transform \"%s\" for output %s\n",
> +t, output->name);
> + transform = default_transform;
> + }
> + free(t);
> + }
> +
> + if (parsed_transform != UINT32_MAX)
> + transform = 

Re: [PATCH 01/10] libweston: Add more functionality for handling weston_output objects

2016-08-12 Thread Armin Krezović
On 12.08.2016 15:02, Pekka Paalanen wrote:
> On Thu, 11 Aug 2016 17:33:56 +0200
> Armin Krezović  wrote:
> 
>> This patch implements additional functionality that will be used
>> for configuring, enabling and disabling weston's outputs. Its
>> indended use is by the compositors or user programs that want to
>> be able to configure, enable or disable an output at any time. An
>> output can only be configured while it's disabled.
>>
>> The compositor and backend specific functionality is required
>> for these functions to be useful, and those will come later in
>> this series.
>>
>> All the new functions have been documented, so I'll avoid
>> describing them here.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  libweston/compositor.c | 346 
>> -
>>  libweston/compositor.h |  29 +
>>  2 files changed, 340 insertions(+), 35 deletions(-)
> 
> Hi Armin,
> 
> this patch is one tough nut to review. I've been struggling with it for
> over two hours now.
> 
>>
>> diff --git a/libweston/compositor.c b/libweston/compositor.c
>> index 2eb3a3b..f60ebb8 100644
>> --- a/libweston/compositor.c
>> +++ b/libweston/compositor.c
>> @@ -4101,41 +4101,6 @@ weston_compositor_reflow_outputs(struct 
>> weston_compositor *compositor,
>>  }
>>  
>>  WL_EXPORT void
>> -weston_output_destroy(struct weston_output *output)
>> -{
>> -struct wl_resource *resource;
>> -struct weston_view *view;
>> -
>> -output->destroying = 1;
>> -
>> -wl_list_for_each(view, >compositor->view_list, link) {
>> -if (view->output_mask & (1u << output->id))
>> -weston_view_assign_output(view);
>> -}
>> -
>> -wl_event_source_remove(output->repaint_timer);
>> -
>> -weston_presentation_feedback_discard_list(>feedback_list);
>> -
>> -weston_compositor_reflow_outputs(output->compositor, output, 
>> output->width);
>> -wl_list_remove(>link);
>> -
>> -wl_signal_emit(>compositor->output_destroyed_signal, output);
>> -wl_signal_emit(>destroy_signal, output);
>> -
>> -free(output->name);
>> -pixman_region32_fini(>region);
>> -pixman_region32_fini(>previous_damage);
>> -output->compositor->output_id_pool &= ~(1u << output->id);
>> -
>> -wl_resource_for_each(resource, >resource_list) {
>> -wl_resource_set_destructor(resource, NULL);
>> -}
>> -
>> -wl_global_destroy(output->global);
>> -}
>> -
>> -WL_EXPORT void
>>  weston_output_update_matrix(struct weston_output *output)
>>  {
>>  float magnification;
>> @@ -4325,6 +4290,8 @@ weston_output_init(struct weston_output *output, 
>> struct weston_compositor *c,
>>  output->global =
>>  wl_global_create(c->wl_display, _output_interface, 3,
>>   output, bind_output);
>> +
>> +output->initialized = true;
>>  }
>>  
>>  /** Adds an output to the compositor's output list and
>> @@ -4363,6 +4330,309 @@ weston_output_transform_coordinate(struct 
>> weston_output *output,
>>  *y = p.f[1] / p.f[3];
>>  }
>>  
>> +/** Undoes changes to an output done by weston_output_init()
>> + *
>> + * \param output The weston_output object that needs the changes undone.
>> + *
>> + * Removes the repaint timer.
>> + * Destroys the Wayland global assigned to the output.
>> + * Destroys pixman regions allocated to the output.
>> + * Deallocates output's ID and updates compositor's output_id_pool.
>> + */
>> +static void
>> +weston_output_deinit(struct weston_output *output)
>> +{
>> +if (!output->initialized)
>> +return;
>> +
>> +wl_event_source_remove(output->repaint_timer);
>> +
>> +wl_global_destroy(output->global);
> 
> Destroying the global on deinit instead of disable looks odd...
> The same goes for repaint_timer too. It is only needed when the output
> is enabled.
> 
>> +
>> +pixman_region32_fini(>region);
>> +pixman_region32_fini(>previous_damage);
> 
> Finalizing these regions is the opposite of
> weston_output_init_geometry() which is called from
> weston_output_init(). So far so good, but patch 10 should move these
> into weston_output_disable(), so that it matches weston_output_enable()
> initializing these regions.
> 
>> +output->compositor->output_id_pool &= ~(1u << output->id);
> 
> I wonder if output id would be needed only while enabled, but that's not
> important.
> 
> Hmm. The three comments above are actually misguided. I wrote them
> assuming the deinit is the opposite of init, but it's not. Deinit is the
> opposite of enable, more or less.
> 

Without this, the output could be left partially enabled in 
weston_output_enable(),
see weston_output_enable() call to output->enable().

That means that (currently) weston_output_init() called from 
weston_output_enable()
will create a global, repaint timer and some pixman regions. Still, 
output->enable()
MAY fail for some reason, and we want to return the output that was passed to

Re: [PATCH 01/10] libweston: Add more functionality for handling weston_output objects

2016-08-12 Thread Pekka Paalanen
On Thu, 11 Aug 2016 17:33:56 +0200
Armin Krezović  wrote:

> This patch implements additional functionality that will be used
> for configuring, enabling and disabling weston's outputs. Its
> indended use is by the compositors or user programs that want to
> be able to configure, enable or disable an output at any time. An
> output can only be configured while it's disabled.
> 
> The compositor and backend specific functionality is required
> for these functions to be useful, and those will come later in
> this series.
> 
> All the new functions have been documented, so I'll avoid
> describing them here.
> 
> Signed-off-by: Armin Krezović 
> ---
>  libweston/compositor.c | 346 
> -
>  libweston/compositor.h |  29 +
>  2 files changed, 340 insertions(+), 35 deletions(-)

Hi Armin,

this patch is one tough nut to review. I've been struggling with it for
over two hours now.

> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 2eb3a3b..f60ebb8 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4101,41 +4101,6 @@ weston_compositor_reflow_outputs(struct 
> weston_compositor *compositor,
>  }
>  
>  WL_EXPORT void
> -weston_output_destroy(struct weston_output *output)
> -{
> - struct wl_resource *resource;
> - struct weston_view *view;
> -
> - output->destroying = 1;
> -
> - wl_list_for_each(view, >compositor->view_list, link) {
> - if (view->output_mask & (1u << output->id))
> - weston_view_assign_output(view);
> - }
> -
> - wl_event_source_remove(output->repaint_timer);
> -
> - weston_presentation_feedback_discard_list(>feedback_list);
> -
> - weston_compositor_reflow_outputs(output->compositor, output, 
> output->width);
> - wl_list_remove(>link);
> -
> - wl_signal_emit(>compositor->output_destroyed_signal, output);
> - wl_signal_emit(>destroy_signal, output);
> -
> - free(output->name);
> - pixman_region32_fini(>region);
> - pixman_region32_fini(>previous_damage);
> - output->compositor->output_id_pool &= ~(1u << output->id);
> -
> - wl_resource_for_each(resource, >resource_list) {
> - wl_resource_set_destructor(resource, NULL);
> - }
> -
> - wl_global_destroy(output->global);
> -}
> -
> -WL_EXPORT void
>  weston_output_update_matrix(struct weston_output *output)
>  {
>   float magnification;
> @@ -4325,6 +4290,8 @@ weston_output_init(struct weston_output *output, struct 
> weston_compositor *c,
>   output->global =
>   wl_global_create(c->wl_display, _output_interface, 3,
>output, bind_output);
> +
> + output->initialized = true;
>  }
>  
>  /** Adds an output to the compositor's output list and
> @@ -4363,6 +4330,309 @@ weston_output_transform_coordinate(struct 
> weston_output *output,
>   *y = p.f[1] / p.f[3];
>  }
>  
> +/** Undoes changes to an output done by weston_output_init()
> + *
> + * \param output The weston_output object that needs the changes undone.
> + *
> + * Removes the repaint timer.
> + * Destroys the Wayland global assigned to the output.
> + * Destroys pixman regions allocated to the output.
> + * Deallocates output's ID and updates compositor's output_id_pool.
> + */
> +static void
> +weston_output_deinit(struct weston_output *output)
> +{
> + if (!output->initialized)
> + return;
> +
> + wl_event_source_remove(output->repaint_timer);
> +
> + wl_global_destroy(output->global);

Destroying the global on deinit instead of disable looks odd...
The same goes for repaint_timer too. It is only needed when the output
is enabled.

> +
> + pixman_region32_fini(>region);
> + pixman_region32_fini(>previous_damage);

Finalizing these regions is the opposite of
weston_output_init_geometry() which is called from
weston_output_init(). So far so good, but patch 10 should move these
into weston_output_disable(), so that it matches weston_output_enable()
initializing these regions.

> + output->compositor->output_id_pool &= ~(1u << output->id);

I wonder if output id would be needed only while enabled, but that's not
important.

Hmm. The three comments above are actually misguided. I wrote them
assuming the deinit is the opposite of init, but it's not. Deinit is the
opposite of enable, more or less.

> +
> + output->initialized = false;
> +}
> +
> +/** Sets the output scale for a given output.
> + *
> + * \param output The weston_output object that the scale is set for.
> + * \param scale  Scale factor for the given output.
> + *
> + * It only supports setting scale for an output that
> + * is not initialized and it can only be ran once.
> + */
> +WL_EXPORT void
> +weston_output_set_scale(struct weston_output *output,
> + int32_t scale)
> +{
> + /* We can only set scale on an uninitialized output */
> + 

Re: [PATCH 10/10] Cleanup unneeded stuff left during the porting phrase

2016-08-12 Thread Pekka Paalanen
On Thu, 11 Aug 2016 17:34:05 +0200
Armin Krezović  wrote:

> - Removed weston_backend_output_config structure; Outputs
>   should be configured from compositors using plugin-api.
> 
> - Merged weston_output_init() into weston_output_enable()
> 
> - Renamed weston_output_init_pending() to weston_output_init()

Hi Armin,

I think these should really be three separate patches.

This patch should update the weston_output_deinit() documentation to
say it undoes weston_output_enable(). Maybe even rename it to
weston_output_enable_undo(), since you cannot just call
weston_output_disable().

> 
> Signed-off-by: Armin Krezović 
> ---
>  libweston/compositor-drm.c  |   2 +-
>  libweston/compositor-fbdev.c|   2 +-
>  libweston/compositor-headless.c |   2 +-
>  libweston/compositor-rdp.c  |   2 +-
>  libweston/compositor-wayland.c  |   4 +-
>  libweston/compositor-x11.c  |   2 +-
>  libweston/compositor.c  | 130 
> ++--
>  libweston/compositor.h  |  22 +--
>  8 files changed, 54 insertions(+), 112 deletions(-)


Thanks,
pq


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


[PATCH] gl-renderer: emit frame_signal after eglSwapBuffers

2016-08-12 Thread Fabien Dessenne
Emit frame_signal at the end of the GL renderer processing, so the
frame_signal clients are informed after the buffer is actually updated.

Signed-off-by: Fabien Dessenne 
---
 libweston/gl-renderer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index d624453..f4d4a5e 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -1138,7 +1138,6 @@ gl_renderer_repaint_output(struct weston_output *output,
draw_output_borders(output, border_damage);
 
pixman_region32_copy(>previous_damage, output_damage);
-   wl_signal_emit(>frame_signal, output);
 
if (gr->swap_buffers_with_damage) {
pixman_region32_init(_damage);
@@ -1185,6 +1184,7 @@ gl_renderer_repaint_output(struct weston_output *output,
}
 
go->border_status = BORDER_STATUS_CLEAN;
+   wl_signal_emit(>frame_signal, output);
 }
 
 static int
-- 
1.9.1

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


Re: [PATCH libinput 1/3] Add configurable button map to tappings

2016-08-12 Thread Hans de Goede

Hi,

On 22-07-16 04:46, Peter Hutterer wrote:

The previously hardcoded button map for tapping is 1/2/3 to LRM. But the
middle button is a common feature on the desktop (used for paste, most
prominently) and three-finger tapping is almost impossible to do reliably on
some touchpads (e.g. the T440 has a recognition rate of ~1 in 5).

Left and right buttons have a prominent physical position (either softbuttons
or physical buttons) so make the tap order configurable. Those that require
middle buttons reliably can use the [software] buttons for left/right and
2-finger tap for a middle button.

https://bugs.freedesktop.org/show_bug.cgi?id=96962

Signed-off-by: Peter Hutterer 


Series looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
 src/evdev-mt-touchpad-tap.c | 22 
 src/libinput-private.h  |  5 +++
 src/libinput.c  | 36 
 src/libinput.h  | 82 +
 src/libinput.sym|  6 
 tools/shared.c  | 21 
 tools/shared.h  |  1 +
 7 files changed, 173 insertions(+)

diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index c2b331c..3ca4f95 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -935,6 +935,25 @@ tp_tap_config_get_default(struct libinput_device *device)
 }

 static enum libinput_config_status
+tp_tap_config_set_map(struct libinput_device *device,
+ enum libinput_config_tap_button_map map)
+{
+   return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
+}
+
+static enum libinput_config_tap_button_map
+tp_tap_config_get_map(struct libinput_device *device)
+{
+   return LIBINPUT_CONFIG_TAP_MAP_LRM;
+}
+
+static enum libinput_config_tap_button_map
+tp_tap_config_get_default_map(struct libinput_device *device)
+{
+   return LIBINPUT_CONFIG_TAP_MAP_LRM;
+}
+
+static enum libinput_config_status
 tp_tap_config_set_drag_enabled(struct libinput_device *device,
   enum libinput_config_drag_state enabled)
 {
@@ -1017,6 +1036,9 @@ tp_init_tap(struct tp_dispatch *tp)
tp->tap.config.set_enabled = tp_tap_config_set_enabled;
tp->tap.config.get_enabled = tp_tap_config_is_enabled;
tp->tap.config.get_default = tp_tap_config_get_default;
+   tp->tap.config.set_map = tp_tap_config_set_map;
+   tp->tap.config.get_map = tp_tap_config_get_map;
+   tp->tap.config.get_default_map = tp_tap_config_get_default_map;
tp->tap.config.set_drag_enabled = tp_tap_config_set_drag_enabled;
tp->tap.config.get_drag_enabled = tp_tap_config_get_drag_enabled;
tp->tap.config.get_default_drag_enabled = 
tp_tap_config_get_default_drag_enabled;
diff --git a/src/libinput-private.h b/src/libinput-private.h
index 472f6f3..1f27af6 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -158,6 +158,11 @@ struct libinput_device_config_tap {
enum libinput_config_tap_state (*get_enabled)(struct libinput_device 
*device);
enum libinput_config_tap_state (*get_default)(struct libinput_device 
*device);

+   enum libinput_config_status (*set_map)(struct libinput_device *device,
+  enum 
libinput_config_tap_button_map map);
+   enum libinput_config_tap_button_map (*get_map)(struct libinput_device 
*device);
+   enum libinput_config_tap_button_map (*get_default_map)(struct 
libinput_device *device);
+
enum libinput_config_status (*set_drag_enabled)(struct libinput_device 
*device,
enum 
libinput_config_drag_state);
enum libinput_config_drag_state (*get_drag_enabled)(struct 
libinput_device *device);
diff --git a/src/libinput.c b/src/libinput.c
index a8240bd..6958042 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -3352,6 +3352,42 @@ libinput_device_config_tap_get_default_enabled(struct 
libinput_device *device)
 }

 LIBINPUT_EXPORT enum libinput_config_status
+libinput_device_config_tap_set_button_map(struct libinput_device *device,
+   enum libinput_config_tap_button_map 
map)
+{
+   switch (map) {
+   case LIBINPUT_CONFIG_TAP_MAP_LRM:
+   case LIBINPUT_CONFIG_TAP_MAP_LMR:
+   break;
+   default:
+   return LIBINPUT_CONFIG_STATUS_INVALID;
+   }
+
+   if (libinput_device_config_tap_get_finger_count(device) == 0)
+   return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
+
+   return device->config.tap->set_map(device, map);
+}
+
+LIBINPUT_EXPORT enum libinput_config_tap_button_map
+libinput_device_config_tap_get_button_map(struct libinput_device *device)
+{
+   if (libinput_device_config_tap_get_finger_count(device) == 0)
+   return LIBINPUT_CONFIG_TAP_MAP_LRM;
+
+   return device->config.tap->get_map(device);
+}
+
+LIBINPUT_EXPORT 

Re: [PATCH 03/10] compositor: Implement output configuration using windowed_output_api

2016-08-12 Thread Quentin Glidic

On 11/08/2016 17:33, Armin Krezović wrote:

This implements output configuration for outputs which use
previously added weston_windowed_output_api. The function
takes an output that's to be configured, default configuration
that's to be set in case no configuration is specified in
the config file or on command line and optional third argument,
parsed_options, which will override defaults and options for
configuration if they are present.

This also introduces new compositor specific functions for
setting output's scale and transform from either hardcoded
default, config file option or command line option.

Pending output handling is also wired up in the compositor.

Signed-off-by: Armin Krezović 


Look goods:
Reviewed-by: Quentin Glidic 

Cheers,



---
 compositor/main.c | 171 ++
 1 file changed, 171 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 0e5af5b..c5d8e81 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -63,11 +63,21 @@
 #include "compositor-fbdev.h"
 #include "compositor-x11.h"
 #include "compositor-wayland.h"
+#include "output-api.h"

 #define WINDOW_TITLE "Weston Compositor"

+struct wet_output_config {
+   int width;
+   int height;
+   int32_t scale;
+   uint32_t transform;
+};
+
 struct wet_compositor {
struct weston_config *config;
+   struct wet_output_config *parsed_options;
+   struct wl_listener pending_output_listener;
 };

 static FILE *weston_logfile = NULL;
@@ -425,6 +435,47 @@ to_wet_compositor(struct weston_compositor *compositor)
return weston_compositor_get_user_data(compositor);
 }

+static void
+wet_set_pending_output_handler(struct weston_compositor *ec,
+  wl_notify_func_t handler)
+{
+   struct wet_compositor *compositor = to_wet_compositor(ec);
+
+   compositor->pending_output_listener.notify = handler;
+   wl_signal_add(>output_pending_signal, 
>pending_output_listener);
+}
+
+static struct wet_output_config *
+wet_get_parsed_options(struct weston_compositor *ec)
+{
+   struct wet_compositor *compositor = to_wet_compositor(ec);
+
+   return compositor->parsed_options;
+}
+
+static struct wet_output_config *
+wet_init_parsed_options(struct weston_compositor *ec)
+{
+   struct wet_compositor *compositor = to_wet_compositor(ec);
+   struct wet_output_config *config = NULL;
+
+   config = zalloc(sizeof *config);
+
+   if (!config) {
+   perror("out of memory");
+   return NULL;
+   }
+
+   config->width = 0;
+   config->height = 0;
+   config->scale = 0;
+   config->transform = UINT32_MAX;
+
+   compositor->parsed_options = config;
+
+   return config;
+}
+
 WL_EXPORT struct weston_config *
 wet_get_config(struct weston_compositor *ec)
 {
@@ -940,6 +991,120 @@ handle_exit(struct weston_compositor *c)
wl_display_terminate(c->wl_display);
 }

+static void
+wet_output_set_scale(struct weston_output *output,
+struct weston_config_section *section,
+int32_t default_scale,
+int32_t parsed_scale)
+{
+   int32_t scale = default_scale;
+
+   if (section)
+   weston_config_section_get_int(section, "scale", , 
default_scale);
+
+   if (parsed_scale)
+   scale = parsed_scale;
+
+   weston_output_set_scale(output, scale);
+}
+
+/* UINT32_MAX is treated as invalid because 0 is a valid
+ * enumeration value and the parameter is unsigned
+ */
+static void
+wet_output_set_transform(struct weston_output *output,
+struct weston_config_section *section,
+uint32_t default_transform,
+uint32_t parsed_transform)
+{
+   char *t;
+   uint32_t transform = default_transform;
+
+   if (section) {
+   weston_config_section_get_string(section,
+"transform", , "normal");
+
+   if (weston_parse_transform(t, ) < 0) {
+   weston_log("Invalid transform \"%s\" for output %s\n",
+  t, output->name);
+   transform = default_transform;
+   }
+   free(t);
+   }
+
+   if (parsed_transform != UINT32_MAX)
+   transform = parsed_transform;
+
+   weston_output_set_transform(output, transform);
+}
+
+static int
+wet_configure_windowed_output_from_config(struct weston_output *output,
+ struct wet_output_config *defaults,
+ struct wet_output_config 
*parsed_options)
+{
+   const struct weston_windowed_output_api *api =
+   weston_windowed_output_get_api(output->compositor);
+
+   struct weston_config *wc = wet_get_config(output->compositor);
+   

Re: [PATCH 02/10] libweston: Add initial output API for windowed outputs configuration

2016-08-12 Thread Quentin Glidic

On 11/08/2016 17:33, Armin Krezović wrote:

This adds new plugin-specific API for configuring outputs
on "windowed" backends, such as X11, wayland/non-fullscreen
and even headless (although, it doesn't have any windows,
its configuration is very similar). It can be used from
compositors to configure pending outputs and should be used
with previously added weston_output_set_{scale,transform}
to properly configure an output before enabling it.

It also supports creating additional outputs on the mentioned
backends.

Signed-off-by: Armin Krezović 
---
 Makefile.am|  1 +
 libweston/output-api.h | 88 ++
 2 files changed, 89 insertions(+)
 create mode 100644 libweston/output-api.h

diff --git a/Makefile.am b/Makefile.am
index 32627f5..038e4da 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -245,6 +245,7 @@ libwestoninclude_HEADERS =  \
libweston/compositor-rdp.h  \
libweston/compositor-wayland.h  \
libweston/compositor-x11.h  \
+   libweston/output-api.h  \
libweston/plugin-registry.h \
libweston/timeline-object.h \
shared/matrix.h \
diff --git a/libweston/output-api.h b/libweston/output-api.h
new file mode 100644
index 000..ef33587
--- /dev/null
+++ b/libweston/output-api.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * 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.
+ */
+
+#ifndef WESTON_OUTPUT_API_H
+#define WESTON_OUTPUT_API_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include "plugin-registry.h"
+
+struct weston_compositor;
+struct weston_output;
+
+#define WESTON_WINDOWED_OUTPUT_API_NAME "weston_windowed_output_api_v1"
+
+struct weston_windowed_output_api {
+   /** Configure an output with given width and height.
+*
+* \param output An output to be configured.
+* \param width  Desired width of the output.
+* \param height Desired height of the output.
+*
+* This configures a windowed output with desired width and
+* height. The backend decides what should be done and applies
+* the desired configuration. After using this function and
+* generic weston_output_set_{scale,transform}, a windowed


Might be "weston_output_set_*" to avoid future needs to change it.

Anyway:
Reviewed-by: Quentin Glidic 

Cheers,



+* output should be in a state where weston_output_enable()
+* can be run.
+*/
+   int (*output_configure)(struct weston_output *output,
+   int width, int height);
+
+   /** Create a new windowed output.
+*
+* \param compositor The compositor instance.
+* \param name   Desired name for a new output.
+*
+* This creates a new output in the backend using this API.
+* After this function is ran, the created output should be
+* ready for configuration using the output_configure() and
+* weston_output_set_{scale,transform}().
+*
+* An optional name can be assigned to it, so it can be used
+* by compositor to configure it. It can be NULL.
+*/
+   int (*output_create)(struct weston_compositor *compositor,
+const char *name);
+};
+
+static inline const struct weston_windowed_output_api *
+weston_windowed_output_get_api(struct weston_compositor *compositor)
+{
+   const void *api;
+   api = weston_plugin_api_get(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
+   sizeof(struct weston_windowed_output_api));
+
+   return (const struct weston_windowed_output_api *)api;
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif /* WESTON_OUTPUT_API_H */




--


Re: [PATCH 10/10] Cleanup unneeded stuff left during the porting phrase

2016-08-12 Thread Quentin Glidic

On 11/08/2016 17:34, Armin Krezović wrote:

- Removed weston_backend_output_config structure; Outputs
  should be configured from compositors using plugin-api.

- Merged weston_output_init() into weston_output_enable()

- Renamed weston_output_init_pending() to weston_output_init()

Signed-off-by: Armin Krezović 


I love this one:
Reviewed-by: Quentin Glidic 

Cheers,



---
 libweston/compositor-drm.c  |   2 +-
 libweston/compositor-fbdev.c|   2 +-
 libweston/compositor-headless.c |   2 +-
 libweston/compositor-rdp.c  |   2 +-
 libweston/compositor-wayland.c  |   4 +-
 libweston/compositor-x11.c  |   2 +-
 libweston/compositor.c  | 130 ++--
 libweston/compositor.h  |  22 +--
 8 files changed, 54 insertions(+), 112 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 76c1314..b3c63d6 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2550,7 +2550,7 @@ create_output_for_connector(struct drm_backend *b,
output->destroy_pending = 0;
output->disable_pending = 0;

-   weston_output_init_pending(>base, b->compositor);
+   weston_output_init(>base, b->compositor);

return 0;
 }
diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
index afa1e7a..0dad030 100644
--- a/libweston/compositor-fbdev.c
+++ b/libweston/compositor-fbdev.c
@@ -498,7 +498,7 @@ fbdev_output_create(struct fbdev_backend *backend,
output->base.disable = NULL;
output->base.enable = fbdev_output_enable;

-   weston_output_init_pending(>base, backend->compositor);
+   weston_output_init(>base, backend->compositor);

/* only one static mode in list */
output->mode.flags =
diff --git a/libweston/compositor-headless.c b/libweston/compositor-headless.c
index 793b8a9..31ae0e2 100644
--- a/libweston/compositor-headless.c
+++ b/libweston/compositor-headless.c
@@ -222,7 +222,7 @@ headless_output_create(struct weston_compositor *compositor,
output->base.disable = headless_output_disable;
output->base.enable = headless_output_enable;

-   weston_output_init_pending(>base, compositor);
+   weston_output_init(>base, compositor);

return 0;
 }
diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index b217d7d..7058567 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -570,7 +570,7 @@ rdp_backend_create_output(struct weston_compositor 
*compositor)
output->base.disable = rdp_output_disable;
output->base.enable = rdp_output_enable;

-   weston_output_init_pending(>base, compositor);
+   weston_output_init(>base, compositor);

return 0;
 }
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index e67adf9..2e68674 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1125,7 +1125,7 @@ wayland_output_create(struct weston_compositor 
*compositor, const char *name)

output->base.name = name ? strdup(name) : NULL;

-   weston_output_init_pending(>base, compositor);
+   weston_output_init(>base, compositor);

return 0;
 }
@@ -1224,7 +1224,7 @@ wayland_output_create_for_parent_output(struct 
wayland_backend *b,
output->user_data = poutput;
output->base.name = NULL;

-   weston_output_init_pending(>base, b->compositor);
+   weston_output_init(>base, b->compositor);

return 0;
 }
diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index 10bce65..0158d4f 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -1017,7 +1017,7 @@ x11_output_create(struct weston_compositor *compositor,
output->base.disable = x11_output_disable;
output->base.enable = x11_output_enable;

-   weston_output_init_pending(>base, compositor);
+   weston_output_init(>base, compositor);

return 0;
 }
diff --git a/libweston/compositor.c b/libweston/compositor.c
index f60ebb8..84715ac 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4220,80 +4220,6 @@ weston_output_move(struct weston_output *output, int x, 
int y)
}
 }

-/** Initialize a weston_output object's parameters
- *
- * \param output The weston_output object to initialize
- * \param c  The output's compositor
- * \param x  x coordinate for the output in global coordinate space
- * \param y  y coordinate for the output in global coordinate space
- * \param mm_width   Physical width of the output as reported by the backend
- * \param mm_height  Physical height of the output as reported by the backend
- * \param transform  Rotation of the output
- * \param scale  Native scaling factor for the output
- *
- * Sets up the transformation, zoom, and geometry of the output using
- * the input properties.
- *
- * Establishes a repaint 

Re: [PATCH 07/10] weston: Port RDP backend to new output handling API

2016-08-12 Thread Quentin Glidic

On 11/08/2016 17:34, Armin Krezović wrote:

This is a complete port of the RDP backend that uses
recently added output handling API for output
configuration.

Output can be configured at runtime by passing the
necessary configuration parameters, which can be
filled in manually or obtained from the command line
using previously added functionality. It is required
that the scale and transform values are set using
the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

Signed-off-by: Armin Krezović 


Looks ok:
Reviewed-by: Quentin Glidic 

Cheers,



---
 compositor/main.c  |  50 +++--
 libweston/compositor-rdp.c | 132 +++--
 libweston/compositor-rdp.h |  20 ++-
 3 files changed, 155 insertions(+), 47 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index c9a33f8..c09cd95 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1304,13 +1304,44 @@ load_headless_backend(struct weston_compositor *c,
 }

 static void
+rdp_backend_output_configure(struct wl_listener *listener, void *data)
+{
+   struct weston_output *output = data;
+   struct weston_compositor *ec = output->compositor;
+   struct wet_output_config *parsed_options = wet_get_parsed_options(ec);
+   const struct weston_rdp_output_api *api = 
weston_rdp_output_get_api(output->compositor);
+   int width = 640;
+   int height = 480;
+
+   if (!api) {
+   weston_log("Cannot use weston_rdp_output_api.\n");
+   return;
+   }
+
+   if (parsed_options && parsed_options->width)
+   width = parsed_options->width;
+
+   if (parsed_options && parsed_options->height)
+   height = parsed_options->height;
+
+   weston_output_set_scale(output, 1);
+   weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
+
+   if (api->output_configure(output, width, height) < 0) {
+   weston_log("Cannot configure output \"%s\" using 
weston_rdp_output_api.\n",
+  output->name);
+   return;
+   }
+
+   weston_output_enable(output);
+}
+
+static void
 weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
 {
config->base.struct_version = WESTON_RDP_BACKEND_CONFIG_VERSION;
config->base.struct_size = sizeof(struct weston_rdp_backend_config);

-   config->width = 640;
-   config->height = 480;
config->bind_address = NULL;
config->port = 3389;
config->rdp_key = NULL;
@@ -1327,12 +1358,16 @@ load_rdp_backend(struct weston_compositor *c,
struct weston_rdp_backend_config config  = {{ 0, }};
int ret = 0;

+   struct wet_output_config *parsed_options = wet_init_parsed_options(c);
+   if (!parsed_options)
+   return -1;
+
weston_rdp_backend_config_init();

const struct weston_option rdp_options[] = {
{ WESTON_OPTION_BOOLEAN, "env-socket", 0, _socket },
-   { WESTON_OPTION_INTEGER, "width", 0,  },
-   { WESTON_OPTION_INTEGER, "height", 0,  },
+   { WESTON_OPTION_INTEGER, "width", 0, _options->width },
+   { WESTON_OPTION_INTEGER, "height", 0, _options->height },
{ WESTON_OPTION_STRING,  "address", 0, _address },
{ WESTON_OPTION_INTEGER, "port", 0,  },
{ WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, 
_clients_resize },
@@ -1346,10 +1381,17 @@ load_rdp_backend(struct weston_compositor *c,
ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP,
 );

+   if (ret < 0)
+   goto out;
+
+   wet_set_pending_output_handler(c, rdp_backend_output_configure);
+
+out:
free(config.bind_address);
free(config.rdp_key);
free(config.server_cert);
free(config.server_key);
+
return ret;
 }

diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index 11f5f05..b217d7d 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -371,15 +371,6 @@ rdp_output_repaint(struct weston_output *output_base, 
pixman_region32_t *damage)
return 0;
 }

-static void
-rdp_output_destroy(struct weston_output *output_base)
-{
-   struct rdp_output *output = to_rdp_output(output_base);
-
-   wl_event_source_remove(output->finish_frame_timer);
-   free(output);
-}
-
 static int
 finish_frame_handler(void *data)
 {
@@ -471,17 +462,13 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode)
 }

 static int
-rdp_backend_create_output(struct rdp_backend *b, int width, int height)
+rdp_output_configure(struct weston_output *base,
+int width, int height)
 {
-   struct rdp_output *output;
-   struct wl_event_loop *loop;

Re: [PATCH 04/10] weston: Port DRM backend to new output handling API

2016-08-12 Thread Armin Krezović
On 12.08.2016 13:28, Quentin Glidic wrote:
> On 11/08/2016 17:33, Armin Krezović wrote:
>> This is a complete port of the DRM backend that uses
>> recently added output handling API for output
>> configuration.
>>
>> Output can be configured at runtime by passing the
>> necessary configuration parameters, which can be
>> filled in manually or obtained from the configuration
>> file using previously added functionality. It is
>> required that the scale and transform values are set
>> using the previously added functionality.
>>
>> After everything has been set, output needs to be
>> enabled manually using weston_output_enable().
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  compositor/main.c  | 103 ++-
>>  libweston/compositor-drm.c | 429 
>> +
>>  libweston/compositor-drm.h |  42 +++--
>>  3 files changed, 327 insertions(+), 247 deletions(-)
>>
>> diff --git a/compositor/main.c b/compositor/main.c
>> index c5d8e81..8be8717 100644
>> --- a/compositor/main.c
>> +++ b/compositor/main.c
>> @@ -1105,48 +1105,6 @@ wet_configure_windowed_output_from_config(struct 
>> weston_output *output,
>>  return 0;
>>  }
>>
>> -static enum weston_drm_backend_output_mode
>> -drm_configure_output(struct weston_compositor *c,
>> - bool use_current_mode,
>> - const char *name,
>> - struct weston_drm_backend_output_config *config)
>> -{
>> -struct weston_config *wc = wet_get_config(c);
>> -struct weston_config_section *section;
>> -char *s;
>> -int scale;
>> -enum weston_drm_backend_output_mode mode =
>> -WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
>> -
>> -section = weston_config_get_section(wc, "output", "name", name);
>> -weston_config_section_get_string(section, "mode", , "preferred");
>> -if (strcmp(s, "off") == 0) {
>> -free(s);
>> -return WESTON_DRM_BACKEND_OUTPUT_OFF;
> 
> We can remove that value from the enum I think. Or do we use it anywhere else?
> 
> 
>> -}
>> -
>> -if (use_current_mode || strcmp(s, "current") == 0) {
>> -mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
>> -} else if (strcmp(s, "preferred") != 0) {
>> -config->modeline = s;
>> -s = NULL;
>> -}
>> -free(s);
>> -
>> -weston_config_section_get_int(section, "scale", , 1);
>> -config->base.scale = scale >= 1 ? scale : 1;
>> -weston_config_section_get_string(section, "transform", , "normal");
>> -if (weston_parse_transform(s, >base.transform) < 0)
>> -weston_log("Invalid transform \"%s\" for output %s\n",
>> -   s, name);
>> -free(s);
>> -
>> -weston_config_section_get_string(section,
>> - "gbm-format", >gbm_format, NULL);
>> -weston_config_section_get_string(section, "seat", >seat, "");
>> -return mode;
>> -}
>> -
>>  static void
>>  configure_input_device(struct weston_compositor *compositor,
>> struct libinput_device *device)
>> @@ -1171,6 +1129,64 @@ configure_input_device(struct weston_compositor 
>> *compositor,
>>  }
>>  }
>>
>> +static void
>> +drm_backend_output_configure(struct wl_listener *listener, void *data)
>> +{
>> +struct weston_output *output = data;
>> +struct weston_config *wc = wet_get_config(output->compositor);
>> +struct weston_config_section *section;
>> +const struct weston_drm_output_api *api = 
>> weston_drm_output_get_api(output->compositor);
>> +enum weston_drm_backend_output_mode mode =
>> +WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
>> +
>> +char *s;
>> +char *modeline = NULL;
>> +char *gbm_format = NULL;
>> +char *seat = NULL;
>> +
>> +if (!api) {
>> +weston_log("Cannot use weston_drm_output_api.\n");
>> +return;
>> +}
>> +
>> +section = weston_config_get_section(wc, "output", "name", output->name);
>> +weston_config_section_get_string(section, "mode", , "preferred");
>> +
>> +if (strcmp(s, "off") == 0) {
>> +weston_output_disable(output);
>> +free(s);
>> +return;
>> +} else if (strcmp(s, "current") == 0) {
>> +mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
>> +} else if (strcmp(s, "preferred") != 0) {
>> +modeline = s;
>> +s = NULL;
>> +}
>> +free(s);
>> +
>> +if (api->set_mode(output, mode, modeline) < 0) {
>> +weston_log("Cannot configure an output using 
>> weston_drm_output_api.\n");
>> +return;
>> +}
>> +free(modeline);
>> +
>> +wet_output_set_scale(output, section, 1, 0);
>> +wet_output_set_transform(output, section, WL_OUTPUT_TRANSFORM_NORMAL, 
>> UINT32_MAX);
>> +
>> +weston_config_section_get_string(section,
>> + "gbm-format", _format, NULL);
>> +
>> +api->set_gbm_format(output, gbm_format);
>> +free(gbm_format);
>> +
>> +weston_config_section_get_string(section, "seat", , "");
>> +
>> +api->set_seat(output, 

Re: [PATCH 06/10] weston: Port headless backend to new output handling API

2016-08-12 Thread Quentin Glidic

On 11/08/2016 17:34, Armin Krezović wrote:

This is a complete port of the headless backend that
uses recently added output handling API for output
configuration.

- Output can be configured at runtime by passing the
  necessary configuration parameters, which can be
  filled in manually, obtained from the configuration
  file or obtained from the command line using
  previously added functionality. It is required that
  the scale and transform values are set using the
  previously added functionality.

- Output can be created at runtime using the output
  API. The output creation only creates a pending
  output, which needs to be configured the same way as
  mentioned above.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

Same as before, a single output is created at runtime
using the default configuration or a configuration
parsed from the command line. The no-outputs
functionality is also preserved, which means that no
output will be created initially, but more outputs can
be added at runtime using the output API.

Signed-off-by: Armin Krezović 


Looks good:
Reviewed-by: Quentin Glidic 

Cheers,



---
 compositor/main.c   |  54 +--
 libweston/compositor-headless.c | 146 ++--
 libweston/compositor-headless.h |   6 --
 3 files changed, 144 insertions(+), 62 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 817eb2e..c9a33f8 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1225,31 +1225,54 @@ load_drm_backend(struct weston_compositor *c,
return ret;
 }

+static void
+headless_backend_output_configure(struct wl_listener *listener, void *data)
+{
+   struct weston_output *output = data;
+   struct weston_compositor *ec = output->compositor;
+   struct wet_output_config *parsed_options = wet_get_parsed_options(ec);
+
+   struct wet_output_config defaults = {
+   .width = 1024,
+   .height = 640,
+   .scale = 1,
+   .transform = WL_OUTPUT_TRANSFORM_NORMAL
+   };
+
+   if (wet_configure_windowed_output_from_config(output, , 
parsed_options) < 0)
+   weston_log("Cannot configure output \"%s\".\n",
+  output->name ? output->name : "unnamed");
+}
+
 static int
 load_headless_backend(struct weston_compositor *c,
  int *argc, char **argv, struct weston_config *wc)
 {
+   const struct weston_windowed_output_api *api;
struct weston_headless_backend_config config = {{ 0, }};
+   int no_outputs = 0;
int ret = 0;
char *transform = NULL;

-   config.width = 1024;
-   config.height = 640;
+   struct wet_output_config *parsed_options = wet_init_parsed_options(c);
+   if (!parsed_options)
+   return -1;

const struct weston_option options[] = {
-   { WESTON_OPTION_INTEGER, "width", 0,  },
-   { WESTON_OPTION_INTEGER, "height", 0,  },
+   { WESTON_OPTION_INTEGER, "width", 0, _options->width },
+   { WESTON_OPTION_INTEGER, "height", 0, _options->height },
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, _pixman },
{ WESTON_OPTION_STRING, "transform", 0,  },
-   { WESTON_OPTION_BOOLEAN, "no-outputs", 0, _outputs },
+   { WESTON_OPTION_BOOLEAN, "no-outputs", 0, _outputs },
};

parse_options(options, ARRAY_LENGTH(options), argc, argv);

-   config.transform = WL_OUTPUT_TRANSFORM_NORMAL;
if (transform) {
-   if (weston_parse_transform(transform, ) < 0)
+   if (weston_parse_transform(transform, _options->transform) 
< 0) {
weston_log("Invalid transform \"%s\"\n", transform);
+   parsed_options->transform = UINT32_MAX;
+   }
free(transform);
}

@@ -1260,6 +1283,23 @@ load_headless_backend(struct weston_compositor *c,
ret = weston_compositor_load_backend(c, WESTON_BACKEND_HEADLESS,
 );

+   if (ret < 0)
+   return ret;
+
+   wet_set_pending_output_handler(c, headless_backend_output_configure);
+
+   if (!no_outputs) {
+   api = weston_windowed_output_get_api(c);
+
+   if (!api) {
+   weston_log("Cannot use weston_windowed_output_api.\n");
+   return -1;
+   }
+
+   if (api->output_create(c, "headless") < 0)
+   return -1;
+   }
+
return ret;
 }

diff --git a/libweston/compositor-headless.c b/libweston/compositor-headless.c
index 8b51207..793b8a9 100644
--- a/libweston/compositor-headless.c
+++ b/libweston/compositor-headless.c
@@ -37,6 +37,7 @@
 #include "shared/helpers.h"
 #include "pixman-renderer.h"
 #include 

Re: [PATCH 05/10] weston: Port fbdev backend to new output handling API

2016-08-12 Thread Quentin Glidic

On 11/08/2016 17:34, Armin Krezović wrote:

This is a complete port of the fbdev backend that uses
recently added output handling API for output
configuration.

It is required that the scale and transform values are
set using the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

Signed-off-by: Armin Krezović 


Nice:
Reviewed-by: Quentin Glidic 

Cheers,



---
 compositor/main.c| 30 ++-
 libweston/compositor-fbdev.c | 87 +++-
 libweston/compositor-fbdev.h |  2 -
 3 files changed, 74 insertions(+), 45 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 8be8717..817eb2e 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1313,13 +1313,26 @@ load_rdp_backend(struct weston_compositor *c,
return ret;
 }

+static void
+fbdev_backend_output_configure(struct wl_listener *listener, void *data)
+{
+   struct weston_output *output = data;
+   struct weston_config *wc = wet_get_config(output->compositor);
+   struct weston_config_section *section;
+
+   section = weston_config_get_section(wc, "output", "name", "fbdev");
+
+   wet_output_set_transform(output, section, WL_OUTPUT_TRANSFORM_NORMAL, 
UINT32_MAX);
+   weston_output_set_scale(output, 1);
+
+   weston_output_enable(output);
+}
+
 static int
 load_fbdev_backend(struct weston_compositor *c,
  int *argc, char **argv, struct weston_config *wc)
 {
struct weston_fbdev_backend_config config = {{ 0, }};
-   struct weston_config_section *section;
-   char *s = NULL;
int ret = 0;

const struct weston_option fbdev_options[] = {
@@ -1332,12 +1345,6 @@ load_fbdev_backend(struct weston_compositor *c,
if (!config.device)
config.device = strdup("/dev/fb0");

-   section = weston_config_get_section(wc, "output", "name", "fbdev");
-   weston_config_section_get_string(section, "transform", , "normal");
-   if (weston_parse_transform(s, _transform) < 0)
-   weston_log("Invalid transform \"%s\" for output fbdev\n", s);
-   free(s);
-
config.base.struct_version = WESTON_FBDEV_BACKEND_CONFIG_VERSION;
config.base.struct_size = sizeof(struct weston_fbdev_backend_config);
config.configure_device = configure_input_device;
@@ -1346,8 +1353,13 @@ load_fbdev_backend(struct weston_compositor *c,
ret = weston_compositor_load_backend(c, WESTON_BACKEND_FBDEV,
 );

-   free(config.device);
+   if (ret < 0)
+   goto out;
+
+   wet_set_pending_output_handler(c, fbdev_backend_output_configure);

+out:
+   free(config.device);
return ret;
 }

diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
index 852acc0..afa1e7a 100644
--- a/libweston/compositor-fbdev.c
+++ b/libweston/compositor-fbdev.c
@@ -426,12 +426,56 @@ static void fbdev_output_destroy(struct weston_output 
*base);
 static void fbdev_output_disable(struct weston_output *base);

 static int
+fbdev_output_enable(struct weston_output *base)
+{
+   struct fbdev_output *output = to_fbdev_output(base);
+   struct fbdev_backend *backend = to_fbdev_backend(base->compositor);
+   int fb_fd;
+   struct wl_event_loop *loop;
+
+   /* Create the frame buffer. */
+   fb_fd = fbdev_frame_buffer_open(output, output->device, 
>fb_info);
+   if (fb_fd < 0) {
+   weston_log("Creating frame buffer failed.\n");
+   return -1;
+   }
+
+   if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
+   weston_log("Mapping frame buffer failed.\n");
+   return -1;
+   }
+
+   output->base.start_repaint_loop = fbdev_output_start_repaint_loop;
+   output->base.repaint = fbdev_output_repaint;
+
+   if (pixman_renderer_output_create(>base) < 0)
+   goto out_hw_surface;
+
+   loop = wl_display_get_event_loop(backend->compositor->wl_display);
+   output->finish_frame_timer =
+   wl_event_loop_add_timer(loop, finish_frame_handler, output);
+
+   weston_log("fbdev output %d×%d px\n",
+  output->mode.width, output->mode.height);
+   weston_log_continue(STAMP_SPACE "guessing %d Hz and 96 dpi\n",
+   output->mode.refresh / 1000);
+
+   return 0;
+
+out_hw_surface:
+   pixman_image_unref(output->hw_surface);
+   output->hw_surface = NULL;
+   fbdev_frame_buffer_destroy(output);
+
+   return -1;
+}
+
+static int
 fbdev_output_create(struct fbdev_backend *backend,
 const char *device)
 {
struct fbdev_output *output;
int fb_fd;
-   struct wl_event_loop *loop;

weston_log("Creating fbdev output.\n");

@@ -449,14 +493,12 @@ fbdev_output_create(struct 

Re: [PATCH 04/10] weston: Port DRM backend to new output handling API

2016-08-12 Thread Quentin Glidic

On 11/08/2016 17:33, Armin Krezović wrote:

This is a complete port of the DRM backend that uses
recently added output handling API for output
configuration.

Output can be configured at runtime by passing the
necessary configuration parameters, which can be
filled in manually or obtained from the configuration
file using previously added functionality. It is
required that the scale and transform values are set
using the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 103 ++-
 libweston/compositor-drm.c | 429 +
 libweston/compositor-drm.h |  42 +++--
 3 files changed, 327 insertions(+), 247 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index c5d8e81..8be8717 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1105,48 +1105,6 @@ wet_configure_windowed_output_from_config(struct 
weston_output *output,
return 0;
 }

-static enum weston_drm_backend_output_mode
-drm_configure_output(struct weston_compositor *c,
-bool use_current_mode,
-const char *name,
-struct weston_drm_backend_output_config *config)
-{
-   struct weston_config *wc = wet_get_config(c);
-   struct weston_config_section *section;
-   char *s;
-   int scale;
-   enum weston_drm_backend_output_mode mode =
-   WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
-
-   section = weston_config_get_section(wc, "output", "name", name);
-   weston_config_section_get_string(section, "mode", , "preferred");
-   if (strcmp(s, "off") == 0) {
-   free(s);
-   return WESTON_DRM_BACKEND_OUTPUT_OFF;


We can remove that value from the enum I think. Or do we use it anywhere 
else?




-   }
-
-   if (use_current_mode || strcmp(s, "current") == 0) {
-   mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
-   } else if (strcmp(s, "preferred") != 0) {
-   config->modeline = s;
-   s = NULL;
-   }
-   free(s);
-
-   weston_config_section_get_int(section, "scale", , 1);
-   config->base.scale = scale >= 1 ? scale : 1;
-   weston_config_section_get_string(section, "transform", , "normal");
-   if (weston_parse_transform(s, >base.transform) < 0)
-   weston_log("Invalid transform \"%s\" for output %s\n",
-  s, name);
-   free(s);
-
-   weston_config_section_get_string(section,
-"gbm-format", >gbm_format, 
NULL);
-   weston_config_section_get_string(section, "seat", >seat, "");
-   return mode;
-}
-
 static void
 configure_input_device(struct weston_compositor *compositor,
   struct libinput_device *device)
@@ -1171,6 +1129,64 @@ configure_input_device(struct weston_compositor 
*compositor,
}
 }

+static void
+drm_backend_output_configure(struct wl_listener *listener, void *data)
+{
+   struct weston_output *output = data;
+   struct weston_config *wc = wet_get_config(output->compositor);
+   struct weston_config_section *section;
+   const struct weston_drm_output_api *api = 
weston_drm_output_get_api(output->compositor);
+   enum weston_drm_backend_output_mode mode =
+   WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
+
+   char *s;
+   char *modeline = NULL;
+   char *gbm_format = NULL;
+   char *seat = NULL;
+
+   if (!api) {
+   weston_log("Cannot use weston_drm_output_api.\n");
+   return;
+   }
+
+   section = weston_config_get_section(wc, "output", "name", output->name);
+   weston_config_section_get_string(section, "mode", , "preferred");
+
+   if (strcmp(s, "off") == 0) {
+   weston_output_disable(output);
+   free(s);
+   return;
+   } else if (strcmp(s, "current") == 0) {
+   mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
+   } else if (strcmp(s, "preferred") != 0) {
+   modeline = s;
+   s = NULL;
+   }
+   free(s);
+
+   if (api->set_mode(output, mode, modeline) < 0) {
+   weston_log("Cannot configure an output using 
weston_drm_output_api.\n");
+   return;
+   }
+   free(modeline);
+
+   wet_output_set_scale(output, section, 1, 0);
+   wet_output_set_transform(output, section, WL_OUTPUT_TRANSFORM_NORMAL, 
UINT32_MAX);
+
+   weston_config_section_get_string(section,
+"gbm-format", _format, NULL);
+
+   api->set_gbm_format(output, gbm_format);
+   free(gbm_format);
+
+   weston_config_section_get_string(section, "seat", , "");
+
+   api->set_seat(output, seat);
+   free(seat);
+
+   weston_output_enable(output);
+}
+
 static int
 

Re: [PATCH 2/2] fullscreen-shell: Ensure that fs surface is presented on all outputs

2016-08-12 Thread Pekka Paalanen
On Thu, 11 Aug 2016 15:49:59 +0200
Armin Krezović  wrote:

> When no outputs are present, and no output resource is given,
> a fullscreen surface won't get configured. This code ensures
> that surface is properly presented on all outputs that get
> connected after a surface has been created, but only if no
> output resource was previously given.
> 
> Signed-off-by: Armin Krezović 
> ---
>  fullscreen-shell/fullscreen-shell.c | 75 
> +
>  1 file changed, 75 insertions(+)

Hi Armin,

in patch 1 I fixed a { being on a wrong line. Then I pushed both
patches:
   96c205a..ccfd029  master -> master


Thanks,
pq


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


Re: [PATCH weston 6/6] clients/simple-dmabuf-v4l: Port to xdg_shell unstable v6

2016-08-12 Thread Quentin Glidic

On 12/08/2016 05:40, Jonas Ådahl wrote:

Signed-off-by: Jonas Ådahl 


Same as simple-dmabuf-intel, maybe a comment? :-)
Reviewed-by: Quentin Glidic 

Cheers,



---
 Makefile.am |  6 +--
 clients/simple-dmabuf-v4l.c | 96 ++---
 2 files changed, 66 insertions(+), 36 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 7fdca41..00fc0ff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -590,8 +590,8 @@ if BUILD_SIMPLE_DMABUF_V4L_CLIENT
 demo_clients += weston-simple-dmabuf-v4l
 weston_simple_dmabuf_v4l_SOURCES = clients/simple-dmabuf-v4l.c
 nodist_weston_simple_dmabuf_v4l_SOURCES =  \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
@@ -832,8 +832,6 @@ BUILT_SOURCES +=\
protocol/presentation-time-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
protocol/xdg-shell-unstable-v6-protocol.c   \
protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/ivi-hmi-controller-protocol.c  \
diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
index c92a3eb..ce124cc 100644
--- a/clients/simple-dmabuf-v4l.c
+++ b/clients/simple-dmabuf-v4l.c
@@ -44,12 +44,15 @@

 #include 
 #include "shared/zalloc.h"
-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"

 #define CLEAR(x) memset(&(x), 0, sizeof(x))

+static void
+redraw(void *data, struct wl_callback *callback, uint32_t time);
+
 static int
 xioctl(int fh, int request, void *arg)
 {
@@ -94,7 +97,7 @@ struct display {
struct wl_compositor *compositor;
struct wl_seat *seat;
struct wl_keyboard *keyboard;
-   struct xdg_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
bool requested_format_found;
@@ -119,9 +122,12 @@ struct buffer {
 struct window {
struct display *display;
struct wl_surface *surface;
-   struct xdg_surface *xdg_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
struct buffer buffers[NUM_BUFFERS];
struct wl_callback *callback;
+   bool wait_for_configure;
+   bool initialized;
 };

 static bool running = true;
@@ -524,21 +530,38 @@ start_capture(struct display *display)
 }

 static void
-handle_configure(void *data, struct xdg_surface *surface,
-int32_t width, int32_t height,
-struct wl_array *states, uint32_t serial)
+xdg_surface_handle_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
 {
+   struct window *window = data;
+
+   zxdg_surface_v6_ack_configure(surface, serial);
+
+   if (window->initialized && window->wait_for_configure)
+   redraw(window, NULL, 0);
+   window->wait_for_configure = false;
 }

+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   xdg_surface_handle_configure,
+};
+
 static void
-handle_delete(void *data, struct xdg_surface *xdg_surface)
+xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
+ int32_t width, int32_t height,
+ struct wl_array *states)
 {
-   running = false;
 }

-static const struct xdg_surface_listener xdg_surface_listener = {
-   handle_configure,
-   handle_delete,
+static void
+xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
+{
+   running = 0;
+}
+
+static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
+   xdg_toplevel_handle_configure,
+   xdg_toplevel_handle_close,
 };

 static struct window *
@@ -556,15 +579,26 @@ create_window(struct display *display)

if (display->shell) {
window->xdg_surface =
-   xdg_shell_get_xdg_surface(display->shell,
- window->surface);
+   zxdg_shell_v6_get_xdg_surface(display->shell,
+  

Re: [PATCH weston 5/6] clients/simple-dmabuf-intel: Port to xdg_shell unstable v6

2016-08-12 Thread Quentin Glidic

On 12/08/2016 05:40, Jonas Ådahl wrote:

Signed-off-by: Jonas Ådahl 


Here we could get the configure event early, but initialized would be 
false anyway. Ok. Maybe a comment? :-)

Reviewed-by: Quentin Glidic 

Cheers,



---
 Makefile.am   |  4 +-
 clients/simple-dmabuf-intel.c | 94 +--
 2 files changed, 65 insertions(+), 33 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d0693c5..7fdca41 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -575,8 +575,8 @@ if BUILD_SIMPLE_DMABUF_INTEL_CLIENT
 demo_clients += weston-simple-dmabuf-intel
 weston_simple_dmabuf_intel_SOURCES = clients/simple-dmabuf-intel.c
 nodist_weston_simple_dmabuf_intel_SOURCES =\
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index 505ecb0..ec5f1cb 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -42,7 +42,7 @@

 #include 
 #include "shared/zalloc.h"
-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"

@@ -50,7 +50,7 @@ struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct xdg_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
int xrgb_format_found;
@@ -81,15 +81,21 @@ struct window {
struct display *display;
int width, height;
struct wl_surface *surface;
-   struct xdg_surface *xdg_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
struct buffer buffers[NUM_BUFFERS];
struct buffer *prev_buffer;
struct wl_callback *callback;
+   bool initialized;
+   bool wait_for_configure;
 };

 static int running = 1;

 static void
+redraw(void *data, struct wl_callback *callback, uint32_t time);
+
+static void
 buffer_release(void *data, struct wl_buffer *buffer)
 {
struct buffer *mybuf = data;
@@ -290,21 +296,38 @@ error:
 }

 static void
-handle_configure(void *data, struct xdg_surface *surface,
-int32_t width, int32_t height,
-struct wl_array *states, uint32_t serial)
+xdg_surface_handle_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
 {
+   struct window *window = data;
+
+   zxdg_surface_v6_ack_configure(surface, serial);
+
+   if (window->initialized && window->wait_for_configure)
+   redraw(window, NULL, 0);
+   window->wait_for_configure = false;
 }

+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   xdg_surface_handle_configure,
+};
+
 static void
-handle_delete(void *data, struct xdg_surface *xdg_surface)
+xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
+ int32_t width, int32_t height,
+ struct wl_array *states)
+{
+}
+
+static void
+xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
 {
running = 0;
 }

-static const struct xdg_surface_listener xdg_surface_listener = {
-   handle_configure,
-   handle_delete,
+static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
+   xdg_toplevel_handle_configure,
+   xdg_toplevel_handle_close,
 };

 static struct window *
@@ -326,15 +349,26 @@ create_window(struct display *display, int width, int 
height)

if (display->shell) {
window->xdg_surface =
-   xdg_shell_get_xdg_surface(display->shell,
- window->surface);
+   zxdg_shell_v6_get_xdg_surface(display->shell,
+ window->surface);

assert(window->xdg_surface);

-   xdg_surface_add_listener(window->xdg_surface,
-_surface_listener, window);
+   zxdg_surface_v6_add_listener(window->xdg_surface,
+_surface_listener, window);
+
+   window->xdg_toplevel =
+   zxdg_surface_v6_get_toplevel(window->xdg_surface);
+
+   assert(window->xdg_toplevel);

-   

Re: [PATCH weston 4/6] clients/simple-damage: Port to xdg_shell unstable v6

2016-08-12 Thread Quentin Glidic

On 12/08/2016 05:40, Jonas Ådahl wrote:

Signed-off-by: Jonas Ådahl 


Same as simple-shm, maybe add a comment.
Reviewed-by: Quentin Glidic 

Cheers,



---
 Makefile.am |  4 +--
 clients/simple-damage.c | 92 -
 2 files changed, 63 insertions(+), 33 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index eb093b8..d0693c5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -532,8 +532,8 @@ weston_simple_damage_SOURCES = clients/simple-damage.c
 nodist_weston_simple_damage_SOURCES =  \
protocol/viewporter-protocol.c  \
protocol/viewporter-client-protocol.h   \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h
 weston_simple_damage_CFLAGS = $(AM_CFLAGS) $(SIMPLE_CLIENT_CFLAGS)
diff --git a/clients/simple-damage.c b/clients/simple-damage.c
index 9f0eb3e..ea2d3f9 100644
--- a/clients/simple-damage.c
+++ b/clients/simple-damage.c
@@ -39,7 +39,7 @@
 #include 
 #include "shared/os-compatibility.h"
 #include "shared/zalloc.h"
-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "viewporter-client-protocol.h"

@@ -51,7 +51,7 @@ struct display {
int compositor_version;
struct wl_compositor *compositor;
struct wp_viewporter *viewporter;
-   struct xdg_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
uint32_t formats;
@@ -74,10 +74,12 @@ struct window {
int width, height, border;
struct wl_surface *surface;
struct wp_viewport *viewport;
-   struct xdg_surface *xdg_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
struct wl_callback *callback;
struct buffer buffers[2];
struct buffer *prev_buffer;
+   bool wait_for_configure;

enum window_flags flags;
int scale;
@@ -94,6 +96,9 @@ struct window {
 static int running = 1;

 static void
+redraw(void *data, struct wl_callback *callback, uint32_t time);
+
+static void
 buffer_release(void *data, struct wl_buffer *buffer)
 {
struct buffer *mybuf = data;
@@ -144,21 +149,39 @@ create_shm_buffer(struct display *display, struct buffer 
*buffer,
 }

 static void
-handle_configure(void *data, struct xdg_surface *surface,
-int32_t width, int32_t height, struct wl_array *states,
-uint32_t serial)
+xdg_surface_handle_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
 {
+   struct window *window = data;
+
+   zxdg_surface_v6_ack_configure(surface, serial);
+
+   if (window->wait_for_configure) {
+   redraw(window, NULL, 0);
+   window->wait_for_configure = false;
+   }
 }

+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   xdg_surface_handle_configure,
+};
+
 static void
-handle_close(void *data, struct xdg_surface *xdg_surface)
+xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
+ int32_t width, int32_t height,
+ struct wl_array *states)
+{
+}
+
+static void
+xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
 {
running = 0;
 }

-static const struct xdg_surface_listener xdg_surface_listener = {
-   handle_configure,
-   handle_close,
+static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
+   xdg_toplevel_handle_configure,
+   xdg_toplevel_handle_close,
 };

 static float
@@ -296,15 +319,26 @@ create_window(struct display *display, int width, int 
height,

if (display->shell) {
window->xdg_surface =
-   xdg_shell_get_xdg_surface(display->shell,
- window->surface);
+   zxdg_shell_v6_get_xdg_surface(display->shell,
+ window->surface);

assert(window->xdg_surface);

-   xdg_surface_add_listener(window->xdg_surface,
-_surface_listener, window);
+   zxdg_surface_v6_add_listener(window->xdg_surface,
+_surface_listener, window);
+
+   window->xdg_toplevel =
+   zxdg_surface_v6_get_toplevel(window->xdg_surface);

-   

Re: [PATCH weston 3/6] clients/simple-shm: Port to xdg_shell unstable v6

2016-08-12 Thread Quentin Glidic

On 12/08/2016 11:44, Jonas Ådahl wrote:

On Fri, Aug 12, 2016 at 11:27:11AM +0200, Quentin Glidic wrote:

On 12/08/2016 05:40, Jonas Ådahl wrote:

Signed-off-by: Jonas Ådahl 


One concern (in two places) below.



---
 Makefile.am  |  4 +--
 clients/simple-shm.c | 93 
 2 files changed, 60 insertions(+), 37 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index dcd0a25..eb093b8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -519,8 +519,8 @@ demo_clients += \

 weston_simple_shm_SOURCES = clients/simple-shm.c
 nodist_weston_simple_shm_SOURCES = \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/ivi-application-protocol.c \
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index b1fc5f1..9fa2e21 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -37,7 +37,7 @@
 #include 
 #include "shared/os-compatibility.h"
 #include "shared/zalloc.h"
-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"

 #include 
@@ -48,7 +48,7 @@ struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct xdg_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
bool has_xrgb;
@@ -65,16 +65,21 @@ struct window {
struct display *display;
int width, height;
struct wl_surface *surface;
-   struct xdg_surface *xdg_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
struct ivi_surface *ivi_surface;
struct buffer buffers[2];
struct buffer *prev_buffer;
struct wl_callback *callback;
+   bool wait_for_configure;
 };

 static int running = 1;

 static void
+redraw(void *data, struct wl_callback *callback, uint32_t time);
+
+static void
 buffer_release(void *data, struct wl_buffer *buffer)
 {
struct buffer *mybuf = data;
@@ -125,22 +130,39 @@ create_shm_buffer(struct display *display, struct buffer 
*buffer,
 }

 static void
-handle_configure(void *data, struct xdg_surface *surface,
-int32_t width, int32_t height,
-struct wl_array *states, uint32_t serial)
+handle_xdg_surface_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
 {
-   xdg_surface_ack_configure(surface, serial);
+   struct window *window = data;
+
+   zxdg_surface_v6_ack_configure(surface, serial);
+
+   if (window->wait_for_configure) {
+   redraw(window, NULL, 0);
+   window->wait_for_configure = false;
+   }


So you trigger a redraw (and a frame callback, which means a full series of
redraws) on configure. Ok. Now below…



 }

+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   handle_xdg_surface_configure,
+};
+
 static void
-handle_delete(void *data, struct xdg_surface *xdg_surface)
+handle_xdg_toplevel_configure(void *data, struct zxdg_toplevel_v6 
*xdg_toplevel,
+ int32_t width, int32_t height,
+ struct wl_array *state)
+{
+}
+
+static void
+handle_xdg_toplevel_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
 {
running = 0;
 }

-static const struct xdg_surface_listener xdg_surface_listener = {
-   handle_configure,
-   handle_delete,
+static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
+   handle_xdg_toplevel_configure,
+   handle_xdg_toplevel_close,
 };

 static void
@@ -171,16 +193,21 @@ create_window(struct display *display, int width, int 
height)

if (display->shell) {
window->xdg_surface =
-   xdg_shell_get_xdg_surface(display->shell,
+   zxdg_shell_v6_get_xdg_surface(display->shell,
  window->surface);
-
assert(window->xdg_surface);
-
-   xdg_surface_add_listener(window->xdg_surface,
-_surface_listener, window);
-
-   xdg_surface_set_title(window->xdg_surface, "simple-shm");
-
+   zxdg_surface_v6_add_listener(window->xdg_surface,
+_surface_listener, window);
+
+   window->xdg_toplevel =
+   

Re: [PATCH weston 3/6] clients/simple-shm: Port to xdg_shell unstable v6

2016-08-12 Thread Jonas Ådahl
On Fri, Aug 12, 2016 at 11:27:11AM +0200, Quentin Glidic wrote:
> On 12/08/2016 05:40, Jonas Ådahl wrote:
> > Signed-off-by: Jonas Ådahl 
> 
> One concern (in two places) below.
> 
> 
> > ---
> >  Makefile.am  |  4 +--
> >  clients/simple-shm.c | 93 
> > 
> >  2 files changed, 60 insertions(+), 37 deletions(-)
> > 
> > diff --git a/Makefile.am b/Makefile.am
> > index dcd0a25..eb093b8 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -519,8 +519,8 @@ demo_clients += \
> > 
> >  weston_simple_shm_SOURCES = clients/simple-shm.c
> >  nodist_weston_simple_shm_SOURCES = \
> > -   protocol/xdg-shell-unstable-v5-protocol.c   \
> > -   protocol/xdg-shell-unstable-v5-client-protocol.h\
> > +   protocol/xdg-shell-unstable-v6-protocol.c   \
> > +   protocol/xdg-shell-unstable-v6-client-protocol.h\
> > protocol/fullscreen-shell-unstable-v1-protocol.c\
> > protocol/fullscreen-shell-unstable-v1-client-protocol.h \
> > protocol/ivi-application-protocol.c \
> > diff --git a/clients/simple-shm.c b/clients/simple-shm.c
> > index b1fc5f1..9fa2e21 100644
> > --- a/clients/simple-shm.c
> > +++ b/clients/simple-shm.c
> > @@ -37,7 +37,7 @@
> >  #include 
> >  #include "shared/os-compatibility.h"
> >  #include "shared/zalloc.h"
> > -#include "xdg-shell-unstable-v5-client-protocol.h"
> > +#include "xdg-shell-unstable-v6-client-protocol.h"
> >  #include "fullscreen-shell-unstable-v1-client-protocol.h"
> > 
> >  #include 
> > @@ -48,7 +48,7 @@ struct display {
> > struct wl_display *display;
> > struct wl_registry *registry;
> > struct wl_compositor *compositor;
> > -   struct xdg_shell *shell;
> > +   struct zxdg_shell_v6 *shell;
> > struct zwp_fullscreen_shell_v1 *fshell;
> > struct wl_shm *shm;
> > bool has_xrgb;
> > @@ -65,16 +65,21 @@ struct window {
> > struct display *display;
> > int width, height;
> > struct wl_surface *surface;
> > -   struct xdg_surface *xdg_surface;
> > +   struct zxdg_surface_v6 *xdg_surface;
> > +   struct zxdg_toplevel_v6 *xdg_toplevel;
> > struct ivi_surface *ivi_surface;
> > struct buffer buffers[2];
> > struct buffer *prev_buffer;
> > struct wl_callback *callback;
> > +   bool wait_for_configure;
> >  };
> > 
> >  static int running = 1;
> > 
> >  static void
> > +redraw(void *data, struct wl_callback *callback, uint32_t time);
> > +
> > +static void
> >  buffer_release(void *data, struct wl_buffer *buffer)
> >  {
> > struct buffer *mybuf = data;
> > @@ -125,22 +130,39 @@ create_shm_buffer(struct display *display, struct 
> > buffer *buffer,
> >  }
> > 
> >  static void
> > -handle_configure(void *data, struct xdg_surface *surface,
> > -int32_t width, int32_t height,
> > -struct wl_array *states, uint32_t serial)
> > +handle_xdg_surface_configure(void *data, struct zxdg_surface_v6 *surface,
> > +uint32_t serial)
> >  {
> > -   xdg_surface_ack_configure(surface, serial);
> > +   struct window *window = data;
> > +
> > +   zxdg_surface_v6_ack_configure(surface, serial);
> > +
> > +   if (window->wait_for_configure) {
> > +   redraw(window, NULL, 0);
> > +   window->wait_for_configure = false;
> > +   }
> 
> So you trigger a redraw (and a frame callback, which means a full series of
> redraws) on configure. Ok. Now below…
> 
> 
> >  }
> > 
> > +static const struct zxdg_surface_v6_listener xdg_surface_listener = {
> > +   handle_xdg_surface_configure,
> > +};
> > +
> >  static void
> > -handle_delete(void *data, struct xdg_surface *xdg_surface)
> > +handle_xdg_toplevel_configure(void *data, struct zxdg_toplevel_v6 
> > *xdg_toplevel,
> > + int32_t width, int32_t height,
> > + struct wl_array *state)
> > +{
> > +}
> > +
> > +static void
> > +handle_xdg_toplevel_close(void *data, struct zxdg_toplevel_v6 
> > *xdg_toplevel)
> >  {
> > running = 0;
> >  }
> > 
> > -static const struct xdg_surface_listener xdg_surface_listener = {
> > -   handle_configure,
> > -   handle_delete,
> > +static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
> > +   handle_xdg_toplevel_configure,
> > +   handle_xdg_toplevel_close,
> >  };
> > 
> >  static void
> > @@ -171,16 +193,21 @@ create_window(struct display *display, int width, int 
> > height)
> > 
> > if (display->shell) {
> > window->xdg_surface =
> > -   xdg_shell_get_xdg_surface(display->shell,
> > +   zxdg_shell_v6_get_xdg_surface(display->shell,
> >   window->surface);
> > -
> > assert(window->xdg_surface);
> > -
> > -   xdg_surface_add_listener(window->xdg_surface,
> > -_surface_listener, window);
> > -
> > -   

[PATCH weston v2] clients/simple-shm: Port to xdg_shell unstable v6

2016-08-12 Thread Jonas Ådahl
Signed-off-by: Jonas Ådahl 
Acked-by: Bryce Harrington 
Acked-by: Pekka Paalanen 
---

> … here. You trigger a redraw (chain) if configure was received, but in this
> case, the redraw is already triggered.
> I guess you used the same code for all simple-*, except this one lacks (or
> don’t need) the "initialized" check.

True. I changed to a state machine. By default (non-xdg-shell-v6 paths) it'll
go from 'none' to 'drawing' in main(), while in the xdg-shell v6 case, it'll go
from 'none' to 'wait_for_configure' when creating the window, then from
'wait_for_configure' to 'drawing' in the configure handler. That should fix the
issue you mentioned. Thus..

Changes since v1:

  * Changed 'wait_for_configure' bool to a state machine


Jonas


 Makefile.am  |   4 +-
 clients/simple-shm.c | 111 +++
 2 files changed, 78 insertions(+), 37 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index dcd0a25..eb093b8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -519,8 +519,8 @@ demo_clients += \
 
 weston_simple_shm_SOURCES = clients/simple-shm.c
 nodist_weston_simple_shm_SOURCES = \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/ivi-application-protocol.c \
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index b1fc5f1..8333d32 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -37,7 +37,7 @@
 #include 
 #include "shared/os-compatibility.h"
 #include "shared/zalloc.h"
-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 
 #include 
@@ -48,7 +48,7 @@ struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct xdg_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
bool has_xrgb;
@@ -61,20 +61,31 @@ struct buffer {
int busy;
 };
 
+enum window_draw_state {
+   WINDOW_DRAW_STATE_NONE,
+   WINDOW_DRAW_STATE_WAIT_FOR_CONFIGURE,
+   WINDOW_DRAW_STATE_DRAWING
+};
+
 struct window {
struct display *display;
int width, height;
struct wl_surface *surface;
-   struct xdg_surface *xdg_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
struct ivi_surface *ivi_surface;
struct buffer buffers[2];
struct buffer *prev_buffer;
struct wl_callback *callback;
+   enum window_draw_state draw_state;
 };
 
 static int running = 1;
 
 static void
+redraw(void *data, struct wl_callback *callback, uint32_t time);
+
+static void
 buffer_release(void *data, struct wl_buffer *buffer)
 {
struct buffer *mybuf = data;
@@ -125,22 +136,44 @@ create_shm_buffer(struct display *display, struct buffer 
*buffer,
 }
 
 static void
-handle_configure(void *data, struct xdg_surface *surface,
-int32_t width, int32_t height,
-struct wl_array *states, uint32_t serial)
+handle_xdg_surface_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
+{
+   struct window *window = data;
+
+   zxdg_surface_v6_ack_configure(surface, serial);
+
+   switch (window->draw_state) {
+   case WINDOW_DRAW_STATE_WAIT_FOR_CONFIGURE:
+   redraw(window, NULL, 0);
+   window->draw_state = WINDOW_DRAW_STATE_DRAWING;
+   break;
+   case WINDOW_DRAW_STATE_NONE:
+   case WINDOW_DRAW_STATE_DRAWING:
+   break;
+   }
+}
+
+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   handle_xdg_surface_configure,
+};
+
+static void
+handle_xdg_toplevel_configure(void *data, struct zxdg_toplevel_v6 
*xdg_toplevel,
+ int32_t width, int32_t height,
+ struct wl_array *state)
 {
-   xdg_surface_ack_configure(surface, serial);
 }
 
 static void
-handle_delete(void *data, struct xdg_surface *xdg_surface)
+handle_xdg_toplevel_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
 {
running = 0;
 }
 
-static const struct xdg_surface_listener xdg_surface_listener = {
-   handle_configure,
-   handle_delete,
+static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
+   handle_xdg_toplevel_configure,
+   handle_xdg_toplevel_close,
 };
 
 static void
@@ 

Re: [PATCH weston 1/6] toytoolkit: Port to xdg_shell unstable v6

2016-08-12 Thread Jonas Ådahl
On Fri, Aug 12, 2016 at 11:16:22AM +0200, Quentin Glidic wrote:
> On 12/08/2016 05:40, Jonas Ådahl wrote:
> > Signed-off-by: Jonas Ådahl 
> > ---
> >  Makefile.am  |  10 ++-
> >  clients/window.c | 268 
> > ---
> >  2 files changed, 184 insertions(+), 94 deletions(-)
> > 
> > diff --git a/Makefile.am b/Makefile.am
> > index 47fc643..3a42a93 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -613,8 +613,8 @@ nodist_libtoytoolkit_la_SOURCES =   
> > \
> > protocol/text-cursor-position-client-protocol.h \
> > protocol/viewporter-protocol.c  \
> > protocol/viewporter-client-protocol.h   \
> > -   protocol/xdg-shell-unstable-v5-protocol.c   \
> > -   protocol/xdg-shell-unstable-v5-client-protocol.h\
> > +   protocol/xdg-shell-unstable-v6-protocol.c   \
> > +   protocol/xdg-shell-unstable-v6-client-protocol.h\
> > protocol/ivi-application-protocol.c \
> > protocol/ivi-application-client-protocol.h  \
> > protocol/pointer-constraints-unstable-v1-protocol.c \
> > @@ -834,6 +834,8 @@ BUILT_SOURCES +=
> > \
> > protocol/fullscreen-shell-unstable-v1-client-protocol.h \
> > protocol/xdg-shell-unstable-v5-protocol.c   \
> > protocol/xdg-shell-unstable-v5-client-protocol.h\
> > +   protocol/xdg-shell-unstable-v6-protocol.c   \
> > +   protocol/xdg-shell-unstable-v6-client-protocol.h\
> > protocol/ivi-hmi-controller-protocol.c  \
> > protocol/ivi-hmi-controller-client-protocol.h   \
> > protocol/ivi-application-protocol.c \
> > @@ -911,8 +913,8 @@ desktop_shell_la_SOURCES =  
> > \
> >  nodist_desktop_shell_la_SOURCES =  \
> > protocol/weston-desktop-shell-protocol.c\
> > protocol/weston-desktop-shell-server-protocol.h \
> > -   protocol/xdg-shell-unstable-v5-protocol.c   \
> > -   protocol/xdg-shell-unstable-v5-server-protocol.h
> > +   protocol/xdg-shell-unstable-v6-protocol.c   \
> > +   protocol/xdg-shell-unstable-v6-server-protocol.h
> > 
> >  BUILT_SOURCES += $(nodist_desktop_shell_la_SOURCES)
> >  endif
> > diff --git a/clients/window.c b/clients/window.c
> > index 38ca659..0c43b98 100644
> > --- a/clients/window.c
> > +++ b/clients/window.c
> > @@ -71,7 +71,7 @@ typedef void *EGLContext;
> >  #include "shared/helpers.h"
> >  #include "shared/xalloc.h"
> >  #include "shared/zalloc.h"
> > -#include "xdg-shell-unstable-v5-client-protocol.h"
> > +#include "xdg-shell-unstable-v6-client-protocol.h"
> >  #include "text-cursor-position-client-protocol.h"
> >  #include "pointer-constraints-unstable-v1-client-protocol.h"
> >  #include "relative-pointer-unstable-v1-client-protocol.h"
> > @@ -103,7 +103,7 @@ struct display {
> > struct wl_shm *shm;
> > struct wl_data_device_manager *data_device_manager;
> > struct text_cursor_position *text_cursor_position;
> > -   struct xdg_shell *xdg_shell;
> > +   struct zxdg_shell_v6 *xdg_shell;
> > struct ivi_application *ivi_application; /* ivi style shell */
> > struct zwp_relative_pointer_manager_v1 *relative_pointer_manager;
> > struct zwp_pointer_constraints_v1 *pointer_constraints;
> > @@ -232,6 +232,7 @@ struct window {
> > struct rectangle pending_allocation;
> > struct rectangle last_geometry;
> > int x, y;
> > +   int redraw_inhibited;
> > int redraw_needed;
> > int redraw_task_scheduled;
> > struct task redraw_task;
> > @@ -258,8 +259,9 @@ struct window {
> > window_locked_pointer_motion_handler_t locked_pointer_motion_handler;
> > 
> > struct surface *main_surface;
> > -   struct xdg_surface *xdg_surface;
> > -   struct xdg_popup *xdg_popup;
> > +   struct zxdg_surface_v6 *xdg_surface;
> > +   struct zxdg_toplevel_v6 *xdg_toplevel;
> > +   struct zxdg_popup_v6 *xdg_popup;
> > 
> > struct window *parent;
> > struct window *last_parent;
> > @@ -1588,10 +1590,12 @@ window_destroy(struct window *window)
> > if (window->frame)
> > window_frame_destroy(window->frame);
> > 
> > -   if (window->xdg_surface)
> > -   xdg_surface_destroy(window->xdg_surface);
> > +   if (window->xdg_toplevel)
> > +   zxdg_toplevel_v6_destroy(window->xdg_toplevel);
> > if (window->xdg_popup)
> > -   xdg_popup_destroy(window->xdg_popup);
> > +   zxdg_popup_v6_destroy(window->xdg_popup);
> > +   if (window->xdg_surface)
> > +   zxdg_surface_v6_destroy(window->xdg_surface);
> > 
> > if (window->ivi_surface)
> > ivi_surface_destroy(window->ivi_surface);
> > @@ -2422,22 +2426,22 @@ frame_handle_status(struct window_frame *frame, 
> > struct input *input,
> > return;
> > }
> > 
> > -   if 

Re: [PATCH weston 3/6] clients/simple-shm: Port to xdg_shell unstable v6

2016-08-12 Thread Quentin Glidic

On 12/08/2016 05:40, Jonas Ådahl wrote:

Signed-off-by: Jonas Ådahl 


One concern (in two places) below.



---
 Makefile.am  |  4 +--
 clients/simple-shm.c | 93 
 2 files changed, 60 insertions(+), 37 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index dcd0a25..eb093b8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -519,8 +519,8 @@ demo_clients += \

 weston_simple_shm_SOURCES = clients/simple-shm.c
 nodist_weston_simple_shm_SOURCES = \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/ivi-application-protocol.c \
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index b1fc5f1..9fa2e21 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -37,7 +37,7 @@
 #include 
 #include "shared/os-compatibility.h"
 #include "shared/zalloc.h"
-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"

 #include 
@@ -48,7 +48,7 @@ struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct xdg_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
bool has_xrgb;
@@ -65,16 +65,21 @@ struct window {
struct display *display;
int width, height;
struct wl_surface *surface;
-   struct xdg_surface *xdg_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
struct ivi_surface *ivi_surface;
struct buffer buffers[2];
struct buffer *prev_buffer;
struct wl_callback *callback;
+   bool wait_for_configure;
 };

 static int running = 1;

 static void
+redraw(void *data, struct wl_callback *callback, uint32_t time);
+
+static void
 buffer_release(void *data, struct wl_buffer *buffer)
 {
struct buffer *mybuf = data;
@@ -125,22 +130,39 @@ create_shm_buffer(struct display *display, struct buffer 
*buffer,
 }

 static void
-handle_configure(void *data, struct xdg_surface *surface,
-int32_t width, int32_t height,
-struct wl_array *states, uint32_t serial)
+handle_xdg_surface_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
 {
-   xdg_surface_ack_configure(surface, serial);
+   struct window *window = data;
+
+   zxdg_surface_v6_ack_configure(surface, serial);
+
+   if (window->wait_for_configure) {
+   redraw(window, NULL, 0);
+   window->wait_for_configure = false;
+   }


So you trigger a redraw (and a frame callback, which means a full series 
of redraws) on configure. Ok. Now below…




 }

+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   handle_xdg_surface_configure,
+};
+
 static void
-handle_delete(void *data, struct xdg_surface *xdg_surface)
+handle_xdg_toplevel_configure(void *data, struct zxdg_toplevel_v6 
*xdg_toplevel,
+ int32_t width, int32_t height,
+ struct wl_array *state)
+{
+}
+
+static void
+handle_xdg_toplevel_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
 {
running = 0;
 }

-static const struct xdg_surface_listener xdg_surface_listener = {
-   handle_configure,
-   handle_delete,
+static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
+   handle_xdg_toplevel_configure,
+   handle_xdg_toplevel_close,
 };

 static void
@@ -171,16 +193,21 @@ create_window(struct display *display, int width, int 
height)

if (display->shell) {
window->xdg_surface =
-   xdg_shell_get_xdg_surface(display->shell,
+   zxdg_shell_v6_get_xdg_surface(display->shell,
  window->surface);
-
assert(window->xdg_surface);
-
-   xdg_surface_add_listener(window->xdg_surface,
-_surface_listener, window);
-
-   xdg_surface_set_title(window->xdg_surface, "simple-shm");
-
+   zxdg_surface_v6_add_listener(window->xdg_surface,
+_surface_listener, window);
+
+   window->xdg_toplevel =
+   zxdg_surface_v6_get_toplevel(window->xdg_surface);
+   assert(window->xdg_toplevel);
+   

Re: [PATCH weston 2/6] clients/simple-egl: Port to xdg_shell unstable v6

2016-08-12 Thread Quentin Glidic

On 12/08/2016 05:40, Jonas Ådahl wrote:

Signed-off-by: Jonas Ådahl 


Looks good:
Reviewed-by: Quentin Glidic 

Cheers,



---
 Makefile.am  |   4 +-
 clients/simple-egl.c | 106 +++
 2 files changed, 66 insertions(+), 44 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 3a42a93..dcd0a25 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -563,8 +563,8 @@ if BUILD_SIMPLE_EGL_CLIENTS
 demo_clients += weston-simple-egl
 weston_simple_egl_SOURCES = clients/simple-egl.c
 nodist_weston_simple_egl_SOURCES = \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/ivi-application-protocol.c \
protocol/ivi-application-client-protocol.h
 weston_simple_egl_CFLAGS = $(AM_CFLAGS) $(SIMPLE_EGL_CLIENT_CFLAGS)
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index ddf2f9b..9d401f9 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -42,7 +42,7 @@
 #include 
 #include 

-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include 
 #include 
 #include "protocol/ivi-application-client-protocol.h"
@@ -58,7 +58,7 @@ struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct xdg_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct wl_seat *seat;
struct wl_pointer *pointer;
struct wl_touch *touch;
@@ -94,11 +94,13 @@ struct window {
uint32_t benchmark_time, frames;
struct wl_egl_window *native;
struct wl_surface *surface;
-   struct xdg_surface *xdg_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
struct ivi_surface *ivi_surface;
EGLSurface egl_surface;
struct wl_callback *callback;
int fullscreen, opaque, buffer_size, frame_sync;
+   bool wait_for_configure;
 };

 static const char *vert_shader_text =
@@ -271,9 +273,24 @@ init_gl(struct window *window)
 }

 static void
-handle_surface_configure(void *data, struct xdg_surface *surface,
-int32_t width, int32_t height,
-struct wl_array *states, uint32_t serial)
+handle_surface_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
+{
+   struct window *window = data;
+
+   zxdg_surface_v6_ack_configure(surface, serial);
+
+   window->wait_for_configure = false;
+}
+
+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   handle_surface_configure
+};
+
+static void
+handle_toplevel_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
+ int32_t width, int32_t height,
+ struct wl_array *states)
 {
struct window *window = data;
uint32_t *p;
@@ -282,7 +299,7 @@ handle_surface_configure(void *data, struct xdg_surface 
*surface,
wl_array_for_each(p, states) {
uint32_t state = *p;
switch (state) {
-   case XDG_SURFACE_STATE_FULLSCREEN:
+   case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
window->fullscreen = 1;
break;
}
@@ -303,19 +320,17 @@ handle_surface_configure(void *data, struct xdg_surface 
*surface,
wl_egl_window_resize(window->native,
 window->geometry.width,
 window->geometry.height, 0, 0);
-
-   xdg_surface_ack_configure(surface, serial);
 }

 static void
-handle_surface_delete(void *data, struct xdg_surface *xdg_surface)
+handle_toplevel_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
 {
running = 0;
 }

-static const struct xdg_surface_listener xdg_surface_listener = {
-   handle_surface_configure,
-   handle_surface_delete,
+static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
+   handle_toplevel_configure,
+   handle_toplevel_close,
 };

 static void
@@ -340,13 +355,20 @@ static const struct ivi_surface_listener 
ivi_surface_listener = {
 static void
 create_xdg_surface(struct window *window, struct display *display)
 {
-   window->xdg_surface = xdg_shell_get_xdg_surface(display->shell,
-   window->surface);
+   window->xdg_surface = zxdg_shell_v6_get_xdg_surface(display->shell,
+   window->surface);
+   zxdg_surface_v6_add_listener(window->xdg_surface,
+_surface_listener, window);

-   

Re: [PATCH weston 3/6] Introduce libweston-desktop

2016-08-12 Thread Pekka Paalanen
On Fri, 12 Aug 2016 10:44:32 +0200
Quentin Glidic  wrote:

> On 12/08/2016 10:41, Quentin Glidic wrote:
> > From: Quentin Glidic 
> >
> > libweston-desktop is an abstraction library for compositors wanting to
> > support desktop-like shells.
> >
> > The API is designed from xdg_shell features, as it will eventually be
> > the recommended shell for modern applications to use.
> > In the future, adding new shell protocols support will be easier, as
> > limited to libweston-desktop.
> >
> > The library versioning is the same as libweston. If one of them break
> > ABI compatibility, the other will too.  
> 
> This may need an update of the release doc? I wanted libweston-desktop 
> to basically be tied to libweston, as if they were one library, to keep 
> things simple (only one set of variables in configure.ac).
> If you have any wording suggestion or comment about that, please tell.

Hi,

well, as you do not add any new variables to configure.ac then there is
no need to update releasing.txt, since there is nothing to change or
check by the release manager.

However, README might need some words on the relationship and
versioning of libweston-desktop vs. libweston. I also believe that
distributions will package the two libraries separately, so we should
explain their interdependencies in the README.

Personally I am fine with the two libraries using the same version
number. The catch is that people breaking libweston-desktop need to
know to bump the libweston major if it has not been bumped already.

Obviously people breaking libweston will need to bump libweston major
if not bumped already too, but I haven't written that down anywhere.

> > The compositor will only ever see toplevel surfaces (“windows”), with
> > all the other being internal implementation details.
> > Thus, popups and associated grabs are handled entirely in
> > libweston-desktop.
> > Xwayland special surfaces (override-redirect) are special-cased to a
> > dedicated layer, as the compositor should not know about them.
> >
> > All the shell error checking is taken care of too, as well as some
> > specification rules (e.g. sizes constraint for maximized and fullscreen
> > surfaces).
> >
> > All the compositor has to do is define a few callbacks in the interface
> > struct, and manage toplevel surfaces.
> >
> > Signed-off-by: Quentin Glidic 
> > Reviewed-by: Jonas Ådahl 
> > Acked-by: Giulio Camuffo 
> >
> > Differential Revision: https://phabricator.freedesktop.org/D1207
> > ---
> >
> > Added a line for versioning and ABI compatibility, not sure about this
> > one.
> >
> >  Makefile.am   |  31 +-
> >  configure.ac  |   1 +
> >  libweston-desktop/client.c| 212 
> >  libweston-desktop/internal.h  | 236 +
> >  libweston-desktop/libweston-desktop.c | 234 +
> >  libweston-desktop/libweston-desktop.h | 166 ++
> >  libweston-desktop/libweston-desktop.pc.in |  12 +
> >  libweston-desktop/seat.c  | 368 ++
> >  libweston-desktop/surface.c   | 818 
> > ++
> >  libweston-desktop/wl-shell.c  | 464 +
> >  libweston-desktop/xdg-shell-v5.c  | 798 
> > +
> >  libweston-desktop/xwayland.c  | 360 +
> >  libweston/compositor.c|  37 ++
> >  libweston/compositor.h|  16 +
> >  14 files changed, 3752 insertions(+), 1 deletion(-)
> >  create mode 100644 libweston-desktop/client.c
> >  create mode 100644 libweston-desktop/internal.h
> >  create mode 100644 libweston-desktop/libweston-desktop.c
> >  create mode 100644 libweston-desktop/libweston-desktop.h
> >  create mode 100644 libweston-desktop/libweston-desktop.pc.in
> >  create mode 100644 libweston-desktop/seat.c
> >  create mode 100644 libweston-desktop/surface.c
> >  create mode 100644 libweston-desktop/wl-shell.c
> >  create mode 100644 libweston-desktop/xdg-shell-v5.c
> >  create mode 100644 libweston-desktop/xwayland.c
> >
> > diff --git a/Makefile.am b/Makefile.am
> > index 32627f5..217d21f 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -105,6 +105,29 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES =   
> > \
> > shared/platform.h   \
> > libweston/weston-egl-ext.h
> >
> > +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)
> > +libweston_desktop_@LIBWESTON_MAJOR@_la_LIBADD = 
> > libweston-@LIBWESTON_MAJOR@.la $(COMPOSITOR_LIBS)
> > +libweston_desktop_@LIBWESTON_MAJOR@_la_LDFLAGS = -version-info 
> > $(LT_VERSION_INFO)
> > 

Re: [PATCH weston 1/6] toytoolkit: Port to xdg_shell unstable v6

2016-08-12 Thread Quentin Glidic

On 12/08/2016 05:40, Jonas Ådahl wrote:

Signed-off-by: Jonas Ådahl 
---
 Makefile.am  |  10 ++-
 clients/window.c | 268 ---
 2 files changed, 184 insertions(+), 94 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 47fc643..3a42a93 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -613,8 +613,8 @@ nodist_libtoytoolkit_la_SOURCES =   \
protocol/text-cursor-position-client-protocol.h \
protocol/viewporter-protocol.c  \
protocol/viewporter-client-protocol.h   \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/ivi-application-protocol.c \
protocol/ivi-application-client-protocol.h  \
protocol/pointer-constraints-unstable-v1-protocol.c \
@@ -834,6 +834,8 @@ BUILT_SOURCES +=\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/xdg-shell-unstable-v5-protocol.c   \
protocol/xdg-shell-unstable-v5-client-protocol.h\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/ivi-hmi-controller-protocol.c  \
protocol/ivi-hmi-controller-client-protocol.h   \
protocol/ivi-application-protocol.c \
@@ -911,8 +913,8 @@ desktop_shell_la_SOURCES =  \
 nodist_desktop_shell_la_SOURCES =  \
protocol/weston-desktop-shell-protocol.c\
protocol/weston-desktop-shell-server-protocol.h \
-   protocol/xdg-shell-unstable-v5-protocol.c   \
-   protocol/xdg-shell-unstable-v5-server-protocol.h
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-server-protocol.h

 BUILT_SOURCES += $(nodist_desktop_shell_la_SOURCES)
 endif
diff --git a/clients/window.c b/clients/window.c
index 38ca659..0c43b98 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -71,7 +71,7 @@ typedef void *EGLContext;
 #include "shared/helpers.h"
 #include "shared/xalloc.h"
 #include "shared/zalloc.h"
-#include "xdg-shell-unstable-v5-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "text-cursor-position-client-protocol.h"
 #include "pointer-constraints-unstable-v1-client-protocol.h"
 #include "relative-pointer-unstable-v1-client-protocol.h"
@@ -103,7 +103,7 @@ struct display {
struct wl_shm *shm;
struct wl_data_device_manager *data_device_manager;
struct text_cursor_position *text_cursor_position;
-   struct xdg_shell *xdg_shell;
+   struct zxdg_shell_v6 *xdg_shell;
struct ivi_application *ivi_application; /* ivi style shell */
struct zwp_relative_pointer_manager_v1 *relative_pointer_manager;
struct zwp_pointer_constraints_v1 *pointer_constraints;
@@ -232,6 +232,7 @@ struct window {
struct rectangle pending_allocation;
struct rectangle last_geometry;
int x, y;
+   int redraw_inhibited;
int redraw_needed;
int redraw_task_scheduled;
struct task redraw_task;
@@ -258,8 +259,9 @@ struct window {
window_locked_pointer_motion_handler_t locked_pointer_motion_handler;

struct surface *main_surface;
-   struct xdg_surface *xdg_surface;
-   struct xdg_popup *xdg_popup;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
+   struct zxdg_popup_v6 *xdg_popup;

struct window *parent;
struct window *last_parent;
@@ -1588,10 +1590,12 @@ window_destroy(struct window *window)
if (window->frame)
window_frame_destroy(window->frame);

-   if (window->xdg_surface)
-   xdg_surface_destroy(window->xdg_surface);
+   if (window->xdg_toplevel)
+   zxdg_toplevel_v6_destroy(window->xdg_toplevel);
if (window->xdg_popup)
-   xdg_popup_destroy(window->xdg_popup);
+   zxdg_popup_v6_destroy(window->xdg_popup);
+   if (window->xdg_surface)
+   zxdg_surface_v6_destroy(window->xdg_surface);

if (window->ivi_surface)
ivi_surface_destroy(window->ivi_surface);
@@ -2422,22 +2426,22 @@ frame_handle_status(struct window_frame *frame, struct 
input *input,
return;
}

-   if ((status & FRAME_STATUS_MOVE) && window->xdg_surface) {
+   if ((status & FRAME_STATUS_MOVE) && window->xdg_toplevel) {
input_ungrab(input);
-   xdg_surface_move(window->xdg_surface,
-

Re: [PATCH wayland v5] Add API to install protocol loggers on the server wl_display

2016-08-12 Thread Pekka Paalanen
On Fri, 12 Aug 2016 09:34:46 +0200
Giulio Camuffo  wrote:

> Ah sorry, i forgot to add Yong's R-b.
> 
> 2016-08-12 9:33 GMT+02:00 Giulio Camuffo :
> > The new wl_display_add_protocol_logger allows to set a function as
> > a logger, which will get called when a new request is received or an
> > event is sent.
> > This is akin to setting WAYLAND_DEBUG=1, but more powerful because it
> > can be enabled at run time and allows to show the log e.g. in a UI view.
> > A test is added for the new functionality.
> >
> > Signed-off-by: Giulio Camuffo 
> > Reviewed-by: Jonas Ådahl 
> > ---
> >
> > v5: fixed documentation
> >
> >  Makefile.am  |   5 +-
> >  src/wayland-server-core.h|  24 +++
> >  src/wayland-server.c | 102 +++--
> >  tests/protocol-logger-test.c | 148 
> > +++
> >  4 files changed, 272 insertions(+), 7 deletions(-)
> >  create mode 100644 tests/protocol-logger-test.c
> >


Added my and Yong R-b and pushed:
   2f61725..450f06e  master -> master


Thanks,
pq


pgpTGR8db7Tn0.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 v4 2/3] Add API to retrieve and iterate over the resources list of a client

2016-08-12 Thread Pekka Paalanen
On Thu, 11 Aug 2016 17:23:10 +0200
Giulio Camuffo  wrote:

> To complement on the new resource created signal, this allows to
> iterate over the existing resources of a client.
> 
> Signed-off-by: Giulio Camuffo 
> Reviewed-by: Jonas Ådahl 
> ---
> 
> v4: - really stop when the iterator says so
> 
>  src/wayland-private.h |  3 ++-
>  src/wayland-server-core.h |  9 +
>  src/wayland-server.c  | 49 
> ++-
>  src/wayland-util.c| 18 -
>  src/wayland-util.h| 11 +++
>  5 files changed, 83 insertions(+), 7 deletions(-)

Hi Giulio,

patches 1 and 2 pushed:
   596024f..2f61725  master -> master


But I did do some minor changes.

In patch 1, I added:
+   /* This is defined to be safe also after client destruction */
+   wl_list_remove(_listener.listener.link);

in the test so that we also remove the listener at some point.

In patch 2, see below.

> 
> diff --git a/src/wayland-private.h b/src/wayland-private.h
> index adfbe01..ac712d9 100644
> --- a/src/wayland-private.h
> +++ b/src/wayland-private.h
> @@ -75,7 +75,8 @@ struct wl_map {
>   uint32_t free_list;
>  };
>  
> -typedef void (*wl_iterator_func_t)(void *element, void *data);
> +typedef enum wl_iterator_result (*wl_iterator_func_t)(void *element,
> +   void *data);
>  
>  void
>  wl_map_init(struct wl_map *map, uint32_t side);
> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
> index bb0a989..56e8d80 100644
> --- a/src/wayland-server-core.h
> +++ b/src/wayland-server-core.h
> @@ -216,6 +216,15 @@ void
>  wl_client_add_resource_created_listener(struct wl_client *client,
>  struct wl_listener *listener);
>  
> +typedef enum wl_iterator_result 
> (*wl_client_for_each_resource_iterator_func_t)(
> + struct wl_resource *resource,
> + void *user_data);
> +
> +void
> +wl_client_for_each_resource(struct wl_client *client,
> +wl_client_for_each_resource_iterator_func_t 
> iterator,
> +void *user_data);
> +
>  /** \class wl_listener
>   *
>   * \brief A single listener for Wayland signals
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index a396410..c53a2f4 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -565,7 +565,7 @@ wl_resource_post_no_memory(struct wl_resource *resource)
>  WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
>  }
>  
> -static void
> +static enum wl_iterator_result
>  destroy_resource(void *element, void *data)
>  {
>   struct wl_resource *resource = element;
> @@ -580,6 +580,8 @@ destroy_resource(void *element, void *data)
>  
>   if (!(flags & WL_MAP_ENTRY_LEGACY))
>   free(resource);
> +
> + return WL_ITERATOR_CONTINUE;
>  }
>  
>  WL_EXPORT void
> @@ -1604,6 +1606,51 @@ wl_client_add_resource_created_listener(struct 
> wl_client *client,
>   wl_signal_add(>resource_created_signal, listener);
>  }
>  
> +struct wl_resource_iterator_context {
> + void *user_data;
> + wl_client_for_each_resource_iterator_func_t it;
> +};
> +
> +static enum wl_iterator_result
> +resource_iterator_helper(void *res, void *user_data)
> +{
> + struct wl_resource_iterator_context *context = user_data;
> + struct wl_resource *resource = res;

Added newline.

> + return context->it(resource, context->user_data);
> +}
> +
> +/** Iterate over all the resources of a client
> + *
> + * \param client The client object
> + * \param iterator The iterator function
> + * \param user_data The user data pointer
> + *
> + * The function pointed by \a iterator will be called for each
> + * resource owned by the client. The \a user_data will be passed
> + * as the second argument of the iterator function.
> + * If the \a iterator function returns \a WL_ITERATOR_CONTINUE the iteration
> + * will continue, if it returns \a WL_ITERATOR_STOP it will stop.
> + *
> + * Creating and destroying resources while iterating is safe, but new
> + * resources may or may not be picked up by the iterator.
> + *
> + * \sa wl_iterator_result
> + *
> + * \memberof wl_client
> + */
> +WL_EXPORT void
> +wl_client_for_each_resource(struct wl_client *client,
> + wl_client_for_each_resource_iterator_func_t 
> iterator,
> + void *user_data)
> +{
> + struct wl_resource_iterator_context context = {
> + .user_data = user_data,
> + .it = iterator,
> + };
> +
> + wl_map_for_each(>objects, resource_iterator_helper, );
> +}
> +
>  /** \cond */ /* Deprecated functions below. */
>  
>  uint32_t
> diff --git a/src/wayland-util.c b/src/wayland-util.c
> index 7467366..43aab83 100644
> --- a/src/wayland-util.c
> +++ 

Re: [PATCH wayland-protocols v2] Introduce xdg-foreign protocol

2016-08-12 Thread Jonas Ådahl
On Sun, Aug 07, 2016 at 08:14:32AM -0500, Derek Foreman wrote:
> On 05/08/16 10:52 AM, Jonas Ådahl wrote:
> > On Fri, Aug 05, 2016 at 07:45:50AM -0500, Derek Foreman wrote:
> >> On 27/07/16 02:54 AM, Jonas Ådahl wrote:
> >>> xdg-foreign is a protocol meant to enable setting up inter surface
> >>> relationships across clients. Potential use cases are out-of-process
> >>> dialogs, such as file dialogs, meant to be used by sandboxed processes
> >>> that may not have the access it needs to implement such dialogs.
> >>>
> >>> It works by enabling a client to export a surface, creating a handle
> >>> for the exported surface. The handle, in form of a unique string, may
> >>> be shared in some way with other clients (for example the provider of
> >>> the file dialog) which can then import the exported surface.
> >>
> >> Have you considered passing an fd (have the compositor create a pipe)
> >> instead of a string?
> >>
> >> Then the shared token is impossible to guess.
> > 
> > As Carsten wrote in the other E-mail, a client can be lazy and generate
> > a bad string. The client also wouldn't be able to generate a globally
> > unique string, so to import a handle, the importing client would also
> > need to associate the string with some kind of client id.
> 
> Why would clients be generating strings?
> 
> I think maybe I was too terse, I've explained what I'd intended the fd
> to be used for in my other reply.
> 
> I'm fine with the proposal as-is though,  I just though perhaps a method
> in which nobody generated a string at all would be better. :)

Passing a string has the benefit of making it easy to pass in a display
protocol agnostic parent protocol (which is the case for the flatpak
portal; it either passes "x11:" or "wayland:". Maybe it would be possible to still have it pass a string some
how even if the protocol doesn't include that part, but lets explore
that another day.

I landed the patch as is with the RB's given in this thread, and it was
included in the same release as the idle-inhibit protocol.


Jonas

> 
> Thanks,
> Derek
> 
> >>
> >> Even so, this looks workable and not too hard to implement.
> >>
> >> Reviewed-by: Derek Foreman 
> > 
> > Thanks!
> > 
> > 
> > Jonas
> > 
> >>
> >> Thanks,
> >> Derek
> >>> Signed-off-by: Jonas Ådahl 
> >>> ---
> >>>
> >>> Changes since v1:
> >>>
> >>>  - Spelling and grammar fixes
> >>>  - Wording changes (unexport -> revoke)
> >>>  - Fixed the "Warning! .. unstable .." paragraph (was an old version)
> >>>  - Added sandbox client -> unsandboxed file browser dialog example to 
> >>> protocol
> >>>description
> >>>  - Removed left-over note about restriction of importing a handle only 
> >>> once. It
> >>>should be possible to import a handle multiple times, but the protocol 
> >>> text
> >>>had only been updated in one of two places.
> >>>
> >>>
> >>> Jonas
> >>>
> >>>
> >>>
> >>>  Makefile.am  |   1 +
> >>>  unstable/xdg-foreign/README  |   4 +
> >>>  unstable/xdg-foreign/xdg-foreign-unstable-v1.xml | 186 
> >>> +++
> >>>  3 files changed, 191 insertions(+)
> >>>  create mode 100644 unstable/xdg-foreign/README
> >>>  create mode 100644 unstable/xdg-foreign/xdg-foreign-unstable-v1.xml
> >>>
> >>> diff --git a/Makefile.am b/Makefile.am
> >>> index 9e2a029..35df201 100644
> >>> --- a/Makefile.am
> >>> +++ b/Makefile.am
> >>> @@ -9,6 +9,7 @@ unstable_protocols =  
> >>> \
> >>>   unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
> >>> \
> >>>   unstable/tablet/tablet-unstable-v1.xml  
> >>> \
> >>>   unstable/tablet/tablet-unstable-v2.xml  
> >>> \
> >>> + unstable/xdg-foreign/xdg-foreign-unstable-v1.xml
> >>> \
> >>>   $(NULL)
> >>>  
> >>>  stable_protocols =   
> >>> \
> >>> diff --git a/unstable/xdg-foreign/README b/unstable/xdg-foreign/README
> >>> new file mode 100644
> >>> index 000..f5bcb83
> >>> --- /dev/null
> >>> +++ b/unstable/xdg-foreign/README
> >>> @@ -0,0 +1,4 @@
> >>> +xdg foreign protocol
> >>> +
> >>> +Maintainers:
> >>> +Jonas Ådahl 
> >>> diff --git a/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml 
> >>> b/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml
> >>> new file mode 100644
> >>> index 000..c6f5775
> >>> --- /dev/null
> >>> +++ b/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml
> >>> @@ -0,0 +1,186 @@
> >>> +
> >>> +
> >>> +
> >>> +  
> >>> +Copyright © 2015-2016 Red Hat Inc.
> >>> +
> >>> +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 
> >>> 

[PATCH weston 0/6] libweston-desktop, finally

2016-08-12 Thread Quentin Glidic
From: Quentin Glidic 

Hi everyone,

Here is the final shape of my libweston-desktop series.
A lot of things happened on Phabricator[1], and this is the result.

Thanks to Jonas for the deep reviews that made it useful for real.
And thanks to Giulio for the API concerns that will make it useful to
more compositors.

This series (minus xdg_shell_v6) will land by tomorrow, unless someone
has a strong objection.
We can always break API/ABI later if some big rework is needed to
support a use case we overlooked or didn’t think about.

Cheers,

[1] 

Quentin Glidic (6):
  input: Add helpers for all keyboard/pointer/touch events
  libweston: Rename weston_surface::configure to ::committed
  Introduce libweston-desktop
  xwayland: Introduce a private struct for XWayland interface
  desktop-shell: Port to libweston-desktop
  libweston-desktop: Implement xdg_shell_v6

 Makefile.am   |   38 +-
 configure.ac  |1 +
 desktop-shell/input-panel.c   |   16 +-
 desktop-shell/shell.c | 3044 ++---
 desktop-shell/shell.h |4 +
 fullscreen-shell/fullscreen-shell.c   |   24 +-
 ivi-shell/input-panel-ivi.c   |   16 +-
 ivi-shell/ivi-shell.c |   16 +-
 libweston-desktop/client.c|  212 ++
 libweston-desktop/internal.h  |  236 +++
 libweston-desktop/libweston-desktop.c |  244 +++
 libweston-desktop/libweston-desktop.h |  166 ++
 libweston-desktop/libweston-desktop.pc.in |   12 +
 libweston-desktop/seat.c  |  368 
 libweston-desktop/surface.c   |  818 
 libweston-desktop/wl-shell.c  |  464 +
 libweston-desktop/xdg-shell-v5.c  |  798 
 libweston-desktop/xdg-shell-v6.c  | 1230 
 libweston-desktop/xwayland.c  |  372 
 libweston/compositor.c|   61 +-
 libweston/compositor.h|   89 +-
 libweston/data-device.c   |   22 +-
 libweston/input.c |  388 +++-
 shared/helpers.h  |   11 +
 tests/weston-test.c   |   10 +-
 xwayland/launcher.c   |   17 +
 xwayland/window-manager.c |  130 +-
 xwayland/xwayland-api.h   |   42 +
 xwayland/xwayland-internal-interface.h|   62 +
 29 files changed, 6197 insertions(+), 2714 deletions(-)
 create mode 100644 libweston-desktop/client.c
 create mode 100644 libweston-desktop/internal.h
 create mode 100644 libweston-desktop/libweston-desktop.c
 create mode 100644 libweston-desktop/libweston-desktop.h
 create mode 100644 libweston-desktop/libweston-desktop.pc.in
 create mode 100644 libweston-desktop/seat.c
 create mode 100644 libweston-desktop/surface.c
 create mode 100644 libweston-desktop/wl-shell.c
 create mode 100644 libweston-desktop/xdg-shell-v5.c
 create mode 100644 libweston-desktop/xdg-shell-v6.c
 create mode 100644 libweston-desktop/xwayland.c
 create mode 100644 xwayland/xwayland-internal-interface.h

-- 
2.9.2

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


[PATCH weston 4/6] xwayland: Introduce a private struct for XWayland interface

2016-08-12 Thread Quentin Glidic
From: Quentin Glidic 

libweston-desktop implements this private struct.

Signed-off-by: Quentin Glidic 
Reviewed-by: Jonas Ådahl 
Acked-by: Giulio Camuffo 

Differential Revision: https://phabricator.freedesktop.org/D1208
---
 Makefile.am|   1 +
 libweston-desktop/xwayland.c   | 126 +---
 libweston/compositor.h |   5 ++
 xwayland/launcher.c|  17 +
 xwayland/window-manager.c  | 128 +
 xwayland/xwayland-api.h|  42 +++
 xwayland/xwayland-internal-interface.h |  62 
 7 files changed, 264 insertions(+), 117 deletions(-)
 create mode 100644 xwayland/xwayland-internal-interface.h

diff --git a/Makefile.am b/Makefile.am
index 217d21f..e7a76c1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1028,6 +1028,7 @@ xwayland_la_CFLAGS =  \
$(CAIRO_CFLAGS)
 xwayland_la_SOURCES =  \
xwayland/xwayland.h \
+   xwayland/xwayland-internal-interface.h  \
xwayland/window-manager.c   \
xwayland/selection.c\
xwayland/dnd.c  \
diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
index 9282bf2..7362a72 100644
--- a/libweston-desktop/xwayland.c
+++ b/libweston-desktop/xwayland.c
@@ -35,6 +35,7 @@
 
 #include "libweston-desktop.h"
 #include "internal.h"
+#include "xwayland/xwayland-internal-interface.h"
 
 enum weston_desktop_xwayland_surface_state {
NONE,
@@ -51,13 +52,13 @@ struct weston_desktop_xwayland {
struct weston_layer layer;
 };
 
-struct shell_surface {
+struct weston_desktop_xwayland_surface {
struct weston_desktop_xwayland *xwayland;
struct weston_desktop *desktop;
struct weston_desktop_surface *surface;
struct wl_listener resource_destroy_listener;
struct weston_view *view;
-   const struct weston_shell_client *client;
+   const struct weston_xwayland_client_interface *client_interface;
struct weston_geometry next_geometry;
bool has_next_geometry;
bool added;
@@ -65,7 +66,7 @@ struct shell_surface {
 };
 
 static void
-weston_desktop_xwayland_surface_change_state(struct shell_surface *surface,
+weston_desktop_xwayland_surface_change_state(struct 
weston_desktop_xwayland_surface *surface,
 enum 
weston_desktop_xwayland_surface_state state,
 struct weston_desktop_surface 
*parent,
 int32_t x, int32_t y)
@@ -114,7 +115,7 @@ weston_desktop_xwayland_surface_committed(struct 
weston_desktop_surface *dsurfac
  void *user_data, bool new_buffer,
  int32_t sx, int32_t sy)
 {
-   struct shell_surface *surface = user_data;
+   struct weston_desktop_xwayland_surface *surface = user_data;
 
if (surface->has_next_geometry) {
surface->has_next_geometry = false;
@@ -129,20 +130,21 @@ weston_desktop_xwayland_surface_committed(struct 
weston_desktop_surface *dsurfac
 
 static void
 weston_desktop_xwayland_surface_set_size(struct weston_desktop_surface 
*dsurface,
- void *user_data,
- int32_t width, int32_t height)
+void *user_data,
+int32_t width, int32_t height)
 {
-   struct shell_surface *surface = user_data;
+   struct weston_desktop_xwayland_surface *surface = user_data;
+   struct weston_surface *wsurface =
+   weston_desktop_surface_get_surface(surface->surface);
 
-   
surface->client->send_configure(weston_desktop_surface_get_surface(surface->surface),
-  width, height);
+   surface->client_interface->send_configure(wsurface, width, height);
 }
 
 static void
 weston_desktop_xwayland_surface_destroy(struct weston_desktop_surface 
*dsurface,
void *user_data)
 {
-   struct shell_surface *surface = user_data;
+   struct weston_desktop_xwayland_surface *surface = user_data;
 
wl_list_remove(>resource_destroy_listener.link);
 
@@ -158,18 +160,18 @@ weston_desktop_xwayland_surface_destroy(struct 
weston_desktop_surface *dsurface,
 
 static bool
 weston_desktop_xwayland_surface_get_maximized(struct weston_desktop_surface 
*dsurface,
-  void *user_data)
+ void *user_data)
 {
-   struct shell_surface *surface = user_data;
+   struct weston_desktop_xwayland_surface 

[PATCH weston 6/6] libweston-desktop: Implement xdg_shell_v6

2016-08-12 Thread Quentin Glidic
From: Quentin Glidic 

Signed-off-by: Quentin Glidic 
Acked-by: Jonas Ådahl 
Acked-by: Giulio Camuffo 

Differential Revision: https://phabricator.freedesktop.org/D1210
---
 Makefile.am   |4 +
 libweston-desktop/libweston-desktop.c |   10 +
 libweston-desktop/xdg-shell-v6.c  | 1230 +
 libweston/compositor.c|6 +
 libweston/compositor.h|2 +
 5 files changed, 1252 insertions(+)
 create mode 100644 libweston-desktop/xdg-shell-v6.c

diff --git a/Makefile.am b/Makefile.am
index 85fd718..47fc643 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -119,13 +119,17 @@ libweston_desktop_@LIBWESTON_MAJOR@_la_SOURCES =  \
libweston-desktop/seat.c\
libweston-desktop/surface.c \
libweston-desktop/wl-shell.c\
+   libweston-desktop/xdg-shell-v6.c\
libweston-desktop/xdg-shell-v5.c\
libweston-desktop/xwayland.c
 
 nodist_libweston_desktop_@LIBWESTON_MAJOR@_la_SOURCES =\
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-server-protocol.h\
protocol/xdg-shell-unstable-v5-protocol.c   \
protocol/xdg-shell-unstable-v5-server-protocol.h
 
+libweston-desktop-@LIBWESTON_MAJOR@.la 
libweston-desktop/libweston_desktop_@LIBWESTON_MAJOR@_la-xdg-shell-v6.lo: 
protocol/xdg-shell-unstable-v6-server-protocol.h
 libweston-desktop-@LIBWESTON_MAJOR@.la 
libweston-desktop/libweston_desktop_@LIBWESTON_MAJOR@_la-xdg-shell-v5.lo: 
protocol/xdg-shell-unstable-v5-server-protocol.h
 
 if SYSTEMD_NOTIFY_SUPPORT
diff --git a/libweston-desktop/libweston-desktop.c 
b/libweston-desktop/libweston-desktop.c
index 4583ede..0ee1139 100644
--- a/libweston-desktop/libweston-desktop.c
+++ b/libweston-desktop/libweston-desktop.c
@@ -40,6 +40,7 @@ struct weston_desktop {
struct weston_compositor *compositor;
struct weston_desktop_api api;
void *user_data;
+   struct wl_global *xdg_shell_v6;
struct wl_global *xdg_shell_v5;
struct wl_global *wl_shell;
 };
@@ -69,6 +70,13 @@ weston_desktop_create(struct weston_compositor *compositor,
MIN(sizeof(struct weston_desktop_api), api->struct_size);
memcpy(>api, api, desktop->api.struct_size);
 
+   desktop->xdg_shell_v6 =
+   weston_desktop_xdg_shell_v6_create(desktop, display);
+   if (desktop->xdg_shell_v6 == NULL) {
+   weston_desktop_destroy(desktop);
+   return NULL;
+   }
+
desktop->xdg_shell_v5 =
weston_desktop_xdg_shell_v5_create(desktop, display);
if (desktop->xdg_shell_v5 == NULL) {
@@ -98,6 +106,8 @@ weston_desktop_destroy(struct weston_desktop *desktop)
wl_global_destroy(desktop->wl_shell);
if (desktop->xdg_shell_v5 != NULL)
wl_global_destroy(desktop->xdg_shell_v5);
+   if (desktop->xdg_shell_v6 != NULL)
+   wl_global_destroy(desktop->xdg_shell_v6);
 
free(desktop);
 }
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
new file mode 100644
index 000..2f9c9ae
--- /dev/null
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -0,0 +1,1230 @@
+/*
+ * Copyright © 2010-2012 Intel Corporation
+ * Copyright © 2011-2012 Collabora, Ltd.
+ * Copyright © 2013 Raspberry Pi Foundation
+ * Copyright © 2016 Quentin "Sardem FF7" Glidic
+ *
+ * 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 "compositor.h"
+#include "zalloc.h"
+#include "protocol/xdg-shell-unstable-v6-server-protocol.h"
+
+#include "libweston-desktop.h"
+#include 

[PATCH weston 1/6] input: Add helpers for all keyboard/pointer/touch events

2016-08-12 Thread Quentin Glidic
From: Quentin Glidic 

These are useful to implement grabs.

Signed-off-by: Quentin Glidic 
Reviewed-by: Jonas Ådahl 
Acked-by: Giulio Camuffo 

Differential Revision: https://phabricator.freedesktop.org/D1245
---
 libweston/compositor.h |  33 +
 libweston/input.c  | 374 +
 2 files changed, 316 insertions(+), 91 deletions(-)

diff --git a/libweston/compositor.h b/libweston/compositor.h
index 0133084..fdf4592 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -424,6 +424,14 @@ weston_pointer_create(struct weston_seat *seat);
 void
 weston_pointer_destroy(struct weston_pointer *pointer);
 void
+weston_pointer_send_motion(struct weston_pointer *pointer, uint32_t time,
+  struct weston_pointer_motion_event *event);
+bool
+weston_pointer_has_focus_resource(struct weston_pointer *pointer);
+void
+weston_pointer_send_button(struct weston_pointer *pointer,
+  uint32_t time, uint32_t button, uint32_t state_w);
+void
 weston_pointer_send_axis(struct weston_pointer *pointer,
 uint32_t time,
 struct weston_pointer_axis_event *event);
@@ -477,6 +485,18 @@ int
 weston_keyboard_set_locks(struct weston_keyboard *keyboard,
  uint32_t mask, uint32_t value);
 
+bool
+weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
+void
+weston_keyboard_send_key(struct weston_keyboard *keyboard,
+uint32_t time, uint32_t key,
+enum wl_keyboard_key_state state);
+void
+weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
+  uint32_t serial, uint32_t mods_depressed,
+  uint32_t mods_latched,
+  uint32_t mods_locked, uint32_t group);
+
 struct weston_touch *
 weston_touch_create(void);
 void
@@ -490,6 +510,19 @@ weston_touch_start_grab(struct weston_touch *device,
 void
 weston_touch_end_grab(struct weston_touch *touch);
 
+bool
+weston_touch_has_focus_resource(struct weston_touch *touch);
+void
+weston_touch_send_down(struct weston_touch *touch, uint32_t time,
+  int touch_id, wl_fixed_t x, wl_fixed_t y);
+void
+weston_touch_send_up(struct weston_touch *touch, uint32_t time, int touch_id);
+void
+weston_touch_send_motion(struct weston_touch *touch, uint32_t time,
+int touch_id, wl_fixed_t x, wl_fixed_t y);
+void
+weston_touch_send_frame(struct weston_touch *touch);
+
 void
 wl_data_device_set_keyboard_focus(struct weston_seat *seat);
 
diff --git a/libweston/input.c b/libweston/input.c
index 6e931bd..4ed08fd 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -340,9 +340,9 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab)
 }
 
 static void
-weston_pointer_send_relative_motion(struct weston_pointer *pointer,
-   uint32_t time,
-   struct weston_pointer_motion_event *event)
+pointer_send_relative_motion(struct weston_pointer *pointer,
+uint32_t time,
+struct weston_pointer_motion_event *event)
 {
uint64_t time_usec;
double dx, dy, dx_unaccel, dy_unaccel;
@@ -379,8 +379,8 @@ weston_pointer_send_relative_motion(struct weston_pointer 
*pointer,
 }
 
 static void
-weston_pointer_send_motion(struct weston_pointer *pointer, uint32_t time,
-  wl_fixed_t sx, wl_fixed_t sy)
+pointer_send_motion(struct weston_pointer *pointer, uint32_t time,
+   wl_fixed_t sx, wl_fixed_t sy)
 {
struct wl_list *resource_list;
struct wl_resource *resource;
@@ -393,11 +393,10 @@ weston_pointer_send_motion(struct weston_pointer 
*pointer, uint32_t time,
wl_pointer_send_motion(resource, time, sx, sy);
 }
 
-static void
-default_grab_pointer_motion(struct weston_pointer_grab *grab, uint32_t time,
-   struct weston_pointer_motion_event *event)
+WL_EXPORT void
+weston_pointer_send_motion(struct weston_pointer *pointer, uint32_t time,
+  struct weston_pointer_motion_event *event)
 {
-   struct weston_pointer *pointer = grab->pointer;
wl_fixed_t x, y;
wl_fixed_t old_sx = pointer->sx;
wl_fixed_t old_sy = pointer->sy;
@@ -411,50 +410,78 @@ default_grab_pointer_motion(struct weston_pointer_grab 
*grab, uint32_t time,
weston_pointer_move(pointer, event);
 
if (old_sx != pointer->sx || old_sy != pointer->sy) {
-   weston_pointer_send_motion(pointer, time,
-  pointer->sx, pointer->sy);
+   pointer_send_motion(pointer, time,
+   pointer->sx, pointer->sy);
}
 
-   

[PATCH weston 2/6] libweston: Rename weston_surface::configure to ::committed

2016-08-12 Thread Quentin Glidic
From: Quentin Glidic 

Signed-off-by: Quentin Glidic 
Reviewed-by: Jonas Ådahl 
Acked-by: Giulio Camuffo 

Differential Revision: https://phabricator.freedesktop.org/D1246
---
 desktop-shell/input-panel.c | 16 -
 desktop-shell/shell.c   | 72 ++---
 fullscreen-shell/fullscreen-shell.c | 24 ++---
 ivi-shell/input-panel-ivi.c | 16 -
 ivi-shell/ivi-shell.c   | 16 -
 libweston/compositor.c  | 18 +-
 libweston/compositor.h  |  4 +--
 libweston/data-device.c | 22 ++--
 libweston/input.c   | 14 
 tests/weston-test.c | 10 +++---
 xwayland/window-manager.c   |  2 +-
 11 files changed, 107 insertions(+), 107 deletions(-)

diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c
index 2e18e28..58a4cd0 100644
--- a/desktop-shell/input-panel.c
+++ b/desktop-shell/input-panel.c
@@ -166,9 +166,9 @@ input_panel_get_label(struct weston_surface *surface, char 
*buf, size_t len)
 }
 
 static void
-input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
+input_panel_committed(struct weston_surface *surface, int32_t sx, int32_t sy)
 {
-   struct input_panel_surface *ip_surface = surface->configure_private;
+   struct input_panel_surface *ip_surface = surface->committed_private;
struct desktop_shell *shell = ip_surface->shell;
struct weston_view *view;
float x, y;
@@ -201,7 +201,7 @@ destroy_input_panel_surface(struct input_panel_surface 
*input_panel_surface)
wl_list_remove(_panel_surface->surface_destroy_listener.link);
wl_list_remove(_panel_surface->link);
 
-   input_panel_surface->surface->configure = NULL;
+   input_panel_surface->surface->committed = NULL;
weston_surface_set_label_func(input_panel_surface->surface, NULL);
weston_view_destroy(input_panel_surface->view);
 
@@ -211,8 +211,8 @@ destroy_input_panel_surface(struct input_panel_surface 
*input_panel_surface)
 static struct input_panel_surface *
 get_input_panel_surface(struct weston_surface *surface)
 {
-   if (surface->configure == input_panel_configure) {
-   return surface->configure_private;
+   if (surface->committed == input_panel_committed) {
+   return surface->committed_private;
} else {
return NULL;
}
@@ -242,8 +242,8 @@ create_input_panel_surface(struct desktop_shell *shell,
if (!input_panel_surface)
return NULL;
 
-   surface->configure = input_panel_configure;
-   surface->configure_private = input_panel_surface;
+   surface->committed = input_panel_committed;
+   surface->committed_private = input_panel_surface;
weston_surface_set_label_func(surface, input_panel_get_label);
 
input_panel_surface->shell = shell;
@@ -328,7 +328,7 @@ input_panel_get_input_panel_surface(struct wl_client 
*client,
if (!ipsurf) {
wl_resource_post_error(surface_resource,
   WL_DISPLAY_ERROR_INVALID_OBJECT,
-  "surface->configure already set");
+  "surface->committed already set");
return;
}
 
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 64979cd..b6ee729 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -705,15 +705,15 @@ focus_surface_get_label(struct weston_surface *surface, 
char *buf, size_t len)
 
 /* no-op func for checking focus surface */
 static void
-focus_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
+focus_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy)
 {
 }
 
 static struct focus_surface *
 get_focus_surface(struct weston_surface *surface)
 {
-   if (surface->configure == focus_surface_configure)
-   return surface->configure_private;
+   if (surface->committed == focus_surface_committed)
+   return surface->committed_private;
else
return NULL;
 }
@@ -721,7 +721,7 @@ get_focus_surface(struct weston_surface *surface)
 static bool
 is_focus_surface (struct weston_surface *es)
 {
-   return (es->configure == focus_surface_configure);
+   return (es->committed == focus_surface_committed);
 }
 
 static bool
@@ -748,10 +748,10 @@ create_focus_surface(struct weston_compositor *ec,
return NULL;
}
 
-   surface->configure = focus_surface_configure;
+   surface->committed = focus_surface_committed;
surface->output = output;
surface->is_mapped = true;
-   surface->configure_private = fsurf;
+   surface->committed_private = fsurf;
weston_surface_set_label_func(surface, 

Re: [PATCH wayland-protocols v4] Add screensaver idle inhibitor protocol

2016-08-12 Thread Jonas Ådahl
As one probably already noticed, this was pushed earlier and was
included in wayland-protocols 1.6.


Jonas

On Thu, Jul 14, 2016 at 06:35:31PM -0700, Bryce Harrington wrote:
> This interface allows disabling of screensaver/screenblanking on a
> per-surface basis.  As long as the surface remains visible and
> non-occluded it blocks the screensaver, etc. from activating on the
> output(s) that the surface is visible on.
> 
> To uninhibit, simply destroy the inhibitor object.
> 
> Signed-off-by: Bryce Harrington 
> ---
>  Makefile.am|  1 +
>  unstable/idle-inhibit/README   |  4 ++
>  unstable/idle-inhibit/idle-inhibit-unstable-v1.xml | 83 
> ++
>  3 files changed, 88 insertions(+)
>  create mode 100644 unstable/idle-inhibit/README
>  create mode 100644 unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
> 
> diff --git a/Makefile.am b/Makefile.am
> index 71d2632..de691db 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -8,6 +8,7 @@ unstable_protocols =  
> \
>   unstable/relative-pointer/relative-pointer-unstable-v1.xml  
> \
>   unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
> \
>   unstable/tablet/tablet-unstable-v1.xml  
> \
> + unstable/idle-inhibit/idle-inhibit-unstable-v1.xml  
> \
>   $(NULL)
>  
>  stable_protocols =   
> \
> diff --git a/unstable/idle-inhibit/README b/unstable/idle-inhibit/README
> new file mode 100644
> index 000..396e871
> --- /dev/null
> +++ b/unstable/idle-inhibit/README
> @@ -0,0 +1,4 @@
> +Screensaver inhibition protocol
> +
> +Maintainers:
> +Bryce Harrington 
> diff --git a/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml 
> b/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
> new file mode 100644
> index 000..70372fc
> --- /dev/null
> +++ b/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
> @@ -0,0 +1,83 @@
> +
> +
> +
> +  
> +Copyright © 2015 Samsung Electronics Co., Ltd
> +
> +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.
> +  
> +
> +  
> +
> +  This interface permits inhibiting the idle behavior such as screen
> +  blanking, locking, and screensaving.  The client binds the idle manager
> +  globally, then creates idle-inhibitor objects for each surface.
> +
> +  Warning! The protocol described in this file is experimental and
> +  backward incompatible changes may be made. Backward compatible changes
> +  may be added together with the corresponding interface version bump.
> +  Backward incompatible changes are done by bumping the version number in
> +  the protocol and interface names and resetting the interface version.
> +  Once the protocol is to be declared stable, the 'z' prefix and the
> +  version number in the protocol and interface names are removed and the
> +  interface version number is reset.
> +
> +
> +
> +  
> + This destroys the inhibit manager.
> +  
> +
> +
> +
> +  
> + Create a new inhibitor object associated with the given surface.
> +  
> +  
> +   +summary="the surface that inhibits the idle behavior"/>
> +
> +
> +  
> +
> +  
> +
> +  An idle inhibitor prevents the output that the associated surface is
> +  visible on from being set to a state where it is not visually usable 
> due
> +  to lack of user interaction (e.g. blanked, dimmed, locked, set to power
> +  save, etc.)  Any screensaver processes are also blocked from 
> displaying.
> +
> +  If the surface is destroyed, unmapped, becomes occluded, loses
> +  visibility, or 

Re: [PATCH weston v3 6/6] Add API to install protocol loggers on the server wl_display

2016-08-12 Thread Giulio Camuffo
2016-08-12 10:25 GMT+02:00 Pekka Paalanen :
> On Thu, 11 Aug 2016 17:06:02 +0200
> Giulio Camuffo  wrote:
>
>> 2016-08-11 16:39 GMT+02:00 Pekka Paalanen :
>> > On Tue,  9 Aug 2016 12:46:56 +0200
>> > Giulio Camuffo  wrote:
>> >
>> >> The new wl_display_add_protocol_logger allows to set a function as
>> >> a logger, which will get called when a new request is received or an
>> >> event is sent.
>> >> This is akin to setting WAYLAND_DEBUG=1, but more powerful because it
>> >> can be enabled at run time and allows to show the log e.g. in a UI view.
>> >> A test is added for the new functionality.
>> >>
>> >> Signed-off-by: Giulio Camuffo 
>> >> ---
>> >>
>> >> v3: - added missing test file
>> >> - renamed wl_protocol_logger_direction to wl_protocol_logger_type
>> >> - renamed closure_log to log_closure
>> >> - renamed wl_display_remove_protocol_logger to 
>> >> wl_protocol_logger_destroy
>> >> - improved documentation
>> >>
>> >>  Makefile.am  |   5 +-
>> >>  src/wayland-server-core.h|  24 +++
>> >>  src/wayland-server.c | 103 --
>> >>  tests/protocol-logger-test.c | 146 
>> >> +++
>> >>  4 files changed, 271 insertions(+), 7 deletions(-)
>> >>  create mode 100644 tests/protocol-logger-test.c
>> >>
>> >> diff --git a/Makefile.am b/Makefile.am
>> >> index e684a87..3eb6fd5 100644
>> >> --- a/Makefile.am
>> >> +++ b/Makefile.am
>> >> @@ -161,7 +161,8 @@ TESTS =   \
>> >>   resources-test  \
>> >>   message-test\
>> >>   headers-test\
>> >> - compositor-introspection-test
>> >> + compositor-introspection-test   \
>> >> + protocol-logger-test
>> >>
>> >>  if ENABLE_CPP_TEST
>> >>  TESTS += cpp-compile-test
>> >> @@ -220,6 +221,8 @@ message_test_SOURCES = tests/message-test.c
>> >>  message_test_LDADD = libtest-runner.la
>> >>  compositor_introspection_test_SOURCES = 
>> >> tests/compositor-introspection-test.c
>> >>  compositor_introspection_test_LDADD = libtest-runner.la
>> >> +protocol_logger_test_SOURCES = tests/protocol-logger-test.c
>> >> +protocol_logger_test_LDADD = libtest-runner.la
>> >>  headers_test_SOURCES = tests/headers-test.c \
>> >>  tests/headers-protocol-test.c \
>> >>  tests/headers-protocol-core-test.c
>> >> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
>> >> index 56e8d80..8e118dc 100644
>> >> --- a/src/wayland-server-core.h
>> >> +++ b/src/wayland-server-core.h
>> >> @@ -522,6 +522,30 @@ wl_shm_buffer_create(struct wl_client *client,
>> >>  void
>> >>  wl_log_set_handler_server(wl_log_func_t handler);
>> >>
>> >> +enum wl_protocol_logger_type {
>> >> + WL_PROTOCOL_LOGGER_REQUEST,
>> >> + WL_PROTOCOL_LOGGER_EVENT,
>> >> +};
>> >> +
>> >> +struct wl_protocol_logger_message {
>> >> + struct wl_resource *resource;
>> >> + int message_opcode;
>> >> + const struct wl_message *message;
>> >> + int arguments_count;
>> >> + const union wl_argument *arguments;
>> >> +};
>> >> +
>> >> +typedef void (*wl_protocol_logger_func_t)(void *user_data,
>> >> +   enum wl_protocol_logger_type 
>> >> direction,
>> >> +   const struct 
>> >> wl_protocol_logger_message *message);
>> >> +struct wl_protocol_logger;
>> >> +struct wl_protocol_logger *
>> >> +wl_display_add_protocol_logger(struct wl_display *display,
>> >> +wl_protocol_logger_func_t, void *user_data);
>> >
>> > Hi Giulio,
>> >
>> > the API looks ok to me. Just a thought, might there some day be need
>> > for a client-side protocol logger like this one? I'm thinking about
>> > possible symbol name clashes. I suppose we can just add "_client"
>> > somewhere in the names that need a different implementation.
>>
>> Well, we also have two different wl_display, so even if we add a
>> client logger, we just have to make sure we don't mix them.
>
> Hi,
>
> wl_display is an opaque type, so it works.
>
> If we needed a different wl_protocol_logger_destroy() for each side, it
> wouldn't work. And wl_display_add_protocol_logger() must be different
> for each side since wl_display is different.
>
> I'm thinking about exported symbol conflicts between libwayland-server
> and libwayland-client for a program that links to both.

Ah i get it, you're talking about the functions... You're right, but
on the other hand i doubt a client side version will be needed, and if
it will be i think just adding _client is ok, without needing to add
_server to this one.

>
>> >
>> > Btw. have you tested this can properly report also file descriptors?
>> > I think the file descriptor the logger sees is always a dup'd one, 

Re: [PATCH weston v3 6/6] Add API to install protocol loggers on the server wl_display

2016-08-12 Thread Pekka Paalanen
On Thu, 11 Aug 2016 17:06:02 +0200
Giulio Camuffo  wrote:

> 2016-08-11 16:39 GMT+02:00 Pekka Paalanen :
> > On Tue,  9 Aug 2016 12:46:56 +0200
> > Giulio Camuffo  wrote:
> >  
> >> The new wl_display_add_protocol_logger allows to set a function as
> >> a logger, which will get called when a new request is received or an
> >> event is sent.
> >> This is akin to setting WAYLAND_DEBUG=1, but more powerful because it
> >> can be enabled at run time and allows to show the log e.g. in a UI view.
> >> A test is added for the new functionality.
> >>
> >> Signed-off-by: Giulio Camuffo 
> >> ---
> >>
> >> v3: - added missing test file
> >> - renamed wl_protocol_logger_direction to wl_protocol_logger_type
> >> - renamed closure_log to log_closure
> >> - renamed wl_display_remove_protocol_logger to 
> >> wl_protocol_logger_destroy
> >> - improved documentation
> >>
> >>  Makefile.am  |   5 +-
> >>  src/wayland-server-core.h|  24 +++
> >>  src/wayland-server.c | 103 --
> >>  tests/protocol-logger-test.c | 146 
> >> +++
> >>  4 files changed, 271 insertions(+), 7 deletions(-)
> >>  create mode 100644 tests/protocol-logger-test.c
> >>
> >> diff --git a/Makefile.am b/Makefile.am
> >> index e684a87..3eb6fd5 100644
> >> --- a/Makefile.am
> >> +++ b/Makefile.am
> >> @@ -161,7 +161,8 @@ TESTS =   \
> >>   resources-test  \
> >>   message-test\
> >>   headers-test\
> >> - compositor-introspection-test
> >> + compositor-introspection-test   \
> >> + protocol-logger-test
> >>
> >>  if ENABLE_CPP_TEST
> >>  TESTS += cpp-compile-test
> >> @@ -220,6 +221,8 @@ message_test_SOURCES = tests/message-test.c
> >>  message_test_LDADD = libtest-runner.la
> >>  compositor_introspection_test_SOURCES = 
> >> tests/compositor-introspection-test.c
> >>  compositor_introspection_test_LDADD = libtest-runner.la
> >> +protocol_logger_test_SOURCES = tests/protocol-logger-test.c
> >> +protocol_logger_test_LDADD = libtest-runner.la
> >>  headers_test_SOURCES = tests/headers-test.c \
> >>  tests/headers-protocol-test.c \
> >>  tests/headers-protocol-core-test.c
> >> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
> >> index 56e8d80..8e118dc 100644
> >> --- a/src/wayland-server-core.h
> >> +++ b/src/wayland-server-core.h
> >> @@ -522,6 +522,30 @@ wl_shm_buffer_create(struct wl_client *client,
> >>  void
> >>  wl_log_set_handler_server(wl_log_func_t handler);
> >>
> >> +enum wl_protocol_logger_type {
> >> + WL_PROTOCOL_LOGGER_REQUEST,
> >> + WL_PROTOCOL_LOGGER_EVENT,
> >> +};
> >> +
> >> +struct wl_protocol_logger_message {
> >> + struct wl_resource *resource;
> >> + int message_opcode;
> >> + const struct wl_message *message;
> >> + int arguments_count;
> >> + const union wl_argument *arguments;
> >> +};
> >> +
> >> +typedef void (*wl_protocol_logger_func_t)(void *user_data,
> >> +   enum wl_protocol_logger_type 
> >> direction,
> >> +   const struct 
> >> wl_protocol_logger_message *message);
> >> +struct wl_protocol_logger;
> >> +struct wl_protocol_logger *
> >> +wl_display_add_protocol_logger(struct wl_display *display,
> >> +wl_protocol_logger_func_t, void *user_data);  
> >
> > Hi Giulio,
> >
> > the API looks ok to me. Just a thought, might there some day be need
> > for a client-side protocol logger like this one? I'm thinking about
> > possible symbol name clashes. I suppose we can just add "_client"
> > somewhere in the names that need a different implementation.  
> 
> Well, we also have two different wl_display, so even if we add a
> client logger, we just have to make sure we don't mix them.

Hi,

wl_display is an opaque type, so it works.

If we needed a different wl_protocol_logger_destroy() for each side, it
wouldn't work. And wl_display_add_protocol_logger() must be different
for each side since wl_display is different.

I'm thinking about exported symbol conflicts between libwayland-server
and libwayland-client for a program that links to both.

> >
> > Btw. have you tested this can properly report also file descriptors?
> > I think the file descriptor the logger sees is always a dup'd one, so
> > just looking at the value wouldn't tell much, you need to ask the
> > kernel what it points to.  
> 
> I'm not sure what you're saying. The logger reports the fd value, then
> the user can check what it is, or just report the value just like
> WAYLAND_DEBUG does.

File descriptors are passed on a side-channel, not in the normal data
flow of a unix socket. I wasn't quite sure if the closure makes that

Re: [PATCH weston 0/6] Switch client to xdg_shell unstable v6

2016-08-12 Thread Pekka Paalanen
On Thu, 11 Aug 2016 21:40:14 -0700
Bryce Harrington  wrote:

> On Fri, Aug 12, 2016 at 11:40:00AM +0800, Jonas Ådahl wrote:
> > Hi,
> > 
> > With a xdg_shell unstable v6 release around the corner, and a 
> > libweston-desktop
> > about to land with a xdg_shell unstable v6 implementation available, I think
> > now is a good time to switch weston to use the new version, moving us one 
> > step
> > closer to a stable desktop shell protocol.
> > 
> > Assuming these patches can be reviewed in time, I'd will land these prior to
> > the alpha scheduled to be released on Tuesday. If anyone have any 
> > objections,
> > please raise them now.
> > 
> > The porting itself is pretty straight forward. Apart from renaming things 
> > and
> > creating both a zxdg_surface_v6 and a zxdg_toplevel_v6 for every toplevel
> > surface, there is also the 'perfect first frame' semantics adaptation 
> > meaning
> > clients need to wait for the first zxdg_surface_v6.configure event before
> > attaching its first buffer.
> > 
> > 
> > Jonas  
> 
> I haven't reviewed the individual patches, but in principle am ok seeing
> these landed by alpha, so:
> 
> Acked-by: Bryce Harrington 

Yup, agreed, provided the v6 implementation actually lands first, and a
wayland-protocols release with the v6 is done first also, then:
Acked-by: Pekka Paalanen 


Thanks,
pq

> > Jonas Ådahl (6):
> >   toytoolkit: Port to xdg_shell unstable v6
> >   clients/simple-egl: Port to xdg_shell unstable v6
> >   clients/simple-shm: Port to xdg_shell unstable v6
> >   clients/simple-damage: Port to xdg_shell unstable v6
> >   clients/simple-dmabuf-intel: Port to xdg_shell unstable v6
> >   clients/simple-dmabuf-v4l: Port to xdg_shell unstable v6
> > 
> >  Makefile.am   |  32 ++---
> >  clients/simple-damage.c   |  92 ++-
> >  clients/simple-dmabuf-intel.c |  94 ++-
> >  clients/simple-dmabuf-v4l.c   |  96 ++-
> >  clients/simple-egl.c  | 106 ++---
> >  clients/simple-shm.c  |  93 +--
> >  clients/window.c  | 268 
> > --
> >  7 files changed, 504 insertions(+), 277 deletions(-)
> > 
> > -- 
> > 2.7.4
> > 
> > ___
> > wayland-devel mailing list
> > wayland-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel  
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel



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


Re: [PATCH weston 2/7] weston-egl-ext.h: remove EGL_EGLEXT_PROTOTYPES sections

2016-08-12 Thread Pekka Paalanen
On Mon,  4 Jul 2016 15:27:14 +0100
Emil Velikov  wrote:

> From: Emil Velikov 
> 
> Those the function declarations alongside the EGL_EGLEXT_PROTOTYPES
> guards. Although those are copy/paste sections from the header(s),
> having and/or using them is a bad idea, as per the EGL spec.
> 
> Signed-off-by: Emil Velikov 
> ---
> If people like them one could keep them I, but considering they are not
> used (and they shouldn't be used) it's better to remove them.
> ---
>  libweston/weston-egl-ext.h | 10 --
>  1 file changed, 10 deletions(-)

Hi Emil,

it seems pretty hard to make a mind on this change. Daniel is leaning
on kinda maybe not and I was leaning on kinda maybe yes. The policy of
being a copy vs. not having stuff we don't use.

I'll choose to solve this on the "copy" side. We copy whole extension
blocks into this file regardless whether all the bits are actually used
or not, particularly all the #defines. To follow that logic, let's drop
this patch.


Thanks,
pq

> 
> diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
> index 32f6108..e1754f5 100644
> --- a/libweston/weston-egl-ext.h
> +++ b/libweston/weston-egl-ext.h
> @@ -33,10 +33,6 @@
>  
>  struct wl_display;
>  
> -#ifdef EGL_EGLEXT_PROTOTYPES
> -EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL(EGLDisplay dpy, struct 
> wl_display *display);
> -EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL(EGLDisplay dpy, 
> struct wl_display *display);
> -#endif
>  typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay 
> dpy, struct wl_display *display);
>  typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay 
> dpy, struct wl_display *display);
>  #endif
> @@ -63,18 +59,12 @@ typedef EGLBoolean (EGLAPIENTRYP 
> PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy,
>  #define EGL_TEXTURE_EXTERNAL_WL 0x31DA
>  
>  struct wl_resource;
> -#ifdef EGL_EGLEXT_PROTOTYPES
> -EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL(EGLDisplay dpy, struct 
> wl_resource *buffer, EGLint attribute, EGLint *value);
> -#endif
>  typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay 
> dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value);
>  #endif
>  
>  #ifndef EGL_WL_create_wayland_buffer_from_image
>  #define EGL_WL_create_wayland_buffer_from_image 1
>  
> -#ifdef EGL_EGLEXT_PROTOTYPES
> -EGLAPI struct wl_buffer * EGLAPIENTRY 
> eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImageKHR image);
> -#endif
>  typedef struct wl_buffer * (EGLAPIENTRYP 
> PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (EGLDisplay dpy, EGLImageKHR image);
>  #endif
>  



pgpM22zO8WFNh.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 v5] Add API to install protocol loggers on the server wl_display

2016-08-12 Thread Giulio Camuffo
Ah sorry, i forgot to add Yong's R-b.

2016-08-12 9:33 GMT+02:00 Giulio Camuffo :
> The new wl_display_add_protocol_logger allows to set a function as
> a logger, which will get called when a new request is received or an
> event is sent.
> This is akin to setting WAYLAND_DEBUG=1, but more powerful because it
> can be enabled at run time and allows to show the log e.g. in a UI view.
> A test is added for the new functionality.
>
> Signed-off-by: Giulio Camuffo 
> Reviewed-by: Jonas Ådahl 
> ---
>
> v5: fixed documentation
>
>  Makefile.am  |   5 +-
>  src/wayland-server-core.h|  24 +++
>  src/wayland-server.c | 102 +++--
>  tests/protocol-logger-test.c | 148 
> +++
>  4 files changed, 272 insertions(+), 7 deletions(-)
>  create mode 100644 tests/protocol-logger-test.c
>
> diff --git a/Makefile.am b/Makefile.am
> index e684a87..3eb6fd5 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -161,7 +161,8 @@ TESTS = \
> resources-test  \
> message-test\
> headers-test\
> -   compositor-introspection-test
> +   compositor-introspection-test   \
> +   protocol-logger-test
>
>  if ENABLE_CPP_TEST
>  TESTS += cpp-compile-test
> @@ -220,6 +221,8 @@ message_test_SOURCES = tests/message-test.c
>  message_test_LDADD = libtest-runner.la
>  compositor_introspection_test_SOURCES = tests/compositor-introspection-test.c
>  compositor_introspection_test_LDADD = libtest-runner.la
> +protocol_logger_test_SOURCES = tests/protocol-logger-test.c
> +protocol_logger_test_LDADD = libtest-runner.la
>  headers_test_SOURCES = tests/headers-test.c \
>tests/headers-protocol-test.c \
>tests/headers-protocol-core-test.c
> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
> index 56e8d80..21465af 100644
> --- a/src/wayland-server-core.h
> +++ b/src/wayland-server-core.h
> @@ -522,6 +522,30 @@ wl_shm_buffer_create(struct wl_client *client,
>  void
>  wl_log_set_handler_server(wl_log_func_t handler);
>
> +enum wl_protocol_logger_type {
> +   WL_PROTOCOL_LOGGER_REQUEST,
> +   WL_PROTOCOL_LOGGER_EVENT,
> +};
> +
> +struct wl_protocol_logger_message {
> +   struct wl_resource *resource;
> +   int message_opcode;
> +   const struct wl_message *message;
> +   int arguments_count;
> +   const union wl_argument *arguments;
> +};
> +
> +typedef void (*wl_protocol_logger_func_t)(void *user_data,
> + enum wl_protocol_logger_type 
> direction,
> + const struct 
> wl_protocol_logger_message *message);
> +
> +struct wl_protocol_logger *
> +wl_display_add_protocol_logger(struct wl_display *display,
> +  wl_protocol_logger_func_t, void *user_data);
> +
> +void
> +wl_protocol_logger_destroy(struct wl_protocol_logger *logger);
> +
>  #ifdef  __cplusplus
>  }
>  #endif
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index c53a2f4..965d348 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -95,6 +95,7 @@ struct wl_display {
> struct wl_list global_list;
> struct wl_list socket_list;
> struct wl_list client_list;
> +   struct wl_list protocol_loggers;
>
> struct wl_signal destroy_signal;
> struct wl_signal create_client_signal;
> @@ -123,8 +124,42 @@ struct wl_resource {
> wl_dispatcher_func_t dispatcher;
>  };
>
> +struct wl_protocol_logger {
> +   struct wl_list link;
> +   wl_protocol_logger_func_t func;
> +   void *user_data;
> +};
> +
>  static int debug_server = 0;
>
> +static void
> +log_closure(struct wl_resource *resource,
> +   struct wl_closure *closure, int send)
> +{
> +   struct wl_object *object = >object;
> +   struct wl_display *display = resource->client->display;
> +   struct wl_protocol_logger *protocol_logger;
> +   struct wl_protocol_logger_message message;
> +
> +   if (debug_server)
> +   wl_closure_print(closure, object, send);
> +
> +   if (!wl_list_empty(>protocol_loggers)) {
> +   message.resource = resource;
> +   message.message_opcode = closure->opcode;
> +   message.message = closure->message;
> +   message.arguments_count = closure->count;
> +   message.arguments = closure->args;
> +   wl_list_for_each(protocol_logger,
> +>protocol_loggers, link) {
> +   protocol_logger->func(protocol_logger->user_data,
> + send ? WL_PROTOCOL_LOGGER_EVENT 
> :
> +
> 

[PATCH wayland v5] Add API to install protocol loggers on the server wl_display

2016-08-12 Thread Giulio Camuffo
The new wl_display_add_protocol_logger allows to set a function as
a logger, which will get called when a new request is received or an
event is sent.
This is akin to setting WAYLAND_DEBUG=1, but more powerful because it
can be enabled at run time and allows to show the log e.g. in a UI view.
A test is added for the new functionality.

Signed-off-by: Giulio Camuffo 
Reviewed-by: Jonas Ådahl 
---

v5: fixed documentation

 Makefile.am  |   5 +-
 src/wayland-server-core.h|  24 +++
 src/wayland-server.c | 102 +++--
 tests/protocol-logger-test.c | 148 +++
 4 files changed, 272 insertions(+), 7 deletions(-)
 create mode 100644 tests/protocol-logger-test.c

diff --git a/Makefile.am b/Makefile.am
index e684a87..3eb6fd5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -161,7 +161,8 @@ TESTS = \
resources-test  \
message-test\
headers-test\
-   compositor-introspection-test
+   compositor-introspection-test   \
+   protocol-logger-test
 
 if ENABLE_CPP_TEST
 TESTS += cpp-compile-test
@@ -220,6 +221,8 @@ message_test_SOURCES = tests/message-test.c
 message_test_LDADD = libtest-runner.la
 compositor_introspection_test_SOURCES = tests/compositor-introspection-test.c
 compositor_introspection_test_LDADD = libtest-runner.la
+protocol_logger_test_SOURCES = tests/protocol-logger-test.c
+protocol_logger_test_LDADD = libtest-runner.la
 headers_test_SOURCES = tests/headers-test.c \
   tests/headers-protocol-test.c \
   tests/headers-protocol-core-test.c
diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
index 56e8d80..21465af 100644
--- a/src/wayland-server-core.h
+++ b/src/wayland-server-core.h
@@ -522,6 +522,30 @@ wl_shm_buffer_create(struct wl_client *client,
 void
 wl_log_set_handler_server(wl_log_func_t handler);
 
+enum wl_protocol_logger_type {
+   WL_PROTOCOL_LOGGER_REQUEST,
+   WL_PROTOCOL_LOGGER_EVENT,
+};
+
+struct wl_protocol_logger_message {
+   struct wl_resource *resource;
+   int message_opcode;
+   const struct wl_message *message;
+   int arguments_count;
+   const union wl_argument *arguments;
+};
+
+typedef void (*wl_protocol_logger_func_t)(void *user_data,
+ enum wl_protocol_logger_type 
direction,
+ const struct 
wl_protocol_logger_message *message);
+
+struct wl_protocol_logger *
+wl_display_add_protocol_logger(struct wl_display *display,
+  wl_protocol_logger_func_t, void *user_data);
+
+void
+wl_protocol_logger_destroy(struct wl_protocol_logger *logger);
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/src/wayland-server.c b/src/wayland-server.c
index c53a2f4..965d348 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -95,6 +95,7 @@ struct wl_display {
struct wl_list global_list;
struct wl_list socket_list;
struct wl_list client_list;
+   struct wl_list protocol_loggers;
 
struct wl_signal destroy_signal;
struct wl_signal create_client_signal;
@@ -123,8 +124,42 @@ struct wl_resource {
wl_dispatcher_func_t dispatcher;
 };
 
+struct wl_protocol_logger {
+   struct wl_list link;
+   wl_protocol_logger_func_t func;
+   void *user_data;
+};
+
 static int debug_server = 0;
 
+static void
+log_closure(struct wl_resource *resource,
+   struct wl_closure *closure, int send)
+{
+   struct wl_object *object = >object;
+   struct wl_display *display = resource->client->display;
+   struct wl_protocol_logger *protocol_logger;
+   struct wl_protocol_logger_message message;
+
+   if (debug_server)
+   wl_closure_print(closure, object, send);
+
+   if (!wl_list_empty(>protocol_loggers)) {
+   message.resource = resource;
+   message.message_opcode = closure->opcode;
+   message.message = closure->message;
+   message.arguments_count = closure->count;
+   message.arguments = closure->args;
+   wl_list_for_each(protocol_logger,
+>protocol_loggers, link) {
+   protocol_logger->func(protocol_logger->user_data,
+ send ? WL_PROTOCOL_LOGGER_EVENT :
+WL_PROTOCOL_LOGGER_REQUEST,
+ );
+   }
+   }
+}
+
 WL_EXPORT void
 wl_resource_post_event_array(struct wl_resource *resource, uint32_t opcode,
 union wl_argument *args)
@@ -143,8 +178,7 @@ wl_resource_post_event_array(struct wl_resource *resource, 
uint32_t opcode,
   

Re: [PATCH wayland v4 3/3] Add API to install protocol loggers on the server wl_display

2016-08-12 Thread Giulio Camuffo
2016-08-12 3:33 GMT+02:00 Jonas Ådahl :
> On Thu, Aug 11, 2016 at 05:23:11PM +0200, Giulio Camuffo wrote:
>> The new wl_display_add_protocol_logger allows to set a function as
>> a logger, which will get called when a new request is received or an
>> event is sent.
>> This is akin to setting WAYLAND_DEBUG=1, but more powerful because it
>> can be enabled at run time and allows to show the log e.g. in a UI view.
>> A test is added for the new functionality.
>>
>> Signed-off-by: Giulio Camuffo 
>
> With one documentation nit below, this is
>
> Reviewed-by: Jonas Ådahl 
>
>> ---
>>
>> v4: - set a timeout of 1s for the test
>> - don't init the logger's list link
>> - remove unneeded forward declaration
>>
>>  Makefile.am  |   5 +-
>>  src/wayland-server-core.h|  24 +++
>>  src/wayland-server.c | 103 --
>>  tests/protocol-logger-test.c | 146 
>> +++
>>  4 files changed, 271 insertions(+), 7 deletions(-)
>>  create mode 100644 tests/protocol-logger-test.c
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index e684a87..3eb6fd5 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -161,7 +161,8 @@ TESTS =   \
>>   resources-test  \
>>   message-test\
>>   headers-test\
>> - compositor-introspection-test
>> + compositor-introspection-test   \
>> + protocol-logger-test
>>
>>  if ENABLE_CPP_TEST
>>  TESTS += cpp-compile-test
>> @@ -220,6 +221,8 @@ message_test_SOURCES = tests/message-test.c
>>  message_test_LDADD = libtest-runner.la
>>  compositor_introspection_test_SOURCES = 
>> tests/compositor-introspection-test.c
>>  compositor_introspection_test_LDADD = libtest-runner.la
>> +protocol_logger_test_SOURCES = tests/protocol-logger-test.c
>> +protocol_logger_test_LDADD = libtest-runner.la
>>  headers_test_SOURCES = tests/headers-test.c \
>>  tests/headers-protocol-test.c \
>>  tests/headers-protocol-core-test.c
>> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
>> index 56e8d80..8e118dc 100644
>> --- a/src/wayland-server-core.h
>> +++ b/src/wayland-server-core.h
>> @@ -522,6 +522,30 @@ wl_shm_buffer_create(struct wl_client *client,
>>  void
>>  wl_log_set_handler_server(wl_log_func_t handler);
>>
>> +enum wl_protocol_logger_type {
>> + WL_PROTOCOL_LOGGER_REQUEST,
>> + WL_PROTOCOL_LOGGER_EVENT,
>> +};
>> +
>> +struct wl_protocol_logger_message {
>> + struct wl_resource *resource;
>> + int message_opcode;
>> + const struct wl_message *message;
>> + int arguments_count;
>> + const union wl_argument *arguments;
>> +};
>> +
>> +typedef void (*wl_protocol_logger_func_t)(void *user_data,
>> +   enum wl_protocol_logger_type 
>> direction,
>> +   const struct 
>> wl_protocol_logger_message *message);
>> +struct wl_protocol_logger;
>> +struct wl_protocol_logger *
>> +wl_display_add_protocol_logger(struct wl_display *display,
>> +wl_protocol_logger_func_t, void *user_data);
>> +
>> +void
>> +wl_protocol_logger_destroy(struct wl_protocol_logger *logger);
>> +
>>  #ifdef  __cplusplus
>>  }
>>  #endif
>> diff --git a/src/wayland-server.c b/src/wayland-server.c
>> index c53a2f4..fdabd2d 100644
>> --- a/src/wayland-server.c
>> +++ b/src/wayland-server.c
>> @@ -95,6 +95,7 @@ struct wl_display {
>>   struct wl_list global_list;
>>   struct wl_list socket_list;
>>   struct wl_list client_list;
>> + struct wl_list protocol_loggers;
>>
>>   struct wl_signal destroy_signal;
>>   struct wl_signal create_client_signal;
>> @@ -123,8 +124,42 @@ struct wl_resource {
>>   wl_dispatcher_func_t dispatcher;
>>  };
>>
>> +struct wl_protocol_logger {
>> + struct wl_list link;
>> + wl_protocol_logger_func_t func;
>> + void *user_data;
>> +};
>> +
>>  static int debug_server = 0;
>>
>> +static void
>> +log_closure(struct wl_resource *resource,
>> + struct wl_closure *closure, int send)
>> +{
>> + struct wl_object *object = >object;
>> + struct wl_display *display = resource->client->display;
>> + struct wl_protocol_logger *protocol_logger;
>> + struct wl_protocol_logger_message message;
>> +
>> + if (debug_server)
>> + wl_closure_print(closure, object, send);
>> +
>> + if (!wl_list_empty(>protocol_loggers)) {
>> + message.resource = resource;
>> + message.message_opcode = closure->opcode;
>> + message.message = closure->message;
>> + message.arguments_count = closure->count;
>> + message.arguments = closure->args;
>> + wl_list_for_each(protocol_logger,
>> +  

RDP client fails to connect

2016-08-12 Thread John Obaterspok
Hi,

I'm using Fedora 25 with Weston 1.10 and freerdp 2.0.0 git b02943a
I get "unable to checkDescriptor"  once I connect with Windows 7/10 client.
I also tried to put selinux in Permissive mode (setenforce 0)

Any ideas why?

$ winpr-makecert -rdp server
$ weston --backend=rdp-backend.so --rdp-tls-cert=server.crt
--rdp-tls-key=server.key
Date: 2016-08-12 CEST
[08:52:06.947] weston 1.10.0
   http://wayland.freedesktop.org
   Bug reports to:
https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland=weston=1.10.0
   Build: 1.9.93-2-gd45de28 configure.ac: bump to version
1.10.0 for the official release (2016-02-16 12:37:43 -0800)
[08:52:06.947] OS: Linux, 4.6.5-300.fc24.x86_64, #1 SMP Thu Jul 28 01:10:12
UTC 2016, x86_64
[08:52:06.949] Starting with no config file.
[08:52:06.949] Output repaint window is 7 ms maximum.
[08:52:06.949] Loading module '/usr/lib64/weston/rdp-backend.so'
[08:52:06.982] using FreeRDP version 2.0.0
[08:52:06.982] TLS support activated
[08:52:06:512] [3902:3902] [INFO][com.freerdp.core.listener] - Listening on
0.0.0.0:3389
[08:52:06.987] Compositor capabilities:
   arbitrary surface rotation: yes
   screen capture uses y-flip: yes
   presentation clock: CLOCK_MONOTONIC_RAW, id 4
[08:52:06.989] Loading module '/usr/lib64/weston/desktop-shell.so'
[08:52:06.989] launching '/usr/libexec/weston-keyboard'
[08:52:06.990] launching '/usr/libexec/weston-desktop-shell'
[08:52:11:143] [3902:3902] [INFO][com.freerdp.core.connection] - Client
Security: NLA:1 TLS:1 RDP:0
[08:52:11:143] [3902:3902] [INFO][com.freerdp.core.connection] - Server
Security: NLA:0 TLS:1 RDP:1
[08:52:11:144] [3902:3902] [INFO][com.freerdp.core.connection] - Negotiated
Security: NLA:0 TLS:1 RDP:0
[08:52:11.667] unable to checkDescriptor for 0x55d92931cda0
[08:52:13:610] [3902:3902] [INFO][com.freerdp.core.connection] - Client
Security: NLA:1 TLS:1 RDP:0
[08:52:13:610] [3902:3902] [INFO][com.freerdp.core.connection] - Server
Security: NLA:0 TLS:1 RDP:1
[08:52:13:610] [3902:3902] [INFO][com.freerdp.core.connection] - Negotiated
Security: NLA:0 TLS:1 RDP:0
[08:52:13:632] [3902:3902] [INFO][com.freerdp.core.connection] - Accepted
client: DESKTOP-OL92SEC
[08:52:13:632] [3902:3902] [INFO][com.freerdp.core.connection] - Accepted
channels:
[08:52:13:632] [3902:3902] [INFO][com.freerdp.core.connection] -  rdpdr
[08:52:13:632] [3902:3902] [INFO][com.freerdp.core.connection] -  rdpsnd
[08:52:13:632] [3902:3902] [INFO][com.freerdp.core.connection] -  cliprdr
[08:52:13:632] [3902:3902] [INFO][com.freerdp.core.connection] -  drdynvc
[08:52:13:632] [3902:3902] [INFO][com.freerdp.core.gcc] - Active rdp
encryption level: NONE
[08:52:13:632] [3902:3902] [INFO][com.freerdp.core.gcc] - Selected rdp
encryption method: NONE
[08:52:13.194] kbd_layout:0x41d kbd_type:0x4 kbd_subType:0x0
kbd_functionKeys:0xc
[08:52:13.194] xf_peer_activate: matching layout=se variant=(null)
[08:52:13.305] unable to checkDescriptor for 0x55d9293cb2d0
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH 1/3 v3] wayland-server: Add API to control globals visibility

2016-08-12 Thread Olivier Fourdan
Hi Yong,

Thanks for your follow-up.

I don;t necessarily agree with your all of comments though, see below.

> > @@ -164,6 +165,15 @@ wl_global_create(struct wl_display *display,
> > void
> > wl_global_destroy(struct wl_global *global);
> > 
> > +typedef bool (*wl_display_filter_global_func_t)(const struct wl_client
> > *client,
> 
> After reading this patch a few times, and writing some sample use cases,
> I really think this type should be named wl_display_global_filter_func_t,
> meaning "this is a global filter function."

Err, nope, I disagree, it's not what is meant, precisely.

Using something like "global_filter" makes it sound like "global" is an 
adjective for the filter, i.e. the filter is global, which is not the meaning 
of global here, global here is a noun for "wl_global" (but 
"wl_display_filter_wl_global_func_t" would sound awkward).

I intentionally named it "filter_global" to avoid that confusion.

> Second, perhaps a short comment is necessary here, before the typedef, that
> states something like:
> 
> "A filter function enables the server to decide which globals to
> advertise to clients. This function should return true if..."

Yeap, I agree.

> > +   const struct wl_global *global,
> > +   void *data);
> > +
> > +void
> > +wl_display_set_filter_global(struct wl_display *display,
> 
> This should be set_global_filter, matching the name of the struct member...

Nope, for the same reasons as above.

> > +wl_display_filter_global_func_t filter,
> > +void *data);
> > +
> > struct wl_client *
> > wl_client_create(struct wl_display *display, int fd);
> > 
> > diff --git a/src/wayland-server.c b/src/wayland-server.c
> > index 19aa2e8..480af23 100644
> > --- a/src/wayland-server.c
> > +++ b/src/wayland-server.c
> > @@ -98,6 +98,9 @@ struct wl_display {
> > struct wl_signal destroy_signal;
> > 
> > struct wl_array additional_shm_formats;
> > +
> > +   wl_display_filter_global_func_t global_filter;
> 
> ... Here, where again the type is better described as
> wl_display_global_filter_func_t.

Nope, for the same reasons as above.

> > +   void *global_filter_data;
> > };
> > 
> > struct wl_global {
> > @@ -714,6 +717,16 @@ wl_client_destroy(struct wl_client *client)
> > free(client);
> > }
> > 
> 
> I would add a short comment here for the filter_global function,
> that at least explains when it returns true. /Better yet/, if you
> named this function, say, `is_visible`, `is_advertised`, `is_listed`,
> or perhaps even
> 
> wl_global_is_visible(const struct wl_global *global,
>   const struct wl_client *client)
> 
> Then its usage within registry_bind and display_get_registry
> becomes very clear.

Yeap, makes sense, agreed.
 
> > +static bool
> > +filter_global(const struct wl_client *client,
> > + const struct wl_global *global)
> > +{
> > +   struct wl_display *display = client->display;
> > +
> > +   return (display->global_filter == NULL ||
> > +   display->global_filter(client, global, 
> > display->global_filter_data));
> > +}
> > +
> > static void
> > registry_bind(struct wl_client *client,
> >   struct wl_resource *resource, uint32_t name,
> > @@ -740,6 +753,10 @@ registry_bind(struct wl_client *client,
> >WL_DISPLAY_ERROR_INVALID_OBJECT,
> >"invalid version for global %s (%d): 
> > have %d, wanted %d",
> >interface, name, global->version, 
> > version);
> > +   else if (!filter_global(client, global))
> > +   wl_resource_post_error(resource,
> > +  WL_DISPLAY_ERROR_INVALID_OBJECT,
> > +  "invalid global %s (%d)", interface, 
> > name);
> > else
> > global->bind(client, global->data, version, id);
> > }
> > @@ -795,11 +812,12 @@ display_get_registry(struct wl_client *client,
> >_resource->link);
> > 
> > wl_list_for_each(global, >global_list, link)
> > -   wl_resource_post_event(registry_resource,
> > -  WL_REGISTRY_GLOBAL,
> > -  global->name,
> > -  global->interface->name,
> > -  global->version);
> > +   if (filter_global(client, global))
> > +   wl_resource_post_event(registry_resource,
> > +  WL_REGISTRY_GLOBAL,
> > +  global->name,
> > +  global->interface->name,
> > +  global->version);
> > }
> > 
> > static const struct wl_display_interface display_interface = {
> > @@ -868,6 +886,9 @@ wl_display_create(void)
> > display->id = 1;
> > display->serial = 0;
> >