Re: Automatically choosing a VT for DRM compositor?

2017-10-24 Thread Armin Krezović
GDM seems to use VT_OPENQRY .

https://git.gnome.org/browse/gdm/tree/daemon/gdm-session-worker.c#n2209

(Sent from gmail web interface)

On Tue, Oct 24, 2017 at 8:33 AM, Pekka Paalanen  wrote:

> On Mon, 23 Oct 2017 14:37:37 -0500
> Matt Hoosier  wrote:
>
> > It would be nice for non-session uses of Weston (embedded systems) if
> > the controlling TTY didn't need to be manually supplied.
> >
> > Has anybody suggested using something like VT_OPENQRY in the
> > weston-launcher code to pick a TTY if one wasn't manually given? (Or
> > if that's too auto-magic for taste here, then only do that if a
> > specific command-line option is supplied.)
>
> Hi,
>
> I do not recall such proposals. I'd like to hear more about your use
> case.
>
> Do you mean in 'weston-launch' specifically, or in all the launcher
> implementations?
>
> If for 'weston-launch' specifically, then I'd like to ask why you want
> that instead of a logind service?
>
> I've been hoping there would be no need for new development on
> weston-launch. It is sensitive code, being setuid root. It seems it
> cannot be nicely generalized to support all libweston-based compositors.
>
> What is the launching context in you use case? E.g.
> - manual login, type 'weston' in VT
> - type 'weston -Bdrm-backend.so' in a terminal window
> - launching weston from a systemd system unit
> - launching weston from a systemd user unit
> - something else?
>
> What is the "non-session" use exactly? Why do you not care which VT
> weston will occupy in that case?
>
> I haven't checked recently, but I have a feeling that Weston is not
> expecting to be spawned on a currently inactive VT, so that might need
> fixing as well.
>
> >
> > The closest I can find to a question about this topic prior on the
> > mailing list is
> > https://lists.freedesktop.org/archives/wayland-devel/2013-
> October/011472.html.
> > That change was never adopted, but it doesn't look like the use of
> > VT_OPENQRY has anything to do with Kristian's objections at the time.
>
> Picking the first free VT sounds fine to me, but do display servers
> actually do that on their own or does e.g. the graphical login manager
> do it for them? Or rather, when and who usually picks the VT?
>
>
> Thanks,
> pq
>
> ___
> 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] compositor-wayland: Use correct damage coordinates for pixman backend

2017-10-23 Thread Armin Krezović
Damage coordinates are in global coordinate space, and they need to
be translated to local coordinate space so multiple outputs can work.
---
 libweston/compositor-wayland.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 1f77385b..e9054221 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -556,11 +556,15 @@ wayland_shm_buffer_attach(struct wayland_shm_buffer *sb)
int i, n;
 
pixman_region32_init(&damage);
+   pixman_region32_copy(&damage, &sb->damage);
+   pixman_region32_translate(&damage, -sb->output->base.x,
+ -sb->output->base.y);
+
weston_transformed_region(sb->output->base.width,
  sb->output->base.height,
  sb->output->base.transform,
  sb->output->base.current_scale,
- &sb->damage, &damage);
+ &damage, &damage);
 
if (sb->output->frame) {
frame_interior(sb->output->frame, &ix, &iy, &iwidth, &iheight);
-- 
2.14.2

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


Re: Contact for freenode #wayland adminstration questions?

2017-10-23 Thread Armin Krezović
On Mon, 2017-10-23 at 08:46 -0500, Matt Hoosier wrote:
> I'm having some trouble joining the Wayland channel on Freenode. Is
> there a specific person to contact about that?
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel

To join #wayland channel, you need to have your nick registered and
identified to the services. See https://freenode.net/kb/answer/registra
tion

signature.asc
Description: This is a digitally signed message part
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] libweston: Support autodetection of the current XDG_SEAT

2017-08-15 Thread Armin Krezović
On 15.08.2017 04:02, nerdopolis wrote:

Hi,

> ---
>   libweston/compositor-drm.c   | 5 +
>   libweston/compositor-fbdev.c | 5 +
>   2 files changed, 10 insertions(+)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 10adb463..44b2e448 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -3502,8 +3502,13 @@ drm_backend_create(struct weston_compositor 
> *compositor,
>   struct udev_device *drm_device;
>   struct wl_event_loop *loop;
>   const char *seat_id = default_seat;
> + const char *session_seat;
>   int ret;
>   
> + session_seat=getenv("XDG_SEAT");
> + if (session_seat)
> + seat_id=session_seat;
> +

seat_id can already be overriden, using --seat=whatever weston option, as seen 
here:

https://cgit.freedesktop.org/wayland/weston/tree/compositor/main.c#n1224
https://cgit.freedesktop.org/wayland/weston/tree/libweston/compositor-drm.c#n3549

Not sure if there's same thing for fbdev backend, but even if there's not, it 
should
be implemented the same way.

>   weston_log("initializing drm backend\n");
>   
>   b = zalloc(sizeof *b);
> diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
> index e80a5040..81e5ec3b 100644
> --- a/libweston/compositor-fbdev.c
> +++ b/libweston/compositor-fbdev.c
> @@ -712,6 +712,11 @@ fbdev_backend_create(struct weston_compositor 
> *compositor,
>   {
>   struct fbdev_backend *backend;
>   const char *seat_id = default_seat;
> + const char *session_seat;
> +
> + session_seat=getenv("XDG_SEAT");
> + if (session_seat)
> + seat_id=session_seat;
>   
>   weston_log("initializing fbdev backend\n");
>   
> 

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


Re: [PATCH weston] compositor-fbdev: fix start-up assertion

2017-08-15 Thread Armin Krezović
On 15.08.2017 09:43, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Fixes the failure to start with fbdev-backend:
> 
> weston: /home/pq/git/weston/libweston/compositor.c:4733: 
> weston_compositor_add_pending_output: Assertion `output->disable' failed.
> 
> The disable hook was completely unimplemented, and the regression was
> caused by e952a01c3b42c7c870091e71488e9469bd897153
> "libweston: move asserts to add_pending_output()".
> It used to work because Weston never tried to explicitly disable the
> fbdev output, but now it is hitting the assert.
> 
> Fix it by tentatively implementing a disable hook. It has not been
> tested to work for explicit disabling, but it does solve the regression.
> 
> Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=102208
> Cc: bluescreen_aven...@verizon.net
> Signed-off-by: Pekka Paalanen 

Hi,

Looks reasonable:

Reviewed-by: Armin Krezović 

Cheers.

> ---
>   libweston/compositor-fbdev.c | 23 +--
>   1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
> index e80a5040..6a305385 100644
> --- a/libweston/compositor-fbdev.c
> +++ b/libweston/compositor-fbdev.c
> @@ -473,6 +473,21 @@ out_hw_surface:
>   }
>   
>   static int
> +fbdev_output_disable_handler(struct weston_output *base)
> +{
> + if (!base->enabled)
> + return 0;
> +
> + /* Close the frame buffer. */
> + fbdev_output_disable(base);
> +
> + if (base->renderer_state != NULL)
> + pixman_renderer_output_destroy(base);
> +
> + return 0;
> +}
> +
> +static int
>   fbdev_output_create(struct fbdev_backend *backend,
>   const char *device)
>   {
> @@ -497,7 +512,7 @@ fbdev_output_create(struct fbdev_backend *backend,
>   
>   output->base.name = strdup("fbdev");
>   output->base.destroy = fbdev_output_destroy;
> - output->base.disable = NULL;
> + output->base.disable = fbdev_output_disable_handler;
>   output->base.enable = fbdev_output_enable;
>   
>   weston_output_init(&output->base, backend->compositor);
> @@ -539,11 +554,7 @@ fbdev_output_destroy(struct weston_output *base)
>   
>   weston_log("Destroying fbdev output.\n");
>   
> - /* Close the frame buffer. */
> - fbdev_output_disable(base);
> -
> - if (base->renderer_state != NULL)
> - pixman_renderer_output_destroy(base);
> + fbdev_output_disable_handler(base);
>   
>   /* Remove the output. */
>   weston_output_destroy(&output->base);
> 

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


Re: [PATCH weston v2 14/14] libweston: introduce weston_output_from_resource()

2017-07-24 Thread Armin Krezović
On 24.07.2017 17:08, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> This is a simple wrapper for casting the user data of a wl_resource into
> a struct weston_output pointer. Using the wrapper clearly marks all the
> places where a wl_output protocol object is used.
> 
> Replace ALL wl_output related calls to wl_resource_get_user_data() with
> a call to weston_output_from_resource().
> 
> v2: add type assert in weston_output_from_resource().
> 
> Signed-off-by: Pekka Paalanen 

Hi,

Now this is lot better:

Reviewed-by: Armin Krezović 

Thanks,

Armin


> ---
>   compositor/weston-screenshooter.c   |  2 +-
>   desktop-shell/input-panel.c |  2 +-
>   desktop-shell/shell.c   |  4 ++--
>   fullscreen-shell/fullscreen-shell.c |  4 ++--
>   ivi-shell/input-panel-ivi.c |  2 +-
>   libweston-desktop/wl-shell.c|  2 +-
>   libweston-desktop/xdg-shell-v5.c|  2 +-
>   libweston-desktop/xdg-shell-v6.c|  2 +-
>   libweston/compositor.c  | 16 
>   libweston/compositor.h  |  3 +++
>   tests/weston-test.c |  2 +-
>   11 files changed, 30 insertions(+), 11 deletions(-)
> 
> diff --git a/compositor/weston-screenshooter.c 
> b/compositor/weston-screenshooter.c
> index 909e..f874c3eb 100644
> --- a/compositor/weston-screenshooter.c
> +++ b/compositor/weston-screenshooter.c
> @@ -66,7 +66,7 @@ screenshooter_shoot(struct wl_client *client,
>   struct wl_resource *buffer_resource)
>   {
>   struct weston_output *output =
> - wl_resource_get_user_data(output_resource);
> + weston_output_from_resource(output_resource);
>   struct weston_buffer *buffer =
>   weston_buffer_from_resource(buffer_resource);
>   
> diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c
> index 40a4092e..e6b1541a 100644
> --- a/desktop-shell/input-panel.c
> +++ b/desktop-shell/input-panel.c
> @@ -274,7 +274,7 @@ input_panel_surface_set_toplevel(struct wl_client *client,
>   wl_list_insert(&shell->input_panel.surfaces,
>  &input_panel_surface->link);
>   
> - input_panel_surface->output = 
> wl_resource_get_user_data(output_resource);
> + input_panel_surface->output = 
> weston_output_from_resource(output_resource);
>   input_panel_surface->panel = 0;
>   }
>   
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index f1577c12..832a7b74 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -2941,7 +2941,7 @@ desktop_shell_set_background(struct wl_client *client,
>   surface->committed = background_committed;
>   surface->committed_private = shell;
>   weston_surface_set_label_func(surface, background_get_label);
> - surface->output = wl_resource_get_user_data(output_resource);
> + surface->output = weston_output_from_resource(output_resource);
>   view->output = surface->output;
>   weston_desktop_shell_send_configure(resource, 0,
>   surface_resource,
> @@ -3026,7 +3026,7 @@ desktop_shell_set_panel(struct wl_client *client,
>   surface->committed = panel_committed;
>   surface->committed_private = shell;
>   weston_surface_set_label_func(surface, panel_get_label);
> - surface->output = wl_resource_get_user_data(output_resource);
> + surface->output = weston_output_from_resource(output_resource);
>   view->output = surface->output;
>   weston_desktop_shell_send_configure(resource, 0,
>   surface_resource,
> diff --git a/fullscreen-shell/fullscreen-shell.c 
> b/fullscreen-shell/fullscreen-shell.c
> index 7368cb42..6f4565a7 100644
> --- a/fullscreen-shell/fullscreen-shell.c
> +++ b/fullscreen-shell/fullscreen-shell.c
> @@ -769,7 +769,7 @@ fullscreen_shell_present_surface(struct wl_client *client,
>   }
>   
>   if (output_res) {
> - output = wl_resource_get_user_data(output_res);
> + output = weston_output_from_resource(output_res);
>   fsout = fs_output_for_output(output);
>   fs_output_set_surface(fsout, surface, method, 0, 0);
>   } else {
> @@ -813,7 +813,7 @@ fullscreen_shell_present_surface_for_mode(struct 
> wl_client *client,
>   struct weston_seat *seat;
>   struct fs_output *fsout;
>   
> - output = wl_resource_get_user_data(output_res);
> + output = weston_output_from_resource(output_res);
>   fsout = fs_output_for_output(output);
>   
>   if (surface_res == NULL) {
> diff --git a/ivi-shell/input-panel-ivi

Re: [PATCH weston v2 10/14] libweston: move output id into add/remove_output()

2017-07-24 Thread Armin Krezović
On 24.07.2017 17:08, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Move the output id management into weston_compositor_add_output() and
> weston_compositor_remove_output(). This is a more logical place, and
> works towards assimilating weston_output_enable_undo().
> 
> The output id is no longer available to the backend enable() vfuncs, but
> it was not used there to begin with.
> 
> v2: moved assert earlier in weston_compositor_add_output()
> 
> Signed-off-by: Pekka Paalanen 

Hi,

Nice:

Reviewed-by: Armin Krezović 

Thanks,

Armin

> ---
>   libweston/compositor.c | 30 ++
>   1 file changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 6f8d9391..3c6d6db8 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4472,6 +4472,8 @@ weston_output_move(struct weston_output *output, int x, 
> int y)
>* Removes the output from the pending list and adds it to the compositor's
>* list of enabled outputs. The output created signal is emitted.
>*
> + * The output gets an internal ID assigned.
> + *
>* \param compositor The compositor instance.
>* \param output The output to be added.
>*
> @@ -4484,6 +4486,17 @@ weston_compositor_add_output(struct weston_compositor 
> *compositor,
>   struct weston_view *view, *next;
>   
>   assert(!output->enabled);
> +
> + /* Verify we haven't reached the limit of 32 available output IDs */
> + assert(ffs(~compositor->output_id_pool) > 0);
> +
> + /* Invert the output id pool and look for the lowest numbered
> +  * switch (the least significant bit).  Take that bit's position
> +  * as our ID, and mark it used in the compositor's output_id_pool.
> +  */
> + output->id = ffs(~compositor->output_id_pool) - 1;
> + compositor->output_id_pool |= 1u << output->id;
> +
>   wl_list_remove(&output->link);
>   wl_list_insert(compositor->output_list.prev, &output->link);
>   output->enabled = true;
> @@ -4532,7 +4545,6 @@ weston_output_transform_coordinate(struct weston_output 
> *output,
>* 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_enable_undo(struct weston_output *output)
> @@ -4541,7 +4553,6 @@ weston_output_enable_undo(struct weston_output *output)
>   
>   pixman_region32_fini(&output->region);
>   pixman_region32_fini(&output->previous_damage);
> - output->compositor->output_id_pool &= ~(1u << output->id);
>   }
>   
>   /** Removes output from compositor's list of enabled outputs
> @@ -4566,6 +4577,8 @@ weston_output_enable_undo(struct weston_output *output)
>* - wl_output protocol objects referencing this weston_output
>*   are made inert.
>*
> + * - The output's internal ID is released.
> + *
>* \memberof weston_output
>* \internal
>*/
> @@ -4598,6 +4611,9 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   wl_resource_for_each(resource, &output->resource_list) {
>   wl_resource_set_destructor(resource, NULL);
>   }
> +
> + compositor->output_id_pool &= ~(1u << output->id);
> + output->id = 0x; /* invalid */
>   }
>   
>   /** Sets the output scale for a given output.
> @@ -4768,9 +4784,6 @@ weston_output_enable(struct weston_output *output)
>   /* Make sure we have a transform set */
>   assert(output->transform != UINT32_MAX);
>   
> - /* Verify we haven't reached the limit of 32 available output IDs */
> - assert(ffs(~c->output_id_pool) > 0);
> -
>   output->x = x;
>   output->y = y;
>   output->dirty = 1;
> @@ -4788,13 +4801,6 @@ weston_output_enable(struct weston_output *output)
>   wl_list_init(&output->resource_list);
>   wl_list_init(&output->feedback_list);
>   
> - /* Invert the output id pool and look for the lowest numbered
> -  * switch (the least significant bit).  Take that bit's position
> -  * as our ID, and mark it used in the compositor's output_id_pool.
> -  */
> - output->id = ffs(~output->compositor->output_id_pool) - 1;
> - output->compositor->output_id_pool |= 1u << output->id;
> -
>   output->global =
>   wl_global_create(c->wl_display, &wl_output_interface, 3,
>output, bind_output);
> 

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


Re: [PATCH weston v2 03/14] libweston: let add/remove_output handle the lists

2017-07-24 Thread Armin Krezović
On 24.07.2017 17:07, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> A weston_output available to the compositor should always be either in
> the list of pending outputs or the list of enabled outputs. Let
> weston_compositor_add_output() and weston_compositor_remove_output()
> handle the moves between the lists.
> 
> This way weston_output_enable() does not need to remove and
> oops-it-failed-add-it-back. weston_output_disable() does not need to
> manually re-add the output back to the pending list.
> 
> To make everything nicely symmetric and fix any unbalancing caused by
> this:
> - weston_output_destroy() explicitly wl_list_remove()s
> - weston_compositor_add_pending_output() first removes then inserts, as
> we have the assumption that the link is always valid, even if empty.
> 
> Update the documentations, too.
> 
> v2:
> - talk about "list of enabled outputs"
> - keep wl_list_remove in weston_compositor_remove_output in its old
>    place
> 
> Signed-off-by: Pekka Paalanen 

Hi,

Now, for real:

Reviewed-by: Armin Krezović 

Thanks, Armin

> ---
>   libweston/compositor.c | 26 ++
>   1 file changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 5d51e198..98813d7b 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4464,8 +4464,10 @@ weston_output_move(struct weston_output *output, int 
> x, int y)
>   }
>   }
>   
> -/** Adds an output to the compositor's output list and
> - *  send the compositor's output_created signal.
> +/** Signal that a pending output is taken into use.
> + *
> + * Removes the output from the pending list and adds it to the compositor's
> + * list of enabled outputs. The output created signal is emitted.
>*
>* \param compositor The compositor instance.
>* \param output The output to be added.
> @@ -4476,7 +4478,9 @@ weston_compositor_add_output(struct weston_compositor 
> *compositor,
>   {
>   struct weston_view *view, *next;
>   
> + wl_list_remove(&output->link);
>   wl_list_insert(compositor->output_list.prev, &output->link);
> +
>   wl_signal_emit(&compositor->output_created_signal, output);
>   
>   wl_list_for_each_safe(view, next, &compositor->view_list, link)
> @@ -4535,6 +4539,8 @@ weston_output_enable_undo(struct weston_output *output)
>* - Compositor is notified that outputs were changed and
>*   applies the necessary changes to re-layout outputs.
>*
> + * - The output is put back in the pending outputs list.
> + *
>* - Signal is emitted to notify all users of the weston_output
>*   object that the output is being destroyed.
>*
> @@ -4558,7 +4564,9 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   weston_presentation_feedback_discard_list(&output->feedback_list);
>   
>   weston_compositor_reflow_outputs(compositor, output, output->width);
> +
>   wl_list_remove(&output->link);
> + wl_list_insert(compositor->pending_output_list.prev, &output->link);
>   
>   wl_signal_emit(&compositor->output_destroyed_signal, output);
>   wl_signal_emit(&output->destroy_signal, output);
> @@ -4654,11 +4662,14 @@ weston_output_init(struct weston_output *output,
>*
>* Also notifies the compositor that an output is pending for
>* configuration.
> + *
> + * The opposite of this operation is built into weston_output_destroy().
>*/
>   WL_EXPORT void
>   weston_compositor_add_pending_output(struct weston_output *output,
>struct weston_compositor *compositor)
>   {
> + wl_list_remove(&output->link);
>   wl_list_insert(compositor->pending_output_list.prev, &output->link);
>   wl_signal_emit(&compositor->output_pending_signal, output);
>   }
> @@ -4716,9 +4727,6 @@ weston_output_enable(struct weston_output *output)
>   /* Make sure we have a transform set */
>   assert(output->transform != UINT32_MAX);
>   
> - /* Remove it from pending/disabled output list */
> - wl_list_remove(&output->link);
> -
>   /* Verify we haven't reached the limit of 32 available output IDs */
>   assert(ffs(~c->output_id_pool) > 0);
>   
> @@ -4738,7 +4746,6 @@ weston_output_enable(struct weston_output *output)
>   wl_list_init(&output->animation_list);
>   wl_list_init(&output->resource_list);
>   wl_list_init(&output->feedback_list);
> - wl_list_init(&output->link);
>   
>   /* Invert the output id

Re: [PATCH weston v2 01/14] libweston: untangle weston_compositor_remove_output doc

2017-07-24 Thread Armin Krezović
On 24.07.2017 17:07, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Trying to make it more readable. Things that happen in the same step are
> kept in the same paragraph.
> 
> v2: talk about "list of enabled outputs"
> 
> Signed-off-by: Pekka Paalanen 

Hi,

Seeing that all my concerns were addressed, have a

Reviewed-by: Armin Krezović 

But I must ask: The series did contain 15 patches last time,
and this one was no 2, so what happened to the first one from
last time?

Cheers,

Armin.

> ---
>   libweston/compositor.c | 26 --
>   1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 2a3074db..65b3de20 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4521,19 +4521,25 @@ weston_output_enable_undo(struct weston_output 
> *output)
>   output->enabled = false;
>   }
>   
> -/** Removes output from compositor's output list
> +/** Removes output from compositor's list of enabled outputs
>*
>* \param output The weston_output object that is being removed.
>*
> - * Presentation feedback is discarded.
> - * Compositor is notified that outputs were changed and
> - * applies the necessary changes.
> - * All views assigned to the weston_output object are
> - * moved to a new output.
> - * Signal is emitted to notify all users of the weston_output
> - * object that the output is being destroyed.
> - * wl_output protocol objects referencing this weston_output
> - * are made inert.
> + * The following happens:
> + *
> + * - The output assignments of all views in the current scenegraph are
> + *   recomputed.
> + *
> + * - Presentation feedback is discarded.
> + *
> + * - Compositor is notified that outputs were changed and
> + *   applies the necessary changes to re-layout outputs.
> + *
> + * - Signal is emitted to notify all users of the weston_output
> + *   object that the output is being destroyed.
> + *
> + * - wl_output protocol objects referencing this weston_output
> + *   are made inert.
>*/
>   static void
>   weston_compositor_remove_output(struct weston_output *output)
> 

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


Re: [PATCH libinput 1/5] util: drop GCC specifics for container_of

2017-05-10 Thread Armin Krezović
On 10.05.2017 05:47, Peter Hutterer wrote:
> clang supports __typeof__ which was the only real difference. Not sure any
> other compilers matter (that don't support __typeof__)
> 

Hi,

Fun fact:  Clang defines __GNUC__ because it's gcc compatible
and the gcc path was always used by clang, the other one
was not used by anything.

Nevertheless, for the series

Reviewed-by: Armin Krezović 
Tested-by: Armin Krezović 

Please backport these to 1.7 branch (or at least the one that
fixes container_of).

Thanks, Armin.

> Signed-off-by: Peter Hutterer 
> ---
>   src/libinput-util.h | 6 --
>   1 file changed, 6 deletions(-)
> 
> diff --git a/src/libinput-util.h b/src/libinput-util.h
> index 4e97e011..a9a2b660 100644
> --- a/src/libinput-util.h
> +++ b/src/libinput-util.h
> @@ -85,15 +85,9 @@ void list_insert(struct list *list, struct list *elm);
>   void list_remove(struct list *elm);
>   bool list_empty(const struct list *list);
>   
> -#ifdef __GNUC__
>   #define container_of(ptr, sample, member)   \
>   (__typeof__(sample))((char *)(ptr)  -   \
>((char *)&(sample)->member - (char *)(sample)))
> -#else
> -#define container_of(ptr, sample, member)\
> - (void *)((char *)(ptr)  -   \
> -  ((char *)&(sample)->member - (char *)(sample)))
> -#endif
>   
>   #define list_for_each(pos, head, member)\
>   for (pos = 0, pos = container_of((head)->next, pos, member);\
> 

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


Re: [PATCH weston 02/15] libweston: untangle weston_compositor_remove_output doc

2017-04-12 Thread Armin Krezović
On 11.04.2017 14:49, Pekka Paalanen wrote:
> On Tue, 4 Apr 2017 21:30:04 +0200
> Armin Krezović  wrote:
> 
>> On 04.04.2017 12:58, Pekka Paalanen wrote:
>>> From: Pekka Paalanen 
>>>
>>> Trying to make it more readable. Things that happen in the same step are
>>> kept in the same paragraph.
>>>
>>> Signed-off-by: Pekka Paalanen 
>>> ---
>>>  libweston/compositor.c | 24 
>>>  1 file changed, 16 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/libweston/compositor.c b/libweston/compositor.c
>>> index 2bca19c..7510fab 100644
>>> --- a/libweston/compositor.c
>>> +++ b/libweston/compositor.c
>>> @@ -4516,18 +4516,26 @@ weston_output_enable_undo(struct weston_output 
>>> *output)
>>> output->enabled = false;
>>>  }
>>>  
>>> -/** Removes output from compositor's output list
>>> +/** Removes output from compositor's live outputs list  
>>
>> live -> enabled? Also, there's pending output list and just output list.
>> Not sure if the latter could use some renaming (probably not), to avoid
>> any further confusion?
> 
> Ok, I'll start using "list of enabled outputs" to refer to output_list.
> 
>>>   *
>>>   * \param output The weston_output object that is being removed.
>>>   *
>>> - * Presentation feedback is discarded.
>>> - * Compositor is notified that outputs were changed and
>>> - * applies the necessary changes.
>>> - * All views assigned to the weston_output object are
>>> - * moved to a new output.
>>> - * Signal is emitted to notify all users of the weston_output
>>> + * The following happens:
>>> + *
>>> + * - The output assignments of all views in the current scenegraph are
>>> + * recomputed.  
>>
>> Minor nit: If you are going to use -, make sure lines that are broken up
>> are aligned. Not a big deal, though.
> 
> Hmm, never crossed my mind to indent more. Let's hope doxygen knows to
> drop the whitespace.
> 
>>> + *
>>> + * - Presentation feedback is discarded.
>>> + *
>>> + * - Compositor is notified that outputs were changed and
>>> + * applies the necessary changes to re-layout outputs.
>>> + *
>>> + * - Signal is emitted to notify all users of the weston_output
>>>   * object that the output is being destroyed.

This one -^

>>> - * wl_output protocol objects referencing this weston_output
>>> + * All views assigned to the weston_output object are
>>> + * moved to a new output by the shell, if necessary.
>>> + *  
>>
>> Is this really worth mentioning? shell is, after all, an user of the output.
>> It does not have to be this way. fullscreen-shell doesn't do any moving, for
>> example. It just nukes the output. But still, if this belongs here, did you
>> forget - in the beginning of the line? Or is it part of "Signal is 
>> emitted..."?
> 
> That is what I thought the original comment was vaguely referring to.
> It's wasn't?
> 
> I can drop that.
> 

Yes, but the original comment is still there, right above it. I believe this
one is redundant.

> 
> Thanks,
> pq
> 
> 
>>> + * - wl_output protocol objects referencing this weston_output
>>>   * are made inert.
>>>   */
>>>  static void
>>>   
>>
>> Cheers. Armin.
>>
> 

Armin.



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


Re: [PATCH weston 04/15] libweston: let add/remove_output handle the lists

2017-04-07 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> A weston_output available to the compositor should always be either in
> the pending or the live outputs list. Let weston_compositor_add_output()
> and weston_compositor_remove_output() handle the moves between the
> lists.
> 
> This way weston_output_enable() does not need to remove and
> oops-it-failed-add-it-back. weston_output_disable() does not need to
> manually re-add the output back to the pending list.
> 
> To make everything nicely symmetric and fix any unbalancing caused by
> this:
> - weston_output_destroy() explicitly wl_list_remove()s
> - weston_compositor_add_pending_output() first removes then inserts, as
> we have the assumption that the link is always valid, even if empty.
> 
> Update the documentations, too.
> 

Hi again.

> Signed-off-by: Pekka Paalanen 
> ---
>  libweston/compositor.c | 28 +++-
>  1 file changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 60cbae0..09a3db2 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4537,6 +4541,8 @@ weston_output_enable_undo(struct weston_output *output)
>   *
>   * - wl_output protocol objects referencing this weston_output
>   * are made inert.
> + *
> + * - The output is put back in the pending outputs list.
>   */
>  static void
>  weston_compositor_remove_output(struct weston_output *output)
> @@ -4555,7 +4561,6 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   weston_presentation_feedback_discard_list(&output->feedback_list);
>  
>   weston_compositor_reflow_outputs(compositor, output, output->width);
> - wl_list_remove(&output->link);
>  

When I looked more closely at this part when I applied your patches, I found a
potential problem with moving this down below. The original code first removed
the output from the enabled output list, then emitted the signals.

Signal listeners might iterate through output list before this function 
"returns",
ie, to pick a new output for a view, and could potentially pick this output 
again.

Even worse, wl_list_empty(&c->output_list) will return false even if this is the
last output going away, throwing previous work about "all outputs gone at 
runtime"
down the drain.

>   wl_signal_emit(&compositor->output_destroyed_signal, output);
>   wl_signal_emit(&output->destroy_signal, output);
> @@ -4563,6 +4568,9 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   wl_resource_for_each(resource, &output->resource_list) {
>   wl_resource_set_destructor(resource, NULL);
>   }
> +
> + wl_list_remove(&output->link);
> + wl_list_insert(compositor->pending_output_list.prev, &output->link);
>  }
>  




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


Re: [PATCH weston 15/15] libweston: introduce weston_output_from_resource()

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> This is a simple wrapper for casting the user data of a wl_resource into
> a struct weston_output pointer. Using the wrapper clearly marks all the
> places where a wl_output protocol object is used.
> 
> Replace ALL wl_output related calls to wl_resource_get_user_data() with
> a call to weston_output_from_resource().
> 
> This patch does not add any type checks or asserts to ensure the user
> data actually is a weston_output. That is left for another patch, as
> well as introducing similar wrappers for other casts.
> 

Hi,

Now, introducing and exporting this, without any safety checks is
just asking for trouble. If it wasn't exported, it would be
fine. But don't underestimate libweston user, people make mistakes.

Thanks, Armin.

> Signed-off-by: Pekka Paalanen 
> ---
>  compositor/weston-screenshooter.c   |  2 +-
>  desktop-shell/input-panel.c |  2 +-
>  desktop-shell/shell.c   |  4 ++--
>  fullscreen-shell/fullscreen-shell.c |  4 ++--
>  ivi-shell/input-panel-ivi.c |  2 +-
>  libweston-desktop/wl-shell.c|  2 +-
>  libweston-desktop/xdg-shell-v5.c|  2 +-
>  libweston-desktop/xdg-shell-v6.c|  2 +-
>  libweston/compositor.c  | 13 +
>  libweston/compositor.h  |  3 +++
>  tests/weston-test.c |  2 +-
>  11 files changed, 27 insertions(+), 11 deletions(-)
> 
> diff --git a/compositor/weston-screenshooter.c 
> b/compositor/weston-screenshooter.c
> index 909..f874c3e 100644
> --- a/compositor/weston-screenshooter.c
> +++ b/compositor/weston-screenshooter.c
> @@ -66,7 +66,7 @@ screenshooter_shoot(struct wl_client *client,
>   struct wl_resource *buffer_resource)
>  {
>   struct weston_output *output =
> - wl_resource_get_user_data(output_resource);
> + weston_output_from_resource(output_resource);
>   struct weston_buffer *buffer =
>   weston_buffer_from_resource(buffer_resource);
>  
> diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c
> index 40a4092..e6b1541 100644
> --- a/desktop-shell/input-panel.c
> +++ b/desktop-shell/input-panel.c
> @@ -274,7 +274,7 @@ input_panel_surface_set_toplevel(struct wl_client *client,
>   wl_list_insert(&shell->input_panel.surfaces,
>  &input_panel_surface->link);
>  
> - input_panel_surface->output = 
> wl_resource_get_user_data(output_resource);
> + input_panel_surface->output = 
> weston_output_from_resource(output_resource);
>   input_panel_surface->panel = 0;
>  }
>  
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index c905879..8a4f2e1 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -2941,7 +2941,7 @@ desktop_shell_set_background(struct wl_client *client,
>   surface->committed = background_committed;
>   surface->committed_private = shell;
>   weston_surface_set_label_func(surface, background_get_label);
> - surface->output = wl_resource_get_user_data(output_resource);
> + surface->output = weston_output_from_resource(output_resource);
>   view->output = surface->output;
>   weston_desktop_shell_send_configure(resource, 0,
>   surface_resource,
> @@ -3026,7 +3026,7 @@ desktop_shell_set_panel(struct wl_client *client,
>   surface->committed = panel_committed;
>   surface->committed_private = shell;
>   weston_surface_set_label_func(surface, panel_get_label);
> - surface->output = wl_resource_get_user_data(output_resource);
> + surface->output = weston_output_from_resource(output_resource);
>   view->output = surface->output;
>   weston_desktop_shell_send_configure(resource, 0,
>   surface_resource,
> diff --git a/fullscreen-shell/fullscreen-shell.c 
> b/fullscreen-shell/fullscreen-shell.c
> index 7368cb4..6f4565a 100644
> --- a/fullscreen-shell/fullscreen-shell.c
> +++ b/fullscreen-shell/fullscreen-shell.c
> @@ -769,7 +769,7 @@ fullscreen_shell_present_surface(struct wl_client *client,
>   }
>  
>   if (output_res) {
> - output = wl_resource_get_user_data(output_res);
> + output = weston_output_from_resource(output_res);
>   fsout = fs_output_for_output(output);
>   fs_output_set_surface(fsout, surface, method, 0, 0);
>   } else {
> @@ -813,7 +813,7 @@ fullscreen_shell_present_surface_for_mode(struct 
> wl_client *client,
>   struct weston_seat *seat;
>   struct fs_output *fsout;
>  
> - output = wl_resource_get_user_data(output_res);
> + output = weston_output_from_resource(output_res);
>   fsout = fs_output_for_output(output);
>  
>   if (surface_res == NULL) {
> diff --git a/ivi-shell/input-panel-ivi.c b/ivi-shell/input-panel-ivi.c
> index 57d1cb2..0008a52 100644
> --- a/ivi-shell/input-panel-ivi.c
> +++ b/ivi-shell/input-panel-ivi.c

Re: [PATCH weston 14/15] libweston: make weston_output::connection_internal a bool

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> It really is a boolean.
> 
> Signed-off-by: Pekka Paalanen 

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor-drm.c | 2 +-
>  libweston/compositor.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 3f7e97e..3de11b8 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -2512,7 +2512,7 @@ drm_output_enable(struct weston_output *base)
>   find_and_parse_output_edid(b, output, output->connector);
>   if (output->connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
>   output->connector->connector_type == DRM_MODE_CONNECTOR_eDP)
> - output->base.connection_internal = 1;
> + output->base.connection_internal = true;
>  
>   weston_plane_init(&output->cursor_plane, b->compositor,
> INT32_MIN, INT32_MIN);
> diff --git a/libweston/compositor.h b/libweston/compositor.h
> index 4eebe6c..c375f48 100644
> --- a/libweston/compositor.h
> +++ b/libweston/compositor.h
> @@ -223,7 +223,7 @@ struct weston_output {
>   void (*set_backlight)(struct weston_output *output, uint32_t value);
>   void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
>  
> - int connection_internal;
> + bool connection_internal;
>   uint16_t gamma_size;
>   void (*set_gamma)(struct weston_output *output,
> uint16_t size,
> 




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


Re: [PATCH weston 13/15] libweston: extend output->region lifetime

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> It's a little awkward to try to keep the weston_output::region and
> weston_output::previous_damage allocate exactly only when the output is
> enabled. There was also a leak: weston_output_move() was calling
> weston_output_init_geometry() on an already allocated regions without
> fini in between.
> 
> Fix both issues by allocating the regions in weston_output_init(),
> always fini/init'ing them in weston_output_init_geometry(), and fini'ing
> for good in weston_output_destroy().
> 
> This nicely gets rid of weston_output_enable_undo() so I do not need to
> try to figure out what to do with it later.
> 
> Signed-off-by: Pekka Paalanen 

Nice work on getting rid of weston_output_enable_undo()

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor.c | 32 ++--
>  1 file changed, 10 insertions(+), 22 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index e8d5443..cd5b6ec 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4421,7 +4421,10 @@ weston_output_init_geometry(struct weston_output 
> *output, int x, int y)
>   output->x = x;
>   output->y = y;
>  
> + pixman_region32_fini(&output->previous_damage);
>   pixman_region32_init(&output->previous_damage);
> +
> + pixman_region32_fini(&output->region);
>   pixman_region32_init_rect(&output->region, x, y,
> output->width,
> output->height);
> @@ -4537,20 +4540,6 @@ weston_output_transform_coordinate(struct 
> weston_output *output,
>   *y = p.f[1] / p.f[3];
>  }
>  
> -/** Undoes changes to an output done by weston_output_enable()
> - *
> - * \param output The weston_output object that needs the changes undone.
> - *
> - * Removes the repaint timer.
> - * Destroys pixman regions allocated to the output.
> - */
> -static void
> -weston_output_enable_undo(struct weston_output *output)
> -{
> - pixman_region32_fini(&output->region);
> - pixman_region32_fini(&output->previous_damage);
> -}
> -
>  /** Removes output from compositor's live outputs list
>   *
>   * \param output The weston_output object that is being removed.
> @@ -4699,6 +4688,9 @@ weston_output_init(struct weston_output *output,
>   output->scale = 0;
>   /* Can't use -1 on uint32_t and 0 is valid enum value */
>   output->transform = UINT32_MAX;
> +
> + pixman_region32_init(&output->previous_damage);
> + pixman_region32_init(&output->region);
>  }
>  
>  /** Adds weston_output object to pending output list.
> @@ -4807,8 +4799,6 @@ weston_output_enable(struct weston_output *output)
>*/
>   if (output->enable(output) < 0) {
>   weston_log("Enabling output \"%s\" failed.\n", output->name);
> -
> - weston_output_enable_undo(output);
>   return -1;
>   }
>  
> @@ -4860,10 +4850,8 @@ weston_output_disable(struct weston_output *output)
>   if (output->disable(output) < 0)
>   return;
>  
> - if (output->enabled) {
> + if (output->enabled)
>   weston_compositor_remove_output(output);
> - weston_output_enable_undo(output);
> - }
>  
>   output->destroying = 0;
>  }
> @@ -4897,11 +4885,11 @@ weston_output_destroy(struct weston_output *output)
>  {
>   output->destroying = 1;
>  
> - if (output->enabled) {
> + if (output->enabled)
>   weston_compositor_remove_output(output);
> - weston_output_enable_undo(output);
> - }
>  
> + pixman_region32_fini(&output->region);
> + pixman_region32_fini(&output->previous_damage);
>   wl_list_remove(&output->link);
>   free(output->name);
>  }
> 




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


Re: [PATCH weston 12/15] libweston: move globals to weston_compositor_add_output()

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Move the wl_output global management into weston_compositor_add_output()
> and weston_compositor_remove_output().
> 
> If weston_output_enable() fails, there is no need to clean up the global
> and the clients will not see a wl_output come and go.
> 
> Signed-off-by: Pekka Paalanen 

Nice,

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor.c | 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index e2d28db..e8d5443 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4467,7 +4467,8 @@ weston_output_move(struct weston_output *output, int x, 
> int y)
>   * Removes the output from the pending list and adds it
>   * to the compositor's live outputs list. The output created signal is 
> emitted.
>   *
> - * The output gets an internal ID assigned.
> + * The output gets an internal ID assigned, and the wl_output global is
> + * created.
>   *
>   * \param compositor The compositor instance.
>   * \param output The output to be added.
> @@ -4495,6 +4496,10 @@ weston_compositor_add_output(struct weston_compositor 
> *compositor,
>   wl_list_insert(compositor->output_list.prev, &output->link);
>   output->enabled = true;
>  
> + output->global = wl_global_create(compositor->wl_display,
> +   &wl_output_interface, 3,
> +   output, bind_output);
> +
>   wl_signal_emit(&compositor->output_created_signal, output);
>  
>   wl_list_for_each_safe(view, next, &compositor->view_list, link)
> @@ -4537,14 +4542,11 @@ weston_output_transform_coordinate(struct 
> weston_output *output,
>   * \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.
>   */
>  static void
>  weston_output_enable_undo(struct weston_output *output)
>  {
> - wl_global_destroy(output->global);
> -
>   pixman_region32_fini(&output->region);
>   pixman_region32_fini(&output->previous_damage);
>  }
> @@ -4569,7 +4571,7 @@ weston_output_enable_undo(struct weston_output *output)
>   * moved to a new output by the shell, if necessary.
>   *
>   * - wl_output protocol objects referencing this weston_output
> - * are made inert.
> + * are made inert, and the wl_output global is removed.
>   *
>   * - The output is put back in the pending outputs list.
>   *
> @@ -4600,6 +4602,8 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   wl_signal_emit(&compositor->output_destroyed_signal, output);
>   wl_signal_emit(&output->destroy_signal, output);
>  
> + wl_global_destroy(output->global);
> + output->global = NULL;
>   wl_resource_for_each(resource, &output->resource_list) {
>   wl_resource_set_destructor(resource, NULL);
>   }
> @@ -4797,10 +4801,6 @@ weston_output_enable(struct weston_output *output)
>   wl_list_init(&output->resource_list);
>   wl_list_init(&output->feedback_list);
>  
> - output->global =
> - wl_global_create(c->wl_display, &wl_output_interface, 3,
> -  output, bind_output);
> -
>   /* Enable the output (set up the crtc or create a
>* window representing the output, set up the
>* renderer, etc)
> 




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


Re: [PATCH weston 11/15] libweston: move output id into add/remove_output()

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Move the output id management into weston_compositor_add_output() and
> weston_compositor_remove_output(). This is a more logical place, and
> works towards assimilating weston_output_enable_undo().
> 
> The output id is no longer available to the backend enable() vfuncs, but
> it was not used there to begin with.
> 
> Signed-off-by: Pekka Paalanen 
> ---
>  libweston/compositor.c | 29 +
>  1 file changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 987dd99..e2d28db 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4467,6 +4467,8 @@ weston_output_move(struct weston_output *output, int x, 
> int y)
>   * Removes the output from the pending list and adds it
>   * to the compositor's live outputs list. The output created signal is 
> emitted.
>   *
> + * The output gets an internal ID assigned.
> + *
>   * \param compositor The compositor instance.
>   * \param output The output to be added.
>   *
> @@ -4478,6 +4480,16 @@ weston_compositor_add_output(struct weston_compositor 
> *compositor,
>  {
>   struct weston_view *view, *next;
>  
> + /* Verify we haven't reached the limit of 32 available output IDs */
> + assert(ffs(~compositor->output_id_pool) > 0);
> +
> + /* Invert the output id pool and look for the lowest numbered
> +  * switch (the least significant bit).  Take that bit's position
> +  * as our ID, and mark it used in the compositor's output_id_pool.
> +  */
> + output->id = ffs(~compositor->output_id_pool) - 1;
> + compositor->output_id_pool |= 1u << output->id;
> +
>   assert(!output->enabled);

Hi,

I'd move this assert line before/after the assert above. You might end up 
overwriting
an already assigned id if the output is previously enabled (not that it would 
matter,
given that this assert would terminate the compositor immediately).

Thanks, Armin.

>   wl_list_remove(&output->link);
>   wl_list_insert(compositor->output_list.prev, &output->link);
> @@ -4527,7 +4539,6 @@ weston_output_transform_coordinate(struct weston_output 
> *output,
>   * 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_enable_undo(struct weston_output *output)
> @@ -4536,7 +4547,6 @@ weston_output_enable_undo(struct weston_output *output)
>  
>   pixman_region32_fini(&output->region);
>   pixman_region32_fini(&output->previous_damage);
> - output->compositor->output_id_pool &= ~(1u << output->id);
>  }
>  
>  /** Removes output from compositor's live outputs list
> @@ -4563,6 +4573,8 @@ weston_output_enable_undo(struct weston_output *output)
>   *
>   * - The output is put back in the pending outputs list.
>   *
> + * - The output's internal ID is released.
> + *
>   * \memberof weston_output
>   * \internal
>   */
> @@ -4595,6 +4607,9 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   wl_list_remove(&output->link);
>   wl_list_insert(compositor->pending_output_list.prev, &output->link);
>   output->enabled = false;
> +
> + compositor->output_id_pool &= ~(1u << output->id);
> + output->id = 0x; /* invalid */
>  }
>  
>  /** Sets the output scale for a given output.
> @@ -4765,9 +4780,6 @@ weston_output_enable(struct weston_output *output)
>   /* Make sure we have a transform set */
>   assert(output->transform != UINT32_MAX);
>  
> - /* Verify we haven't reached the limit of 32 available output IDs */
> - assert(ffs(~c->output_id_pool) > 0);
> -
>   output->x = x;
>   output->y = y;
>   output->dirty = 1;
> @@ -4785,13 +4797,6 @@ weston_output_enable(struct weston_output *output)
>   wl_list_init(&output->resource_list);
>   wl_list_init(&output->feedback_list);
>  
> - /* Invert the output id pool and look for the lowest numbered
> -  * switch (the least significant bit).  Take that bit's position
> -  * as our ID, and mark it used in the compositor's output_id_pool.
> -  */
> - output->id = ffs(~output->compositor->output_id_pool) - 1;
> - output->compositor->output_id_pool |= 1u << output->id;
> -
>   output->global =
>   wl_global_create(c->wl_display, &wl_output_interface, 3,
>output, bind_output);
> 




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


Re: [PATCH weston 10/15] libweston: prevent double weston_output_enable()

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
Hi,

> Enabling an already enabled output is an error, at least with the
> current implementation.

Ouch, how embarrasing.

> 
> However, disabling and output that has not been enabled is ok.

an output ^

> 
> Cope with the first and document the second.
> 
> Signed-off-by: Pekka Paalanen 

Reviewed-by: Armin Krezović 

> ---
>  libweston/compositor.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index e7293ea..987dd99 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4709,7 +4709,8 @@ weston_compositor_add_pending_output(struct 
> weston_output *output,
>  
>  /** Constructs a weston_output object that can be used by the compositor.
>   *
> - * \param output The weston_output object that needs to be enabled.
> + * \param output The weston_output object that needs to be enabled. Must not
> + * be enabled already.
>   *
>   * Output coordinates are calculated and each new output is by default
>   * assigned to the right of previous one.
> @@ -4746,6 +4747,12 @@ weston_output_enable(struct weston_output *output)
>   struct weston_output *iterator;
>   int x = 0, y = 0;
>  
> + if (output->enabled) {
> + weston_log("Error: attempt to enable an enabled output '%s'\n",
> +output->name);
> + return -1;
> + }
> +
>   iterator = container_of(c->output_list.prev,
>   struct weston_output, link);
>  
> @@ -4826,6 +4833,10 @@ weston_output_enable(struct weston_output *output)
>   *
>   * See weston_output_init() for more information on the
>   * state output is returned to.
> + *
> + * If the output has never been enabled yet, this function can still be
> + * called to ensure that the output is actually turned off rather than left
> + * in the state it was discovered in.
>   */

Again, turning off is only related to drm-backend. I'd make it more generic,
i.e., mention that backend is free to make an output disabled in its own way
(turning crtc off is one way). This explanation ain't bad either, which
is why I gave my review already.

>  WL_EXPORT void
>  weston_output_disable(struct weston_output *output)
> 

Thanks, Armin.



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


Re: [PATCH weston 09/15] libweston: specify weston_output::enabled

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 

Hi,

> It was ambiguous what this flag meant - it did not mean whether the
> backend is considering this output to be enabled, because
> weston_output_destroy() unsets it while deliberately not calling the
> backend disable() vfunc.
> 
> Perhaps the most clear definition is with respect to the output's
> assignment in the pending vs. live output lists. There is also a whole
> bunch of variables that are allocated only when enabled is true.
> 

Can you guess what I'm doing to ask here? :P

> Since the flag is related to the list membership, set and clear the flag
> only when manipulating the lists.
> 
> Assert that weston_compositor_add_output() and
> weston_compositor_remove_output() are not called in a wrong state.
> 
> Signed-off-by: Pekka Paalanen 
Reviewed-by: Armin Krezović 

> ---
>  libweston/compositor.c | 9 -
>  libweston/compositor.h | 2 +-
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 4e6d9f7..e7293ea 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4478,8 +4478,10 @@ weston_compositor_add_output(struct weston_compositor 
> *compositor,
>  {
>   struct weston_view *view, *next;
>  
> + assert(!output->enabled);
>   wl_list_remove(&output->link);
>   wl_list_insert(compositor->output_list.prev, &output->link);
> + output->enabled = true;
>  
>   wl_signal_emit(&compositor->output_created_signal, output);
>  
> @@ -4535,8 +4537,6 @@ weston_output_enable_undo(struct weston_output *output)
>   pixman_region32_fini(&output->region);
>   pixman_region32_fini(&output->previous_damage);
>   output->compositor->output_id_pool &= ~(1u << output->id);
> -
> - output->enabled = false;
>  }
>  
>  /** Removes output from compositor's live outputs list
> @@ -4574,6 +4574,7 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   struct weston_view *view;
>  
>   assert(output->destroying);
> + assert(output->enabled);
>  
>   wl_list_for_each(view, &compositor->view_list, link) {
>   if (view->output_mask & (1u << output->id))
> @@ -4593,6 +4594,7 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>  
>   wl_list_remove(&output->link);
>   wl_list_insert(compositor->pending_output_list.prev, &output->link);
> + output->enabled = false;
>  }
>  
>  /** Sets the output scale for a given output.
> @@ -4668,7 +4670,6 @@ weston_output_init(struct weston_output *output,
>   assert(output->name);
>  
>   wl_list_init(&output->link);
> -
>   output->enabled = false;
>  
>   /* Add some (in)sane defaults which can be used
> @@ -4788,8 +4789,6 @@ weston_output_enable(struct weston_output *output)
>   wl_global_create(c->wl_display, &wl_output_interface, 3,
>output, bind_output);
>  
> - output->enabled = true;
> -
>   /* Enable the output (set up the crtc or create a
>* window representing the output, set up the
>* renderer, etc)
> diff --git a/libweston/compositor.h b/libweston/compositor.h
> index 28e9466..4eebe6c 100644
> --- a/libweston/compositor.h
> +++ b/libweston/compositor.h
> @@ -233,7 +233,7 @@ struct weston_output {
>  
>   struct weston_timeline_object timeline;
>  
> - bool enabled;
> + bool enabled; /**< is in the output_list, not pending list */

live output list? :P

>   int scale;
>  
>   int (*enable)(struct weston_output *output);
> 

Thanks, Armin.



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


Re: [PATCH weston 08/15] libweston: move asserts to add_pending_output()

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> weston_compositor_add_pending_output() is the point through which all
> backends must go when creating a new output. The enable and disable
> vfuns are essential for anything to be done with the output, so it makes
> sense to check them here, rather than when actually enabling or
> disabling.
> 
> Particularly the disable vfunc is rarely called, so this gets the check
> better excercised.
> 
> Signed-off-by: Pekka Paalanen 

Makes sense.

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index baa4176..4e6d9f7 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4698,6 +4698,9 @@ WL_EXPORT void
>  weston_compositor_add_pending_output(struct weston_output *output,
>struct weston_compositor *compositor)
>  {
> + assert(output->disable);
> + assert(output->enable);
> +
>   wl_list_remove(&output->link);
>   wl_list_insert(compositor->pending_output_list.prev, &output->link);
>   wl_signal_emit(&compositor->output_pending_signal, output);
> @@ -4742,8 +4745,6 @@ weston_output_enable(struct weston_output *output)
>   struct weston_output *iterator;
>   int x = 0, y = 0;
>  
> - assert(output->enable);
> -
>   iterator = container_of(c->output_list.prev,
>   struct weston_output, link);
>  
> @@ -4830,8 +4831,6 @@ weston_output_enable(struct weston_output *output)
>  WL_EXPORT void
>  weston_output_disable(struct weston_output *output)
>  {
> - assert(output->disable);
> -
>   /* Should we rename this? */
>   output->destroying = 1;
>  
> 




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


Re: [PATCH weston 07/15] libweston: unexport weston_output_update_matrix()

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Only used internally in core. Needs to happen automatically when
> something changes, so there should no need to call it from outside.
> 
> Signed-off-by: Pekka Paalanen 

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor.c | 5 -
>  libweston/compositor.h | 2 --
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 3c8be62..baa4176 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -67,6 +67,9 @@
>  #define DEFAULT_REPAINT_WINDOW 7 /* milliseconds */
>  
>  static void
> +weston_output_update_matrix(struct weston_output *output);
> +
> +static void
>  weston_output_transform_scale_init(struct weston_output *output,
>  uint32_t transform, uint32_t scale);
>  
> @@ -4339,7 +4342,7 @@ weston_compositor_reflow_outputs(struct 
> weston_compositor *compositor,
>   }
>  }
>  
> -WL_EXPORT void
> +static void
>  weston_output_update_matrix(struct weston_output *output)
>  {
>   float magnification;
> diff --git a/libweston/compositor.h b/libweston/compositor.h
> index 6c05d59..28e9466 100644
> --- a/libweston/compositor.h
> +++ b/libweston/compositor.h
> @@ -1710,8 +1710,6 @@ void
>  weston_output_activate_zoom(struct weston_output *output,
>   struct weston_seat *seat);
>  void
> -weston_output_update_matrix(struct weston_output *output);
> -void
>  weston_output_move(struct weston_output *output, int x, int y);
>  
>  void
> 




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


Re: [PATCH weston 06/15] libweston: unexport weston_compositor_add_output()

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Only used by weston_output_enable().
> 
> Signed-off-by: Pekka Paalanen 

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor.c | 2 +-
>  libweston/compositor.h | 3 ---
>  2 files changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 69e63c2..3c8be62 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4469,7 +4469,7 @@ weston_output_move(struct weston_output *output, int x, 
> int y)
>   *
>   * \internal
>   */
> -WL_EXPORT void
> +static void
>  weston_compositor_add_output(struct weston_compositor *compositor,
>   struct weston_output *output)
>  {
> diff --git a/libweston/compositor.h b/libweston/compositor.h
> index 6070c77..6c05d59 100644
> --- a/libweston/compositor.h
> +++ b/libweston/compositor.h
> @@ -1715,9 +1715,6 @@ void
>  weston_output_move(struct weston_output *output, int x, int y);
>  
>  void
> -weston_compositor_add_output(struct weston_compositor *compositor,
> - struct weston_output *output);
> -void
>  weston_output_destroy(struct weston_output *output);
>  void
>  weston_output_transform_coordinate(struct weston_output *output,
> 




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


Re: [PATCH weston 05/15] libweston: two more weston_output docs

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Document two more functions of the weston_output API.
> 
> Exported functions marked internal are meant for backends only.
> Exported functions not marked internal are meant for libweston users.
> 
> Signed-off-by: Pekka Paalanen 

I'm not familiar with (guessing) doxygen notations, but wording and spelling
seem in order. Documentation is always welcome, thank you. Again, same question
about live -> enabled in this patch, too.

Nevertheless,

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor.c | 40 
>  1 file changed, 40 insertions(+)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 09a3db2..69e63c2 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4466,6 +4466,8 @@ weston_output_move(struct weston_output *output, int x, 
> int y)
>   *
>   * \param compositor The compositor instance.
>   * \param output The output to be added.
> + *
> + * \internal
>   */
>  WL_EXPORT void
>  weston_compositor_add_output(struct weston_compositor *compositor,
> @@ -4482,6 +4484,20 @@ weston_compositor_add_output(struct weston_compositor 
> *compositor,
>   weston_view_geometry_dirty(view);
>  }
>  
> +/** Transform device coordinates into global coordinates
> + *
> + * \param device_x[in] X coordinate in device units.
> + * \param device_y[in] Y coordinate in device units.
> + * \param x[out] X coordinate in the global space.
> + * \param y[out] Y coordinate in the global space.
> + *
> + * Transforms coordinates from the device coordinate space
> + * (physical pixel units) to the global coordinate space (logical pixel 
> units).
> + * This takes into account output transform and scale.
> + *
> + * \memberof weston_output
> + * \internal
> + */
>  WL_EXPORT void
>  weston_output_transform_coordinate(struct weston_output *output,
>  double device_x, double device_y,
> @@ -4543,6 +4559,9 @@ weston_output_enable_undo(struct weston_output *output)
>   * are made inert.
>   *
>   * - The output is put back in the pending outputs list.
> + *
> + * \memberof weston_output
> + * \internal
>   */
>  static void
>  weston_compositor_remove_output(struct weston_output *output)
> @@ -4580,6 +4599,8 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   *
>   * It only supports setting scale for an output that
>   * is not enabled and it can only be ran once.
> + *
> + * \memberof weston_output
>   */
>  WL_EXPORT void
>  weston_output_set_scale(struct weston_output *output,
> @@ -4605,6 +4626,8 @@ weston_output_set_scale(struct weston_output *output,
>   * Refer to wl_output::transform section located at
>   * https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output
>   * for list of values that can be passed to this function.
> + *
> + * \memberof weston_output
>   */
>  WL_EXPORT void
>  weston_output_set_transform(struct weston_output *output,
> @@ -4627,6 +4650,9 @@ weston_output_set_transform(struct weston_output 
> *output,
>   *
>   * Sets initial values for fields that are expected to be
>   * configured either by compositors or backends.
> + *
> + * \memberof weston_output
> + * \internal
>   */
>  WL_EXPORT void
>  weston_output_init(struct weston_output *output,
> @@ -4661,6 +4687,9 @@ weston_output_init(struct weston_output *output,
>   * configuration.
>   *
>   * The opposite of this operation is built into weston_output_destroy().
> + *
> + * \memberof weston_output
> + * \internal
>   */
>  WL_EXPORT void
>  weston_compositor_add_pending_output(struct weston_output *output,
> @@ -4835,6 +4864,17 @@ weston_pending_output_coldplug(struct 
> weston_compositor *compositor)
>   wl_signal_emit(&compositor->output_pending_signal, output);
>  }
>  
> +/** Uninitialize an output
> + *
> + * Removes the output from the live outputs list if necessary, but
> + * does not call the backend's output disable function.
> + *
> + * All fields of weston_output become uninitialized, i.e. should not be used
> + * anymore. The caller can free the memory after this.
> + *
> + * \memberof weston_output
> + * \internal
> + */
>  WL_EXPORT void
>  weston_output_destroy(struct weston_output *output)
>  {
> 




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


Re: [PATCH weston 04/15] libweston: let add/remove_output handle the lists

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> A weston_output available to the compositor should always be either in
> the pending or the live outputs list. Let weston_compositor_add_output()
> and weston_compositor_remove_output() handle the moves between the
> lists.
> 
> This way weston_output_enable() does not need to remove and
> oops-it-failed-add-it-back. weston_output_disable() does not need to
> manually re-add the output back to the pending list.
> 
> To make everything nicely symmetric and fix any unbalancing caused by
> this:
> - weston_output_destroy() explicitly wl_list_remove()s
> - weston_compositor_add_pending_output() first removes then inserts, as
> we have the assumption that the link is always valid, even if empty.
> 
> Update the documentations, too.
> 
> Signed-off-by: Pekka Paalanen 

Nice simplification, just one minor question down below.

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor.c | 28 +++-
>  1 file changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 60cbae0..09a3db2 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4459,8 +4459,10 @@ weston_output_move(struct weston_output *output, int 
> x, int y)
>   }
>  }
>  
> -/** Adds an output to the compositor's output list and
> - *  send the compositor's output_created signal.
> +/** Signal that a pending output is taken into use.
> + *
> + * Removes the output from the pending list and adds it
> + * to the compositor's live outputs list. The output created signal is 
> emitted.
>   *

Again, live -> enabled?

>   * \param compositor The compositor instance.
>   * \param output The output to be added.
> @@ -4471,7 +4473,9 @@ weston_compositor_add_output(struct weston_compositor 
> *compositor,
>  {
>   struct weston_view *view, *next;
>  
> + wl_list_remove(&output->link);
>   wl_list_insert(compositor->output_list.prev, &output->link);
> +
>   wl_signal_emit(&compositor->output_created_signal, output);
>  
>   wl_list_for_each_safe(view, next, &compositor->view_list, link)
> @@ -4537,6 +4541,8 @@ weston_output_enable_undo(struct weston_output *output)
>   *
>   * - wl_output protocol objects referencing this weston_output
>   * are made inert.
> + *
> + * - The output is put back in the pending outputs list.
>   */
>  static void
>  weston_compositor_remove_output(struct weston_output *output)
> @@ -4555,7 +4561,6 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   weston_presentation_feedback_discard_list(&output->feedback_list);
>  
>   weston_compositor_reflow_outputs(compositor, output, output->width);
> - wl_list_remove(&output->link);
>  
>   wl_signal_emit(&compositor->output_destroyed_signal, output);
>   wl_signal_emit(&output->destroy_signal, output);
> @@ -4563,6 +4568,9 @@ weston_compositor_remove_output(struct weston_output 
> *output)
>   wl_resource_for_each(resource, &output->resource_list) {
>   wl_resource_set_destructor(resource, NULL);
>   }
> +
> + wl_list_remove(&output->link);
> + wl_list_insert(compositor->pending_output_list.prev, &output->link);
>  }
>  
>  /** Sets the output scale for a given output.
> @@ -4651,11 +4659,14 @@ weston_output_init(struct weston_output *output,
>   *
>   * Also notifies the compositor that an output is pending for
>   * configuration.
> + *
> + * The opposite of this operation is built into weston_output_destroy().
>   */
>  WL_EXPORT void
>  weston_compositor_add_pending_output(struct weston_output *output,
>struct weston_compositor *compositor)
>  {
> + wl_list_remove(&output->link);
>   wl_list_insert(compositor->pending_output_list.prev, &output->link);
>   wl_signal_emit(&compositor->output_pending_signal, output);
>  }
> @@ -4713,9 +4724,6 @@ weston_output_enable(struct weston_output *output)
>   /* Make sure we have a transform set */
>   assert(output->transform != UINT32_MAX);
>  
> - /* Remove it from pending/disabled output list */
> - wl_list_remove(&output->link);
> -
>   /* Verify we haven't reached the limit of 32 available output IDs */
>   assert(ffs(~c->output_id_pool) > 0);
>  
> @@ -4735,7 +4743,6 @@ weston_output_enable(struct weston_output *output)
>   wl_list_init(&output->animation_list);
>   wl_list_init(&output->resourc

Re: [PATCH weston 03/15] libweston: use helper var in weston_compositor_remove_output

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> To shorten lines.
> 
> Signed-off-by: Pekka Paalanen 

Trivial.

Reviewed-by: Armin Krezović 

Thanks, Armin.

> ---
>  libweston/compositor.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 7510fab..60cbae0 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4541,22 +4541,23 @@ weston_output_enable_undo(struct weston_output 
> *output)
>  static void
>  weston_compositor_remove_output(struct weston_output *output)
>  {
> + struct weston_compositor *compositor = output->compositor;
>   struct wl_resource *resource;
>   struct weston_view *view;
>  
>   assert(output->destroying);
>  
> - wl_list_for_each(view, &output->compositor->view_list, link) {
> + wl_list_for_each(view, &compositor->view_list, link) {
>   if (view->output_mask & (1u << output->id))
>   weston_view_assign_output(view);
>   }
>  
>   weston_presentation_feedback_discard_list(&output->feedback_list);
>  
> - weston_compositor_reflow_outputs(output->compositor, output, 
> output->width);
> + weston_compositor_reflow_outputs(compositor, output, output->width);
>   wl_list_remove(&output->link);
>  
> - wl_signal_emit(&output->compositor->output_destroyed_signal, output);
> + wl_signal_emit(&compositor->output_destroyed_signal, output);
>   wl_signal_emit(&output->destroy_signal, output);
>  
>   wl_resource_for_each(resource, &output->resource_list) {
> 




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


Re: [PATCH weston 02/15] libweston: untangle weston_compositor_remove_output doc

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Trying to make it more readable. Things that happen in the same step are
> kept in the same paragraph.
> 
> Signed-off-by: Pekka Paalanen 
> ---
>  libweston/compositor.c | 24 
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 2bca19c..7510fab 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4516,18 +4516,26 @@ weston_output_enable_undo(struct weston_output 
> *output)
>   output->enabled = false;
>  }
>  
> -/** Removes output from compositor's output list
> +/** Removes output from compositor's live outputs list

live -> enabled? Also, there's pending output list and just output list.
Not sure if the latter could use some renaming (probably not), to avoid
any further confusion?

>   *
>   * \param output The weston_output object that is being removed.
>   *
> - * Presentation feedback is discarded.
> - * Compositor is notified that outputs were changed and
> - * applies the necessary changes.
> - * All views assigned to the weston_output object are
> - * moved to a new output.
> - * Signal is emitted to notify all users of the weston_output
> + * The following happens:
> + *
> + * - The output assignments of all views in the current scenegraph are
> + * recomputed.

Minor nit: If you are going to use -, make sure lines that are broken up
are aligned. Not a big deal, though.

> + *
> + * - Presentation feedback is discarded.
> + *
> + * - Compositor is notified that outputs were changed and
> + * applies the necessary changes to re-layout outputs.
> + *
> + * - Signal is emitted to notify all users of the weston_output
>   * object that the output is being destroyed.
> - * wl_output protocol objects referencing this weston_output
> + * All views assigned to the weston_output object are
> + * moved to a new output by the shell, if necessary.
> + *

Is this really worth mentioning? shell is, after all, an user of the output.
It does not have to be this way. fullscreen-shell doesn't do any moving, for
example. It just nukes the output. But still, if this belongs here, did you
forget - in the beginning of the line? Or is it part of "Signal is emitted..."?

> + * - wl_output protocol objects referencing this weston_output
>   * are made inert.
>   */
>  static void
> 

Cheers. Armin.



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


Re: [PATCH weston 01/15] libweston: improve weston_output_disable() comments

2017-04-04 Thread Armin Krezović
On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen 
> 
> Reorder some paragraphs to be more logically ordered. Rewrite the
> description of the backend-specific disable function to explain the
> semantics instead of the mechanics. Remove the paragraph about
> pending_output_list as unnecessary details.
> 
> Add a big fat comment on why we call output->disable() always instead of
> only for actually enabled outputs.
> 

Might also note that it's only relevant to drm-backend at the moment.

> Signed-off-by: Pekka Paalanen 

Nevertheless,

Reviewed-by: Armin Krezović 

> ---
>  libweston/compositor.c | 32 +---
>  1 file changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index 048b195..2bca19c 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4764,28 +4764,22 @@ weston_output_enable(struct weston_output *output)
>   *
>   * \param output The weston_output object that needs to be disabled.
>   *
> - * See weston_output_init() 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, it is first removed
> + * The backend specific disable function may choose to postpone the disabling
> + * by returning a negative value, in which case this function returns early.
> + * In that case the backend will guarantee the output will be disabled soon
> + * by the backend calling this function again. One must not attempt to 
> re-enable
> + * the output until that happens.
> + *
> + * Otherwise, if the output is being used by the compositor, it is removed
>   * from weston's output_list (see weston_compositor_remove_output())
>   * and is returned to a state it was before weston_output_enable()
>   * was ran (see weston_output_enable_undo()).
>   *
> - * 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 (the compositor specific functions
> - * for handling pending outputs will take care of that).
> - *
> - * If backend specific disable function returns negative value,
> - * this function will return too. It can be used as an indicator
> - * that output cannot be disabled at the present time. In that case
> - * backend needs to make sure the output is disabled when it is
> - * possible.
> + * See weston_output_init() for more information on the
> + * state output is returned to.
>   */
>  WL_EXPORT void
>  weston_output_disable(struct weston_output *output)
> @@ -4795,6 +4789,14 @@ weston_output_disable(struct weston_output *output)
>   /* Should we rename this? */
>   output->destroying = 1;
>  
> + /* Disable is called unconditionally also for not-enabled outputs,
> +  * because at compositor start-up, if there is an output that is
> +  * already on but the compositor wants to turn it off, we have to
> +  * forward the turn-off to the backend so it knows to do it.
> +  * The backend cannot initially turn off everything, because it
> +  * would cause unnecessary mode-sets for all outputs the compositor
> +  * wants to be on.
> +  */
>   if (output->disable(output) < 0)
>   return;
>  
> 




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


Re: [PATCH weston] compositor-wayland: Call weston_compositor_exit when receiving an xdg toplevel close event

2017-04-03 Thread Armin Krezović
On 25.03.2017 17:19, Sergi Granell wrote:
> Signed-off-by: Sergi Granell 
> ---
>  libweston/compositor-wayland.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
> index 1900ab08..a76dd08e 100644
> --- a/libweston/compositor-wayland.c
> +++ b/libweston/compositor-wayland.c
> @@ -1097,6 +1097,9 @@ handle_xdg_toplevel_configure(void *data, struct 
> zxdg_toplevel_v6 *toplevel,
>  static void
>  handle_xdg_toplevel_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
>  {
> + struct wayland_output *output = data;
> +
> + weston_compositor_exit(output->base.compositor);
>  }
>  
>  static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
> 

Hi,

My apologies for bursting in so late and after this has been merged.

I don't think this is the desired behaviour. Correct one is to destroy the 
output / window you
received the event from, and quit when all windows / outputs are gone, since 
there can be more
than one window (see --output-count).

See X11 backend implementation for similar situation:

https://cgit.freedesktop.org/wayland/weston/tree/libweston/compositor-x11.c#n1056

Thanks, Armin.



signature.asc
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/2] compositor-wayland: Check the return value of wayland_output_create_common

2017-03-24 Thread Armin Krezović

On 24.03.2017 19:53, Sergi Granell wrote:

If wayland_output_create_common returns NULL, it means that
the output creation failed.

Signed-off-by: Sergi Granell 


While I think that splitting the definition and initialization
wasn't necessary, the fix is still correct. I did wish that
it was sent as a first patch, as it's trivial. At this point,
it depends on patch 1 from this series.

Still, have a:

Reviewed-by: Armin Krezović 


---
  libweston/compositor-wayland.c | 15 +--
  1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 41834692..c8eceee7 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1261,6 +1261,9 @@ wayland_output_create(struct weston_compositor 
*compositor, const char *name)
  {
struct wayland_output *output = wayland_output_create_common(name);
  
+	if (!output)

+   return -1;
+
weston_output_init(&output->base, compositor);
weston_compositor_add_pending_output(&output->base, compositor);
  
@@ -1319,9 +1322,13 @@ static int

  wayland_output_create_for_parent_output(struct wayland_backend *b,
struct wayland_parent_output *poutput)
  {
-   struct wayland_output *output = 
wayland_output_create_common("wlparent");
+   struct wayland_output *output;
struct weston_mode *mode;
  
+	output = wayland_output_create_common("wlparent");

+   if (!output)
+   return -1;
+
if (poutput->current_mode) {
mode = poutput->current_mode;
} else if (poutput->preferred_mode) {
@@ -1367,9 +1374,13 @@ out:
  static int
  wayland_output_create_fullscreen(struct wayland_backend *b)
  {
-   struct wayland_output *output = 
wayland_output_create_common("wayland-fullscreen");
+   struct wayland_output *output;
int width = 0, height = 0;
  
+	output = wayland_output_create_common("wayland-fullscreen");

+   if (!output)
+   return -1;
+
weston_output_init(&output->base, b->compositor);
  
  	output->base.scale = 1;




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


Re: [PATCH weston 1/2] compositor-wayland: Refactor struct wayland_output::name usage

2017-03-24 Thread Armin Krezović

On 24.03.2017 19:53, Sergi Granell wrote:

struct wayland_output::name was used but never initialized.
Also zxdg_toplevel_v6_set_title was only called for windowed outputs,
and some compositors let you see the client's name even when it is
fullscreen (GNOME Shell's Activities menu for example).

So rename struct wayland_output::name to struct wayland_output::title and
precompute it on wayland_output_create_common(), so it can be later used
on xdg's set_title and frame_create.



Maybe swap the two paragraphs above, but that can be done when commiting.


Signed-off-by: Sergi Granell 


Rest is fine and it fixes an issue introduced by me, so have a:

Reviewed-by: Armin Krezović 


---
  libweston/compositor-wayland.c | 67 +++---
  1 file changed, 30 insertions(+), 37 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index ebdbd13b..41834692 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -111,7 +111,7 @@ struct wayland_output {
  
  	int keyboard_count;
  
-	char *name;

+   char *title;
struct frame *frame;
  
  	struct {

@@ -708,6 +708,7 @@ wayland_output_destroy(struct weston_output *base)
if (output->frame_cb)
wl_callback_destroy(output->frame_cb);
  
+	free(output->title);

free(output);
  }
  
@@ -835,36 +836,17 @@ wayland_output_set_windowed(struct wayland_output *output)

  {
struct wayland_backend *b =
to_wayland_backend(output->base.compositor);
-   int tlen;
-   char *title;
  
  	if (output->frame)

return 0;
  
-	if (output->name) {

-   tlen = strlen(output->name) + strlen(WINDOW_TITLE " - ");
-   title = malloc(tlen + 1);
-   if (!title)
-   return -1;
-
-   snprintf(title, tlen + 1, WINDOW_TITLE " - %s", output->name);
-   } else {
-   title = strdup(WINDOW_TITLE);
-   }
-
-   if (output->parent.xdg_toplevel)
-   zxdg_toplevel_v6_set_title(output->parent.xdg_toplevel, title);
-
if (!b->theme) {
b->theme = theme_create();
-   if (!b->theme) {
-   free(title);
+   if (!b->theme)
return -1;
-   }
}
output->frame = frame_create(b->theme, 100, 100,
-FRAME_BUTTON_CLOSE, title);
-   free(title);
+FRAME_BUTTON_CLOSE, output->title);
if (!output->frame)
return -1;
  
@@ -1139,6 +1121,8 @@ wayland_backend_create_output_surface(struct wayland_output *output)

while (output->parent.wait_for_configure)
wl_display_dispatch(b->parent.wl_display);
  
+		zxdg_toplevel_v6_set_title(output->parent.xdg_toplevel, output->title);

+
weston_log("wayland-backend: Using xdg_shell_v6\n");
}
else if (b->parent.shell) {
@@ -1239,9 +1223,13 @@ err_output:
  }
  
  static struct wayland_output *

-wayland_output_create_common(void)
+wayland_output_create_common(const char *name)
  {
struct wayland_output *output;
+   size_t len;
+
+   /* name can't be NULL. */
+   assert(name);
  
  	output = zalloc(sizeof *output);

if (output == NULL) {
@@ -1252,6 +1240,18 @@ wayland_output_create_common(void)
output->base.destroy = wayland_output_destroy;
output->base.disable = wayland_output_disable;
output->base.enable = wayland_output_enable;
+   output->base.name = strdup(name);
+
+   /* setup output name/title. */
+   len = strlen(WINDOW_TITLE " - ") + strlen(name) + 1;
+   output->title = zalloc(len);
+   if (!output->title) {
+   free(output->base.name);
+   free(output);
+   return NULL;
+   }
+
+   snprintf(output->title, len, WINDOW_TITLE " - %s", name);
  
  	return output;

  }
@@ -1259,12 +1259,7 @@ wayland_output_create_common(void)
  static int
  wayland_output_create(struct weston_compositor *compositor, const char *name)
  {
-   struct wayland_output *output = wayland_output_create_common();
-
-   /* name can't be NULL. */
-   assert(name);
-
-   output->base.name = strdup(name);
+   struct wayland_output *output = wayland_output_create_common(name);
  
  	weston_output_init(&output->base, compositor);

weston_compositor_add_pending_output(&output->base, compositor);
@@ -1324,11 +1319,9 @@ static int
  wayland_output_create_for_parent_output(struct wayland_backend *b,
struct wayland_parent_output *poutput)
  {
-   struct wayland_output *output = wayla

[PATCH weston] libbacklight: Fix backlight detection

2017-02-15 Thread Armin Krezović
On recent kernels, backlight directory does not contain
information about the device, but rather about the
connector. In this case, matching device pci_id and
connector device doesn't work.

This patch makes use of connector name, checks if
the connector directory is present in the device's
/sys path and matches it to the correct backlight
interface, if any.

It also fixes the safe_strtoint usage, so it doesn't
fail when newline is present.

Signed-off-by: Armin Krezović 
---
 Makefile.am|  8 +++--
 libweston/compositor-drm.c | 49 --
 libweston/libbacklight.c   | 31 +--
 libweston/libbacklight.h   |  1 +
 libweston/weston-drm-helpers.c | 48 ++
 libweston/weston-drm-helpers.h | 67 ++
 tests/setbacklight.c   | 28 --
 7 files changed, 169 insertions(+), 63 deletions(-)
 create mode 100644 libweston/weston-drm-helpers.c
 create mode 100644 libweston/weston-drm-helpers.h

diff --git a/Makefile.am b/Makefile.am
index cdf82ab4..f9a72319 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -378,7 +378,9 @@ drm_backend_la_SOURCES =\
shared/helpers.h\
shared/timespec-util.h  \
libweston/libbacklight.c\
-   libweston/libbacklight.h
+   libweston/libbacklight.h\
+   libweston/weston-drm-helpers.c  \
+   libweston/weston-drm-helpers.h
 
 if ENABLE_VAAPI_RECORDER
 drm_backend_la_SOURCES += libweston/vaapi-recorder.c libweston/vaapi-recorder.h
@@ -1465,7 +1467,9 @@ noinst_PROGRAMS += setbacklight
 setbacklight_SOURCES = \
tests/setbacklight.c\
libweston/libbacklight.c\
-   libweston/libbacklight.h
+   libweston/libbacklight.h\
+   libweston/weston-drm-helpers.c  \
+   libweston/weston-drm-helpers.h
 setbacklight_CFLAGS = $(AM_CFLAGS) $(SETBACKLIGHT_CFLAGS)
 setbacklight_LDADD = $(SETBACKLIGHT_LIBS)
 endif
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 2a80c6d7..418bd600 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -53,6 +53,7 @@
 #include "shared/timespec-util.h"
 #include "gl-renderer.h"
 #include "weston-egl-ext.h"
+#include "weston-drm-helpers.h"
 #include "pixman-renderer.h"
 #include "libbacklight.h"
 #include "libinput-seat.h"
@@ -1798,45 +1799,6 @@ drm_set_dpms(struct weston_output *output_base, enum 
dpms_enum level)
output->dpms = level;
 }
 
-static const char * const connector_type_names[] = {
-   [DRM_MODE_CONNECTOR_Unknown] = "Unknown",
-   [DRM_MODE_CONNECTOR_VGA] = "VGA",
-   [DRM_MODE_CONNECTOR_DVII]= "DVI-I",
-   [DRM_MODE_CONNECTOR_DVID]= "DVI-D",
-   [DRM_MODE_CONNECTOR_DVIA]= "DVI-A",
-   [DRM_MODE_CONNECTOR_Composite]   = "Composite",
-   [DRM_MODE_CONNECTOR_SVIDEO]  = "SVIDEO",
-   [DRM_MODE_CONNECTOR_LVDS]= "LVDS",
-   [DRM_MODE_CONNECTOR_Component]   = "Component",
-   [DRM_MODE_CONNECTOR_9PinDIN] = "DIN",
-   [DRM_MODE_CONNECTOR_DisplayPort] = "DP",
-   [DRM_MODE_CONNECTOR_HDMIA]   = "HDMI-A",
-   [DRM_MODE_CONNECTOR_HDMIB]   = "HDMI-B",
-   [DRM_MODE_CONNECTOR_TV]  = "TV",
-   [DRM_MODE_CONNECTOR_eDP] = "eDP",
-#ifdef DRM_MODE_CONNECTOR_DSI
-   [DRM_MODE_CONNECTOR_VIRTUAL] = "Virtual",
-   [DRM_MODE_CONNECTOR_DSI] = "DSI",
-#endif
-};
-
-static char *
-make_connector_name(const drmModeConnector *con)
-{
-   char name[32];
-   const char *type_name = NULL;
-
-   if (con->connector_type < ARRAY_LENGTH(connector_type_names))
-   type_name = connector_type_names[con->connector_type];
-
-   if (!type_name)
-   type_name = "UNNAMED";
-
-   snprintf(name, sizeof name, "%s-%d", type_name, con->connector_type_id);
-
-   return strdup(name);
-}
-
 static int
 find_crtc_for_connector(struct drm_backend *b,
drmModeRes *resources, drmModeConnector *connector)
@@ -2610,18 +2572,19 @@ create_output_for_connector(struct drm_backend *b,
output->pipe = i;
output->connector_id = connector->connector_id;
 
-   output->backlight = backlight_init(drm_device,
-  connector->connector_type);
-
output->base.enable = drm_output_enable;
output->base.destroy = drm_output_destroy;
output->base.disable = drm_ou

[PATCH weston] compositor: Improve xwayland warning message

2017-02-09 Thread Armin Krezović
And fix formatting.

Signed-off-by: Armin Krezović 
---
 compositor/main.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 4bd6e681..72c3cd10 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -860,9 +860,10 @@ load_modules(struct weston_compositor *ec, const char 
*modules,
snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
 
if (strstr(buffer, "xwayland.so")) {
-   weston_log("Old Xwayland module loading detected:"
-  "Please use --xwayland command line option"
-  "or weston.ini xwayland=true\n");
+   weston_log("Old Xwayland module loading detected: "
+  "Please use --xwayland command line option "
+  "or set xwayland=true in the [core] section "
+  "in weston.ini\n");
*xwayland = 1;
} else {
if (wet_load_module(ec, buffer, argc, argv) < 0)
-- 
2.11.1

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


[PATCH 2/2] compositor-drm: Mark eDP connection as internal

2017-02-08 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-drm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 7f1eeda9..13cb5a89 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2425,7 +2425,8 @@ drm_output_enable(struct weston_output *base)
output->base.subpixel = 
drm_subpixel_to_wayland(output->connector->subpixel);
 
find_and_parse_output_edid(b, output, output->connector);
-   if (output->connector->connector_type == DRM_MODE_CONNECTOR_LVDS)
+   if (output->connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
+   output->connector->connector_type == DRM_MODE_CONNECTOR_eDP)
output->base.connection_internal = 1;
 
weston_plane_init(&output->cursor_plane, b->compositor,
-- 
2.11.1

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


[PATCH 1/2] libbacklight: Fix backlight detection on recent kernels

2017-02-08 Thread Armin Krezović
I don't know when it started happening, but recent kernels
give different names for pci_device and backlight parent.

pci_device is tied to the GPU PCI ID, while backlight parent
is tied to the connector, rather than the GPU itself.

On my system, I get the following (paths taken from actual
strings that were parsed):

pci_device: :00:02.0
parent: card0-eDP-1

Obtained by commands equivalent to system calls used:

$ basename $(readlink /sys/devices/pci\:00/\:00\:02.0/drm/card0/device)
$ basename $(readlink /sys/class/backlight/intel_backlight/device)

This also fixes safe_strtoint usage, so it doesn't choke
on newline character.

Signed-off-by: Armin Krezović 
---
 libweston/libbacklight.c | 46 +++---
 1 file changed, 3 insertions(+), 43 deletions(-)

diff --git a/libweston/libbacklight.c b/libweston/libbacklight.c
index 4bbc6db4..d814b583 100644
--- a/libweston/libbacklight.c
+++ b/libweston/libbacklight.c
@@ -67,6 +67,9 @@ static long backlight_get(struct backlight *backlight, char 
*node)
goto out;
}
 
+   if (buffer[ret - 1] == '\n')
+   buffer[ret - 1] = '\0';
+
if (!safe_strtoint(buffer, &value)) {
ret = -1;
goto out;
@@ -153,8 +156,6 @@ void backlight_destroy(struct backlight *backlight)
 struct backlight *backlight_init(struct udev_device *drm_device,
 uint32_t connector_type)
 {
-   const char *syspath = NULL;
-   char *pci_name = NULL;
char *chosen_path = NULL;
char *path = NULL;
DIR *backlights = NULL;
@@ -164,24 +165,6 @@ struct backlight *backlight_init(struct udev_device 
*drm_device,
struct backlight *backlight = NULL;
int ret;
 
-   if (!drm_device)
-   return NULL;
-
-   syspath = udev_device_get_syspath(drm_device);
-   if (!syspath)
-   return NULL;
-
-   if (asprintf(&path, "%s/%s", syspath, "device") < 0)
-   return NULL;
-
-   ret = readlink(path, buffer, sizeof(buffer) - 1);
-   free(path);
-   if (ret < 0)
-   return NULL;
-
-   buffer[ret] = '\0';
-   pci_name = basename(buffer);
-
if (connector_type <= 0)
return NULL;
 
@@ -207,7 +190,6 @@ struct backlight *backlight_init(struct udev_device 
*drm_device,
 
while ((entry = readdir(backlights))) {
char *backlight_path;
-   char *parent;
enum backlight_type entry_type;
int fd;
 
@@ -253,28 +235,6 @@ struct backlight *backlight_init(struct udev_device 
*drm_device,
goto out;
}
 
-   free (path);
-
-   if (asprintf(&path, "%s/%s", backlight_path, "device") < 0)
-   goto err;
-
-   ret = readlink(path, buffer, sizeof(buffer) - 1);
-
-   if (ret < 0)
-   goto out;
-
-   buffer[ret] = '\0';
-
-   parent = basename(buffer);
-
-   /* Perform matching for raw and firmware backlights -
-  platform backlights have to be assumed to match */
-   if (entry_type == BACKLIGHT_RAW ||
-   entry_type == BACKLIGHT_FIRMWARE) {
-   if (!(pci_name && !strcmp(pci_name, parent)))
-   goto out;
-   }
-
if (entry_type < type)
goto out;
 
-- 
2.11.1

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


Re: [PATCH v2] clients: teach simple-dmabuf-v4l to deal with flipped input

2017-02-07 Thread Armin Krezović
If the required definitions are in UAPI headers, maybe you can just import
the most recent header into weston source for the time being. IIRC,
libevdev (used by libinput) does something similar in order to keep the
build from breaking on older kernels. Maybe Peter can explain better.

(Sent from web interface, so no signature available)

On Wed, Feb 8, 2017 at 3:05 AM, Derek Foreman 
wrote:

> On 07/02/17 07:17 PM, Bryce Harrington wrote:
>
>> On Tue, Feb 07, 2017 at 11:48:47AM +0200, Pekka Paalanen wrote:
>>
>>> On Mon,  6 Feb 2017 12:57:41 -0500
>>> Micah Fedke  wrote:
>>>
>>> The v4l2 API can be queried to detect if the input video image is
 horizontally or vertically flipped. If the image is y-flipped, we can
 set the ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT flag to notify the
 compositor.  If the image is h-flipped, we can only print a warning
 since linux_buffer_params_v1 does not support horizontal flipping.

 Signed-off-by: Micah Fedke 
 ---
 This version addresses Pekka's comments by renaming check_v4l2_control
 to
 check_v4l2_control_bool, removing the len parameter, separating out the
 logic
 tests in check_v4l2_control_bool and fixing spacing issues.

  clients/simple-dmabuf-v4l.c | 62 ++
 +--
  1 file changed, 54 insertions(+), 8 deletions(-)

>>>
>>> Hi,
>>>
>>> looks fine, pushed with my R-b:
>>>9a200d7..0fee977  master -> master
>>>
>>
>> Breaks the build on older linux kernels.
>>
>>   CC   clients/weston_simple_dmabuf_v4l-simple-dmabuf-v4l.o
>> clients/simple-dmabuf-v4l.c:358:25: warning: ‘struct
>> v4l2_query_ext_ctrl’ declared inside parameter list [enabled by default]
>>  const int expected_value)
>>  ^
>> clients/simple-dmabuf-v4l.c:358:25: warning: its scope is only this
>> definition or declaration, which is probably not what you want [enabled by
>> default]
>> clients/simple-dmabuf-v4l.c: In function ‘check_v4l2_control_bool’:
>> clients/simple-dmabuf-v4l.c:363:18: error: dereferencing pointer to
>> incomplete type
>>   ctrl.id = qectrl->id;
>>   ^
>> et al.
>>
>> Builds ok with the patch reverted, or with --disable-simple-dmabuf-v4l-client
>> set.
>>
>
> Ouch, bad timing for a build break.
>
> IMHO this patch should land before the final release, to get all the
> y-inversion fix-ups in at the same time, but I don't like the idea of a
> beta release that fails to build after it succeeds at configure for some
> folk...
>
> If a quick fix isn't coming, maybe revert it before the beta release?
>
> It's not a huge stretch to consider properly dealing with y-flip a bug
> fix, and it is just a test app, so I think it'd be ok to land it during the
> beta...
>
> ___
> 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 weston v3] compositor-wayland: Don't use two different presentation methods for fs shell

2017-02-07 Thread Armin Krezović
This patch fixes the wayland backend to not use two different
presentation methods when running on fullscreen-shell.

See also: https://patchwork.freedesktop.org/patch/114534/

v2:

 - Add missing wayland_output_resize_surface() call
 - Start repaint loop after initial frame has been drawn

v3:

 - Redraw the initial frame if present for mode fails

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93514
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 90 --
 1 file changed, 51 insertions(+), 39 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 9d35ef77..010b7a39 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -971,6 +971,38 @@ struct zwp_fullscreen_shell_mode_feedback_v1_listener 
mode_feedback_listener = {
mode_feedback_cancelled,
 };
 
+static enum mode_status
+wayland_output_fullscreen_shell_mode_feedback(struct wayland_output *output,
+ struct weston_mode *mode)
+{
+   struct wayland_backend *b = to_wayland_backend(output->base.compositor);
+   struct zwp_fullscreen_shell_mode_feedback_v1 *mode_feedback;
+   enum mode_status mode_status;
+   int ret = 0;
+
+   mode_feedback =
+   
zwp_fullscreen_shell_v1_present_surface_for_mode(b->parent.fshell,
+
output->parent.surface,
+
output->parent.output,
+mode->refresh);
+
+   zwp_fullscreen_shell_mode_feedback_v1_add_listener(mode_feedback,
+  
&mode_feedback_listener,
+  &mode_status);
+
+   output->parent.draw_initial_frame = false;
+   draw_initial_frame(output);
+   wl_surface_commit(output->parent.surface);
+
+   mode_status = MODE_STATUS_UNKNOWN;
+   while (mode_status == MODE_STATUS_UNKNOWN && ret >= 0)
+   ret = wl_display_dispatch(b->parent.wl_display);
+
+   zwp_fullscreen_shell_mode_feedback_v1_destroy(mode_feedback);
+
+   return mode_status;
+}
+
 static int
 wayland_output_switch_mode(struct weston_output *output_base,
   struct weston_mode *mode)
@@ -979,9 +1011,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
struct wayland_backend *b;
struct wl_surface *old_surface;
struct weston_mode *old_mode;
-   struct zwp_fullscreen_shell_mode_feedback_v1 *mode_feedback;
enum mode_status mode_status;
-   int ret = 0;
 
if (output_base == NULL) {
weston_log("output is NULL.\n");
@@ -1015,25 +1045,11 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
/* Blow the old buffers because we changed size/surfaces */
wayland_output_resize_surface(output);
 
-   mode_feedback =
-   
zwp_fullscreen_shell_v1_present_surface_for_mode(b->parent.fshell,
-
output->parent.surface,
-
output->parent.output,
-mode->refresh);
-   zwp_fullscreen_shell_mode_feedback_v1_add_listener(mode_feedback,
-  
&mode_feedback_listener,
-  &mode_status);
+   mode_status = wayland_output_fullscreen_shell_mode_feedback(output, 
mode);
 
/* This should kick-start things again */
-   output->parent.draw_initial_frame = true;
wayland_output_start_repaint_loop(&output->base);
 
-   mode_status = MODE_STATUS_UNKNOWN;
-   while (mode_status == MODE_STATUS_UNKNOWN && ret >= 0)
-   ret = wl_display_dispatch(b->parent.wl_display);
-
-   zwp_fullscreen_shell_mode_feedback_v1_destroy(mode_feedback);
-
if (mode_status == MODE_STATUS_FAIL) {
output->base.current_mode = old_mode;
wl_surface_destroy(output->parent.surface);
@@ -1162,6 +1178,7 @@ wayland_output_enable(struct weston_output *base)
 {
struct wayland_output *output = to_wayland_output(base);
struct wayland_backend *b = to_wayland_backend(base->compositor);
+   enum mode_status mode_status;
int ret = 0;
 
weston_log("Creating %dx%d wayland output at (%d, %d)\n",
@@ -1199,28 +1216,23 @@ wayland_output_enable(struct weston_output *base)
output->base.switch_mode = wayland_output_switch_mode;
 
if (b->sprawl_across_outputs) {
-   wayl

[PATCH weston v2] compositor-wayland: Don't use two different presentation methods for fs shell

2017-02-07 Thread Armin Krezović
This patch fixes the wayland backend to not use two different
presentation methods when running on fullscreen-shell.

See also: https://patchwork.freedesktop.org/patch/114534/

v2:

 - Add missing wayland_output_resize_surface() call
 - Start repaint loop after initial frame has been drawn

Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 87 +++---
 1 file changed, 48 insertions(+), 39 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 9d35ef77..480e4c58 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -971,6 +971,38 @@ struct zwp_fullscreen_shell_mode_feedback_v1_listener 
mode_feedback_listener = {
mode_feedback_cancelled,
 };
 
+static enum mode_status
+wayland_output_fullscreen_shell_mode_feedback(struct wayland_output *output,
+ struct weston_mode *mode)
+{
+   struct wayland_backend *b = to_wayland_backend(output->base.compositor);
+   struct zwp_fullscreen_shell_mode_feedback_v1 *mode_feedback;
+   enum mode_status mode_status;
+   int ret = 0;
+
+   mode_feedback =
+   
zwp_fullscreen_shell_v1_present_surface_for_mode(b->parent.fshell,
+
output->parent.surface,
+
output->parent.output,
+mode->refresh);
+
+   zwp_fullscreen_shell_mode_feedback_v1_add_listener(mode_feedback,
+  
&mode_feedback_listener,
+  &mode_status);
+
+   output->parent.draw_initial_frame = false;
+   draw_initial_frame(output);
+   wl_surface_commit(output->parent.surface);
+
+   mode_status = MODE_STATUS_UNKNOWN;
+   while (mode_status == MODE_STATUS_UNKNOWN && ret >= 0)
+   ret = wl_display_dispatch(b->parent.wl_display);
+
+   zwp_fullscreen_shell_mode_feedback_v1_destroy(mode_feedback);
+
+   return mode_status;
+}
+
 static int
 wayland_output_switch_mode(struct weston_output *output_base,
   struct weston_mode *mode)
@@ -979,9 +1011,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
struct wayland_backend *b;
struct wl_surface *old_surface;
struct weston_mode *old_mode;
-   struct zwp_fullscreen_shell_mode_feedback_v1 *mode_feedback;
enum mode_status mode_status;
-   int ret = 0;
 
if (output_base == NULL) {
weston_log("output is NULL.\n");
@@ -1015,25 +1045,11 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
/* Blow the old buffers because we changed size/surfaces */
wayland_output_resize_surface(output);
 
-   mode_feedback =
-   
zwp_fullscreen_shell_v1_present_surface_for_mode(b->parent.fshell,
-
output->parent.surface,
-
output->parent.output,
-mode->refresh);
-   zwp_fullscreen_shell_mode_feedback_v1_add_listener(mode_feedback,
-  
&mode_feedback_listener,
-  &mode_status);
+   mode_status = wayland_output_fullscreen_shell_mode_feedback(output, 
mode);
 
/* This should kick-start things again */
-   output->parent.draw_initial_frame = true;
wayland_output_start_repaint_loop(&output->base);
 
-   mode_status = MODE_STATUS_UNKNOWN;
-   while (mode_status == MODE_STATUS_UNKNOWN && ret >= 0)
-   ret = wl_display_dispatch(b->parent.wl_display);
-
-   zwp_fullscreen_shell_mode_feedback_v1_destroy(mode_feedback);
-
if (mode_status == MODE_STATUS_FAIL) {
output->base.current_mode = old_mode;
wl_surface_destroy(output->parent.surface);
@@ -1162,6 +1178,7 @@ wayland_output_enable(struct weston_output *base)
 {
struct wayland_output *output = to_wayland_output(base);
struct wayland_backend *b = to_wayland_backend(base->compositor);
+   enum mode_status mode_status;
int ret = 0;
 
weston_log("Creating %dx%d wayland output at (%d, %d)\n",
@@ -1199,28 +1216,20 @@ wayland_output_enable(struct weston_output *base)
output->base.switch_mode = wayland_output_switch_mode;
 
if (b->sprawl_across_outputs) {
-   wayland_output_set_fullscreen(output,
- 
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER,
-   

[PATCH] compositor-wayland: Don't use two different presentation methods for fs shell

2017-02-07 Thread Armin Krezović
This patch fixes the wayland backend to not use two different
presentation methods when running on fullscreen-shell.

See also: https://patchwork.freedesktop.org/patch/114534/

Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 85 +++---
 1 file changed, 46 insertions(+), 39 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 9d35ef77..31dff880 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -971,6 +971,38 @@ struct zwp_fullscreen_shell_mode_feedback_v1_listener 
mode_feedback_listener = {
mode_feedback_cancelled,
 };
 
+static enum mode_status
+wayland_output_fullscreen_shell_mode_feedback(struct wayland_output *output,
+ struct weston_mode *mode)
+{
+   struct wayland_backend *b = to_wayland_backend(output->base.compositor);
+   struct zwp_fullscreen_shell_mode_feedback_v1 *mode_feedback;
+   enum mode_status mode_status;
+   int ret = 0;
+
+   mode_feedback =
+   
zwp_fullscreen_shell_v1_present_surface_for_mode(b->parent.fshell,
+
output->parent.surface,
+
output->parent.output,
+mode->refresh);
+
+   zwp_fullscreen_shell_mode_feedback_v1_add_listener(mode_feedback,
+  
&mode_feedback_listener,
+  &mode_status);
+
+   output->parent.draw_initial_frame = false;
+   draw_initial_frame(output);
+   wl_surface_commit(output->parent.surface);
+
+   mode_status = MODE_STATUS_UNKNOWN;
+   while (mode_status == MODE_STATUS_UNKNOWN && ret >= 0)
+   ret = wl_display_dispatch(b->parent.wl_display);
+
+   zwp_fullscreen_shell_mode_feedback_v1_destroy(mode_feedback);
+
+   return mode_status;
+}
+
 static int
 wayland_output_switch_mode(struct weston_output *output_base,
   struct weston_mode *mode)
@@ -979,9 +1011,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
struct wayland_backend *b;
struct wl_surface *old_surface;
struct weston_mode *old_mode;
-   struct zwp_fullscreen_shell_mode_feedback_v1 *mode_feedback;
enum mode_status mode_status;
-   int ret = 0;
 
if (output_base == NULL) {
weston_log("output is NULL.\n");
@@ -1015,24 +1045,10 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
/* Blow the old buffers because we changed size/surfaces */
wayland_output_resize_surface(output);
 
-   mode_feedback =
-   
zwp_fullscreen_shell_v1_present_surface_for_mode(b->parent.fshell,
-
output->parent.surface,
-
output->parent.output,
-mode->refresh);
-   zwp_fullscreen_shell_mode_feedback_v1_add_listener(mode_feedback,
-  
&mode_feedback_listener,
-  &mode_status);
-
/* This should kick-start things again */
-   output->parent.draw_initial_frame = true;
wayland_output_start_repaint_loop(&output->base);
 
-   mode_status = MODE_STATUS_UNKNOWN;
-   while (mode_status == MODE_STATUS_UNKNOWN && ret >= 0)
-   ret = wl_display_dispatch(b->parent.wl_display);
-
-   zwp_fullscreen_shell_mode_feedback_v1_destroy(mode_feedback);
+   mode_status = wayland_output_fullscreen_shell_mode_feedback(output, 
mode);
 
if (mode_status == MODE_STATUS_FAIL) {
output->base.current_mode = old_mode;
@@ -1162,6 +1178,7 @@ wayland_output_enable(struct weston_output *base)
 {
struct wayland_output *output = to_wayland_output(base);
struct wayland_backend *b = to_wayland_backend(base->compositor);
+   enum mode_status mode_status;
int ret = 0;
 
weston_log("Creating %dx%d wayland output at (%d, %d)\n",
@@ -1199,28 +1216,18 @@ wayland_output_enable(struct weston_output *base)
output->base.switch_mode = wayland_output_switch_mode;
 
if (b->sprawl_across_outputs) {
-   wayland_output_set_fullscreen(output,
- 
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER,
- output->mode.refresh, 
output->parent.output);
-
-   if (output->parent.xdg_toplevel) {
-   
zxdg_tople

Re: [PATCH weston 2/2] compositor-drm: Restore use-current-mode functionality

2017-01-24 Thread Armin Krezović
On 10.11.2016 11:20, Armin Krezović wrote:
> On 09.11.2016 15:43, Daniel Stone wrote:
>> Hi Armin,
>>
> 
> Hi,
> 
>> On 9 October 2016 at 22:48, Armin Krezović  wrote:
>>> diff --git a/compositor/main.c b/compositor/main.c
>>> index 320305c..ffeadfb 100644
>>> --- a/compositor/main.c
>>> +++ b/compositor/main.c
>>> @@ -78,6 +78,7 @@ struct wet_compositor {
>>> struct weston_config *config;
>>> struct wet_output_config *parsed_options;
>>> struct wl_listener pending_output_listener;
>>> +   bool drm_use_current_mode;
>>>  };
>>
>> I'm fairly confused about this one, though I freely admit I didn't
>> track the libweston config work, so may have missed something.
>>
>> What makes --use-current-mode special enough that it should be the
>> only such option inside struct wet_compositor? What makes it different
>> to, say, use_pixman, which lives in the DRM backend?
>>
> 
> The thing is, --use-pixman flag is used in many places throughout the backend,
> while --use-current-mode is only used by function that sets the mode. That
> function is now called by the user, and is required to be called before
> enabling the output, whereas it was previously done in the backend itself, and
> it got the necessary configuration values by calling into an user-defined 
> function
> (configure output -> user defined function -> set mode).
> 
>>> @@ -1138,7 +1140,7 @@ drm_backend_output_configure(struct wl_listener 
>>> *listener, void *data)
>>> weston_output_disable(output);
>>> free(s);
>>> return;
>>> -   } else if (strcmp(s, "current") == 0) {
>>> +   } else if (wet->drm_use_current_mode || strcmp(s, "current") == 0) {
>>> mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
>>> } else if (strcmp(s, "preferred") != 0) {
>>> modeline = s;
>>
>> What would the difference be to making this check be 'else if
>> (b->use_current_mode || strcmp(s, "current") == 0)'?
>>
>> Cheers,
>> Daniel
>>
> 
> struct drm_backend is private to compositor-drm.c as far as I'm aware. We 
> can't
> use it here.
> 

Ping. I'd like to know what's acceptable solution for this, to fix it
in time for next release. Otherwise, it's a regression, and
--current-mode would be unusable.



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


Re: Fwd: [PATCH weston 01/68] libweston: Add pixel-format helpers

2016-12-09 Thread Armin Krezović
On 09.12.2016 22:30, Daniel Stone wrote:
> Hi,
> 

Hi,

> On 9 December 2016 at 20:37, Armin Krezović  wrote:
>> On 09.12.2016 20:57, Daniel Stone wrote:
>>>  libweston/pixel-formats.c | 398 
>>> ++
>>>  libweston/pixel-formats.h | 112 +
>>
>> Where are corresponding build system modifications?
> 
> Missing, apparently ... :\
> 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>
>> Is it supposed to work without EGL/GLESv2 enabled?
> 
> Not really, no; note that the DRM backend has a hard dependency on GBM
> and the Wayland backend has a hard dependency on libwayland-egl, so
> this only really affects people building the X11/headless backends
> only with no EGL. I suppose we could do a giant #ifdef tree, or just
> pull all the tokens we use into weston-egl-ext.h and use that. Do you
> have any preferences?
> 

Well, if my guess is correct, this is supposed to be part of libweston, no?

I don't think some people would like to have hard EGL dep on libweston itself,
and conditionally building this into the library might produce incompatible
lib with and without --disable-egl using the same source.

That said, I'm all for importing the needed bits into weston-egl-ext.h (if
you prefer to #ifdef a lot, go ahead).

>>> +/**
>>> + * Table of DRM formats supported by Weston; RGB, ARGB and YUV formats are
>>> + * supported. Indexed/greyscale formats, and formats not containing 
>>> complete
>>> + * colour channels, are not supported.
>>> + */
>>
>> I expected something using this immediately. I suggest you squash it with 
>> something
>> else that uses this.
> 
> It could be squashed with 'Store format in drm_fb', but as the
> DRM-specific parts of the series were getting very little review, and
> it can also be useful for gl-renderer's SHM uploads in particular, I
> didn't want to muddle it in with the rest of the series. Depending on
> how that goes (whether I get to porting gl-renderer, if earlier parts
> of the series get reviewed so we can merge this, etc), it can be
> squashed into its first user.
> 

Well, you could've squashed it into that patch and sent it (from what I've
seen it doesn't involve any new code and doesn't depend on anything else),
and I can help you with review and gl-renderer porting, as this can be
landed independently from rest of the series.

Even if they don't fit together, at least make the patch that uses this a
next one, so someone can take a look at example usage without having to
dig through whole series to find out what is using this.

> Cheers,
> Daniel
> 




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


[PATCH weston RFC] compositor-wayland: Support building without EGL

2016-12-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 Makefile.am|  1 +
 configure.ac   |  9 ++---
 libweston/compositor-wayland.c | 23 ++-
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 2219e3d5..704d17af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -383,6 +383,7 @@ wayland_backend_la_LDFLAGS = -module -avoid-version
 wayland_backend_la_LIBADD =\
$(COMPOSITOR_LIBS)  \
$(WAYLAND_COMPOSITOR_LIBS)  \
+   $(WAYLAND_COMPOSITOR_EGL_LIBS)  \
libshared-cairo.la
 wayland_backend_la_CFLAGS =\
$(COMPOSITOR_CFLAGS)\
diff --git a/configure.ac b/configure.ac
index 1e251bfe..0542332c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -237,11 +237,14 @@ AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, 
$ac_wayland_protocols_pkgdatadir)
 AC_ARG_ENABLE(wayland-compositor, [  --enable-wayland-compositor],,
  enable_wayland_compositor=yes)
 AM_CONDITIONAL(ENABLE_WAYLAND_COMPOSITOR,
-  test x$enable_wayland_compositor = xyes -a x$enable_egl = xyes)
-if test x$enable_wayland_compositor = xyes -a x$enable_egl = xyes; then
+  test x$enable_wayland_compositor = xyes)
+if test x$enable_wayland_compositor = xyes; then
   AC_DEFINE([BUILD_WAYLAND_COMPOSITOR], [1],
[Build the Wayland (nested) compositor])
-  PKG_CHECK_MODULES(WAYLAND_COMPOSITOR, [wayland-client >= 
$WAYLAND_PREREQ_VERSION wayland-egl wayland-cursor])
+  PKG_CHECK_MODULES(WAYLAND_COMPOSITOR, [wayland-client >= 
$WAYLAND_PREREQ_VERSION wayland-cursor])
+  if test x$enable_egl = xyes; then
+PKG_CHECK_MODULES(WAYLAND_COMPOSITOR_EGL, [wayland-egl])
+  fi
 fi
 
 
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d1e387df..925d2790 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -38,9 +38,12 @@
 #include 
 
 #include 
-#include 
 #include 
 
+#ifdef ENABLE_EGL
+#include 
+#endif
+
 #include "compositor.h"
 #include "compositor-wayland.h"
 #include "gl-renderer.h"
@@ -386,6 +389,7 @@ draw_initial_frame(struct wayland_output *output)
  output->base.current_mode->height);
 }
 
+#ifdef ENABLE_EGL /* Defined but not used */
 static void
 wayland_output_update_gl_border(struct wayland_output *output)
 {
@@ -455,6 +459,7 @@ wayland_output_update_gl_border(struct wayland_output 
*output)
   
cairo_image_surface_get_stride(output->gl.border.bottom) / 4,
   
cairo_image_surface_get_data(output->gl.border.bottom));
 }
+#endif
 
 static void
 wayland_output_start_repaint_loop(struct weston_output *output_base)
@@ -480,6 +485,7 @@ wayland_output_start_repaint_loop(struct weston_output 
*output_base)
wl_display_flush(wb->parent.wl_display);
 }
 
+#ifdef ENABLE_EGL
 static int
 wayland_output_repaint_gl(struct weston_output *output_base,
  pixman_region32_t *damage)
@@ -498,6 +504,7 @@ wayland_output_repaint_gl(struct weston_output *output_base,
 &ec->primary_plane.damage, damage);
return 0;
 }
+#endif
 
 static void
 wayland_output_update_shm_border(struct wayland_shm_buffer *buffer)
@@ -665,9 +672,11 @@ wayland_output_disable(struct weston_output *base)
 
if (b->use_pixman) {
pixman_renderer_output_destroy(&output->base);
+#ifdef ENABLE_EGL
} else {
gl_renderer->output_destroy(&output->base);
wl_egl_window_destroy(output->gl.egl_window);
+#endif
}
 
wayland_output_destroy_shm_buffers(output);
@@ -702,6 +711,7 @@ wayland_output_destroy(struct weston_output *base)
 
 static const struct wl_shell_surface_listener shell_surface_listener;
 
+#ifdef ENABLE_EGL
 static int
 wayland_output_init_gl_renderer(struct wayland_output *output)
 {
@@ -737,6 +747,7 @@ cleanup_window:
wl_egl_window_destroy(output->gl.egl_window);
return -1;
 }
+#endif
 
 static int
 wayland_output_init_pixman_renderer(struct wayland_output *output)
@@ -785,6 +796,7 @@ wayland_output_resize_surface(struct wayland_output *output)
wl_region_destroy(region);
}
 
+#ifdef ENABLE_EGL
if (output->gl.egl_window) {
wl_egl_window_resize(output->gl.egl_window,
 width, height, 0, 0);
@@ -811,6 +823,7 @@ wayland_output_resize_surface(struct wayland_output *output)
cairo_surface_destroy(output->gl.border.bottom);
output->gl.border.bottom = NULL;
}
+#endif
 
wayland_output_destroy_shm_buffers(output);
 }
@@ -1037,11 +1050,13 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
pixman_renderer_

Re: [PATCH weston 41/68] [XXX] compositor-drm: Don't restore original CRTC mode

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> When leaving Weston, don't attempt to restore the previous CRTC
> settings. The framebuffer may well have disappeared, and in every
> likelihood, whoever gets the KMS device afterwards will be repainting
> anyway.
> 
> XXX: This breaks gamma. Need to work around that.
> 
> Differential Revision: https://phabricator.freedesktop.org/D1502
> 
> Signed-off-by: Daniel Stone 
> ---
>  libweston/compositor-drm.c | 20 +---
>  1 file changed, 1 insertion(+), 19 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 5959aed..2db48f1 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -297,7 +297,6 @@ struct drm_output {
>   uint32_t crtc_id; /* object ID to pass to DRM functions */
>   int pipe; /* index of CRTC in resource array / bitmasks */
>   uint32_t connector_id;
> - drmModeCrtcPtr original_crtc;
>   struct drm_edid edid;
>   drmModePropertyPtr dpms_prop;
>   uint32_t gbm_format;
> @@ -1513,8 +1512,6 @@ drm_output_set_gamma(struct weston_output *output_base,
>   /* check */
>   if (output_base->gamma_size != size)
>   return;
> - if (!output->original_crtc)
> - return;
>  
>   rc = drmModeCrtcSetGamma(backend->drm.fd,
>output->crtc_id,
> @@ -3630,8 +3627,6 @@ drm_output_set_mode(struct weston_output *base,
>   output->base.serial_number = "unknown";
>   wl_list_init(&output->base.mode_list);
>  
> - output->original_crtc = drmModeGetCrtc(b->drm.fd, output->crtc_id);
> -

Can't you just store gamma_size from here? No need to store the original_crtc,
just get the gamma value and let it go.

>   if (connector_get_current_mode(output->connector, b->drm.fd, 
> &crtc_mode) < 0)
>   goto err_free;
>  
> @@ -3658,9 +3653,6 @@ drm_output_set_mode(struct weston_output *base,
>   return 0;
>  
>  err_free:
> - drmModeFreeCrtc(output->original_crtc);
> - output->original_crtc = NULL;
> -
>   wl_list_for_each_safe(drm_mode, next, &output->base.mode_list,
>   base.link) {
>   wl_list_remove(&drm_mode->base.link);
> @@ -3741,7 +3733,7 @@ drm_output_enable(struct weston_output *base)
>   output->base.set_dpms = drm_set_dpms;
>   output->base.switch_mode = drm_output_switch_mode;
>  
> - output->base.gamma_size = output->original_crtc->gamma_size;
> + output->base.gamma_size = 0; /* XXX */
>   output->base.set_gamma = drm_output_set_gamma;
>  
>   output->base.subpixel = 
> drm_subpixel_to_wayland(output->connector->subpixel);
> @@ -3805,7 +3797,6 @@ drm_output_destroy(struct weston_output *base)
>  {
>   struct drm_output *output = to_drm_output(base);
>   struct drm_backend *b = to_drm_backend(base->compositor);
> - drmModeCrtcPtr origcrtc = output->original_crtc;
>  
>   if (output->page_flip_pending || output->vblank_pending) {
>   output->destroy_pending = 1;
> @@ -3816,14 +3807,6 @@ drm_output_destroy(struct weston_output *base)
>   if (output->base.enabled)
>   drm_output_deinit(&output->base);
>  
> - if (origcrtc) {
> - /* Restore original CRTC state */
> - drmModeSetCrtc(b->drm.fd, origcrtc->crtc_id, 
> origcrtc->buffer_id,
> -origcrtc->x, origcrtc->y,
> -&output->connector_id, 1, &origcrtc->mode);
> - drmModeFreeCrtc(origcrtc);
> - }
> -
>   weston_output_destroy(&output->base);
>  
>   drmModeFreeConnector(output->connector);
> @@ -3914,7 +3897,6 @@ create_output_for_connector(struct drm_backend *b,
>  
>   output->destroy_pending = 0;
>   output->disable_pending = 0;
> - output->original_crtc = NULL;
>  
>   output->state_cur = drm_output_state_alloc(output);
>  
> 




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


Re: [PATCH weston 18/68] compositor-drm: Drop output from release_fb

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> We only need it for the GBM surface the FB was originally created
> against; a mismatch here is very bad indeed, so no reason to pass it in
> explictly every time rather than store it.
> 
> Differential Revision: https://phabricator.freedesktop.org/D1490
> 
> Signed-off-by: Daniel Stone 

Makes sense.

Reviewed-by: Armin Krezović 

> ---
>  libweston/compositor-drm.c | 20 +++-
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 7dbfc6b..eb735b2 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -148,6 +148,7 @@ struct drm_fb {
>  
>   /* Used by gbm fbs */
>   struct gbm_bo *bo;
> + struct gbm_surface *gbm_surface;
>  
>   /* Used by dumb fbs */
>   void *map;
> @@ -466,7 +467,7 @@ drm_fb_set_buffer(struct drm_fb *fb, struct weston_buffer 
> *buffer)
>  }
>  
>  static void
> -drm_output_release_fb(struct drm_output *output, struct drm_fb *fb)
> +drm_fb_unref(struct drm_fb *fb)
>  {
>   if (!fb)
>   return;
> @@ -479,7 +480,7 @@ drm_output_release_fb(struct drm_output *output, struct 
> drm_fb *fb)
>   gbm_bo_destroy(fb->bo);
>   break;
>   case BUFFER_GBM_SURFACE:
> - gbm_surface_release_buffer(output->gbm_surface, fb->bo);
> + gbm_surface_release_buffer(fb->gbm_surface, fb->bo);
>   break;
>   default:
>   assert(NULL);
> @@ -615,6 +616,7 @@ drm_output_render_gl(struct drm_output *output, 
> pixman_region32_t *damage)
>   gbm_surface_release_buffer(output->gbm_surface, bo);
>   return;
>   }
> + output->next->gbm_surface = output->gbm_surface;
>  }
>  
>  static void
> @@ -798,7 +800,7 @@ drm_output_repaint(struct weston_output *output_base,
>  err_pageflip:
>   output->cursor_view = NULL;
>   if (output->next) {
> - drm_output_release_fb(output, output->next);
> + drm_fb_unref(output->next);
>   output->next = NULL;
>   }
>  
> @@ -900,7 +902,7 @@ vblank_handler(int fd, unsigned int frame, unsigned int 
> sec, unsigned int usec,
>   drm_output_update_msc(output, frame);
>   output->vblank_pending = 0;
>  
> - drm_output_release_fb(output, s->current);
> + drm_fb_unref(s->current);
>   s->current = s->next;
>   s->next = NULL;
>  
> @@ -930,7 +932,7 @@ page_flip_handler(int fd, unsigned int frame,
>* we just want to page flip to the current buffer to get an accurate
>* timestamp */
>   if (output->page_flip_pending) {
> - drm_output_release_fb(output, output->current);
> + drm_fb_unref(output->current);
>   output->current = output->next;
>   output->next = NULL;
>   }
> @@ -1452,8 +1454,8 @@ drm_output_switch_mode(struct weston_output 
> *output_base, struct weston_mode *mo
>   WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
>  
>   /* reset rendering stuff. */
> - drm_output_release_fb(output, output->current);
> - drm_output_release_fb(output, output->next);
> + drm_fb_unref(output->current);
> + drm_fb_unref(output->next);
>   output->current = output->next = NULL;
>  
>   if (b->use_pixman) {
> @@ -2672,8 +2674,8 @@ destroy_sprites(struct drm_backend *backend)
>   sprite->plane_id,
>   output->crtc_id, 0, 0,
>   0, 0, 0, 0, 0, 0, 0, 0);
> - drm_output_release_fb(output, sprite->current);
> - drm_output_release_fb(output, sprite->next);
> + drm_fb_unref(sprite->current);
> + drm_fb_unref(sprite->next);
>   weston_plane_release(&sprite->plane);
>   free(sprite);
>   }
> 




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


Re: [PATCH weston 16/68] compositor-drm: Store format in drm_fb

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> This uses the new pixel-format helpers, so we can also replace depth/bpp
> with these.
> 
> Signed-off-by: Daniel Stone 
> 
> Differential Revision: https://phabricator.freedesktop.org/D1513

So, this is where code added by patch 1 is being used. I suggest
squashing it with this one (unless I missed an earlier patch that
also uses it).

> ---
>  libweston/compositor-drm.c | 43 +++
>  1 file changed, 27 insertions(+), 16 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 217db32..af43a15 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -54,6 +54,7 @@
>  #include "gl-renderer.h"
>  #include "weston-egl-ext.h"
>  #include "pixman-renderer.h"
> +#include "pixel-formats.h"
>  #include "libbacklight.h"
>  #include "libinput-seat.h"
>  #include "launcher-util.h"
> @@ -140,6 +141,7 @@ struct drm_fb {
>   enum drm_fb_type type;
>  
>   uint32_t fb_id, stride, handle, size;
> + const struct pixel_format_info *format;
>   int width, height;
>   int fd;
>   struct weston_buffer_reference buffer_ref;
> @@ -267,7 +269,6 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int 
> height,
>  {
>   struct drm_fb *fb;
>   int ret;
> - uint32_t bpp, depth;
>  
>   struct drm_mode_create_dumb create_arg;
>   struct drm_mode_destroy_dumb destroy_arg;
> @@ -277,20 +278,20 @@ drm_fb_create_dumb(struct drm_backend *b, int width, 
> int height,
>   if (!fb)
>   return NULL;
>  
> - switch (format) {
> - case GBM_FORMAT_XRGB:
> - bpp = 32;
> - depth = 24;
> - break;
> - case GBM_FORMAT_RGB565:
> - bpp = depth = 16;
> - break;
> - default:
> - return NULL;
> + fb->format = pixel_format_get_info(format);
> + if (!fb->format) {
> + weston_log("failed to look up format 0x%lx\n",
> +(unsigned long) format);
> + goto err_fb;
> + }
> +
> + if (!fb->format->depth || !fb->format->bpp) {
> + weston_log("format 0x%lx is not compatible with dumb buffers\n",
> +(unsigned long) format);
>   }
>  
>   memset(&create_arg, 0, sizeof create_arg);
> - create_arg.bpp = bpp;
> + create_arg.bpp = fb->format->bpp;
>   create_arg.width = width;
>   create_arg.height = height;
>  
> @@ -316,7 +317,8 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int 
> height,
>   offsets[0] = 0;
>  
>   ret = drmModeAddFB2(b->drm.fd, width, height,
> - format, handles, pitches, offsets,
> + fb->format->format,
> + handles, pitches, offsets,
>   &fb->fb_id, 0);
>   if (ret) {
>   weston_log("addfb2 failed: %m\n");
> @@ -325,7 +327,8 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int 
> height,
>   }
>  
>   if (ret) {
> - ret = drmModeAddFB(b->drm.fd, width, height, depth, bpp,
> + ret = drmModeAddFB(b->drm.fd, width, height,
> +fb->format->depth, fb->format->bpp,
>  fb->stride, fb->handle, &fb->fb_id);
>   }
>  
> @@ -402,9 +405,16 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend 
> *backend,
>   fb->height = gbm_bo_get_height(bo);
>   fb->stride = gbm_bo_get_stride(bo);
>   fb->handle = gbm_bo_get_handle(bo).u32;
> + fb->format = pixel_format_get_info(format);
>   fb->size = fb->stride * fb->height;
>   fb->fd = backend->drm.fd;
>  
> + if (!fb->format) {
> + weston_log("couldn't look up format 0x%lx\n",
> +(unsigned long) format);
> + goto err_free;
> + }
> +
>   if (backend->min_width > fb->width ||
>   fb->width > backend->max_width ||
>   backend->min_height > fb->height ||
> @@ -430,9 +440,10 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend 
> *backend,
>   }
>   }
>  
> - if (ret)
> + if (ret && fb->format->depth && fb->format->bpp)
>   ret = drmModeAddFB(backend->drm.fd, fb->width, fb->height,
> -24, 32, fb->stride, fb->handle, &fb->fb_id);
> +fb->format->depth, fb->format->bpp,
> +fb->stride, fb->handle, &fb->fb_id);
>  
>   if (ret) {
>   weston_log("failed to create kms fb: %m\n");
> 




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

Re: [PATCH weston 14/68] compositor-drm: Store width and height inside drm_fb

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> This will be used so we can later determine the compatibility of drm_fbs
> without needing to introspect external state.
> 
> Differential Revision: https://phabricator.freedesktop.org/D1487
> 
> Signed-off-by: Daniel Stone 

Looks fine.

Reviewed-by: Armin Krezović 

> ---
>  libweston/compositor-drm.c | 24 +---
>  1 file changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index a5052b9..4ef7343 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -131,6 +131,7 @@ struct drm_mode {
>  
>  struct drm_fb {
>   uint32_t fb_id, stride, handle, size;
> + int width, height;
>   int fd;
>   int is_client_buffer;
>   struct weston_buffer_reference buffer_ref;
> @@ -292,6 +293,8 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int 
> height,
>   fb->handle = create_arg.handle;
>   fb->stride = create_arg.pitch;
>   fb->size = create_arg.size;
> + fb->width = width;
> + fb->height = height;
>   fb->fd = b->drm.fd;
>  
>   ret = -1;
> @@ -371,7 +374,6 @@ drm_fb_get_from_bo(struct gbm_bo *bo,
>  struct drm_backend *backend, uint32_t format)
>  {
>   struct drm_fb *fb = gbm_bo_get_user_data(bo);
> - int width, height;
>   uint32_t handles[4] = { 0 }, pitches[4] = { 0 }, offsets[4] = { 0 };
>   int ret;
>  
> @@ -384,17 +386,17 @@ drm_fb_get_from_bo(struct gbm_bo *bo,
>  
>   fb->bo = bo;
>  
> - width = gbm_bo_get_width(bo);
> - height = gbm_bo_get_height(bo);
> + fb->width = gbm_bo_get_width(bo);
> + fb->height = gbm_bo_get_height(bo);
>   fb->stride = gbm_bo_get_stride(bo);
>   fb->handle = gbm_bo_get_handle(bo).u32;
> - fb->size = fb->stride * height;
> + fb->size = fb->stride * fb->height;
>   fb->fd = backend->drm.fd;
>  
> - if (backend->min_width > width ||
> - width > backend->max_width ||
> - backend->min_height > height ||
> - height > backend->max_height) {
> + if (backend->min_width > fb->width ||
> + fb->width > backend->max_width ||
> + backend->min_height > fb->height ||
> + fb->height > backend->max_height) {
>   weston_log("bo geometry out of bounds\n");
>   goto err_free;
>   }
> @@ -406,7 +408,7 @@ drm_fb_get_from_bo(struct gbm_bo *bo,
>   pitches[0] = fb->stride;
>   offsets[0] = 0;
>  
> - ret = drmModeAddFB2(backend->drm.fd, width, height,
> + ret = drmModeAddFB2(backend->drm.fd, fb->width, fb->height,
>   format, handles, pitches, offsets,
>   &fb->fb_id, 0);
>   if (ret) {
> @@ -417,8 +419,8 @@ drm_fb_get_from_bo(struct gbm_bo *bo,
>   }
>  
>   if (ret)
> - ret = drmModeAddFB(backend->drm.fd, width, height, 24, 32,
> -fb->stride, fb->handle, &fb->fb_id);
> + ret = drmModeAddFB(backend->drm.fd, fb->width, fb->height,
> +24, 32, fb->stride, fb->handle, &fb->fb_id);
>  
>   if (ret) {
>   weston_log("failed to create kms fb: %m\n");
> 




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


Re: [PATCH weston 13/68] compositor-drm: Use signed int for width/height

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> This makes it sign-compatible with weston_output->{width,height}.
> 
> Differential Revision: https://phabricator.freedesktop.org/D1486
> 
> Signed-off-by: Daniel Stone 
> Reviewed-by: Quentin Glidic 

Makes sense

Reviewed-by: Armin Krezović 

> ---
>  libweston/compositor-drm.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index a9bde0c..a5052b9 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -104,8 +104,8 @@ struct drm_backend {
>* due to out of bounds dimensions, and then mistakenly set
>* sprites_are_broken:
>*/
> - uint32_t min_width, max_width;
> - uint32_t min_height, max_height;
> + int min_width, max_width;
> + int min_height, max_height;
>   int no_addfb2;
>  
>   struct wl_list sprite_list;
> @@ -253,7 +253,7 @@ drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
>  }
>  
>  static struct drm_fb *
> -drm_fb_create_dumb(struct drm_backend *b, unsigned width, unsigned height,
> +drm_fb_create_dumb(struct drm_backend *b, int width, int height,
>  uint32_t format)
>  {
>   struct drm_fb *fb;
> @@ -371,7 +371,7 @@ drm_fb_get_from_bo(struct gbm_bo *bo,
>  struct drm_backend *backend, uint32_t format)
>  {
>   struct drm_fb *fb = gbm_bo_get_user_data(bo);
> - uint32_t width, height;
> + int width, height;
>   uint32_t handles[4] = { 0 }, pitches[4] = { 0 }, offsets[4] = { 0 };
>   int ret;
>  
> @@ -391,7 +391,8 @@ drm_fb_get_from_bo(struct gbm_bo *bo,
>   fb->size = fb->stride * height;
>   fb->fd = backend->drm.fd;
>  
> - if (backend->min_width > width || width > backend->max_width ||
> + if (backend->min_width > width ||
> + width > backend->max_width ||
>   backend->min_height > height ||
>   height > backend->max_height) {
>   weston_log("bo geometry out of bounds\n");
> 

Ha, the patch description didn't mention coding style fix!

(Just kidding)



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


Re: [PATCH weston 12/68] compositor-drm: Use fb->fd consistently

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> Everyone else uses fb->fd rather than pulling the FD back out of GBM.
> Use that in the destroy callback too.
> 
> Signed-off-by: Daniel Stone 
> 

Makes sense.

Reviewed-by: Armin Krezović 

> Differential Revision: https://phabricator.freedesktop.org/D1406
> ---
>  libweston/compositor-drm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 3276ed0..a9bde0c 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -243,10 +243,9 @@ static void
>  drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
>  {
>   struct drm_fb *fb = data;
> - struct gbm_device *gbm = gbm_bo_get_device(bo);
>  
>   if (fb->fb_id)
> - drmModeRmFB(gbm_device_get_fd(gbm), fb->fb_id);
> + drmModeRmFB(fb->fd, fb->fb_id);
>  
>   weston_buffer_reference(&fb->buffer_ref, NULL);
>  
> 




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


Re: [PATCH weston 09/68] compositor-drm: Reshuffle and comment plane conditions

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> Try to harmonise the various plane-import paths a little bit, starting
> with reshuffling and commenting the conditions to do so.
> 
> Signed-off-by: Daniel Stone 
> 

This makes code more readable and understandable. So have a

Reviewed-by: Armin Krezović 

> Differential Revision: https://phabricator.freedesktop.org/D1413
> ---
>  libweston/compositor-drm.c | 79 
> --
>  1 file changed, 48 insertions(+), 31 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 5fb45b4..8cd9d5a 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -502,18 +502,28 @@ drm_output_prepare_scanout_view(struct drm_output 
> *output,
>   struct gbm_bo *bo;
>   uint32_t format;
>  
> - if (ev->geometry.x != output->base.x ||
> - ev->geometry.y != output->base.y ||
> - buffer == NULL || b->gbm == NULL ||
> - buffer->width != output->base.current_mode->width ||
> - buffer->height != output->base.current_mode->height ||
> - output->base.transform != viewport->buffer.transform ||
> - ev->transform.enabled)
> + /* We use GBM to import buffers. */
> + if (b->gbm == NULL)
> + return NULL;
> +
> + if (buffer == NULL)
>   return NULL;
>  
> + /* Make sure our view is exactly compatible with the output. */
> + if (ev->geometry.x != output->base.x ||
> + ev->geometry.y != output->base.y)
> + return NULL;
> + if (ev->transform.enabled)
> + return NULL;
>   if (ev->geometry.scissor_enabled)
>   return NULL;
>  
> + if (buffer->width != output->base.current_mode->width ||
> + buffer->height != output->base.current_mode->height)
> + return NULL;
> + if (viewport->buffer.transform != output->base.transform)
> + return NULL;
> +
>   bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_WL_BUFFER,
>  buffer->resource, GBM_BO_USE_SCANOUT);
>  
> @@ -950,34 +960,33 @@ drm_output_prepare_overlay_view(struct drm_output 
> *output,
>   uint32_t format;
>   wl_fixed_t sx1, sy1, sx2, sy2;
>  
> - if (b->gbm == NULL)
> - return NULL;
> -
> - if (viewport->buffer.transform != output->base.transform)
> - return NULL;
> -
> - if (viewport->buffer.scale != output->base.current_scale)
> - return NULL;
> -
>   if (b->sprites_are_broken)
>   return NULL;
>  
> + /* Don't import buffers which span multiple outputs. */
>   if (ev->output_mask != (1u << output->base.id))
>   return NULL;
>  
> - if (ev->surface->buffer_ref.buffer == NULL)
> + /* We can only import GBM buffers. */
> + if (b->gbm == NULL)
>   return NULL;
> - buffer_resource = ev->surface->buffer_ref.buffer->resource;
>  
> - if (ev->alpha != 1.0f)
> + if (ev->surface->buffer_ref.buffer == NULL)
>   return NULL;
> -
> + buffer_resource = ev->surface->buffer_ref.buffer->resource;
>   if (wl_shm_buffer_get(buffer_resource))
>   return NULL;
>  
> + if (viewport->buffer.transform != output->base.transform)
> + return NULL;
> + if (viewport->buffer.scale != output->base.current_scale)
> + return NULL;
>   if (!drm_view_transform_supported(ev))
>   return NULL;
>  
> + if (ev->alpha != 1.0f)
> + return NULL;
> +
>   wl_list_for_each(s, &b->sprite_list, link) {
>   if (!drm_sprite_crtc_supported(output, s))
>   continue;
> @@ -1114,23 +1123,20 @@ drm_output_prepare_cursor_view(struct drm_output 
> *output,
>   struct weston_buffer_viewport *viewport = &ev->surface->buffer_viewport;
>   struct wl_shm_buffer *shmbuf;
>  
> - if (ev->transform.enabled &&
> - (ev->transform.matrix.type > WESTON_MATRIX_TRANSFORM_TRANSLATE))
> - return NULL;
> - if (b->gbm == NULL)
> - return NULL;
> - if (output->base.transform != WL_OUTPUT_TRANSFORM_NORMAL)
> - return NULL;
> - if (viewport->buffer.scale != output->base.current_scale)
> + if (b->cursors_are_broken)
>   return NULL;
> +
>   if (output->cursor_view)
>   return NULL;
> +
&

Re: [PATCH weston 08/68] compositor-drm: Extract EGL destroy to helper

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> No functional change.
> 
> Differential Revision: https://phabricator.freedesktop.org/D1484
> 
> Signed-off-by: Daniel Stone 

Nice

Reviewed-by: Armin Krezović 

> ---
>  libweston/compositor-drm.c | 26 +++---
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 2d5faa0..5fb45b4 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -1322,9 +1322,6 @@ drm_assign_planes(struct weston_output *output_base)
>   pixman_region32_fini(&overlap);
>  }
>  
> -static void
> -drm_output_fini_pixman(struct drm_output *output);
> -
>  /**
>   * Find the closest-matching mode for a given target
>   *
> @@ -1363,8 +1360,12 @@ choose_mode (struct drm_output *output, struct 
> weston_mode *target_mode)
>  
>  static int
>  drm_output_init_egl(struct drm_output *output, struct drm_backend *b);
> +static void
> +drm_output_fini_egl(struct drm_output *output);
>  static int
>  drm_output_init_pixman(struct drm_output *output, struct drm_backend *b);
> +static void
> +drm_output_fini_pixman(struct drm_output *output);
>  
>  static int
>  drm_output_switch_mode(struct weston_output *output_base, struct weston_mode 
> *mode)
> @@ -1414,9 +1415,7 @@ drm_output_switch_mode(struct weston_output 
> *output_base, struct weston_mode *mo
>   return -1;
>   }
>   } else {
> - gl_renderer->output_destroy(&output->base);
> - gbm_surface_destroy(output->gbm_surface);
> -
> + drm_output_fini_egl(output);
>   if (drm_output_init_egl(output, b) < 0) {
>   weston_log("failed to init output egl state with "
>  "new mode");
> @@ -1853,6 +1852,13 @@ drm_output_init_egl(struct drm_output *output, struct 
> drm_backend *b)
>   return 0;
>  }
>  
> +static void
> +drm_output_fini_egl(struct drm_output *output)
> +{
> + gl_renderer->output_destroy(&output->base);
> + gbm_surface_destroy(output->gbm_surface);
> +}
> +
>  static int
>  drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
>  {
> @@ -2423,12 +2429,10 @@ drm_output_deinit(struct weston_output *base)
>   struct drm_output *output = to_drm_output(base);
>   struct drm_backend *b = to_drm_backend(base->compositor);
>  
> - if (b->use_pixman) {
> + if (b->use_pixman)
>   drm_output_fini_pixman(output);
> - } else {
> - gl_renderer->output_destroy(&output->base);
> - gbm_surface_destroy(output->gbm_surface);
> - }
> + else
> + drm_output_fini_egl(output);
>  
>   weston_plane_release(&output->fb_plane);
>   weston_plane_release(&output->cursor_plane);
> 




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


Re: [PATCH weston 04/68] compositor-drm: Delete drm_backend_set_modes

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> Even if we do have a framebuffer matching the mode, we immediately
> schedule a repaint, meaning we either do work for no reason, or show
> stale content before we bring up the new content.
> 
> Delete this and just let repaint deal with it.
> 
> Differential Revision: https://phabricator.freedesktop.org/D1481
> 
> Signed-off-by: Daniel Stone 

Since drm_output_repaint() calls drmModeSetCrtc() when needed and
weston_compositor_damage_all() will schedule a repaint, this makes
sense.

Reviewed-by: Armin Krezović 

> ---
>  libweston/compositor-drm.c | 33 -
>  1 file changed, 33 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 268117d..7d1c01b 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -2824,38 +2824,6 @@ drm_destroy(struct weston_compositor *ec)
>  }
>  
>  static void
> -drm_backend_set_modes(struct drm_backend *backend)
> -{
> - struct drm_output *output;
> - struct drm_mode *drm_mode;
> - int ret;
> -
> - wl_list_for_each(output, &backend->compositor->output_list, base.link) {
> - if (!output->current) {
> - /* If something that would cause the output to
> -  * switch mode happened while in another vt, we
> -  * might not have a current drm_fb. In that case,
> -  * schedule a repaint and let drm_output_repaint
> -  * handle setting the mode. */
> - weston_output_schedule_repaint(&output->base);
> - continue;
> - }
> -
> - drm_mode = (struct drm_mode *) output->base.current_mode;
> - ret = drmModeSetCrtc(backend->drm.fd, output->crtc_id,
> -  output->current->fb_id, 0, 0,
> -  &output->connector_id, 1,
> -  &drm_mode->mode_info);
> - if (ret < 0) {
> - weston_log(
> - "failed to set mode %dx%d for output at %d,%d: 
> %m\n",
> - drm_mode->base.width, drm_mode->base.height,
> - output->base.x, output->base.y);
> - }
> - }
> -}
> -
> -static void
>  session_notify(struct wl_listener *listener, void *data)
>  {
>   struct weston_compositor *compositor = data;
> @@ -2866,7 +2834,6 @@ session_notify(struct wl_listener *listener, void *data)
>   if (compositor->session_active) {
>   weston_log("activating session\n");
>   compositor->state = b->prev_state;
> - drm_backend_set_modes(b);
>   weston_compositor_damage_all(compositor);
>   udev_input_enable(&b->input);
>   } else {
> 




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


Re: [PATCH weston 03/68] compositor-drm: Comment struct members

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> Clarify the difference between crtc_id (DRM object) and pipe (index into
> drmModeRes->crtcs array, possible_crtcs bitmask).
> 
> Signed-off-by: Daniel Stone 
> Reviewed-by: Quentin Glidic 
> Differential Revision: https://phabricator.freedesktop.org/D1405

Documenting structure members is always welcome.

Reviewed-by: Armin Krezović 

(this time it's me!)

> ---
>  libweston/compositor-drm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index a899213..268117d 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -155,8 +155,8 @@ struct drm_output {
>   struct weston_output base;
>   drmModeConnector *connector;
>  
> - uint32_t crtc_id;
> - int pipe;
> + uint32_t crtc_id; /* object ID to pass to DRM functions */
> + int pipe; /* index of CRTC in resource array / bitmasks */
>   uint32_t connector_id;
>   drmModeCrtcPtr original_crtc;
>   struct drm_edid edid;
> 




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


Re: [PATCH weston 02/68] meson: pixel-formats

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> Differential Revision: https://phabricator.freedesktop.org/D1512
> ---
>  libweston/meson.build | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libweston/meson.build b/libweston/meson.build
> index d396c00..aee444a 100644
> --- a/libweston/meson.build
> +++ b/libweston/meson.build
> @@ -19,6 +19,7 @@ srcs_libweston = [
>   'noop-renderer.c',
>   'pixman-renderer.c',
>   'linux-dmabuf.c',
> + 'pixel-formats.c',
>   'screenshooter.c',
>   '../shared/file-util.c',
>   '../shared/matrix.c',
> 

Since when is meson supported? I don't see it in git master.



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


Re: [PATCH weston 01/68] libweston: Add pixel-format helpers

2016-12-09 Thread Armin Krezović
On 09.12.2016 20:57, Daniel Stone wrote:
> Rather than duplicating knowledge of pixel formats across several
> components, create a custom central repository.
> 

Hi,

> Signed-off-by: Daniel Stone 
> 
> Differential Revision: https://phabricator.freedesktop.org/D1511
> ---
>  libweston/pixel-formats.c | 398 
> ++
>  libweston/pixel-formats.h | 112 +
>  2 files changed, 510 insertions(+)
>  create mode 100644 libweston/pixel-formats.c
>  create mode 100644 libweston/pixel-formats.h
> 

Where are corresponding build system modifications?

> diff --git a/libweston/pixel-formats.c b/libweston/pixel-formats.c
> new file mode 100644
> index 000..9c70e73
> --- /dev/null
> +++ b/libweston/pixel-formats.c
> @@ -0,0 +1,398 @@
> +/*
> + * 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.
> + *
> + * Author: Daniel Stone 
> + */
> +
> +#include "config.h"
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "helpers.h"
> +#include "wayland-util.h"
> +#include "pixel-formats.h"
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +

Is it supposed to work without EGL/GLESv2 enabled?

> +#include "weston-egl-ext.h"
> +
> +/**
> + * Table of DRM formats supported by Weston; RGB, ARGB and YUV formats are
> + * supported. Indexed/greyscale formats, and formats not containing complete
> + * colour channels, are not supported.
> + */

I expected something using this immediately. I suggest you squash it with 
something
else that uses this.



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


Re: [PATCH weston v2] compositor-wayland: Port to xdg-shell-v6

2016-11-21 Thread Armin Krezović
On 21.11.2016 18:42, Armin Krezović wrote:
> v2:
> 
>  - Keep wl_shell code around until xdg_shell is declared stable.
> 
> Signed-off-by: Armin Krezović 

I hereby agree that the following changes can be merged as part of this patch:

https://phabricator.freedesktop.org/P6

> ---
>  Makefile.am|   8 ++-
>  libweston/compositor-wayland.c | 146 
> +
>  2 files changed, 139 insertions(+), 15 deletions(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index b08ce71..b90c4c8 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -391,9 +391,11 @@ wayland_backend_la_CFLAGS =  \
>   $(CAIRO_CFLAGS) \
>   $(WAYLAND_COMPOSITOR_CFLAGS)\
>   $(AM_CFLAGS)
> -wayland_backend_la_SOURCES = \
> - libweston/compositor-wayland.c  \
> - libweston/compositor-wayland.h  \
> +wayland_backend_la_SOURCES = \
> + libweston/compositor-wayland.c  \
> + libweston/compositor-wayland.h  \
> + protocol/xdg-shell-unstable-v6-protocol.c   \
> + protocol/xdg-shell-unstable-v6-client-protocol.h\
>   shared/helpers.h
>  nodist_wayland_backend_la_SOURCES =  \
>   protocol/fullscreen-shell-unstable-v1-protocol.c\
> diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
> index 775da25..6ac11eb 100644
> --- a/libweston/compositor-wayland.c
> +++ b/libweston/compositor-wayland.c
> @@ -51,6 +51,7 @@
>  #include "shared/os-compatibility.h"
>  #include "shared/cairo-util.h"
>  #include "fullscreen-shell-unstable-v1-client-protocol.h"
> +#include "xdg-shell-unstable-v6-client-protocol.h"
>  #include "presentation-time-server-protocol.h"
>  #include "linux-dmabuf.h"
>  #include "windowed-output-api.h"
> @@ -66,6 +67,7 @@ struct wayland_backend {
>   struct wl_registry *registry;
>   struct wl_compositor *compositor;
>   struct wl_shell *shell;
> + struct zxdg_shell_v6 *xdg_shell;
>   struct zwp_fullscreen_shell_v1 *fshell;
>   struct wl_shm *shm;
>  
> @@ -98,7 +100,10 @@ struct wayland_output {
>   uint32_t global_id;
>  
>   struct wl_shell_surface *shell_surface;
> + struct zxdg_surface_v6 *xdg_surface;
> + struct zxdg_toplevel_v6 *xdg_toplevel;
>   int configure_width, configure_height;
> + bool wait_for_configure;
>   } parent;
>  
>   int keyboard_count;
> @@ -623,6 +628,12 @@ wayland_output_repaint_pixman(struct weston_output 
> *output_base,
>  static void
>  wayland_backend_destroy_output_surface(struct wayland_output *output)
>  {
> + if (output->parent.xdg_toplevel)
> + zxdg_toplevel_v6_destroy(output->parent.xdg_toplevel);
> +
> + if (output->parent.xdg_surface)
> + zxdg_surface_v6_destroy(output->parent.xdg_surface);
> +
>   if (output->parent.shell_surface)
>   wl_shell_surface_destroy(output->parent.shell_surface);
>  
> @@ -822,6 +833,9 @@ wayland_output_set_windowed(struct wayland_output *output)
>   title = strdup(WINDOW_TITLE);
>   }
>  
> + if (output->parent.xdg_toplevel)
> + zxdg_toplevel_v6_set_title(output->parent.xdg_toplevel, title);
> +
>   if (!b->theme) {
>   b->theme = theme_create();
>   if (!b->theme) {
> @@ -840,7 +854,8 @@ wayland_output_set_windowed(struct wayland_output *output)
>  
>   wayland_output_resize_surface(output);
>  
> - wl_shell_surface_set_toplevel(output->parent.shell_surface);
> + if (output->parent.shell_surface)
> + wl_shell_surface_set_toplevel(output->parent.shell_surface);
>  
>   return 0;
>  }
> @@ -860,7 +875,9 @@ wayland_output_set_fullscreen(struct wayland_output 
> *output,
>  
>   wayland_output_resize_surface(output);
>  
> - if (output->parent.shell_surface) {
> + if (output->parent.xdg_toplevel) {
> + zxdg_toplevel_v6_set_fullscreen(output->parent.xdg_toplevel, 
> target);
> + } else if (output->parent.shell_surface) {
>   wl_shell_surface_set_fullscreen(output->parent.shell_surface,
>   method, framerate, target);
>   } else if (b->parent.fshell) {
> @@ -961,7 +978,7 @@ wayland_output_switch_mode(struct weston_o

[PATCH weston v2] compositor-wayland: Port to xdg-shell-v6

2016-11-21 Thread Armin Krezović
v2:

 - Keep wl_shell code around until xdg_shell is declared stable.

Signed-off-by: Armin Krezović 
---
 Makefile.am|   8 ++-
 libweston/compositor-wayland.c | 146 +
 2 files changed, 139 insertions(+), 15 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b08ce71..b90c4c8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -391,9 +391,11 @@ wayland_backend_la_CFLAGS =\
$(CAIRO_CFLAGS) \
$(WAYLAND_COMPOSITOR_CFLAGS)\
$(AM_CFLAGS)
-wayland_backend_la_SOURCES =   \
-   libweston/compositor-wayland.c  \
-   libweston/compositor-wayland.h  \
+wayland_backend_la_SOURCES =   \
+   libweston/compositor-wayland.c  \
+   libweston/compositor-wayland.h  \
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
shared/helpers.h
 nodist_wayland_backend_la_SOURCES =\
protocol/fullscreen-shell-unstable-v1-protocol.c\
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 775da25..6ac11eb 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -51,6 +51,7 @@
 #include "shared/os-compatibility.h"
 #include "shared/cairo-util.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "presentation-time-server-protocol.h"
 #include "linux-dmabuf.h"
 #include "windowed-output-api.h"
@@ -66,6 +67,7 @@ struct wayland_backend {
struct wl_registry *registry;
struct wl_compositor *compositor;
struct wl_shell *shell;
+   struct zxdg_shell_v6 *xdg_shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
 
@@ -98,7 +100,10 @@ struct wayland_output {
uint32_t global_id;
 
struct wl_shell_surface *shell_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
int configure_width, configure_height;
+   bool wait_for_configure;
} parent;
 
int keyboard_count;
@@ -623,6 +628,12 @@ wayland_output_repaint_pixman(struct weston_output 
*output_base,
 static void
 wayland_backend_destroy_output_surface(struct wayland_output *output)
 {
+   if (output->parent.xdg_toplevel)
+   zxdg_toplevel_v6_destroy(output->parent.xdg_toplevel);
+
+   if (output->parent.xdg_surface)
+   zxdg_surface_v6_destroy(output->parent.xdg_surface);
+
if (output->parent.shell_surface)
wl_shell_surface_destroy(output->parent.shell_surface);
 
@@ -822,6 +833,9 @@ wayland_output_set_windowed(struct wayland_output *output)
title = strdup(WINDOW_TITLE);
}
 
+   if (output->parent.xdg_toplevel)
+   zxdg_toplevel_v6_set_title(output->parent.xdg_toplevel, title);
+
if (!b->theme) {
b->theme = theme_create();
if (!b->theme) {
@@ -840,7 +854,8 @@ wayland_output_set_windowed(struct wayland_output *output)
 
wayland_output_resize_surface(output);
 
-   wl_shell_surface_set_toplevel(output->parent.shell_surface);
+   if (output->parent.shell_surface)
+   wl_shell_surface_set_toplevel(output->parent.shell_surface);
 
return 0;
 }
@@ -860,7 +875,9 @@ wayland_output_set_fullscreen(struct wayland_output *output,
 
wayland_output_resize_surface(output);
 
-   if (output->parent.shell_surface) {
+   if (output->parent.xdg_toplevel) {
+   zxdg_toplevel_v6_set_fullscreen(output->parent.xdg_toplevel, 
target);
+   } else if (output->parent.shell_surface) {
wl_shell_surface_set_fullscreen(output->parent.shell_surface,
method, framerate, target);
} else if (b->parent.fshell) {
@@ -961,7 +978,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
 
b = to_wayland_backend(output_base->compositor);
 
-   if (output->parent.shell_surface || !b->parent.fshell)
+   if (output->parent.xdg_surface || output->parent.shell_surface || 
!b->parent.fshell)
return -1;
 
mode = wayland_output_choose_mode(output, mode);
@@ -1033,6 +1050,41 @@ err_output:
return -1;
 }
 
+static void
+handle_xdg_surface_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
+{
+   zxdg_surface_v6_ack_configure(surface, serial);
+}
+
+static const struct

Re: [PATCH weston 09/10] compositor-wayland: Port to xdg-shell-v6

2016-11-21 Thread Armin Krezović
On 21.11.2016 17:37, Daniel Stone wrote:
> Hi Armin,
> 
> On 9 October 2016 at 16:30, Armin Krezović  wrote:
>> Signed-off-by: Armin Krezović 
> 
> Could you please spin another version which doesn't jettison wl_shell
> support? I know it's lame, but it's the only thing which is actually
> stable enough to predictably run across a wide range of versions.
> Until xdg_shell has managed to ship one stable version for a little
> while, I think we need to keep wl_shell for our Wayland backend.
> (Ideally also for simple-shm/simple-egl: when the initial xdg_shell
> conversion landed and wl_shell was removed, I think everyone was under
> the impression it would stabilise far sooner than it has ...)
> 
> Cheers,
> Daniel
> 

Alright, fair enough.



signature.asc
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/2] compositor-drm: Restore use-current-mode functionality

2016-11-10 Thread Armin Krezović
On 09.11.2016 15:43, Daniel Stone wrote:
> Hi Armin,
> 

Hi,

> On 9 October 2016 at 22:48, Armin Krezović  wrote:
>> diff --git a/compositor/main.c b/compositor/main.c
>> index 320305c..ffeadfb 100644
>> --- a/compositor/main.c
>> +++ b/compositor/main.c
>> @@ -78,6 +78,7 @@ struct wet_compositor {
>> struct weston_config *config;
>> struct wet_output_config *parsed_options;
>> struct wl_listener pending_output_listener;
>> +   bool drm_use_current_mode;
>>  };
> 
> I'm fairly confused about this one, though I freely admit I didn't
> track the libweston config work, so may have missed something.
> 
> What makes --use-current-mode special enough that it should be the
> only such option inside struct wet_compositor? What makes it different
> to, say, use_pixman, which lives in the DRM backend?
> 

The thing is, --use-pixman flag is used in many places throughout the backend,
while --use-current-mode is only used by function that sets the mode. That
function is now called by the user, and is required to be called before
enabling the output, whereas it was previously done in the backend itself, and
it got the necessary configuration values by calling into an user-defined 
function
(configure output -> user defined function -> set mode).

>> @@ -1138,7 +1140,7 @@ drm_backend_output_configure(struct wl_listener 
>> *listener, void *data)
>> weston_output_disable(output);
>> free(s);
>> return;
>> -   } else if (strcmp(s, "current") == 0) {
>> +   } else if (wet->drm_use_current_mode || strcmp(s, "current") == 0) {
>> mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
>> } else if (strcmp(s, "preferred") != 0) {
>> modeline = s;
> 
> What would the difference be to making this check be 'else if
> (b->use_current_mode || strcmp(s, "current") == 0)'?
> 
> Cheers,
> Daniel
> 

struct drm_backend is private to compositor-drm.c as far as I'm aware. We can't
use it here.



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


Re: weston and graphics tablet support?

2016-10-31 Thread Armin Krezović
On 30.10.2016 23:59, Peter Hutterer wrote:
> On Fri, Oct 28, 2016 at 12:32:00PM +0200, Armin Krezović wrote:
>> Hi
>>
>> On 28.10.2016 07:22, Peter Hutterer wrote:
>>> Time to discuss graphics tablet support in weston: I had a patchset for some
>>> earlier version of the tablet protocol, since then we've added a few bits
>>> and bobs, including the mode switching support.
>>>
>>> Short story behind this email is: I seriously question the point of having a
>>> tablet implementation in weston. I know it's supposed to be the test bed for
>>> protocols (fwiw, we already have mutter + GTK support for tablets). But in
>>> order to test this particular protocol, a lot of supporting infrastructure
>>> has to be there that libtoytoolkit doesn't have. In addition, there are a
>>> couple of things to be added to the compositor support, especially for mode
>>> switching, that I question the value of having this in weston at all [1].
>>>
>>
>> What infrastructure is toytoolkit missing?
> 
> proper events. right now, the events come from the compositor, are maybe
> handled a little bit and passed straight into the client. but it's still
> essentially a straight wayland-event to function pointer mapping. for tablet
> events, the only sensible thing would be to accumulate them in the tool kit,
> then pass them on as opaque event objects to the clients. otherwise, you'll
> have handlers for pressure, tilt, distance, axis, etc. in every client and
> they all have their own way of accumulating them until the frame event
> arrives.
> 

Can't this be done in the compositor?

>> What other compositor features besides the mode switching are missing?
> 
> Automatic and semantic mapping of the tablets to the right monitor. requires
> libwacom to check if it's built-in and some heuristics to get the output
> correct. e.g. Cintiqs are built into a monitor, but laptop-integrated need
> to map to the built-in screen.
> 
> Ratio mapping for external tablets - a 16:10 tablet mapped onto 4:3 monitor
> needs to have its area adjusted so that the input data isn't skewed. This
> has a couple of other implementation questions - do you just clip
> coordinates or do you fake a proximity out in the compositor when you leave
> the active area?
> 
> Relative vs absolute mode switching - somewhere we need the decision which
> input data to use and how to switch it on the fly. Admittedly, we probably
> get by just leaving the mouse in relative mode and everything else in
> absolute.
> 
> Once you want to actually use your pen in a serious manner, you need to
> handle pressure curves as well. Could be done in the compositor or the
> toolkit, jury's still out on that. But the pressure curve essentially means
> that you can configure a physical:virtual pressure mapping to make the
> tool behave like a pencil or a brush, etc.
> 
>> There's support for mode switching in libweston itself, such as
>> weston_output_mode_switch_to_temporary and 
>> weston_output_mode_switch_to_native
>>
>> What's wrong with them? Do they need some enhancements (I understand that not
>> all backends support this - but I can implement it for X11 backend, and we
>> can fake it for the headless one)? 
> 
> it's a different type of mode switch. forget about output stuff here, mode
> switching for tablets means that one tablet button toggles through (or
> directly selects) a mode. That mode then applies to the touch ring/strip and
> optionally the buttons. So in mode 0, your ring may be a scroll wheel, in
> mode 1 it zooms, in mode 2 it pans and in mode 3 it rotates. Button 1 may be
> a left mouse button in mode 0, select the eraser tool in mode 1, etc.
> 
> This is all stuff that's way beyond something called "toytoolkit" :)
> 
> Cheers,
>Peter
> 
>>
>>> Some or most of this work will likely end up being an unused (and thus
>>> untested) code path, the compositors that care about a niche feature like
>>> graphics tablet support are unlikely to be the ones that use libweston.
>>>
>>> So right now, I'm tending to *not* implementing tablet support for weston.
>>> Any opinions? Yay? Nay? Banana!?
>>>
>>> Cheers,
>>>Peter
>>>
>>> [1] yes, you can attribute some of all this to laziness

I agree with what Daniel has said. It would be nice to have a reference 
implementation,
at least on the server side. And now that there's libweston, it can be utilized 
by
others, too.

Thanks, Armin.



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


[PATCH weston 1/2] compositor-x11: Move vfunc setting from set_size to enable

2016-10-28 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-x11.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index 1c6de08..7709d8f 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -917,6 +917,7 @@ x11_output_enable(struct weston_output *base)
weston_log("Failed to create pixman renderer for 
output\n");
x11_output_deinit_shm(b, output);
goto err;
+   output->base.repaint = x11_output_repaint_shm;
}
} else {
/* eglCreatePlatformWindowSurfaceEXT takes a Window*
@@ -931,8 +932,16 @@ x11_output_enable(struct weston_output *base)
 0);
if (ret < 0)
goto err;
+
+   output->base.repaint = x11_output_repaint_gl;
}
 
+   output->base.start_repaint_loop = x11_output_start_repaint_loop;
+   output->base.assign_planes = NULL;
+   output->base.set_backlight = NULL;
+   output->base.set_dpms = NULL;
+   output->base.switch_mode = NULL;
+
loop = wl_display_get_event_loop(b->compositor->wl_display);
output->finish_frame_timer =
wl_event_loop_add_timer(loop, finish_frame_handler, output);
@@ -998,17 +1007,6 @@ x11_output_set_size(struct weston_output *base, int 
width, int height)
output->base.mm_height = height * b->screen->height_in_millimeters /
b->screen->height_in_pixels;
 
-   if (b->use_pixman)
-   output->base.repaint = x11_output_repaint_shm;
-   else
-   output->base.repaint = x11_output_repaint_gl;
-
-   output->base.start_repaint_loop = x11_output_start_repaint_loop;
-   output->base.assign_planes = NULL;
-   output->base.set_backlight = NULL;
-   output->base.set_dpms = NULL;
-   output->base.switch_mode = NULL;
-
return 0;
 }
 
-- 
2.10.1

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


[PATCH weston 2/2] compositor-x11: Implement mode switching

2016-10-28 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-x11.c | 140 ++---
 1 file changed, 132 insertions(+), 8 deletions(-)

diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index 7709d8f..a32ef8d 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -64,6 +64,12 @@
 
 #define DEFAULT_AXIS_STEP_DISTANCE 10
 
+#define WINDOW_MIN_WIDTH 128
+#define WINDOW_MIN_HEIGHT 128
+
+#define WINDOW_MAX_WIDTH 8192
+#define WINDOW_MAX_HEIGHT 8192
+
 struct x11_backend {
struct weston_backendbase;
struct weston_compositor *compositor;
@@ -113,6 +119,7 @@ struct x11_output {
 
xcb_window_twindow;
struct weston_mode  mode;
+   struct weston_mode  native;
struct wl_event_source *finish_frame_timer;
 
xcb_gc_tgc;
@@ -122,6 +129,8 @@ struct x11_output {
void   *buf;
uint8_t depth;
int32_t scale;
+   boolresize_pending;
+   boolwindow_resized;
 };
 
 struct window_delete_data {
@@ -770,6 +779,89 @@ x11_output_init_shm(struct x11_backend *b, struct 
x11_output *output,
 }
 
 static int
+x11_output_switch_mode(struct weston_output *base, struct weston_mode *mode)
+{
+   struct x11_backend *b;
+   struct x11_output *output;
+   static uint32_t values[2];
+   int ret;
+
+   if (base == NULL) {
+   weston_log("output is NULL.\n");
+   return -1;
+   }
+
+   if (mode == NULL) {
+   weston_log("mode is NULL.\n");
+   return -1;
+   }
+
+b = to_x11_backend(base->compositor);
+output = to_x11_output(base);
+
+if (mode->width == output->mode.width &&
+   mode->height == output->mode.height)
+   return 0;
+
+if (mode->width < WINDOW_MIN_WIDTH || mode->width > WINDOW_MAX_WIDTH)
+   return -1;
+
+   if (mode->height < WINDOW_MIN_HEIGHT || mode->height > 
WINDOW_MAX_HEIGHT)
+   return -1;
+
+   /* xcb_configure_window will create an event, and we could end up
+  being called twice */
+   output->resize_pending = true;
+
+   /* window could've been resized by the user, so don't do it twice */
+   if (!output->window_resized) {
+   values[0] = mode->width;
+   values[1] = mode->height;
+   xcb_configure_window(b->conn, output->window, 
XCB_CONFIG_WINDOW_WIDTH |
+XCB_CONFIG_WINDOW_HEIGHT, values);
+   }
+
+   output->mode.width = mode->width;
+   output->mode.height = mode->height;
+
+   if (b->use_pixman) {
+   pixman_renderer_output_destroy(&output->base);
+   x11_output_deinit_shm(b, output);
+
+   if (x11_output_init_shm(b, output,
+   output->base.current_mode->width,
+   output->base.current_mode->height) < 0) 
{
+   weston_log("Failed to initialize SHM for the X11 
output\n");
+   return -1;
+   }
+
+   if (pixman_renderer_output_create(&output->base) < 0) {
+   weston_log("Failed to create pixman renderer for 
output\n");
+   x11_output_deinit_shm(b, output);
+   return -1;
+   }
+   } else {
+   Window xid = (Window) output->window;
+
+   gl_renderer->output_destroy(&output->base);
+
+   ret = gl_renderer->output_create(&output->base,
+(EGLNativeWindowType) 
output->window,
+&xid,
+gl_renderer->opaque_attribs,
+NULL,
+0);
+   if (ret < 0)
+   return -1;
+   }
+
+   output->resize_pending = false;
+   output->window_resized = false;
+
+   return 0;
+}
+
+static int
 x11_output_disable(struct weston_output *base)
 {
struct x11_output *output = to_x11_output(base);
@@ -861,14 +953,13 @@ x11_output_enable(struct weston_output *base)
XCB_ATOM_ATOM, 32,
ARRAY_LENGTH(atom_list), atom_list);
} else {
-   /* Don't resize me. */
memset(&normal_hints, 0, sizeof normal_hints);
normal_hints.flags =
WM_NORMAL_HINTS_MAX_SIZE | WM_NORMAL_HINTS_MIN_SIZE;
-   

Re: weston and graphics tablet support?

2016-10-28 Thread Armin Krezović
Hi

On 28.10.2016 07:22, Peter Hutterer wrote:
> Time to discuss graphics tablet support in weston: I had a patchset for some
> earlier version of the tablet protocol, since then we've added a few bits
> and bobs, including the mode switching support.
> 
> Short story behind this email is: I seriously question the point of having a
> tablet implementation in weston. I know it's supposed to be the test bed for
> protocols (fwiw, we already have mutter + GTK support for tablets). But in
> order to test this particular protocol, a lot of supporting infrastructure
> has to be there that libtoytoolkit doesn't have. In addition, there are a
> couple of things to be added to the compositor support, especially for mode
> switching, that I question the value of having this in weston at all [1].
> 

What infrastructure is toytoolkit missing?

What other compositor features besides the mode switching are missing?

There's support for mode switching in libweston itself, such as
weston_output_mode_switch_to_temporary and weston_output_mode_switch_to_native

What's wrong with them? Do they need some enhancements (I understand that not
all backends support this - but I can implement it for X11 backend, and we
can fake it for the headless one)? 

> Some or most of this work will likely end up being an unused (and thus
> untested) code path, the compositors that care about a niche feature like
> graphics tablet support are unlikely to be the ones that use libweston.
> 
> So right now, I'm tending to *not* implementing tablet support for weston.
> Any opinions? Yay? Nay? Banana!?
> 
> Cheers,
>Peter
> 
> [1] yes, you can attribute some of all this to laziness
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 




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


Re: [PATCH weston 03/10] compositor-wayland: Convert fullscreen flag to bool

2016-10-13 Thread Armin Krezović
On 10.10.2016 14:18, Quentin Glidic wrote:
> On 09/10/2016 17:30, Armin Krezović wrote:
>> Signed-off-by: Armin Krezović 
> 
> You are missing the compositor/main.c change in this one.
> 
> Patches 1, 2 and 4 are Rb me, and pushed:
> 00a03d2..2d321e3  master -> master
> 
> Cheers,
> 
> 

Hi,

Thanks. I've sent a second version of this patch only.

Hope it won't be a problem.

>> ---
>>  libweston/compositor-wayland.c | 2 +-
>>  libweston/compositor-wayland.h | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
>> index 32c44d4..a5a360c 100644
>> --- a/libweston/compositor-wayland.c
>> +++ b/libweston/compositor-wayland.c
>> @@ -77,7 +77,7 @@ struct wayland_backend {
>>
>>  bool use_pixman;
>>  bool sprawl_across_outputs;
>> -int fullscreen;
>> +bool fullscreen;
>>
>>  struct theme *theme;
>>  cairo_device_t *frame_device;
>> diff --git a/libweston/compositor-wayland.h b/libweston/compositor-wayland.h
>> index 3ca875a..d5c29f0 100644
>> --- a/libweston/compositor-wayland.h
>> +++ b/libweston/compositor-wayland.h
>> @@ -41,7 +41,7 @@ struct weston_wayland_backend_config {
>>  bool use_pixman;
>>  bool sprawl;
>>  char *display_name;
>> -int fullscreen;
>> +bool fullscreen;
>>  char *cursor_theme;
>>  int cursor_size;
>>  };
>>
> 
> 




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


[PATCH weston 03/10 v2] compositor-wayland: Convert fullscreen flag to bool

2016-10-13 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 2 +-
 libweston/compositor-wayland.c | 2 +-
 libweston/compositor-wayland.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 320305c..8028ec3 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1577,7 +1577,7 @@ load_wayland_backend(struct weston_compositor *c,
config.cursor_size = 32;
config.cursor_theme = NULL;
config.display_name = NULL;
-   config.fullscreen = 0;
+   config.fullscreen = false;
config.sprawl = false;
config.use_pixman = false;
 
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index df34f91..d26360e 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -77,7 +77,7 @@ struct wayland_backend {
 
bool use_pixman;
bool sprawl_across_outputs;
-   int fullscreen;
+   bool fullscreen;
 
struct theme *theme;
cairo_device_t *frame_device;
diff --git a/libweston/compositor-wayland.h b/libweston/compositor-wayland.h
index 3ca875a..d5c29f0 100644
--- a/libweston/compositor-wayland.h
+++ b/libweston/compositor-wayland.h
@@ -41,7 +41,7 @@ struct weston_wayland_backend_config {
bool use_pixman;
bool sprawl;
char *display_name;
-   int fullscreen;
+   bool fullscreen;
char *cursor_theme;
int cursor_size;
 };
-- 
2.10.1

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


[PATCH weston 2/2] compositor-drm: Restore use-current-mode functionality

2016-10-09 Thread Armin Krezović
It got lost during the porting to the config API.

Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 9 +++--
 libweston/compositor-drm.c | 3 ---
 libweston/compositor-drm.h | 1 -
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 320305c..ffeadfb 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -78,6 +78,7 @@ struct wet_compositor {
struct weston_config *config;
struct wet_output_config *parsed_options;
struct wl_listener pending_output_listener;
+   bool drm_use_current_mode;
 };
 
 static FILE *weston_logfile = NULL;
@@ -1116,6 +1117,7 @@ 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 wet_compositor *wet = to_wet_compositor(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 =
@@ -1138,7 +1140,7 @@ drm_backend_output_configure(struct wl_listener 
*listener, void *data)
weston_output_disable(output);
free(s);
return;
-   } else if (strcmp(s, "current") == 0) {
+   } else if (wet->drm_use_current_mode || strcmp(s, "current") == 0) {
mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
} else if (strcmp(s, "preferred") != 0) {
modeline = s;
@@ -1176,13 +1178,16 @@ load_drm_backend(struct weston_compositor *c,
 {
struct weston_drm_backend_config config = {{ 0, }};
struct weston_config_section *section;
+   struct wet_compositor *wet = to_wet_compositor(c);
int ret = 0;
 
+   wet->drm_use_current_mode = false;
+
const struct weston_option options[] = {
{ WESTON_OPTION_INTEGER, "connector", 0, &config.connector },
{ WESTON_OPTION_STRING, "seat", 0, &config.seat_id },
{ WESTON_OPTION_INTEGER, "tty", 0, &config.tty },
-   { WESTON_OPTION_BOOLEAN, "current-mode", 0, 
&config.use_current_mode },
+   { WESTON_OPTION_BOOLEAN, "current-mode", 0, 
&wet->drm_use_current_mode },
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman },
};
 
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 795e9f0..84da32b 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -122,8 +122,6 @@ struct drm_backend {
 
int32_t cursor_width;
int32_t cursor_height;
-
-   bool use_current_mode;
 };
 
 struct drm_mode {
@@ -3177,7 +3175,6 @@ drm_backend_create(struct weston_compositor *compositor,
b->sprites_are_broken = 1;
b->compositor = compositor;
b->use_pixman = config->use_pixman;
-   b->use_current_mode = config->use_current_mode;
 
if (parse_gbm_format(config->gbm_format, GBM_FORMAT_XRGB, 
&b->gbm_format) < 0)
goto err_compositor;
diff --git a/libweston/compositor-drm.h b/libweston/compositor-drm.h
index 8f89a2b..2e2995a 100644
--- a/libweston/compositor-drm.h
+++ b/libweston/compositor-drm.h
@@ -138,7 +138,6 @@ struct weston_drm_backend_config {
 */
void (*configure_device)(struct weston_compositor *compositor,
 struct libinput_device *device);
-   bool use_current_mode;
 };
 
 #ifdef  __cplusplus
-- 
2.10.1

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


[PATCH weston 1/2] compositor-drm: Construct mode list in create_output_for_connector

2016-10-09 Thread Armin Krezović
And properly deconstruct it in drm_output_destroy.

Might be useful for finding out which modes are supported
before even setting them, in case we want to extend the
modesetting API.

Signed-off-by: Armin Krezović 
---
 libweston/compositor-drm.c | 63 +++---
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index f61e3d9..795e9f0 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2288,29 +2288,19 @@ drm_output_set_mode(struct weston_output *base,
struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
 
-   struct drm_mode *drm_mode, *next, *current;
+   struct drm_mode *current;
drmModeModeInfo crtc_mode;
-   int i;
 
output->base.make = "unknown";
output->base.model = "unknown";
output->base.serial_number = "unknown";
-   wl_list_init(&output->base.mode_list);
-
-   output->original_crtc = drmModeGetCrtc(b->drm.fd, output->crtc_id);
 
if (connector_get_current_mode(output->connector, b->drm.fd, 
&crtc_mode) < 0)
-   goto err_free;
-
-   for (i = 0; i < output->connector->count_modes; i++) {
-   drm_mode = drm_output_add_mode(output, 
&output->connector->modes[i]);
-   if (!drm_mode)
-   goto err_free;
-   }
+   return -1;
 
current = drm_output_choose_initial_mode(b, output, mode, modeline, 
&crtc_mode);
if (!current)
-   goto err_free;
+   return -1;
 
output->base.current_mode = ¤t->base;
output->base.current_mode->flags |= WL_OUTPUT_MODE_CURRENT;
@@ -2323,18 +2313,6 @@ drm_output_set_mode(struct weston_output *base,
output->base.mm_height = output->connector->mmHeight;
 
return 0;
-
-err_free:
-   drmModeFreeCrtc(output->original_crtc);
-   output->original_crtc = NULL;
-
-   wl_list_for_each_safe(drm_mode, next, &output->base.mode_list,
-   base.link) {
-   wl_list_remove(&drm_mode->base.link);
-   free(drm_mode);
-   }
-
-   return -1;
 }
 
 static void
@@ -2457,6 +2435,7 @@ drm_output_destroy(struct weston_output *base)
 {
struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
+   struct drm_mode *drm_mode, *next;
drmModeCrtcPtr origcrtc = output->original_crtc;
 
if (output->page_flip_pending) {
@@ -2468,6 +2447,12 @@ drm_output_destroy(struct weston_output *base)
if (output->base.enabled)
drm_output_deinit(&output->base);
 
+   wl_list_for_each_safe(drm_mode, next, &output->base.mode_list,
+ base.link) {
+   wl_list_remove(&drm_mode->base.link);
+   free(drm_mode);
+   }
+
if (origcrtc) {
/* Restore original CRTC state */
drmModeSetCrtc(b->drm.fd, origcrtc->crtc_id, 
origcrtc->buffer_id,
@@ -2532,17 +2517,18 @@ create_output_for_connector(struct drm_backend *b,
struct udev_device *drm_device)
 {
struct drm_output *output;
+   struct drm_mode *drm_mode;
int i;
 
i = find_crtc_for_connector(b, resources, connector);
if (i < 0) {
weston_log("No usable crtc/encoder pair for connector.\n");
-   return -1;
+   goto err;
}
 
output = zalloc(sizeof *output);
if (output == NULL)
-   return -1;
+   goto err;
 
output->connector = connector;
output->crtc_id = resources->crtcs[i];
@@ -2552,6 +2538,8 @@ create_output_for_connector(struct drm_backend *b,
output->backlight = backlight_init(drm_device,
   connector->connector_type);
 
+   output->original_crtc = drmModeGetCrtc(b->drm.fd, output->crtc_id);
+
output->base.enable = drm_output_enable;
output->base.destroy = drm_output_destroy;
output->base.disable = drm_output_disable;
@@ -2559,15 +2547,30 @@ create_output_for_connector(struct drm_backend *b,
 
output->destroy_pending = 0;
output->disable_pending = 0;
-   output->original_crtc = NULL;
 
b->crtc_allocator |= (1 << output->crtc_id);
b->connector_allocator |= (1 << output->connector_id);
 
weston_output_init(&output->base, b->compositor);
+
+   wl_list_init(&output->base.mode_list);
+
+ 

Re: [PATCH weston 4/4] compositor: Implement horizontal output layout configuration

2016-10-09 Thread Armin Krezović
On 07.10.2016 12:19, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:30 +0200
> Armin Krezović  wrote:
> 
>> This patch adds horizontal output layout configuration using
>> the previously added code.
>>
>> When an output is added, it looks for outputs that it should
>> be placed next to, if they are specified. If such output is
>> found, output layout is updated if needed (outputs on a given
>> position are moved right if they collide with the new output)
>> and the output is positioned next to the specified output,
>> either on its left or its right.
>>
>> If a certain position wasn't specified for the current output,
>> the compositor looks for any existing outputs that have
>> current output specified on that position, and updates the
>> positions accordingly, if corresponding output is found.
>>
>> Output positions can only be set once, where config file
>> specified option is always set, even if such output will
>> never be present. If a certain position wasn't set, the
>> compositor may update the position if it finds another
>> output that wants to be placed next to the output that's
>> being configured. In such case, first existing output that
>> matches the position is picked up, rest is ignored.
>>
>> Default behaviour is still to place outputs that have
>> no matching configuration top right.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  compositor/main.c | 159 
>> +++---
>>  1 file changed, 153 insertions(+), 6 deletions(-)
>>
>> diff --git a/compositor/main.c b/compositor/main.c
>> index e379d8d..c039ae6 100644
>> --- a/compositor/main.c
>> +++ b/compositor/main.c
>> @@ -480,20 +480,167 @@ wet_init_parsed_options(struct weston_compositor *ec)
>>  return config;
>>  }
>>  
>> +static struct wet_output *
>> +wet_output_from_output(struct wet_compositor *compositor, struct 
>> weston_output *output)
>> +{
>> +struct wet_output *iterator, *next;
>> +
>> +if (wl_list_empty(&compositor->output_layout_list))
>> +return NULL;
>> +
>> +wl_list_for_each_safe(iterator, next, &compositor->output_layout_list, 
>> link) {
>> +if (iterator->output == output)
>> +return iterator;
>> +}
> 
> Hi,
> 
> wet_output uses a destroy listener on the output, so use that:
> 
> listener = wl_signal_get(&output->destroy_signal, handle_output_destroy);
> wet_output = container_of(...);
> 

Thanks for the hint.

>> +
>> +return NULL;
>> +}
>> +
>> +static struct wet_output *
>> +wet_output_from_name(struct wet_compositor *compositor, const char *name)
>> +{
>> +struct wet_output *iterator, *next;
>> +
>> +if (wl_list_empty(&compositor->output_layout_list))
>> +return NULL;
>> +
>> +wl_list_for_each_safe(iterator, next, &compositor->output_layout_list, 
>> link) {
>> +if (!strcmp(iterator->output->name, name))
>> +return iterator;
>> +}
> 
> No need to check for empty list, and no need to use _safe. Applies
> probably to all loop below, too.
> 

I have been burned when using non-safe version in the past (getting
random segfaults with non-safe version and not with safe version),
so I keep on using it. I'll see if it's still needed.

>> +
>> +return NULL;
>> +}
>> +
> 
> I kind of wonder how much sense it makes to do first just 1-D layout
> and then later expand to 2-D layout. I fear the code re-use might be
> non-existant.
> 
> If you are struggling with 2-D layout, maybe X.org could provide some
> example?
> 
> I do not have a suggestion for a good layout algorithm or even a method
> of description. People have been configuring X.org for ages, so
> something similar might be familiar.
> 
> Positioning by absolute coordinates I would like to leave out if
> possible, or at least you would need to check that:
> - all outputs create a single connected region (so pointers can travel
>   everywhere)
> - no outputs overlap (IIRC this is a limitation of Weston's damage
>   tracking)
> 
> 
> Thanks,
> pq
> 

I have thought about 2D layout, but I have ran in a problem that I can't
solve.

I'll try to illustrate.


|||-|
||| |
||| |
  |_|
|--|
|  |
|  |

Re: [PATCH weston 3/4] compositor: Add internal output object used for layout configuration

2016-10-09 Thread Armin Krezović
On 07.10.2016 12:08, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:29 +0200
> Armin Krezović  wrote:
> 
>> This adds weston specific output object, which contains information
>> about output's position, relative to other outputs. DRM and Windowed
>> backends code has been updated to make use of the new code and
>> parse new configuration options for a given output, if it was
>> specified.
>>
>> New configuration file options for [output] section have been added:
>>
>> left-of: Specifies which output should be on the right side of the
>> current output.
>>
>> right-of: Specifies which output should be on the left side of the
>> current output.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  compositor/main.c | 81 
>> +++
>>  1 file changed, 81 insertions(+)
>>
>> diff --git a/compositor/main.c b/compositor/main.c
>> index 503016e..e379d8d 100644
>> --- a/compositor/main.c
>> +++ b/compositor/main.c
>> @@ -78,6 +78,18 @@ struct wet_compositor {
>>  struct weston_config *config;
>>  struct wet_output_config *parsed_options;
>>  struct wl_listener pending_output_listener;
>> +struct wl_list output_layout_list;
>> +};
>> +
>> +struct wet_output {
>> +struct weston_output *output;
>> +struct wl_listener output_destroy_listener;
>> +struct wl_list link;
>> +
>> +char *left_output_name;
>> +char *right_output_name;
> 
> Hi
> 

Salut

> Rather than linking by name, would it not be easier to link by pointer
> to struct wet_output?
> 

I can try that, too.

> That means when you encounter a directive like "left-of=F5" and there
> is no output F5 yet, you would create a new struct wet_output for F5
> but leave the weston_output pointer NULL, to be filled out if F5
> actually appears.
> 
> That means you would always have a graph in memory instead of doing
> searches to find if output of this name actually exists. I'm not sure
> if that's actually simpler in the end.
> 

I'd still have to search for a wet_output matching an output when it
gets attached (implement a way of matching an unclaimed wet_output to
weston_output), and if it isn't there, I'll have to create it. That
includes a bit of complexity too. How much however, I can't say
until I try.

> Having the complete graph would allow you to "jump over" outputs that
> do not exist at the moment: e.g. order F1 -> (F2) -> F3.
> 

That could lead to waste of memory, as the output could never get attached,
and I'll have to implement a function free-ing such outputs, as I can't rely
on output destroyed signal as I currently do. Not to mention that the third
output needs to be moved when second one gets attached, so it's not really
a win-win situation, besides having a better picture in the memory.

We could accomplish that using wl_array with this implementation (instead
of wl_list that's currently used).

In the end, the implementation looks more complex than this one, and
we already configure outputs by name, so why not simply keep it?

>> +
>> +bool position_set;
>>  };
>>  
> 
>> +weston_config_section_get_string(section, "left-of", &out, NULL);
>> +wet_output->right_output_name = out ? strdup(out) : NULL;
>> +free(out);
>> +
>> +weston_config_section_get_string(section, "right-of", &out, NULL);
>> +wet_output->left_output_name = out ? strdup(out) : NULL;
>> +free(out);
> 
> Yes, this looks like an intuitive approach, storing the relationship in
> inverse compared to how users write it out in weston.ini.
> 

Heh, this is my bad really. While rushing to finish this part before GSoC
deadline, I managed to invert the intended functionality. I just swapped
these two here, instead of going through the rest of the code as I was
sure the code would be changed anyways as soon as I send it for review.

It will be fixed as soon as we can agree on an approach.

> 
> Thanks,
> pq
> 

Cheers.



signature.asc
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/4] weston: Move output position setting to compositor

2016-10-09 Thread Armin Krezović
On 07.10.2016 11:58, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:28 +0200
> Armin Krezović  wrote:
> 
>> This moves current output positioning code and scale/transform
>> application to the compositor itself, so the compositor
>> can configure output layouts any way it wants.
>>
>> A helper function for setting x and y coordinates is also
>> added, and couple of assertions to weston_output_enable()
>> as well, to make sure everything has been set up.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  compositor/main.c  | 26 ++
>>  libweston/compositor.c | 40 ++--
>>  libweston/compositor.h |  3 +++
>>  3 files changed, 51 insertions(+), 18 deletions(-)
> 
> Hi,
> 
> moving the output positioning out from libweston and into the
> compositor is very good. The setter for x,y is good too.
> 
> I'm just not sure we should assume that outputs cannot occupy the
> negative coordinates. If one hotplugs an output to the left, I'd assume
> the existing windows would stay put on the right. If we cannot use
> negative coordinates, everything has to be moved to keep them at the
> same position from the user point of view.
> 
> 
> Thanks,
> pq
> 

Hi,

I'd rather go for the second approach - move everything to the output it
was on, in case an output gets attached on the left of an output that had
something displayed (weston_output_move() can be easily adapted).

Thanks, Armin.



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


Re: [PATCH weston 1/4] libweston: Export weston_output_transform_scale_init

2016-10-09 Thread Armin Krezović
On 07.10.2016 11:52, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:27 +0200
> Armin Krezović  wrote:
> 
>> This is required for implementing output layout setting
>> which relies on current output width and height, and
>> those are calculated in this function.
>>
>> It also changes the function signature to make use
>> of already stored scale and transform values in the
>> weston_output object.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  libweston/compositor.c | 31 ++-
>>  libweston/compositor.h |  2 ++
>>  2 files changed, 20 insertions(+), 13 deletions(-)
> 
> Hi,
> 
> I think this would need a bit more thought on the API.
> 
> The requirement is that one has to set some output parameters (video
> mode, transform, scale) before the output size is available. Output
> size then is needed for doing the layout.
> 
> IMO it would make more sense to add a new function
> weston_output_get_size(), which would take into account the currently
> set (pending) parameters and compute the resulting size.
> 
> This is also good in the long term since we would like to make struct
> weston_output opaque to the libweston user. We are going to need a
> getter for the size anyway.
> 
> 
> Thanks,
> pq
> 

Hi,

It makes sense, yes. Do you think we'd need a similar function to get
the current output coordinates (used for computing new position)?

Thanks, Armin.



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


[PATCH weston 08/10] compositor-wayland: Destroy shm buffers on output disable

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 0cfc005..d1a38fe 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -629,6 +629,19 @@ wayland_backend_destroy_output_surface(struct 
wayland_output *output)
wl_surface_destroy(output->parent.surface);
 }
 
+static void
+wayland_output_destroy_shm_buffers(struct wayland_output *output)
+{
+   struct wayland_shm_buffer *buffer, *next;
+
+   /* Throw away any remaining SHM buffers */
+   wl_list_for_each_safe(buffer, next, &output->shm.free_buffers, 
free_link)
+   wayland_shm_buffer_destroy(buffer);
+   /* These will get thrown away when they get released */
+   wl_list_for_each(buffer, &output->shm.buffers, link)
+   buffer->output = NULL;
+}
+
 static int
 wayland_output_disable(struct weston_output *base)
 {
@@ -645,6 +658,8 @@ wayland_output_disable(struct weston_output *base)
wl_egl_window_destroy(output->gl.egl_window);
}
 
+   wayland_output_destroy_shm_buffers(output);
+
wayland_backend_destroy_output_surface(output);
 
if (output->frame)
@@ -719,7 +734,6 @@ wayland_output_resize_surface(struct wayland_output *output)
 {
struct wayland_backend *b =
to_wayland_backend(output->base.compositor);
-   struct wayland_shm_buffer *buffer, *next;
int32_t ix, iy, iwidth, iheight;
int32_t width, height;
struct wl_region *region;
@@ -783,12 +797,7 @@ wayland_output_resize_surface(struct wayland_output 
*output)
output->gl.border.bottom = NULL;
}
 
-   /* Throw away any remaining SHM buffers */
-   wl_list_for_each_safe(buffer, next, &output->shm.free_buffers, 
free_link)
-   wayland_shm_buffer_destroy(buffer);
-   /* These will get thrown away when they get released */
-   wl_list_for_each(buffer, &output->shm.buffers, link)
-   buffer->output = NULL;
+   wayland_output_destroy_shm_buffers(output);
 }
 
 static int
-- 
2.10.1

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


[PATCH weston 05/10] compositor-wayland: Move vfunc setting from set_size to enable

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d26360e..42cebe7 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1088,11 +1088,21 @@ wayland_output_enable(struct weston_output *base)
if (b->use_pixman) {
if (wayland_output_init_pixman_renderer(output) < 0)
goto err_output;
+
+   output->base.repaint = wayland_output_repaint_pixman;
} else {
if (wayland_output_init_gl_renderer(output) < 0)
goto err_output;
+
+   output->base.repaint = wayland_output_repaint_gl;
}
 
+   output->base.start_repaint_loop = wayland_output_start_repaint_loop;
+   output->base.assign_planes = NULL;
+   output->base.set_backlight = NULL;
+   output->base.set_dpms = NULL;
+   output->base.switch_mode = wayland_output_switch_mode;
+
if (b->sprawl_across_outputs) {
wayland_output_set_fullscreen(output,
  
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER,
@@ -1166,7 +1176,6 @@ static int
 wayland_output_set_size(struct weston_output *base, int width, int height)
 {
struct wayland_output *output = to_wayland_output(base);
-   struct wayland_backend *b = to_wayland_backend(base->compositor);
int output_width, output_height;
 
/* We can only be called once. */
@@ -1208,17 +1217,6 @@ wayland_output_set_size(struct weston_output *base, int 
width, int height)
output->base.mm_width = width;
output->base.mm_height = height;
 
-   if (b->use_pixman)
-   output->base.repaint = wayland_output_repaint_pixman;
-   else
-   output->base.repaint = wayland_output_repaint_gl;
-
-   output->base.start_repaint_loop = wayland_output_start_repaint_loop;
-   output->base.assign_planes = NULL;
-   output->base.set_backlight = NULL;
-   output->base.set_dpms = NULL;
-   output->base.switch_mode = wayland_output_switch_mode;
-
return 0;
 }
 
-- 
2.10.1

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


[PATCH weston 07/10] compositor-wayland: Properly clean up on backend destroy

2016-10-09 Thread Armin Krezović
Also remove a wrong XXX comment.

Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 133d0c4..0cfc005 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1244,7 +1244,6 @@ wayland_output_create_for_parent_output(struct 
wayland_backend *b,
output->base.make = poutput->physical.make;
output->base.model = poutput->physical.model;
 
-   /* XXX: Clear previously added values */
wl_list_init(&output->base.mode_list);
wl_list_insert_list(&output->base.mode_list, &poutput->mode_list);
wl_list_init(&poutput->mode_list);
@@ -2234,11 +2233,31 @@ wayland_destroy(struct weston_compositor *ec)
 {
struct wayland_backend *b = to_wayland_backend(ec);
 
+   wl_event_source_remove(b->parent.wl_source);
+
weston_compositor_shutdown(ec);
 
if (b->parent.shm)
wl_shm_destroy(b->parent.shm);
 
+   if (b->parent.fshell)
+   zwp_fullscreen_shell_v1_release(b->parent.fshell);
+
+   if (b->parent.compositor)
+   wl_compositor_destroy(b->parent.compositor);
+
+   wl_registry_destroy(b->parent.registry);
+   wl_display_flush(b->parent.wl_display);
+   wl_display_disconnect(b->parent.wl_display);
+
+   if (b->theme)
+   theme_destroy(b->theme);
+
+   if (b->frame_device)
+   cairo_device_destroy(b->frame_device);
+
+   wl_cursor_theme_destroy(b->cursor_theme);
+
free(b);
 }
 
-- 
2.10.1

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


[PATCH weston 10/10] compositor-wayland: Simplify fullscreening for sprawl use case

2016-10-09 Thread Armin Krezović
wayland_output_set_fullscreen() already takes care of
everything and xdg_shell doesn't use any present methods
so a single call to wayland_output_set_fullscreen() is
sufficient.

Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 6d91208..328b170 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -853,7 +853,7 @@ wayland_output_set_windowed(struct wayland_output *output)
 static void
 wayland_output_set_fullscreen(struct wayland_output *output,
  enum wl_shell_surface_fullscreen_method method,
- uint32_t framerate, struct wl_output *target)
+ struct wl_output *target)
 {
struct wayland_backend *b =
to_wayland_backend(output->base.compositor);
@@ -1162,25 +1162,17 @@ wayland_output_enable(struct weston_output *base)
 
if (b->sprawl_across_outputs) {
wayland_output_set_fullscreen(output,
- 
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER,
- output->mode.refresh, 
output->parent.output);
-
-   if (output->parent.xdg_toplevel) {
-   
zxdg_toplevel_v6_set_fullscreen(output->parent.xdg_toplevel,
-   output->parent.output);
-   } else if (b->parent.fshell) {
-   
zwp_fullscreen_shell_v1_present_surface(b->parent.fshell,
-   
output->parent.surface,
-   
ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_CENTER,
-   
output->parent.output);
+ 
ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_CENTER,
+ output->parent.output);
+
+   if (b->parent.fshell)
zwp_fullscreen_shell_mode_feedback_v1_destroy(

zwp_fullscreen_shell_v1_present_surface_for_mode(b->parent.fshell,

 output->parent.surface,

 output->parent.output,

 output->mode.refresh));
-   }
} else if (b->fullscreen) {
-   wayland_output_set_fullscreen(output, 0, 0, NULL);
+   wayland_output_set_fullscreen(output, 0, NULL);
} else {
wayland_output_set_windowed(output);
}
@@ -2358,7 +2350,7 @@ fullscreen_binding(struct weston_keyboard *keyboard, 
uint32_t time,
return;
 
if (input->output->frame)
-   wayland_output_set_fullscreen(input->output, 0, 0, NULL);
+   wayland_output_set_fullscreen(input->output, 0, NULL);
else
wayland_output_set_windowed(input->output);
 
-- 
2.10.1

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


[PATCH weston 09/10] compositor-wayland: Port to xdg-shell-v6

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 Makefile.am|   8 ++-
 libweston/compositor-wayland.c | 158 ++---
 2 files changed, 105 insertions(+), 61 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c94c211..f75aa46 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -391,9 +391,11 @@ wayland_backend_la_CFLAGS =\
$(CAIRO_CFLAGS) \
$(WAYLAND_COMPOSITOR_CFLAGS)\
$(AM_CFLAGS)
-wayland_backend_la_SOURCES =   \
-   libweston/compositor-wayland.c  \
-   libweston/compositor-wayland.h  \
+wayland_backend_la_SOURCES =   \
+   libweston/compositor-wayland.c  \
+   libweston/compositor-wayland.h  \
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
shared/helpers.h
 nodist_wayland_backend_la_SOURCES =\
protocol/fullscreen-shell-unstable-v1-protocol.c\
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d1a38fe..6d91208 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -51,6 +51,7 @@
 #include "shared/os-compatibility.h"
 #include "shared/cairo-util.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "presentation-time-server-protocol.h"
 #include "linux-dmabuf.h"
 #include "windowed-output-api.h"
@@ -65,7 +66,7 @@ struct wayland_backend {
struct wl_display *wl_display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct wl_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
 
@@ -97,8 +98,10 @@ struct wayland_output {
struct wl_output *output;
uint32_t global_id;
 
-   struct wl_shell_surface *shell_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
int configure_width, configure_height;
+   bool wait_for_configure;
} parent;
 
int keyboard_count;
@@ -623,8 +626,11 @@ wayland_output_repaint_pixman(struct weston_output 
*output_base,
 static void
 wayland_backend_destroy_output_surface(struct wayland_output *output)
 {
-   if (output->parent.shell_surface)
-   wl_shell_surface_destroy(output->parent.shell_surface);
+   if (output->parent.xdg_toplevel)
+   zxdg_toplevel_v6_destroy(output->parent.xdg_toplevel);
+
+   if (output->parent.xdg_surface)
+   zxdg_surface_v6_destroy(output->parent.xdg_surface);
 
wl_surface_destroy(output->parent.surface);
 }
@@ -685,8 +691,6 @@ wayland_output_destroy(struct weston_output *base)
free(output);
 }
 
-static const struct wl_shell_surface_listener shell_surface_listener;
-
 static int
 wayland_output_init_gl_renderer(struct wayland_output *output)
 {
@@ -822,6 +826,9 @@ wayland_output_set_windowed(struct wayland_output *output)
title = strdup(WINDOW_TITLE);
}
 
+   if (output->parent.xdg_toplevel)
+   zxdg_toplevel_v6_set_title(output->parent.xdg_toplevel, title);
+
if (!b->theme) {
b->theme = theme_create();
if (!b->theme) {
@@ -840,8 +847,6 @@ wayland_output_set_windowed(struct wayland_output *output)
 
wayland_output_resize_surface(output);
 
-   wl_shell_surface_set_toplevel(output->parent.shell_surface);
-
return 0;
 }
 
@@ -860,9 +865,8 @@ wayland_output_set_fullscreen(struct wayland_output *output,
 
wayland_output_resize_surface(output);
 
-   if (output->parent.shell_surface) {
-   wl_shell_surface_set_fullscreen(output->parent.shell_surface,
-   method, framerate, target);
+   if (output->parent.xdg_toplevel) {
+   zxdg_toplevel_v6_set_fullscreen(output->parent.xdg_toplevel, 
target);
} else if (b->parent.fshell) {
zwp_fullscreen_shell_v1_present_surface(b->parent.fshell,
output->parent.surface,
@@ -961,7 +965,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
 
b = to_wayland_backend(output_base->compositor);
 
-   if (output->parent.shell_surface || !b->parent.fshell)
+   if (output->parent.xdg_surface || !b->parent.fshell)
return -1;
 
mode = wayland_output_choose_mode(output, mod

[PATCH weston 06/10] compositor-wayland: Simplify fullscreen output surface handling

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 42cebe7..133d0c4 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -645,10 +645,7 @@ wayland_output_disable(struct weston_output *base)
wl_egl_window_destroy(output->gl.egl_window);
}
 
-   /* Done on output->enable when not fullscreen, otherwise
-* done in output_create, to get the proper mode */
-   if (!b->fullscreen)
-   wayland_backend_destroy_output_surface(output);
+   wayland_backend_destroy_output_surface(output);
 
if (output->frame)
frame_destroy(output->frame);
@@ -665,13 +662,9 @@ static void
 wayland_output_destroy(struct weston_output *base)
 {
struct wayland_output *output = to_wayland_output(base);
-   struct wayland_backend *b = to_wayland_backend(base->compositor);
 
wayland_output_disable(&output->base);
 
-   if (b->fullscreen)
-   wayland_backend_destroy_output_surface(output);
-
weston_output_destroy(&output->base);
 
free(output);
@@ -1068,15 +1061,12 @@ wayland_output_enable(struct weston_output *base)
struct wayland_backend *b = to_wayland_backend(base->compositor);
int ret = 0;
 
-
weston_log("Creating %dx%d wayland output at (%d, %d)\n",
   output->base.current_mode->width,
   output->base.current_mode->height,
   output->base.x, output->base.y);
 
-   /* If fullscreen was specified, this needs to be done before
-* enable to get the proper mode */
-   if (!b->fullscreen)
+   if (!output->parent.surface)
ret = wayland_backend_create_output_surface(output);
 
if (ret < 0)
@@ -1132,8 +1122,7 @@ wayland_output_enable(struct weston_output *base)
return 0;
 
 err_output:
-   if (!b->fullscreen)
-   wayland_backend_destroy_output_surface(output);
+   wayland_backend_destroy_output_surface(output);
 
return -1;
 }
-- 
2.10.1

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


[PATCH weston 02/10] compositor-wayland: Convert sprawl flag to boolean

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 2 +-
 libweston/compositor-wayland.c | 4 ++--
 libweston/compositor-wayland.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index d081106..320305c 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1578,7 +1578,7 @@ load_wayland_backend(struct weston_compositor *c,
config.cursor_theme = NULL;
config.display_name = NULL;
config.fullscreen = 0;
-   config.sprawl = 0;
+   config.sprawl = false;
config.use_pixman = false;
 
const struct weston_option wayland_options[] = {
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d1ff8d7..32c44d4 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -76,7 +76,7 @@ struct wayland_backend {
} parent;
 
bool use_pixman;
-   int sprawl_across_outputs;
+   bool sprawl_across_outputs;
int fullscreen;
 
struct theme *theme;
@@ -2448,7 +2448,7 @@ backend_init(struct weston_compositor *compositor,
return -1;
 
if (new_config.sprawl || b->parent.fshell) {
-   b->sprawl_across_outputs = 1;
+   b->sprawl_across_outputs = true;
wl_display_roundtrip(b->parent.wl_display);
 
wl_list_for_each(poutput, &b->parent.output_list, link)
diff --git a/libweston/compositor-wayland.h b/libweston/compositor-wayland.h
index 9a9dde8..3ca875a 100644
--- a/libweston/compositor-wayland.h
+++ b/libweston/compositor-wayland.h
@@ -39,7 +39,7 @@ extern "C" {
 struct weston_wayland_backend_config {
struct weston_backend_config base;
bool use_pixman;
-   int sprawl;
+   bool sprawl;
char *display_name;
int fullscreen;
char *cursor_theme;
-- 
2.10.1

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


[PATCH weston 01/10] compositor-wayland: Convert use-pixman flag to boolean

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 2 +-
 libweston/compositor-wayland.c | 6 +++---
 libweston/compositor-wayland.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index fca9778..d081106 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1579,7 +1579,7 @@ load_wayland_backend(struct weston_compositor *c,
config.display_name = NULL;
config.fullscreen = 0;
config.sprawl = 0;
-   config.use_pixman = 0;
+   config.use_pixman = false;
 
const struct weston_option wayland_options[] = {
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 46fdde1..d1ff8d7 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -75,7 +75,7 @@ struct wayland_backend {
uint32_t event_mask;
} parent;
 
-   int use_pixman;
+   bool use_pixman;
int sprawl_across_outputs;
int fullscreen;
 
@@ -2345,7 +2345,7 @@ wayland_backend_create(struct weston_compositor 
*compositor,
gl_renderer = weston_load_module("gl-renderer.so",
 "gl_renderer_interface");
if (!gl_renderer)
-   b->use_pixman = 1;
+   b->use_pixman = true;
}
 
if (!b->use_pixman) {
@@ -2357,7 +2357,7 @@ wayland_backend_create(struct weston_compositor 
*compositor,
0) < 0) {
weston_log("Failed to initialize the GL renderer; "
   "falling back to pixman.\n");
-   b->use_pixman = 1;
+   b->use_pixman = true;
}
}
 
diff --git a/libweston/compositor-wayland.h b/libweston/compositor-wayland.h
index 58e0fb1..9a9dde8 100644
--- a/libweston/compositor-wayland.h
+++ b/libweston/compositor-wayland.h
@@ -38,7 +38,7 @@ extern "C" {
 
 struct weston_wayland_backend_config {
struct weston_backend_config base;
-   int use_pixman;
+   bool use_pixman;
int sprawl;
char *display_name;
int fullscreen;
-- 
2.10.1

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


[PATCH weston 00/10] Wayland backend improvements

2016-10-09 Thread Armin Krezović
This series contains some simple fixes for Wayland backend
for issues discovered by Pekka during the output API series
review.

That includes some cleaning up on output/backend destroy,
converting some flags to boolean (nitpick!) and porting
the backend to xdg-shell-v6!

Armin Krezović (10):
  compositor-wayland: Convert use-pixman flag to boolean
  compositor-wayland: Convert sprawl flag to boolean
  compositor-wayland: Convert fullscreen flag to bool
  compositor-wayland: Convert draw_initial_frame to boolean
  compositor-wayland: Move vfunc setting from set_size to enable
  compositor-wayland: Simplify fullscreen output surface handling
  compositor-wayland: Properly clean up on backend destroy
  compositor-wayland: Destroy shm buffers on output disable
  compositor-wayland: Port to xdg-shell-v6
  compositor-wayland: Simplify fullscreening for sprawl use case

 Makefile.am|   8 +-
 compositor/main.c  |   4 +-
 libweston/compositor-wayland.c | 277 -
 libweston/compositor-wayland.h |   6 +-
 4 files changed, 173 insertions(+), 122 deletions(-)

-- 
2.10.1

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


[PATCH weston 03/10] compositor-wayland: Convert fullscreen flag to bool

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 2 +-
 libweston/compositor-wayland.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 32c44d4..a5a360c 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -77,7 +77,7 @@ struct wayland_backend {
 
bool use_pixman;
bool sprawl_across_outputs;
-   int fullscreen;
+   bool fullscreen;
 
struct theme *theme;
cairo_device_t *frame_device;
diff --git a/libweston/compositor-wayland.h b/libweston/compositor-wayland.h
index 3ca875a..d5c29f0 100644
--- a/libweston/compositor-wayland.h
+++ b/libweston/compositor-wayland.h
@@ -41,7 +41,7 @@ struct weston_wayland_backend_config {
bool use_pixman;
bool sprawl;
char *display_name;
-   int fullscreen;
+   bool fullscreen;
char *cursor_theme;
int cursor_size;
 };
-- 
2.10.1

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


[PATCH weston 04/10] compositor-wayland: Convert draw_initial_frame to boolean

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index a5a360c..d26360e 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -91,7 +91,7 @@ struct wayland_output {
struct weston_output base;
 
struct {
-   int draw_initial_frame;
+   bool draw_initial_frame;
struct wl_surface *surface;
 
struct wl_output *output;
@@ -461,7 +461,7 @@ wayland_output_start_repaint_loop(struct weston_output 
*output_base)
 * callback won't be invoked. The buffer is transparent and of the
 * same size as the future real output buffer. */
if (output->parent.draw_initial_frame) {
-   output->parent.draw_initial_frame = 0;
+   output->parent.draw_initial_frame = false;
 
draw_initial_frame(output);
}
@@ -989,7 +989,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
   &mode_status);
 
/* This should kick-start things again */
-   output->parent.draw_initial_frame = 1;
+   output->parent.draw_initial_frame = true;
wayland_output_start_repaint_loop(&output->base);
 
mode_status = MODE_STATUS_UNKNOWN;
@@ -1043,7 +1043,7 @@ wayland_backend_create_output_surface(struct 
wayland_output *output)
 
wl_surface_set_user_data(output->parent.surface, output);
 
-   output->parent.draw_initial_frame = 1;
+   output->parent.draw_initial_frame = true;
 
if (b->parent.shell) {
output->parent.shell_surface =
-- 
2.10.1

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


Re: [PATCH weston] compositor-wayland: Port to xdg-shell

2016-10-09 Thread Armin Krezović
On 09.10.2016 15:06, Armin Krezović wrote:
> Signed-off-by: Armin Krezović 
> ---
>  Makefile.am|   8 ++-
>  libweston/compositor-wayland.c | 155 
> ++---
>  2 files changed, 102 insertions(+), 61 deletions(-)
> 

Please ignore this one. I have more fixes and I will stash them all together.



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


[PATCH weston] compositor-wayland: Port to xdg-shell

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 Makefile.am|   8 ++-
 libweston/compositor-wayland.c | 155 ++---
 2 files changed, 102 insertions(+), 61 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c94c211..f75aa46 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -391,9 +391,11 @@ wayland_backend_la_CFLAGS =\
$(CAIRO_CFLAGS) \
$(WAYLAND_COMPOSITOR_CFLAGS)\
$(AM_CFLAGS)
-wayland_backend_la_SOURCES =   \
-   libweston/compositor-wayland.c  \
-   libweston/compositor-wayland.h  \
+wayland_backend_la_SOURCES =   \
+   libweston/compositor-wayland.c  \
+   libweston/compositor-wayland.h  \
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
shared/helpers.h
 nodist_wayland_backend_la_SOURCES =\
protocol/fullscreen-shell-unstable-v1-protocol.c\
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 46fdde1..2c33daf 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -51,6 +51,7 @@
 #include "shared/os-compatibility.h"
 #include "shared/cairo-util.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "presentation-time-server-protocol.h"
 #include "linux-dmabuf.h"
 #include "windowed-output-api.h"
@@ -65,7 +66,7 @@ struct wayland_backend {
struct wl_display *wl_display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct wl_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
 
@@ -97,8 +98,10 @@ struct wayland_output {
struct wl_output *output;
uint32_t global_id;
 
-   struct wl_shell_surface *shell_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
int configure_width, configure_height;
+   bool wait_for_configure;
} parent;
 
int keyboard_count;
@@ -623,8 +626,11 @@ wayland_output_repaint_pixman(struct weston_output 
*output_base,
 static void
 wayland_backend_destroy_output_surface(struct wayland_output *output)
 {
-   if (output->parent.shell_surface)
-   wl_shell_surface_destroy(output->parent.shell_surface);
+   if (output->parent.xdg_toplevel)
+   zxdg_toplevel_v6_destroy(output->parent.xdg_toplevel);
+
+   if (output->parent.xdg_surface)
+   zxdg_surface_v6_destroy(output->parent.xdg_surface);
 
wl_surface_destroy(output->parent.surface);
 }
@@ -677,8 +683,6 @@ wayland_output_destroy(struct weston_output *base)
free(output);
 }
 
-static const struct wl_shell_surface_listener shell_surface_listener;
-
 static int
 wayland_output_init_gl_renderer(struct wayland_output *output)
 {
@@ -838,8 +842,6 @@ wayland_output_set_windowed(struct wayland_output *output)
 
wayland_output_resize_surface(output);
 
-   wl_shell_surface_set_toplevel(output->parent.shell_surface);
-
return 0;
 }
 
@@ -858,9 +860,8 @@ wayland_output_set_fullscreen(struct wayland_output *output,
 
wayland_output_resize_surface(output);
 
-   if (output->parent.shell_surface) {
-   wl_shell_surface_set_fullscreen(output->parent.shell_surface,
-   method, framerate, target);
+   if (output->parent.xdg_toplevel) {
+   zxdg_toplevel_v6_set_fullscreen(output->parent.xdg_toplevel, 
target);
} else if (b->parent.fshell) {
zwp_fullscreen_shell_v1_present_surface(b->parent.fshell,
output->parent.surface,
@@ -959,7 +960,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
 
b = to_wayland_backend(output_base->compositor);
 
-   if (output->parent.shell_surface || !b->parent.fshell)
+   if (output->parent.xdg_surface || !b->parent.fshell)
return -1;
 
mode = wayland_output_choose_mode(output, mode);
@@ -1031,6 +1032,41 @@ err_output:
return -1;
 }
 
+static void
+handle_surface_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
+{
+   zxdg_surface_v6_ack_configure(surface, serial);
+}
+
+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   handle_surface_configure
+};
+
+static void

Re: [PATCH weston v4 08/14] weston: Port Wayland backend to new output handling API

2016-10-05 Thread Armin Krezović
On 05.10.2016 14:35, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 14:11:09 +0200
> Armin Krezović  wrote:
> 
>> This is a complete port of the Wayland backend that
>> uses the 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.
>>
>> However, the backend can behave both as windowed backend
>> and as a backend that issues "hotplug" events, when
>> running under fullscreen shell or with --sprawl command
>> line option. The first case was covered by reusing
>> previously added functionality. The second case required
>> another API to be introduced and implemented into both
>> the backend and compositor for handling output setup.
>>
>> After everything has been set, output needs to be
>> enabled manually using weston_output_enable().
>>
>> v2:
>>
>>  - Fix wet_configure_windowed_output_from_config() usage.
>>  - Call wayland_output_disable() explicitly from
>>wayland_output_destroy().
>>
>> v3:
>>
>>  - Get rid of weston_wayland_output_api and rework output
>>creation and configuration in case wayland backend is
>>started with --sprawl or on fullscreen-shell.
>>  - Remove unneeded free().
>>  - Disallow calling wayland_output_configure more than once.
>>  - Remove unneeded checks for output->name == NULL as that
>>has been disallowed.
>>  - Use weston_compositor_add_pending_output().
>>
>> v4:
>>
>>  - Drop unused fields from weston_wayland_backend_config
>>and bump WESTON_WAYLAND_BACKEND_CONFIG_VERSION to 2.
>>  - Move output creation to backend itself when
>>--fullscreen is used.
>>  - Prevent possible duplicated output names by assigning
>>a different name to outputs created without any
>>configuration specified.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  compositor/main.c  | 251 +-
>>  libweston/compositor-wayland.c | 399 
>> +++--
>>  libweston/compositor-wayland.h |  12 +-
>>  3 files changed, 350 insertions(+), 312 deletions(-)
>>
> 
>> diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
>> index 0375a11..da0c4fe 100644
>> --- a/libweston/compositor-wayland.c
>> +++ b/libweston/compositor-wayland.c
>> @@ -26,6 +26,7 @@
>>  
>>  #include "config.h"
>>  
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -51,6 +52,7 @@
>>  #include "fullscreen-shell-unstable-v1-client-protocol.h"
>>  #include "presentation-time-server-protocol.h"
>>  #include "linux-dmabuf.h"
>> +#include "windowed-output-api.h"
>>  
>>  #define WINDOW_TITLE "Weston Compositor"
>>  
>> @@ -74,6 +76,7 @@ struct wayland_backend {
>>  
>>  int use_pixman;
>>  int sprawl_across_outputs;
>> +int fullscreen;
>>  
>>  struct theme *theme;
>>  cairo_device_t *frame_device;
>> @@ -617,22 +620,34 @@ wayland_output_repaint_pixman(struct weston_output 
>> *output_base,
>>  }
>>  
>>  static void
>> -wayland_output_destroy(struct weston_output *output_base)
>> +wayland_backend_destroy_output_surface(struct wayland_output *output)
>>  {
>> -struct wayland_output *output = to_wayland_output(output_base);
>> -struct wayland_backend *b =
>> -to_wayland_backend(output->base.compositor);
>> +if (output->parent.shell_surface)
>> +wl_shell_surface_destroy(output->parent.shell_surface);
>> +
>> +wl_surface_destroy(output->parent.surface);
>> +}
>> +
>> +static int
>> +wayland_output_disable(struct weston_output *base)
>> +{
>> +struct wayland_output *output = to_wayland_output(base);
>> +struct wayland_backend *b = to_wayland_backend(base->compositor);
>> +
>> +if (!output->base.enabled)
>&g

Re: starting weston using systemd on tty=1 query

2016-10-05 Thread Armin Krezović
On 05.10.2016 10:51, Vikas Patil wrote:
> Dear All,
> 
> I am working on to start weston on tty=1 using the systemd, however it
> fails to start on boot-up. If I launch weston after bootup using
> "systemd start weston" then it works but not with the bootup. If I use
> tty=2 then it work on bootup. systemd version is 225.
> 
> Could you anyone explain why it fails with tty=1 on bootup and works
> with tty=2? Is there anyway I can start it on tty=1? Is it fine if I
> start it with tty=2?
> 
> Here are the log for failure:
> 
> root@linux123:~# systemctl status weston -l
> ? weston.service - weston (wayland compositor)
>Loaded: loaded (/lib/systemd/system/weston.service; static; vendor
> preset: enabled)
>Active: inactive (dead) since Fri 2016-09-30 10:00:44 UTC; 51s ago
>   Process: 1284 ExecStart=/usr/bin/weston --tty=1 --idle-time=0
> --backend=drm-backend.so --connector=36 --log=/tmp/weston.log
> (code=exited, status=0/SUCCESS)
>   Process: 1278 ExecStartPre=/bin/chmod 0700 /var/run/root/1000
> (code=exited, status=0/SUCCESS)
>   Process: 1271 ExecStartPre=/bin/mkdir -p /var/run/root/1000
> (code=exited, status=0/SUCCESS)
>  Main PID: 1284 (code=exited, status=0/SUCCESS)
> 
> Sep 30 10:00:43 mmt2020 systemd[1]: weston.service: Got notification
> message from PID 1284 (STOPPING=1)
> Sep 30 10:00:43 mmt2020 systemd[1]: weston.service: Changed running ->
> stop-sigterm
> Sep 30 10:00:44 mmt2020 systemd[1]: weston.service: Child 1284 belongs
> to weston.service
> Sep 30 10:00:44 mmt2020 systemd[1]: weston.service: Main process
> exited, code=exited, status=0/SUCCESS
> Sep 30 10:00:44 mmt2020 systemd[1]: weston.service: Changed stop-sigterm -> 
> dead
> Sep 30 10:00:44 mmt2020 systemd[1]: weston.service: cgroup is empty
> 
> Here is my weston.service file
> 
> [Unit]
> Description=weston (wayland compositor)
> DefaultDependencies=false
> Requires=pvrinit.service udevd.service
> After=pvrinit.service udevd.service
> 
> [Service]
> Type=notify
> NotifyAccess=all
> WatchdogSec=20s
> ExecStartPre=/bin/mkdir -p /var/run/root/1000
> ExecStartPre=/bin/chmod 0700 /var/run/root/1000
> ExecStart=/usr/bin/weston --tty=1 --idle-time=0
> --backend=drm-backend.so --connector=36 --log=/tmp/weston.log
> 
> # --- Exec options ---
> Nice=-20
> Environment=XDG_RUNTIME_DIR=/var/run/root/1000
> EnvironmentFile=-/tmp/GlobalSystemSettingsEnvironment
> EnvironmentFile=-/tmp/GlobalSPOTOverrideEnvironment
> 
> # --- Kill options ---
> 
> # EOF
> 
> 
> Here are the output for "dmesg | grep tty"
> 
> root@linux123:~# dmesg | grep tty
> [4.863360] systemd[698]: Spawned
> /lib/systemd/system-generators/systemd-getty-generator as 703.
> [4.875864] systemd-getty-generator[703]: Automatically adding
> serial getty for /dev/ttyO2.
> [4.881230] systemd[698]:
> /lib/systemd/system-generators/systemd-getty-generator succeeded.
> [5.021443] systemd[1]: getty@tty1.service: Installed new job
> getty@tty1.service/start as 61
> [5.021690] systemd[1]: system-getty.slice: Installed new job
> system-getty.slice/start as 62
> [5.021819] systemd[1]: getty.target: Installed new job
> getty.target/start as 60
> [5.022199] systemd[1]: system-serial\x2dgetty.slice: Installed new
> job system-serial\x2dgetty.slice/start as 65
> [5.022456] systemd[1]: serial-getty@ttyS0.service: Installed new
> job serial-getty@ttyS0.service/start as 63
> [5.022829] systemd[1]: serial-getty@ttyO2.service: Installed new
> job serial-getty@ttyO2.service/start as 66
> [5.022908] systemd[1]: dev-ttyS0.device: Installed new job
> dev-ttyS0.device/start as 64
> [5.022977] systemd[1]: dev-ttyO2.device: Installed new job
> dev-ttyO2.device/start as 67
> [5.242611] systemd[1]: system-serial\x2dgetty.slice changed dead -> active
> [5.242637] systemd[1]: system-serial\x2dgetty.slice: Job
> system-serial\x2dgetty.slice/start finished, result=done
> [5.242665] systemd[1]: Created slice system-serial\x2dgetty.slice.
> [5.542780] systemd[1]: system-getty.slice changed dead -> active
> [5.542807] systemd[1]: system-getty.slice: Job
> system-getty.slice/start finished, result=done
> [5.542839] systemd[1]: Created slice system-getty.slice.
> [8.252350] systemd[1]:
> sys-devices-platform-4400.ocp-4806c000.serial-tty-ttyO1.device:
> Changed dead -> plugged
> [9.234335] systemd[1]: serial-getty@ttyO2.service: Job
> serial-getty@ttyO2.service/start finished, result=done
> [9.512323] systemd[1]: getty@tty1.service:
> ConditionPathExists=/dev/tty0 succeeded.
> [9.532327] systemd[1]: getty@tty1.service: Forked /sbin/agetty as 1310
> [9.572372] systemd[1]: getty@tty1.service: Job
> getty@tty1.service/start finished, result=done
> [9.942423] systemd[1]: Sent message type=signal sender=n/a
> destination=n/a
> object=/org/freedesktop/systemd1/unit/dev_2dttyO1_2edevice
> interface=org.freedesktop.DBus.Properties member=PropertiesChanged
> cookie=1 reply_cookie=0 error=n/a
> [9.952428] systemd[1]: Sent

Re: [PATCH weston] configure: remove double equal test bashism

2016-10-01 Thread Armin Krezović
On 29.09.2016 22:24, Murray Calavera wrote:
> Signed-off-by: Murray Calavera 

Reviewed-by: Armin Krezović 

> ---
>  configure.ac | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index f35e887..72715a6 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -440,10 +440,10 @@ AS_IF([test "x$enable_resize_optimization" = "xyes"],
>[AC_DEFINE([USE_RESIZE_POOL], [1], [Use resize memory pool as a 
> performance optimization])])
>  
>  AC_ARG_ENABLE(weston-launch, [  --enable-weston-launch],, 
> enable_weston_launch=yes)
> -AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch == xyes)
> -if test x$enable_weston_launch == xyes; then
> +AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch = xyes)
> +if test x$enable_weston_launch = xyes; then
>WESTON_SEARCH_LIBS([PAM], [pam], [pam_open_session], [have_pam=yes], 
> [have_pam=no])
> -  if test x$have_pam == xno; then
> +  if test x$have_pam = xno; then
>  AC_ERROR([weston-launch requires pam])
>fi
>  fi
> 




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


[PATCH weston 0/4] RFC: Output layout configuration

2016-09-30 Thread Armin Krezović
This series adds necessary code to support horizontal
output layout configuration using weston's config
file.

The output placement is relative to an output that
specifies outputs it should be placed next to, either
left of, or right of a given output. If there's a
conflicting output on that position, it's moved to
right.

For detailed information on the implementation, read
the patches summary.

This series depends on recently sent output configuration
API series, which I believe should be ready for landing [1].
You can find everything in the git repository [2].

Being in RFC stage, no documentation has been added
yet untill we can agree on an approach.

The code has been tested using DRM, Wayland and X11
backend, with the following config file options used
for WL/X11 backends (just change WL -> X for X11 backend):

[output]
name=WL0

[output]
name=WL1
left-of=WL0

[output]
name=WL2
right-of=WL0

[output]
name=WL3
left-of=WL2
right-of=WL5

[output]
name=WL4
left-of=WL3

[output]
name=WL5

[1]: 
https://lists.freedesktop.org/archives/wayland-devel/2016-September/031193.html
[2]: https://github.com/krezovic/weston/commits/output-layout

Armin Krezović (4):
  libweston: Export weston_output_transform_scale_init
  weston: Move output position setting to compositor
  compositor: Add internal output object used for layout configuration
  compositor: Implement horizontal output layout configuration

 compositor/main.c  | 254 +
 libweston/compositor.c |  69 --
 libweston/compositor.h |   5 +
 3 files changed, 298 insertions(+), 30 deletions(-)

-- 
2.10.0

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


[PATCH weston 2/4] weston: Move output position setting to compositor

2016-09-30 Thread Armin Krezović
This moves current output positioning code and scale/transform
application to the compositor itself, so the compositor
can configure output layouts any way it wants.

A helper function for setting x and y coordinates is also
added, and couple of assertions to weston_output_enable()
as well, to make sure everything has been set up.

Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 26 ++
 libweston/compositor.c | 40 ++--
 libweston/compositor.h |  3 +++
 3 files changed, 51 insertions(+), 18 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index fca9778..503016e 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -468,6 +468,22 @@ wet_init_parsed_options(struct weston_compositor *ec)
return config;
 }
 
+static void
+wet_set_output_position(struct weston_output *output)
+{
+   struct weston_output *iterator;
+   int x = 0, y = 0;
+
+   iterator = container_of(output->compositor->output_list.prev,
+   struct weston_output, link);
+
+   if (!wl_list_empty(&output->compositor->output_list))
+   x = iterator->x + iterator->width;
+
+   weston_output_transform_scale_init(output);
+   weston_output_set_position(output, x, y);
+}
+
 WL_EXPORT struct weston_config *
 wet_get_config(struct weston_compositor *ec)
 {
@@ -1082,6 +1098,8 @@ wet_configure_windowed_output_from_config(struct 
weston_output *output,
return -1;
}
 
+   wet_set_output_position(output);
+
weston_output_enable(output);
 
return 0;
@@ -1167,6 +1185,8 @@ drm_backend_output_configure(struct wl_listener 
*listener, void *data)
api->set_seat(output, seat);
free(seat);
 
+   wet_set_output_position(output);
+
weston_output_enable(output);
 }
 
@@ -1314,6 +1334,8 @@ rdp_backend_output_configure(struct wl_listener 
*listener, void *data)
return;
}
 
+   wet_set_output_position(output);
+
weston_output_enable(output);
 }
 
@@ -1388,6 +1410,8 @@ fbdev_backend_output_configure(struct wl_listener 
*listener, void *data)
wet_output_set_transform(output, section, WL_OUTPUT_TRANSFORM_NORMAL, 
UINT32_MAX);
weston_output_set_scale(output, 1);
 
+   wet_set_output_position(output);
+
weston_output_enable(output);
 }
 
@@ -1538,6 +1562,8 @@ wayland_backend_output_configure_hotplug(struct 
wl_listener *listener, void *dat
 {
struct weston_output *output = data;
 
+   wet_set_output_position(output);
+
/* This backend has all values hardcoded, so nothing can be configured 
here */
weston_output_enable(output);
 }
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 7ebc08c..fdb2089 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4421,6 +4421,13 @@ weston_output_set_transform(struct weston_output *output,
output->transform = transform;
 }
 
+WL_EXPORT void
+weston_output_set_position(struct weston_output *output, int x, int y)
+{
+   output->x = x;
+   output->y = y;
+}
+
 /** Initializes a weston_output object with enough data so
  ** an output can be configured.
  *
@@ -4441,6 +4448,7 @@ weston_output_init(struct weston_output *output,
assert(output->name);
 
wl_list_init(&output->link);
+   wl_signal_init(&output->destroy_signal);
 
output->enabled = false;
 
@@ -4454,6 +4462,11 @@ weston_output_init(struct weston_output *output,
output->transform = UINT32_MAX;
 
output->current_mode = NULL;
+
+   output->width = 0;
+   output->height = 0;
+   output->x = -1;
+   output->y = -1;
 }
 
 /** Adds weston_output object to pending output list.
@@ -4476,11 +4489,8 @@ weston_compositor_add_pending_output(struct 
weston_output *output,
  *
  * \param output The weston_output object that needs to be enabled.
  *
- * Output coordinates are calculated and each new output is by default
- * assigned to the right of previous one.
- *
- * Sets up the transformation, zoom, and geometry of the output using
- * the properties that need to be configured by the compositor.
+ * Sets up the zoom and geometry of the output using the properties
+ * that need to be configured by the compositor.
  *
  * Establishes a repaint timer for the output with the relevant display
  * object's event loop. See output_repaint_timer_handler().
@@ -4508,42 +4518,36 @@ WL_EXPORT int
 weston_output_enable(struct weston_output *output)
 {
struct weston_compositor *c = output->compositor;
-   struct weston_output *iterator;
struct wl_event_loop *loop;
-   int x = 0, y = 0;
 
assert(output->enable);
 
-   iterator = container_of(c->output_list.prev,
-   struct weston_output, link);
-
-   if (!wl_list_empty(&c->output_

[PATCH weston 4/4] compositor: Implement horizontal output layout configuration

2016-09-30 Thread Armin Krezović
This patch adds horizontal output layout configuration using
the previously added code.

When an output is added, it looks for outputs that it should
be placed next to, if they are specified. If such output is
found, output layout is updated if needed (outputs on a given
position are moved right if they collide with the new output)
and the output is positioned next to the specified output,
either on its left or its right.

If a certain position wasn't specified for the current output,
the compositor looks for any existing outputs that have
current output specified on that position, and updates the
positions accordingly, if corresponding output is found.

Output positions can only be set once, where config file
specified option is always set, even if such output will
never be present. If a certain position wasn't set, the
compositor may update the position if it finds another
output that wants to be placed next to the output that's
being configured. In such case, first existing output that
matches the position is picked up, rest is ignored.

Default behaviour is still to place outputs that have
no matching configuration top right.

Signed-off-by: Armin Krezović 
---
 compositor/main.c | 159 +++---
 1 file changed, 153 insertions(+), 6 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index e379d8d..c039ae6 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -480,20 +480,167 @@ wet_init_parsed_options(struct weston_compositor *ec)
return config;
 }
 
+static struct wet_output *
+wet_output_from_output(struct wet_compositor *compositor, struct weston_output 
*output)
+{
+   struct wet_output *iterator, *next;
+
+   if (wl_list_empty(&compositor->output_layout_list))
+   return NULL;
+
+   wl_list_for_each_safe(iterator, next, &compositor->output_layout_list, 
link) {
+   if (iterator->output == output)
+   return iterator;
+   }
+
+   return NULL;
+}
+
+static struct wet_output *
+wet_output_from_name(struct wet_compositor *compositor, const char *name)
+{
+   struct wet_output *iterator, *next;
+
+   if (wl_list_empty(&compositor->output_layout_list))
+   return NULL;
+
+   wl_list_for_each_safe(iterator, next, &compositor->output_layout_list, 
link) {
+   if (!strcmp(iterator->output->name, name))
+   return iterator;
+   }
+
+   return NULL;
+}
+
+static void
+wet_update_output_layout(struct wet_output *output)
+{
+   struct weston_compositor *ec = output->output->compositor;
+   struct weston_output *iterator, *next;
+   int x = output->output->x;
+   int y = output->output->y;
+
+   if (wl_list_empty(&ec->output_list))
+   return;
+
+   wl_list_for_each_safe(iterator, next, &ec->output_list, link) {
+   if (y == iterator->y && x <= iterator->x)
+   weston_output_move(iterator, iterator->x + 
output->output->width, y);
+   }
+}
+
+static void
+wet_output_apply_position(struct wet_output *output, int x, int y)
+{
+   weston_output_set_position(output->output, x, y);
+   wet_update_output_layout(output);
+   output->position_set = 1;
+}
+
+static void
+wet_set_output_position_from_config(struct wet_output *output,
+   struct wet_compositor *compositor)
+{
+   struct wet_output *out;
+   int x, y;
+
+   if (output->right_output_name) {
+   out = wet_output_from_name(compositor, 
output->right_output_name);
+
+   if (out && (!out->left_output_name ||
+   !strcmp(out->left_output_name, output->right_output_name))) 
{
+   x = out->output->x;
+   y = out->output->y;
+
+   if (!out->left_output_name)
+   out->left_output_name = 
strdup(output->output->name);
+
+   wet_output_apply_position(output, x, y);
+   }
+
+   /* Can't be right of and left of the same output */
+   if (output->left_output_name &&
+   !strcmp(output->left_output_name, 
output->right_output_name)) {
+   free(output->left_output_name);
+   output->left_output_name = NULL;
+   }
+   }
+
+   if (output->left_output_name) {
+   out = wet_output_from_name(compositor, 
output->left_output_name);
+
+   if (out && (!out->right_output_name ||
+   !strcmp(out->right_output_name, output->left_output_name))) 
{
+   x = out->output->x + out->output->width;
+   y

[PATCH weston 1/4] libweston: Export weston_output_transform_scale_init

2016-09-30 Thread Armin Krezović
This is required for implementing output layout setting
which relies on current output width and height, and
those are calculated in this function.

It also changes the function signature to make use
of already stored scale and transform values in the
weston_output object.

Signed-off-by: Armin Krezović 
---
 libweston/compositor.c | 31 ++-
 libweston/compositor.h |  2 ++
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index d552e18..7ebc08c 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -67,10 +67,6 @@
 #define DEFAULT_REPAINT_WINDOW 7 /* milliseconds */
 
 static void
-weston_output_transform_scale_init(struct weston_output *output,
-  uint32_t transform, uint32_t scale);
-
-static void
 weston_compositor_build_view_list(struct weston_compositor *compositor);
 
 static void weston_mode_switch_finish(struct weston_output *output,
@@ -86,7 +82,7 @@ static void weston_mode_switch_finish(struct weston_output 
*output,
pixman_region32_copy(&old_output_region, &output->region);
 
/* Update output region and transformation matrix */
-   weston_output_transform_scale_init(output, output->transform, 
output->current_scale);
+   weston_output_transform_scale_init(output);
 
pixman_region32_init(&output->previous_damage);
pixman_region32_init_rect(&output->region, output->x, output->y,
@@ -4212,17 +4208,25 @@ weston_output_update_matrix(struct weston_output 
*output)
weston_matrix_invert(&output->inverse_matrix, &output->matrix);
 }
 
-static void
-weston_output_transform_scale_init(struct weston_output *output, uint32_t 
transform, uint32_t scale)
+WL_EXPORT void
+weston_output_transform_scale_init(struct weston_output *output)
 {
-   output->transform = transform;
-   output->native_scale = scale;
-   output->current_scale = scale;
+   /* Make sure transform and scale are set */
+   assert(output->scale);
+   assert(output->transform != UINT32_MAX);
+
+   /* Make sure output->current_mode has been constructed. */
+   assert(output->current_mode);
+
+   /* TODO: Use output->original_scale in weston_output_set_scale() */
+   output->original_scale = output->scale;
+   output->native_scale = output->scale;
+   output->current_scale = output->scale;
 
convert_size_by_transform_scale(&output->width, &output->height,
output->current_mode->width,
output->current_mode->height,
-   transform, scale);
+   output->transform, output->scale);
 }
 
 static void
@@ -4448,6 +4452,8 @@ weston_output_init(struct weston_output *output,
output->scale = 0;
/* Can't use -1 on uint32_t and 0 is valid enum value */
output->transform = UINT32_MAX;
+
+   output->current_mode = NULL;
 }
 
 /** Adds weston_output object to pending output list.
@@ -4529,9 +4535,8 @@ weston_output_enable(struct weston_output *output)
output->x = x;
output->y = y;
output->dirty = 1;
-   output->original_scale = output->scale;
 
-   weston_output_transform_scale_init(output, output->transform, 
output->scale);
+   weston_output_transform_scale_init(output);
weston_output_init_zoom(output);
 
weston_output_init_geometry(output, x, y);
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 3e486d5..a39b327 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1596,6 +1596,8 @@ weston_output_activate_zoom(struct weston_output *output,
 void
 weston_output_update_matrix(struct weston_output *output);
 void
+weston_output_transform_scale_init(struct weston_output *output);
+void
 weston_output_move(struct weston_output *output, int x, int y);
 
 void
-- 
2.10.0

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


[PATCH weston 3/4] compositor: Add internal output object used for layout configuration

2016-09-30 Thread Armin Krezović
This adds weston specific output object, which contains information
about output's position, relative to other outputs. DRM and Windowed
backends code has been updated to make use of the new code and
parse new configuration options for a given output, if it was
specified.

New configuration file options for [output] section have been added:

left-of: Specifies which output should be on the right side of the
current output.

right-of: Specifies which output should be on the left side of the
current output.

Signed-off-by: Armin Krezović 
---
 compositor/main.c | 81 +++
 1 file changed, 81 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 503016e..e379d8d 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -78,6 +78,18 @@ struct wet_compositor {
struct weston_config *config;
struct wet_output_config *parsed_options;
struct wl_listener pending_output_listener;
+   struct wl_list output_layout_list;
+};
+
+struct wet_output {
+   struct weston_output *output;
+   struct wl_listener output_destroy_listener;
+   struct wl_list link;
+
+   char *left_output_name;
+   char *right_output_name;
+
+   bool position_set;
 };
 
 static FILE *weston_logfile = NULL;
@@ -492,6 +504,51 @@ wet_get_config(struct weston_compositor *ec)
return compositor->config;
 }
 
+static void
+wet_output_destroy(struct wet_output *output)
+{
+   wl_list_remove(&output->output_destroy_listener.link);
+   wl_list_remove(&output->link);
+
+   free(output->left_output_name);
+   free(output->right_output_name);
+
+   free(output);
+}
+
+static void
+handle_output_destroy(struct wl_listener *listener, void *data)
+{
+   struct wet_output *output = container_of(listener,
+   struct wet_output, output_destroy_listener);
+
+   wet_output_destroy(output);
+}
+
+static struct wet_output *
+wet_output_create(struct weston_output *output)
+{
+   struct wet_compositor *compositor = 
to_wet_compositor(output->compositor);
+   struct wet_output *out;
+
+   out = zalloc(sizeof *out);
+   if (!out)
+   return NULL;
+
+   out->output = output;
+   out->position_set = false;
+
+   out->left_output_name = NULL;
+   out->right_output_name = NULL;
+
+   out->output_destroy_listener.notify = handle_output_destroy;
+   wl_signal_add(&output->destroy_signal, &out->output_destroy_listener);
+
+   wl_list_insert(compositor->output_layout_list.prev, &out->link);
+
+   return out;
+}
+
 static const char xdg_error_message[] =
"fatal: environment variable XDG_RUNTIME_DIR is not set.\n";
 
@@ -1057,10 +1114,12 @@ wet_configure_windowed_output_from_config(struct 
weston_output *output,
struct weston_config_section *section = NULL;
struct wet_compositor *compositor = 
to_wet_compositor(output->compositor);
struct wet_output_config *parsed_options = compositor->parsed_options;
+   struct wet_output *wet_output = wet_output_create(output);
int width = defaults->width;
int height = defaults->height;
 
assert(parsed_options);
+   assert(wet_output);
 
if (!api) {
weston_log("Cannot use weston_windowed_output_api.\n");
@@ -1071,6 +1130,7 @@ wet_configure_windowed_output_from_config(struct 
weston_output *output,
 
if (section) {
char *mode;
+   char *out;
 
weston_config_section_get_string(section, "mode", &mode, NULL);
if (!mode || sscanf(mode, "%dx%d", &width,
@@ -1081,6 +1141,14 @@ wet_configure_windowed_output_from_config(struct 
weston_output *output,
height = defaults->height;
}
free(mode);
+
+   weston_config_section_get_string(section, "left-of", &out, 
NULL);
+   wet_output->right_output_name = out ? strdup(out) : NULL;
+   free(out);
+
+   weston_config_section_get_string(section, "right-of", &out, 
NULL);
+   wet_output->left_output_name = out ? strdup(out) : NULL;
+   free(out);
}
 
if (parsed_options->width)
@@ -1134,16 +1202,20 @@ 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 wet_output *wet_output = wet_output_create(output);
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

[PATCH weston] gl-renderer: Use EGL_KHR_no_config_context

2016-09-30 Thread Armin Krezović
This patch makes use of recently implemented
EGL_KHR_no_config_context extension in Mesa,
which superseeds EGL_MESA_configless_context.

See also (and the follow-up patch):

https://lists.freedesktop.org/archives/mesa-dev/2016-September/128510.html

v2:

 - Extend existing infrastructure for EGL_MESA_configless_context
   per suggestion from Emmanuel Gil Peyrot.

Signed-off-by: Armin Krezović 
---
 libweston/gl-renderer.c| 9 +
 libweston/weston-egl-ext.h | 3 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 031576b..525d05d 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -2566,8 +2566,8 @@ gl_renderer_output_create(struct weston_output *output,
if (egl_config != gr->egl_config &&
!gr->has_configless_context) {
weston_log("attempted to use a different EGL config for an "
-  "output but EGL_MESA_configless_context is not "
-  "supported\n");
+  "output but EGL_KHR_no_config_context or "
+  "EGL_MESA_configless_context is not supported\n");
return -1;
}
 
@@ -2726,7 +2726,8 @@ gl_renderer_setup_egl_extensions(struct weston_compositor 
*ec)
weston_log("warning: EGL_EXT_swap_buffers_with_damage not "
   "supported. Performance could be affected.\n");
 
-   if (weston_check_egl_extension(extensions, 
"EGL_MESA_configless_context"))
+   if (weston_check_egl_extension(extensions, "EGL_KHR_no_config_context") 
||
+   weston_check_egl_extension(extensions, 
"EGL_MESA_configless_context"))
gr->has_configless_context = 1;
 
if (weston_check_egl_extension(extensions, 
"EGL_KHR_surfaceless_context"))
@@ -3102,7 +3103,7 @@ gl_renderer_setup(struct weston_compositor *ec, 
EGLSurface egl_surface)
context_config = gr->egl_config;
 
if (gr->has_configless_context)
-   context_config = EGL_NO_CONFIG_MESA;
+   context_config = EGL_NO_CONFIG_KHR;
 
gr->egl_context = eglCreateContext(gr->egl_display, context_config,
   EGL_NO_CONTEXT, context_attribs);
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index 6e36996..50964a8 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -152,5 +152,8 @@ typedef EGLSurface (EGLAPIENTRYP 
PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLD
 #define EGL_PLATFORM_X11_KHR 0x31D5
 #endif
 
+#ifndef EGL_NO_CONFIG_KHR
+#define EGL_NO_CONFIG_KHR ((EGLConfig)0)
+#endif
 
 #endif
-- 
2.10.0

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


Re: [PATCH weston] gl-renderer: Use EGL_KHR_no_config_context

2016-09-30 Thread Armin Krezović
On 30.09.2016 13:04, Emil Velikov wrote:
> On 28 September 2016 at 20:54, Armin Krezović  
> wrote:
>> On 27.09.2016 15:18, Emmanuel Gil Peyrot wrote:
>>> On Tue, Sep 27, 2016 at 12:29:51PM +0200, Armin Krezović wrote:
>>>> This patch makes use of recently implemented
>>>> EGL_KHR_no_config_context extension in Mesa,
>>>> which superseeds EGL_MESA_configless_context.
>>>>
>>>> See also (and the follow-up patch):
>>>>
>>>> https://lists.freedesktop.org/archives/mesa-dev/2016-September/128510.html
>>>>
>>>> Signed-off-by: Armin Krezović 
>>>> ---
>>>>  libweston/gl-renderer.c| 14 +++---
>>>>  libweston/weston-egl-ext.h |  3 +++
>>>>  2 files changed, 14 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
>>>> index 031576b..7ef7b89 100644
>>>> --- a/libweston/gl-renderer.c
>>>> +++ b/libweston/gl-renderer.c
>>>> @@ -199,6 +199,8 @@ struct gl_renderer {
>>>>
>>>>  int has_egl_buffer_age;
>>>>
>>>> +int has_no_config_context;
>>>> +
>>>>  int has_configless_context;
>>>
>>> You don’t need to keep two different booleans for that, both extensions
>>> are implemented and exposed the same way, only the wording changes a
>>> bit.
>>>
>>>>
>>>>  int has_surfaceless_context;
>>>> @@ -2564,10 +2566,11 @@ gl_renderer_output_create(struct weston_output 
>>>> *output,
>>>>  }
>>>>
>>>>  if (egl_config != gr->egl_config &&
>>>> +!gr->has_no_config_context &&
>>>>  !gr->has_configless_context) {
>>>>  weston_log("attempted to use a different EGL config for an "
>>>> -   "output but EGL_MESA_configless_context is not "
>>>> -   "supported\n");
>>>> +   "output but EGL_KHR_no_config_context or "
>>>> +   "EGL_MESA_configless_context is not supported\n");
>>>>  return -1;
>>>>  }
>>>>
>>>> @@ -2726,6 +2729,9 @@ gl_renderer_setup_egl_extensions(struct 
>>>> weston_compositor *ec)
>>>>  weston_log("warning: EGL_EXT_swap_buffers_with_damage not "
>>>> "supported. Performance could be affected.\n");
>>>>
>>>> +if (weston_check_egl_extension(extensions, 
>>>> "EGL_KHR_no_config_context"))
>>>> +gr->has_no_config_context = 1;
>>>> +
>>>>  if (weston_check_egl_extension(extensions, 
>>>> "EGL_MESA_configless_context"))
>>>>  gr->has_configless_context = 1;
>>>
>>> Same here, you can safely set gr->has_no_config_context instead.
>>>
>>>>
>>>> @@ -3101,7 +3107,9 @@ gl_renderer_setup(struct weston_compositor *ec, 
>>>> EGLSurface egl_surface)
>>>>
>>>>  context_config = gr->egl_config;
>>>>
>>>> -if (gr->has_configless_context)
>>>> +if (gr->has_no_config_context)
>>>> +context_config = EGL_NO_CONFIG_KHR;
>>>> +else if (gr->has_configless_context)
>>>>  context_config = EGL_NO_CONFIG_MESA;
>>>
>>> And same here, the EGL_NO_CONFIG_KHR and EGL_NO_CONFIG_MESA values are
>>> the same, so as long as you have both in the header (you do), it will
>>> not be an issue.
>>>
>>>>
>>>>  gr->egl_context = eglCreateContext(gr->egl_display, context_config,
>>>> diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
>>>> index 6e36996..50964a8 100644
>>>> --- a/libweston/weston-egl-ext.h
>>>> +++ b/libweston/weston-egl-ext.h
>>>> @@ -152,5 +152,8 @@ typedef EGLSurface (EGLAPIENTRYP 
>>>> PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLD
>>>>  #define EGL_PLATFORM_X11_KHR 0x31D5
>>>>  #endif
>>>>
>>>> +#ifndef EGL_NO_CONFIG_KHR
>>>> +#define EGL_NO_CONFIG_KHR ((EGLConfig)0)
>>>> +#endif
>>>>
>>>>  #endif
>>>> --
>>>> 2.10.0
>>>>
>>>> ___
>>>> wayland-devel mailing list
>>>> wayland-devel@lists.freedesktop.org
>>>> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
>>>
>>
>> Hi Emmanuel,
>>
>> Thanks for the review. I was going to implement it that way, but I wanted to 
>> keep
>> up the tradition.
>>
>> If nobody complains about the way you suggested, I'll implement it that way.
>>
> Fwiw, I believe Emmanuel's suggestion is spot on.
> 
> The only difference between the two extensions is that the mesa
> extension lacks explicit text error handling corner case. Everything
> else is identical afaict, thus there's little need for a special case
> in weston/other EGL users.
> 
> Regards,
> Emil
> 

Fair enough.

Armin.



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


[PATCH weston v4 01/14] libweston: Add more functionality for handling weston_output objects

2016-09-30 Thread Armin Krezović
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.

v2:

 - Minor documentation improvements.
 - Rename output-initialized to output->enabled.
 - Split weston_output_disable() further into
   weston_compositor_remove_output().
 - Rename weston_output_deinit() to weston_output_enable_undo().

 - Make weston_output_disable() call two functions mentioned
   above instead of calling weston_output_disable() directly.
   This means that backend needs to take care of doing backend
   specific disable in backend specific destroy function.

v3:

 - Require output->name to be set before calling
   weston_output_init_pending().
 - Require output->destroying to be set before
   calling weston_compositor_remove_output().
 - Split weston_output_init_pending() into
   weston_compositor_add_pending_output() so pending outputs
   can be announced separately.
 - Require output->disable() to be set in order for
   weston_output_disable() to be usable.
 - Fix output removing regression that happened when
   weston_output_disable() was split.
 - Minor documentation fix.

v4:

 - Bump libweston version to 2 as this patch breaks the ABI.

Reviewed-by: Pekka Paalanen 
Signed-off-by: Armin Krezović 
---
 configure.ac   |   6 +-
 libweston/compositor.c | 362 -
 libweston/compositor.h |  33 +
 3 files changed, 363 insertions(+), 38 deletions(-)

diff --git a/configure.ac b/configure.ac
index f35e887..671d707 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,9 +3,9 @@ m4_define([weston_minor_version],  [12])
 m4_define([weston_micro_version],  [90])
 m4_define([weston_version],
   [weston_major_version.weston_minor_version.weston_micro_version])
-m4_define([libweston_major_version], [1])
-m4_define([libweston_minor_version], [12])
-m4_define([libweston_patch_version], [90])
+m4_define([libweston_major_version], [2])
+m4_define([libweston_minor_version], [0])
+m4_define([libweston_patch_version], [0])
 
 AC_PREREQ([2.64])
 AC_INIT([weston],
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 8c3872d..e5deeab 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4153,41 +4153,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, &output->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(&output->feedback_list);
-
-   weston_compositor_reflow_outputs(output->compositor, output, 
output->width);
-   wl_list_remove(&output->link);
-
-   wl_signal_emit(&output->compositor->output_destroyed_signal, output);
-   wl_signal_emit(&output->destroy_signal, output);
-
-   free(output->name);
-   pixman_region32_fini(&output->region);
-   pixman_region32_fini(&output->previous_damage);
-   output->compositor->output_id_pool &= ~(1u << output->id);
-
-   wl_resource_for_each(resource, &output->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;
@@ -4377,6 +4342,8 @@ weston_output_init(struct weston_output *output, struct 
weston_compositor *c,
output->global =
wl_global_create(c->wl_display, &wl_output_interface, 3,
 output, bind_output);
+
+   output->enabled = true;
 }
 
 /** Adds an output to the compositor's output list and
@@ -4415,6 +4382,325 @@ weston_output_transform_coordinate(struct weston_output 
*output,
*y = p.f[1] / p.f[3];
 }
 
+/** Undoes changes to an output done by weston_output_enable()
+ *
+ * \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 up

[PATCH weston v3 09/14] weston: Port X11 backend to new output handling API

2016-09-30 Thread Armin Krezović
This is a complete port of the X11 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.

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

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call x11_output_disable() explicitly from
   x11_output_destroy().

v3:

 - Remove unneeded free().
 - Disallow calling x11_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().
 - Bump weston_x11_backend_config version to 2.

Reviewed-by: Pekka Paalanen 
Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 151 +-
 libweston/compositor-x11.c | 312 +
 libweston/compositor-x11.h |  13 +-
 3 files changed, 235 insertions(+), 241 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index d19b3f0..fca9778 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1426,48 +1426,43 @@ out:
return ret;
 }
 
-static int
-weston_x11_backend_config_append_output_config(struct 
weston_x11_backend_config *config,
-  struct 
weston_x11_backend_output_config *output_config) {
-   struct weston_x11_backend_output_config *new_outputs;
-
-   new_outputs = realloc(config->outputs, (config->num_outputs+1) *
- sizeof(struct weston_x11_backend_output_config));
-   if (new_outputs == NULL)
-   return -1;
-
-   config->outputs = new_outputs;
-   config->outputs[config->num_outputs].width = output_config->width;
-   config->outputs[config->num_outputs].height = output_config->height;
-   config->outputs[config->num_outputs].transform = 
output_config->transform;
-   config->outputs[config->num_outputs].scale = output_config->scale;
-   config->outputs[config->num_outputs].name = strdup(output_config->name);
-   config->num_outputs++;
+static void
+x11_backend_output_configure(struct wl_listener *listener, void *data)
+{
+   struct weston_output *output = data;
+   struct wet_output_config defaults = {
+   .width = 1024,
+   .height = 600,
+   .scale = 1,
+   .transform = WL_OUTPUT_TRANSFORM_NORMAL
+   };
 
-   return 0;
+   if (wet_configure_windowed_output_from_config(output, &defaults) < 0)
+   weston_log("Cannot configure output \"%s\".\n", output->name);
 }
 
 static int
 load_x11_backend(struct weston_compositor *c,
 int *argc, char **argv, struct weston_config *wc)
 {
-   struct weston_x11_backend_output_config default_output;
+   char *default_output;
+   const struct weston_windowed_output_api *api;
struct weston_x11_backend_config config = {{ 0, }};
struct weston_config_section *section;
int ret = 0;
-   int option_width = 0;
-   int option_height = 0;
-   int option_scale = 0;
int option_count = 1;
int output_count = 0;
char const *section_name;
int i;
-   uint32_t j;
+
+   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, &option_width },
-  { WESTON_OPTION_INTEGER, "height", 0, &option_height },
-  { WESTON_OPTION_INTEGER, "scale", 0, &option_scale },
+  { WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
+  { WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
+  { WESTON_OPTION_INTEGER, "scale", 0, &parsed_options->scale },
   { WESTON_OPTION_BOOLEAN, "fullscreen", 'f', &config.fullscreen },
   { WESTON_OPTION_INTEGER, "output-count", 0, &option_count },
   { WESTON_OPTION_BOOLEAN, "no-input", 0, 

[PATCH weston v3 11/14] weston: Rename weston_output_init_pending() to weston_output_init()

2016-09-30 Thread Armin Krezović
v2:

 - Rebased for latest changes.

v3:

 - Rebased for changes in wayland backend.

Reviewed-by: Quentin Glidic 
Reviewed-by: Pekka Paalanen 
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  | 6 +++---
 libweston/compositor-x11.c  | 2 +-
 libweston/compositor.c  | 6 +++---
 libweston/compositor.h  | 8 +++-
 8 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 491f171..567240f 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2563,7 +2563,7 @@ create_output_for_connector(struct drm_backend *b,
b->crtc_allocator |= (1 << output->crtc_id);
b->connector_allocator |= (1 << output->connector_id);
 
-   weston_output_init_pending(&output->base, b->compositor);
+   weston_output_init(&output->base, b->compositor);
weston_compositor_add_pending_output(&output->base, b->compositor);
 
return 0;
diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
index 8b55332..0c45e98 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(&output->base, backend->compositor);
+   weston_output_init(&output->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 ea23717..e7fc397 100644
--- a/libweston/compositor-headless.c
+++ b/libweston/compositor-headless.c
@@ -239,7 +239,7 @@ headless_output_create(struct weston_compositor *compositor,
output->base.disable = headless_output_disable;
output->base.enable = headless_output_enable;
 
-   weston_output_init_pending(&output->base, compositor);
+   weston_output_init(&output->base, compositor);
weston_compositor_add_pending_output(&output->base, compositor);
 
return 0;
diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index b34024a..d385a31 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -573,7 +573,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(&output->base, compositor);
+   weston_output_init(&output->base, compositor);
weston_compositor_add_pending_output(&output->base, compositor);
 
return 0;
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index da0c4fe..580c7b5 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1155,7 +1155,7 @@ wayland_output_create(struct weston_compositor 
*compositor, const char *name)
 
output->base.name = strdup(name);
 
-   weston_output_init_pending(&output->base, compositor);
+   weston_output_init(&output->base, compositor);
weston_compositor_add_pending_output(&output->base, compositor);
 
return 0;
@@ -1242,7 +1242,7 @@ wayland_output_create_for_parent_output(struct 
wayland_backend *b,
goto out;
}
 
-   weston_output_init_pending(&output->base, b->compositor);
+   weston_output_init(&output->base, b->compositor);
 
output->base.scale = 1;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
@@ -1280,7 +1280,7 @@ wayland_output_create_fullscreen(struct wayland_backend 
*b)
 
output->base.name = strdup("wayland-fullscreen");
 
-   weston_output_init_pending(&output->base, b->compositor);
+   weston_output_init(&output->base, b->compositor);
 
output->base.scale = 1;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index 86241c6..dadcd10 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -1031,7 +1031,7 @@ x11_output_create(struct weston_compositor *compositor,
output->base.disable = x11_output_disable;
output->base.enable = x11_output_enable;
 
-   weston_output_init_pending(&output->base, compositor);
+   weston_output_init(&output->base, compositor);
weston_compositor_add_pending_output(&output->base, compositor);
 
return 0;
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 30eab1d..2f83313 100644
--- 

[PATCH weston v4 08/14] weston: Port Wayland backend to new output handling API

2016-09-30 Thread Armin Krezović
This is a complete port of the Wayland backend that
uses the 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.

However, the backend can behave both as windowed backend
and as a backend that issues "hotplug" events, when
running under fullscreen shell or with --sprawl command
line option. The first case was covered by reusing
previously added functionality. The second case required
another API to be introduced and implemented into both
the backend and compositor for handling output setup.

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

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call wayland_output_disable() explicitly from
   wayland_output_destroy().

v3:

 - Get rid of weston_wayland_output_api and rework output
   creation and configuration in case wayland backend is
   started with --sprawl or on fullscreen-shell.
 - Remove unneeded free().
 - Disallow calling wayland_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().

v4:

 - Drop unused fields from weston_wayland_backend_config
   and bump WESTON_WAYLAND_BACKEND_CONFIG_VERSION to 2.
 - Move output creation to backend itself when
   --fullscreen is used.
 - Prevent possible duplicated output names by assigning
   a different name to outputs created without any
   configuration specified.

Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 251 +-
 libweston/compositor-wayland.c | 399 +++--
 libweston/compositor-wayland.h |  12 +-
 3 files changed, 350 insertions(+), 312 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 7007901..d19b3f0 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1567,221 +1567,140 @@ out:
 }
 
 static void
-weston_wayland_output_config_init(struct weston_wayland_backend_output_config 
*output_config,
- struct weston_config_section *config_section,
- int option_width, int option_height,
- int option_scale)
+wayland_backend_output_configure_hotplug(struct wl_listener *listener, void 
*data)
 {
-   char *mode, *t, *str;
-   unsigned int slen;
-
-   weston_config_section_get_string(config_section, "name", 
&output_config->name,
-NULL);
-   if (output_config->name) {
-   slen = strlen(output_config->name);
-   slen += strlen(WINDOW_TITLE " - ");
-   str = malloc(slen + 1);
-   if (str)
-   snprintf(str, slen + 1, WINDOW_TITLE " - %s",
-output_config->name);
-   free(output_config->name);
-   output_config->name = str;
-   }
-   if (!output_config->name)
-   output_config->name = strdup(WINDOW_TITLE);
-
-   weston_config_section_get_string(config_section,
-"mode", &mode, "1024x600");
-   if (sscanf(mode, "%dx%d", &output_config->width, 
&output_config->height) != 2) {
-   weston_log("Invalid mode \"%s\" for output %s\n",
-  mode, output_config->name);
-   output_config->width = 1024;
-   output_config->height = 640;
-   }
-   free(mode);
-
-   if (option_width)
-   output_config->width = option_width;
-   if (option_height)
-   output_config->height = option_height;
-
-   weston_config_section_get_int(config_section, "scale", 
&output_config->scale, 1);
-
-   if (option_scale)
-   output_config->scale = option_scale;
-
-   weston_config_section_get_string(config_section,
-"transform", &t, "normal");
-   if (weston_parse_transform(t, &output_config->transform) < 0)
-   weston_log("Invalid transform \"%s\" for output %s\n",
-  t, output_config->name);
-   free(t);
+   struct weston_output *output = data;
 
+   /* This backend has all values 

[PATCH weston 12/14] libweston: Remove weston_backend_output_config structure

2016-09-30 Thread Armin Krezović
Reviewed-by: Quentin Glidic 
Reviewed-by: Pekka Paalanen 
Signed-off-by: Armin Krezović 
---
 libweston/compositor.h | 14 --
 1 file changed, 14 deletions(-)

diff --git a/libweston/compositor.h b/libweston/compositor.h
index 6cca4f3..3e486d5 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -694,20 +694,6 @@ enum weston_capability {
WESTON_CAP_VIEW_CLIP_MASK   = 0x0010,
 };
 
-/* Configuration struct for an output.
- *
- * This struct is used to pass the configuration for an output
- * to the compositor backend when creating a new output.
- * The backend can subclass this struct to handle backend
- * specific data.
- */
-struct weston_backend_output_config {
-   uint32_t transform;
-   uint32_t width;
-   uint32_t height;
-   uint32_t scale;
-};
-
 /* Configuration struct for a backend.
  *
  * This struct carries the configuration for a backend, and it's
-- 
2.10.0

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


[PATCH weston 14/14] compositor-rdp: Properly destroy the renderer and pixman image

2016-09-30 Thread Armin Krezović
Reviewed-by: Pekka Paalanen 
Signed-off-by: Armin Krezović 
---
 libweston/compositor-rdp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index d385a31..223382c 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -542,6 +542,9 @@ rdp_output_disable(struct weston_output *base)
if (!output->base.enabled)
return 0;
 
+   pixman_image_unref(output->shadow_surface);
+   pixman_renderer_output_destroy(&output->base);
+
wl_event_source_remove(output->finish_frame_timer);
b->output = NULL;
 
-- 
2.10.0

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


[PATCH weston v3 06/14] weston: Port headless backend to new output handling API

2016-09-30 Thread Armin Krezović
This is a complete port of the headless backend that
uses the 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.

New feature:

This patch also adds, as a bonus of using shared
functionality, support for setting options for outputs
created by this backend in the weston config file in
addition to setting them from the command line.

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call headless_output_disable() explicitly from
   headless_output_destroy().

v3:

 - Add scale support to output width and height.
 - Use scaled values in calls to various functions which
   require width and height.
 - Disallow calling headless_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().
 - Bump weston_headless_backend_config version to 2.

Reviewed-by: Pekka Paalanen 
Signed-off-by: Armin Krezović 
---
 compositor/main.c   |  52 +++---
 libweston/compositor-headless.c | 152 
 libweston/compositor-headless.h |   8 +--
 3 files changed, 154 insertions(+), 58 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 2a1f0e1..12f5e76 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1208,31 +1208,50 @@ 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 wet_output_config defaults = {
+   .width = 1024,
+   .height = 640,
+   .scale = 1,
+   .transform = WL_OUTPUT_TRANSFORM_NORMAL
+   };
+
+   if (wet_configure_windowed_output_from_config(output, &defaults) < 0)
+   weston_log("Cannot configure output \"%s\".\n", output->name);
+}
+
 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, &config.width },
-   { WESTON_OPTION_INTEGER, "height", 0, &config.height },
+   { WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
+   { WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman },
{ WESTON_OPTION_STRING, "transform", 0, &transform },
-   { WESTON_OPTION_BOOLEAN, "no-outputs", 0, &config.no_outputs },
+   { WESTON_OPTION_BOOLEAN, "no-outputs", 0, &no_outputs },
};
 
parse_options(options, ARRAY_LENGTH(options), argc, argv);
 
-   config.transform = WL_OUTPUT_TRANSFORM_NORMAL;
if (transform) {
-   if (weston_parse_transform(transform, &config.transform) < 0)
+   if (weston_parse_transform(transform, 
&parsed_options->transform) < 0) {
weston_log("Invalid transform \"%s\"\n", transform);
+   parsed_options->transform = UINT32_MAX;
+   }
free(transform);
}
 
@@ -1243,7 +1262,24 @@ load_headless_backend(struct weston_compositor *c,
ret = weston_compositor_load_backend(c, WESTON_BACKEND_HEADLESS,
 &config.base);
 
-   return ret;
+   if (ret &

[PATCH weston v3 03/14] compositor: Implement output configuration using windowed_output_api

2016-09-30 Thread Armin Krezović
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 helpers have also been introduced.

v2:

 - Adapt to changes in previous patch.
 - Fix potential double free().
 - Remove redundant variables for scale and transform setting.
 - Drop parsed_options helper and parameter and use it directly
   in wet_configure_windowed_output_from_config().

v3:

 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Stop printing mode if it's invalid, as it can be NULL.

Reviewed-by: Quentin Glidic 
Reviewed-by: Pekka Paalanen 
Signed-off-by: Armin Krezović 
---
 compositor/main.c | 153 ++
 1 file changed, 153 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 0e5af5b..0cc11a5 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 "windowed-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,39 @@ 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(&ec->output_pending_signal, 
&compositor->pending_output_listener);
+}
+
+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;
+
+   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 +983,110 @@ 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", &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", &t, "normal");
+
+   if (weston_parse_transform(t, &transform) < 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

  1   2   3   >