Re: [PATCH 00/14] New output configuration API take 2

2016-08-18 Thread Armin Krezović
On 18.08.2016 18:42, Armin Krezović wrote:
> This is take 3 of my new output configuration API.
> 

Sorry for title mismatch.



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 11/14 v2] weston: Rename weston_output_init_pending() to weston_output_init()

2016-08-18 Thread Armin Krezović
v2:

 - Rebased for latest changes.

Reviewed-by: Quentin Glidic 
Signed-off-by: Armin Krezović 
---
 libweston/compositor-drm.c  | 2 +-
 libweston/compositor-fbdev.c| 2 +-
 libweston/compositor-headless.c | 2 +-
 libweston/compositor-rdp.c  | 2 +-
 libweston/compositor-wayland.c  | 4 ++--
 libweston/compositor-x11.c  | 2 +-
 libweston/compositor.c  | 6 +++---
 libweston/compositor.h  | 8 +++-
 8 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 5b23ea1..82778c2 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2562,7 +2562,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(>base, b->compositor);
+   weston_output_init(>base, b->compositor);
weston_compositor_add_pending_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(>base, backend->compositor);
+   weston_output_init(>base, backend->compositor);
 
/* only one static mode in list */
output->mode.flags =
diff --git a/libweston/compositor-headless.c b/libweston/compositor-headless.c
index 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(>base, compositor);
+   weston_output_init(>base, compositor);
weston_compositor_add_pending_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(>base, compositor);
+   weston_output_init(>base, compositor);
weston_compositor_add_pending_output(>base, compositor);
 
return 0;
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 5fa6cfd..717250f 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1129,7 +1129,7 @@ wayland_output_create(struct weston_compositor 
*compositor, const char *name)
 
output->base.name = strdup(name);
 
-   weston_output_init_pending(>base, compositor);
+   weston_output_init(>base, compositor);
weston_compositor_add_pending_output(>base, compositor);
 
return 0;
@@ -1216,7 +1216,7 @@ wayland_output_create_for_parent_output(struct 
wayland_backend *b,
goto out;
}
 
-   weston_output_init_pending(>base, b->compositor);
+   weston_output_init(>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(>base, compositor);
+   weston_output_init(>base, compositor);
weston_compositor_add_pending_output(>base, compositor);
 
return 0;
diff --git a/libweston/compositor.c b/libweston/compositor.c
index de2c97b..9835f89 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4418,8 +4418,8 @@ weston_output_set_transform(struct weston_output *output,
  * configured either by compositors or backends.
  */
 WL_EXPORT void
-weston_output_init_pending(struct weston_output *output,
-  struct weston_compositor *compositor)
+weston_output_init(struct weston_output *output,
+  struct weston_compositor *compositor)
 {
output->compositor = compositor;
output->destroying = 0;
@@ -4578,7 +4578,7 @@ weston_output_enable(struct weston_output *output)
  *
  * \param output The weston_output object that needs to be disabled.
  *
- * See weston_output_init_pending() for more information on the
+ * See weston_output_init() for more information on the
  * state output 

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

2016-08-18 Thread Armin Krezović
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(>base);
+
wl_event_source_remove(output->finish_frame_timer);
b->output = NULL;
 
-- 
2.9.3

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


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

2016-08-18 Thread Armin Krezović
Reviewed-by: Quentin Glidic 
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 8201e1a..f496bc3 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -700,20 +700,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.9.3

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


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

2016-08-18 Thread Armin Krezović
This is a complete port of the Wayland 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.

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().

Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 257 
 libweston/compositor-wayland.c | 324 +++--
 libweston/compositor-wayland.h |   8 -
 3 files changed, 279 insertions(+), 310 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 7007901..d2df568 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1567,221 +1567,150 @@ 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", 
_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", , "1024x600");
-   if (sscanf(mode, "%dx%d", _config->width, 
_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", 
_config->scale, 1);
-
-   if (option_scale)
-   output_config->scale = option_scale;
-
-   weston_config_section_get_string(config_section,
-"transform", , "normal");
-   if (weston_parse_transform(t, _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 hardcoded, so nothing can be configured 
here */
+   weston_output_enable(output);
 }
 
 static void
-weston_wayland_backend_config_release(struct weston_wayland_backend_config 
*config)
-{
-   int i;
-
-   for (i = 0; i < config->num_outputs; ++i) {
-   free(config->outputs[i].name);
-   }
-   free(config->cursor_theme);
-   free(config->display_name);
-   free(config->outputs);
-}
-
-/*
- * Append a new output struct at the end of new_config.outputs and return a
- * pointer to the newly allocated structure or NULL if fail. The 

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

2016-08-18 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.

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 d2df568..f782294 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, ) < 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, _width },
-  { WESTON_OPTION_INTEGER, "height", 0, _height },
-  { WESTON_OPTION_INTEGER, "scale", 0, _scale },
+  { WESTON_OPTION_INTEGER, "width", 0, _options->width },
+  { WESTON_OPTION_INTEGER, "height", 0, _options->height },
+  { WESTON_OPTION_INTEGER, "scale", 0, _options->scale },
   { WESTON_OPTION_BOOLEAN, "fullscreen", 'f',  },
   { WESTON_OPTION_INTEGER, "output-count", 0, _count },
   { WESTON_OPTION_BOOLEAN, "no-input", 0, _input },
@@ -1476,94 +1471,66 @@ load_x11_backend(struct weston_compositor *c,
 
parse_options(options, ARRAY_LENGTH(options), argc, argv);
 
+   config.base.struct_version = WESTON_X11_BACKEND_CONFIG_VERSION;
+   config.base.struct_size = sizeof(struct weston_x11_backend_config);
+
+   /* load 

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

2016-08-18 Thread Armin Krezović
This is a complete port of the headless backend that
uses recently added output handling API for output
configuration.

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

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

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

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

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.

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, ) < 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,  },
-   { WESTON_OPTION_INTEGER, "height", 0,  },
+   { WESTON_OPTION_INTEGER, "width", 0, _options->width },
+   { WESTON_OPTION_INTEGER, "height", 0, _options->height },
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, _pixman },
{ WESTON_OPTION_STRING, "transform", 0,  },
-   { WESTON_OPTION_BOOLEAN, "no-outputs", 0, _outputs },
+   { WESTON_OPTION_BOOLEAN, "no-outputs", 0, _outputs },
};
 
parse_options(options, ARRAY_LENGTH(options), argc, argv);
 
-   config.transform = WL_OUTPUT_TRANSFORM_NORMAL;
if (transform) {
-   if (weston_parse_transform(transform, ) < 0)
+   if (weston_parse_transform(transform, 
_options->transform) < 0) {
weston_log("Invalid transform \"%s\"\n", transform);
+   parsed_options->transform = UINT32_MAX;
+   }
free(transform);
}
 
@@ -1243,7 +1262,24 @@ load_headless_backend(struct weston_compositor *c,
ret = weston_compositor_load_backend(c, WESTON_BACKEND_HEADLESS,
 );
 
-   return ret;
+   if (ret < 0)
+   return ret;
+
+   wet_set_pending_output_handler(c, headless_backend_output_configure);
+
+   if (!no_outputs) {
+   api = weston_windowed_output_get_api(c);
+
+   if (!api) {
+   weston_log("Cannot use weston_windowed_output_api.\n");
+   

[PATCH weston 02/14 v3] libweston: Add initial output API for windowed outputs configuration

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

It also supports creating additional outputs on the mentioned
backends.

v2:

 - Rename output-api.h to windowed-output-api.h.
 - Rename output_configure() to output_set_size().
 - Document return values.

v3:

 - Fixed copyright.
 - Noted that output name can't be NULL in
   output_create().

Reviewed-by: Quentin Glidic 
Reviewed-by: Pekka Paalanen 
Signed-off-by: Armin Krezović 
---
 Makefile.am |  1 +
 libweston/windowed-output-api.h | 92 +
 2 files changed, 93 insertions(+)
 create mode 100644 libweston/windowed-output-api.h

diff --git a/Makefile.am b/Makefile.am
index 1e63a58..c94c211 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -285,6 +285,7 @@ libwestoninclude_HEADERS =  \
libweston/compositor-rdp.h  \
libweston/compositor-wayland.h  \
libweston/compositor-x11.h  \
+   libweston/windowed-output-api.h \
libweston/plugin-registry.h \
libweston/timeline-object.h \
shared/matrix.h \
diff --git a/libweston/windowed-output-api.h b/libweston/windowed-output-api.h
new file mode 100644
index 000..e0f78b4
--- /dev/null
+++ b/libweston/windowed-output-api.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2016 Armin Krezović
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef WESTON_WINDOWED_OUTPUT_API_H
+#define WESTON_WINDOWED_OUTPUT_API_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include "plugin-registry.h"
+
+struct weston_compositor;
+struct weston_output;
+
+#define WESTON_WINDOWED_OUTPUT_API_NAME "weston_windowed_output_api_v1"
+
+struct weston_windowed_output_api {
+   /** Assign a given width and height to an output.
+*
+* \param output An output to be configured.
+* \param width  Desired width of the output.
+* \param height Desired height of the output.
+*
+* Returns 0 on success, -1 on failure.
+*
+* This assigns a desired width and height to a windowed
+ * output. The backend decides what should be done and applies
+* the desired configuration. After using this function and
+* generic weston_output_set_*, a windowed
+* output should be in a state where weston_output_enable()
+* can be run.
+*/
+   int (*output_set_size)(struct weston_output *output,
+  int width, int height);
+
+   /** Create a new windowed output.
+*
+* \param compositor The compositor instance.
+* \param name   Desired name for a new output.
+*
+* Returns 0 on success, -1 on failure.
+*
+* This creates a new output in the backend using this API.
+* After this function is ran, the created output should be
+* ready for configuration using the output_configure() and
+* weston_output_set_{scale,transform}().
+*
+* An optional name can be assigned to it, so it can be used
+* by compositor to configure it. It can't be NULL.
+*/
+   int (*output_create)(struct weston_compositor *compositor,
+const char *name);
+};
+
+static inline const struct weston_windowed_output_api *
+weston_windowed_output_get_api(struct weston_compositor *compositor)
+{
+   const void *api;

[PATCH weston 10/14] libweston: Merge weston_output_init() into weston_output_enable()

2016-08-18 Thread Armin Krezović
Reviewed-by: Quentin Glidic 
Signed-off-by: Armin Krezović 
---
 libweston/compositor.c | 124 -
 1 file changed, 41 insertions(+), 83 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 2e7212f..de2c97b 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4263,80 +4263,6 @@ weston_output_move(struct weston_output *output, int x, 
int y)
}
 }
 
-/** Initialize a weston_output object's parameters
- *
- * \param output The weston_output object to initialize
- * \param c  The output's compositor
- * \param x  x coordinate for the output in global coordinate space
- * \param y  y coordinate for the output in global coordinate space
- * \param mm_width   Physical width of the output as reported by the backend
- * \param mm_height  Physical height of the output as reported by the backend
- * \param transform  Rotation of the output
- * \param scale  Native scaling factor for the output
- *
- * Sets up the transformation, zoom, and geometry of the output using
- * the input properties.
- *
- * Establishes a repaint timer for the output with the relevant display
- * object's event loop.  See output_repaint_timer_handler().
- *
- * The output is assigned an ID.  Weston can support up to 32 distinct
- * outputs, with IDs numbered from 0-31; the compositor's output_id_pool
- * is referred to and used to find the first available ID number, and
- * then this ID is marked as used in output_id_pool.
- *
- * The output is also assigned a Wayland global with the wl_output
- * external interface.
- */
-WL_EXPORT void
-weston_output_init(struct weston_output *output, struct weston_compositor *c,
-  int x, int y, int mm_width, int mm_height, uint32_t 
transform,
-  int32_t scale)
-{
-   struct wl_event_loop *loop;
-
-   /* Verify we haven't reached the limit of 32 available output IDs */
-   assert(ffs(~c->output_id_pool) > 0);
-
-   output->compositor = c;
-   output->x = x;
-   output->y = y;
-   output->mm_width = mm_width;
-   output->mm_height = mm_height;
-   output->dirty = 1;
-   output->original_scale = scale;
-
-   weston_output_transform_scale_init(output, transform, scale);
-   weston_output_init_zoom(output);
-
-   weston_output_init_geometry(output, x, y);
-   weston_output_damage(output);
-
-   wl_signal_init(>frame_signal);
-   wl_signal_init(>destroy_signal);
-   wl_list_init(>animation_list);
-   wl_list_init(>resource_list);
-   wl_list_init(>feedback_list);
-   wl_list_init(>link);
-
-   loop = wl_display_get_event_loop(c->wl_display);
-   output->repaint_timer = wl_event_loop_add_timer(loop,
-   output_repaint_timer_handler, output);
-
-   /* 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, _output_interface, 3,
-output, bind_output);
-
-   output->enabled = true;
-}
-
 /** Adds an output to the compositor's output list and
  *  send the compositor's output_created signal.
  *
@@ -4531,9 +4457,6 @@ weston_compositor_add_pending_output(struct weston_output 
*output,
wl_signal_emit(>output_pending_signal, output);
 }
 
-/* NOTE: Some documentation is copy/pasted from weston_output_init(), as this
-   is intended to replace it. */
-
 /** Constructs a weston_output object that can be used by the compositor.
  *
  * \param output The weston_output object that needs to be enabled.
@@ -4569,15 +4492,17 @@ weston_compositor_add_pending_output(struct 
weston_output *output,
 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(output->compositor->output_list.prev,
+   iterator = container_of(c->output_list.prev,
struct weston_output, link);
 
-   if (!wl_list_empty(>compositor->output_list))
+   if (!wl_list_empty(>output_list))
x = iterator->x + iterator->width;
 
/* Make sure the width and height are configured */
@@ -4592,10 +4517,43 @@ weston_output_enable(struct weston_output *output)
/* Remove it from pending/disabled output list */
wl_list_remove(>link);
 
-   /* TODO: Merge weston_output_init here. */
-   

[PATCH weston 13/14] libweston: Drop requirement of setting mm_width/mm_height in backends

2016-08-18 Thread Armin Krezović
They were required for transitional phase in order not to
break previous weston_output_init(). Now, they can even
be initialized on enable, or left with defaults if backend
doesn't support them.

Signed-off-by: Armin Krezović 
---
 libweston/compositor.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 9835f89..a45b96f 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4505,9 +4505,6 @@ weston_output_enable(struct weston_output *output)
if (!wl_list_empty(>output_list))
x = iterator->x + iterator->width;
 
-   /* Make sure the width and height are configured */
-   assert(output->mm_width && output->mm_height);
-
/* Make sure the scale is set up */
assert(output->scale);
 
-- 
2.9.3

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


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

2016-08-18 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(>output_pending_signal, 
>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", , 
default_scale);
+
+   if (parsed_scale)
+   scale = parsed_scale;
+
+   weston_output_set_scale(output, scale);
+}
+
+/* UINT32_MAX is treated as invalid because 0 is a valid
+ * enumeration value and the parameter is unsigned
+ */
+static void
+wet_output_set_transform(struct weston_output *output,
+struct weston_config_section *section,
+uint32_t default_transform,
+uint32_t parsed_transform)
+{
+   char *t;
+   uint32_t transform = default_transform;
+
+   if (section) {
+   weston_config_section_get_string(section,
+"transform", , "normal");
+
+   if (weston_parse_transform(t, ) < 0) {
+   weston_log("Invalid transform \"%s\" for output %s\n",
+  t, output->name);
+   transform = default_transform;
+   }
+   free(t);
+   }
+
+   if (parsed_transform != UINT32_MAX)
+   transform = parsed_transform;
+
+   weston_output_set_transform(output, transform);
+}
+
+static int
+wet_configure_windowed_output_from_config(struct weston_output *output,
+ struct wet_output_config *defaults)
+{
+   const struct weston_windowed_output_api *api =
+   

[PATCH weston 07/14 v3] weston: Port RDP backend to new output handling API

2016-08-18 Thread Armin Krezović
This is a complete port of the RDP backend that uses
recently added output handling API for output
configuration.

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

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

v2:

 - Rename output_configure() to output_set_size()
   in plugin API and describe it.
 - Manually fetch parsed_options from wet_compositor.
 - Call rdp_output_disable() explicitly from
   rdp_output_destroy().

v3:

 - Disallow calling rdp_output_set_size more than once.
 - Manually assign a hardcoded name to an output as that's
   now mandatory.
 - Use weston_compositor_add_pending_output().
 - Bump weston_rdp_backend_config version to 2.

Reviewed-by: Quentin Glidic 
Signed-off-by: Armin Krezović 
---
 compositor/main.c  |  52 +++--
 libweston/compositor-rdp.c | 138 +++--
 libweston/compositor-rdp.h |  26 -
 3 files changed, 167 insertions(+), 49 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 12f5e76..7007901 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1283,13 +1283,46 @@ load_headless_backend(struct weston_compositor *c,
 }
 
 static void
+rdp_backend_output_configure(struct wl_listener *listener, void *data)
+{
+   struct weston_output *output = data;
+   struct wet_compositor *compositor = 
to_wet_compositor(output->compositor);
+   struct wet_output_config *parsed_options = compositor->parsed_options;
+   const struct weston_rdp_output_api *api = 
weston_rdp_output_get_api(output->compositor);
+   int width = 640;
+   int height = 480;
+
+   assert(parsed_options);
+
+   if (!api) {
+   weston_log("Cannot use weston_rdp_output_api.\n");
+   return;
+   }
+
+   if (parsed_options->width)
+   width = parsed_options->width;
+
+   if (parsed_options->height)
+   height = parsed_options->height;
+
+   weston_output_set_scale(output, 1);
+   weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
+
+   if (api->output_set_size(output, width, height) < 0) {
+   weston_log("Cannot configure output \"%s\" using 
weston_rdp_output_api.\n",
+  output->name);
+   return;
+   }
+
+   weston_output_enable(output);
+}
+
+static void
 weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
 {
config->base.struct_version = WESTON_RDP_BACKEND_CONFIG_VERSION;
config->base.struct_size = sizeof(struct weston_rdp_backend_config);
 
-   config->width = 640;
-   config->height = 480;
config->bind_address = NULL;
config->port = 3389;
config->rdp_key = NULL;
@@ -1306,12 +1339,16 @@ load_rdp_backend(struct weston_compositor *c,
struct weston_rdp_backend_config config  = {{ 0, }};
int ret = 0;
 
+   struct wet_output_config *parsed_options = wet_init_parsed_options(c);
+   if (!parsed_options)
+   return -1;
+
weston_rdp_backend_config_init();
 
const struct weston_option rdp_options[] = {
{ WESTON_OPTION_BOOLEAN, "env-socket", 0, _socket },
-   { WESTON_OPTION_INTEGER, "width", 0,  },
-   { WESTON_OPTION_INTEGER, "height", 0,  },
+   { WESTON_OPTION_INTEGER, "width", 0, _options->width },
+   { WESTON_OPTION_INTEGER, "height", 0, _options->height },
{ WESTON_OPTION_STRING,  "address", 0, _address },
{ WESTON_OPTION_INTEGER, "port", 0,  },
{ WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, 
_clients_resize },
@@ -1325,10 +1362,17 @@ load_rdp_backend(struct weston_compositor *c,
ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP,
 );
 
+   if (ret < 0)
+   goto out;
+
+   wet_set_pending_output_handler(c, rdp_backend_output_configure);
+
+out:
free(config.bind_address);
free(config.rdp_key);
free(config.server_cert);
free(config.server_key);
+
return ret;
 }
 
diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index ee81300..b34024a 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -25,6 +25,7 @@
 
 #include "config.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -371,15 +372,6 @@ rdp_output_repaint(struct weston_output *output_base, 
pixman_region32_t *damage)
return 0;
 }
 
-static void
-rdp_output_destroy(struct weston_output *output_base)
-{
-   struct rdp_output *output = to_rdp_output(output_base);

[PATCH weston 05/14 v2] weston: Port fbdev backend to new output handling API

2016-08-18 Thread Armin Krezović
This is a complete port of the fbdev backend that uses
recently added output handling API for output
configuration.

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

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

v2:

 - Use weston_compositor_add_pending_output().
 - Bump weston_fbdev_backend_config version to 2.

Reviewed-by: Quentin Glidic 
Signed-off-by: Armin Krezović 
---
 compositor/main.c| 30 ++-
 libweston/compositor-fbdev.c | 87 +++-
 libweston/compositor-fbdev.h |  4 +-
 3 files changed, 76 insertions(+), 45 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 38df77f..2a1f0e1 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1296,13 +1296,26 @@ load_rdp_backend(struct weston_compositor *c,
return ret;
 }
 
+static void
+fbdev_backend_output_configure(struct wl_listener *listener, void *data)
+{
+   struct weston_output *output = data;
+   struct weston_config *wc = wet_get_config(output->compositor);
+   struct weston_config_section *section;
+
+   section = weston_config_get_section(wc, "output", "name", "fbdev");
+
+   wet_output_set_transform(output, section, WL_OUTPUT_TRANSFORM_NORMAL, 
UINT32_MAX);
+   weston_output_set_scale(output, 1);
+
+   weston_output_enable(output);
+}
+
 static int
 load_fbdev_backend(struct weston_compositor *c,
  int *argc, char **argv, struct weston_config *wc)
 {
struct weston_fbdev_backend_config config = {{ 0, }};
-   struct weston_config_section *section;
-   char *s = NULL;
int ret = 0;
 
const struct weston_option fbdev_options[] = {
@@ -1315,12 +1328,6 @@ load_fbdev_backend(struct weston_compositor *c,
if (!config.device)
config.device = strdup("/dev/fb0");
 
-   section = weston_config_get_section(wc, "output", "name", "fbdev");
-   weston_config_section_get_string(section, "transform", , "normal");
-   if (weston_parse_transform(s, _transform) < 0)
-   weston_log("Invalid transform \"%s\" for output fbdev\n", s);
-   free(s);
-
config.base.struct_version = WESTON_FBDEV_BACKEND_CONFIG_VERSION;
config.base.struct_size = sizeof(struct weston_fbdev_backend_config);
config.configure_device = configure_input_device;
@@ -1329,8 +1336,13 @@ load_fbdev_backend(struct weston_compositor *c,
ret = weston_compositor_load_backend(c, WESTON_BACKEND_FBDEV,
 );
 
-   free(config.device);
+   if (ret < 0)
+   goto out;
+
+   wet_set_pending_output_handler(c, fbdev_backend_output_configure);
 
+out:
+   free(config.device);
return ret;
 }
 
diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
index 852acc0..8b55332 100644
--- a/libweston/compositor-fbdev.c
+++ b/libweston/compositor-fbdev.c
@@ -426,12 +426,56 @@ static void fbdev_output_destroy(struct weston_output 
*base);
 static void fbdev_output_disable(struct weston_output *base);
 
 static int
+fbdev_output_enable(struct weston_output *base)
+{
+   struct fbdev_output *output = to_fbdev_output(base);
+   struct fbdev_backend *backend = to_fbdev_backend(base->compositor);
+   int fb_fd;
+   struct wl_event_loop *loop;
+
+   /* Create the frame buffer. */
+   fb_fd = fbdev_frame_buffer_open(output, output->device, 
>fb_info);
+   if (fb_fd < 0) {
+   weston_log("Creating frame buffer failed.\n");
+   return -1;
+   }
+
+   if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
+   weston_log("Mapping frame buffer failed.\n");
+   return -1;
+   }
+
+   output->base.start_repaint_loop = fbdev_output_start_repaint_loop;
+   output->base.repaint = fbdev_output_repaint;
+
+   if (pixman_renderer_output_create(>base) < 0)
+   goto out_hw_surface;
+
+   loop = wl_display_get_event_loop(backend->compositor->wl_display);
+   output->finish_frame_timer =
+   wl_event_loop_add_timer(loop, finish_frame_handler, output);
+
+   weston_log("fbdev output %d×%d px\n",
+  output->mode.width, output->mode.height);
+   weston_log_continue(STAMP_SPACE "guessing %d Hz and 96 dpi\n",
+   output->mode.refresh / 1000);
+
+   return 0;
+
+out_hw_surface:
+   pixman_image_unref(output->hw_surface);
+   output->hw_surface = NULL;
+   fbdev_frame_buffer_destroy(output);
+
+   return -1;
+}
+
+static int
 fbdev_output_create(struct fbdev_backend *backend,
 const char *device)
 {
struct fbdev_output *output;
int fb_fd;
-   struct wl_event_loop *loop;
 
weston_log("Creating fbdev output.\n");
 
@@ 

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

2016-08-18 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.

Reviewed-by: Pekka Paalanen 
Signed-off-by: Armin Krezović 
---
 libweston/compositor.c | 362 -
 libweston/compositor.h |  33 +
 2 files changed, 360 insertions(+), 35 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 47907bb..2e7212f 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4144,41 +4144,6 @@ weston_compositor_reflow_outputs(struct 
weston_compositor *compositor,
 }
 
 WL_EXPORT void
-weston_output_destroy(struct weston_output *output)
-{
-   struct wl_resource *resource;
-   struct weston_view *view;
-
-   output->destroying = 1;
-
-   wl_list_for_each(view, >compositor->view_list, link) {
-   if (view->output_mask & (1u << output->id))
-   weston_view_assign_output(view);
-   }
-
-   wl_event_source_remove(output->repaint_timer);
-
-   weston_presentation_feedback_discard_list(>feedback_list);
-
-   weston_compositor_reflow_outputs(output->compositor, output, 
output->width);
-   wl_list_remove(>link);
-
-   wl_signal_emit(>compositor->output_destroyed_signal, output);
-   wl_signal_emit(>destroy_signal, output);
-
-   free(output->name);
-   pixman_region32_fini(>region);
-   pixman_region32_fini(>previous_damage);
-   output->compositor->output_id_pool &= ~(1u << output->id);
-
-   wl_resource_for_each(resource, >resource_list) {
-   wl_resource_set_destructor(resource, NULL);
-   }
-
-   wl_global_destroy(output->global);
-}
-
-WL_EXPORT void
 weston_output_update_matrix(struct weston_output *output)
 {
float magnification;
@@ -4368,6 +4333,8 @@ weston_output_init(struct weston_output *output, struct 
weston_compositor *c,
output->global =
wl_global_create(c->wl_display, _output_interface, 3,
 output, bind_output);
+
+   output->enabled = true;
 }
 
 /** Adds an output to the compositor's output list and
@@ -4406,6 +4373,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 updates compositor's output_id_pool.
+ */
+static void
+weston_output_enable_undo(struct weston_output *output)
+{
+   wl_event_source_remove(output->repaint_timer);
+
+   wl_global_destroy(output->global);
+
+   pixman_region32_fini(>region);
+   pixman_region32_fini(>previous_damage);
+   output->compositor->output_id_pool &= ~(1u << output->id);
+
+   output->enabled = false;
+}
+
+/** Removes output from compositor's 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 emited to notify all users of the weston_output
+ * object that the output is being destroyed.
+ * wl_output protocol objects referencing this 

[PATCH 00/14] New output configuration API take 2

2016-08-18 Thread Armin Krezović
This is take 3 of my new output configuration API.

Two major changes happened:

- weston_output_init_pending() was split into
  weston_compositor_add_pending_output(), so
  weston_output_init_pending() wouldn't announce
  a new pending output before some configuration
  is done in certain backends.

- First task enabled me to drop wayland_output_api
  entirely for configuring outputs when running
  wayland backend on fullscreen-shell or when started
  with --sprawl. The backend received major rework
  and was simplified a lot.

The rest is all minor, mostly issues raised by Pekka
during the review.

That includes one additional patch, which was split
from previous RDP backend port, to implement something
that wasn't implemented before separately, rather than
through rdp backend porting patch.

Another additional patch to this series was just to
remove requirement of setting mm_width/mm_height, as
that was only required to keep weston_output_init()
working while the backends were ported. After it was
gone, those aren't required to be set anymore.

For information on purpose of this series and information
about previous changes, see:

https://lists.freedesktop.org/archives/wayland-devel/2016-August/030591.html

All patches are available at github, rebased against today's git master:

https://github.com/krezovic/weston/commits/gsoc-v11

Armin Krezović (14):
  libweston: Add more functionality for handling weston_output objects
  libweston: Add initial output API for windowed outputs configuration
  compositor: Implement output configuration using windowed_output_api
  weston: Port DRM backend to new output handling API
  weston: Port fbdev backend to new output handling API
  weston: Port headless backend to new output handling API
  weston: Port RDP backend to new output handling API
  weston: Port Wayland backend to new output handling API
  weston: Port X11 backend to new output handling API
  libweston: Merge weston_output_init() into weston_output_enable()
  weston: Rename weston_output_init_pending() to weston_output_init()
  libweston: Remove weston_backend_output_config structure
  libweston: Drop requirement of setting mm_width/mm_height in backends
  compositor-rdp: Properly destroy the renderer and pixman image

 Makefile.am |   1 +
 compositor/main.c   | 781 
 libweston/compositor-drm.c  | 434 --
 libweston/compositor-drm.h  |  50 ++-
 libweston/compositor-fbdev.c|  87 +++--
 libweston/compositor-fbdev.h|   4 +-
 libweston/compositor-headless.c | 152 +---
 libweston/compositor-headless.h |   8 +-
 libweston/compositor-rdp.c  | 139 ---
 libweston/compositor-rdp.h  |  26 +-
 libweston/compositor-wayland.c  | 324 ++---
 libweston/compositor-wayland.h  |   8 -
 libweston/compositor-x11.c  | 312 +---
 libweston/compositor-x11.h  |  13 +-
 libweston/compositor.c  | 401 +
 libweston/compositor.h  |  51 ++-
 libweston/windowed-output-api.h |  92 +
 17 files changed, 1851 insertions(+), 1032 deletions(-)
 create mode 100644 libweston/windowed-output-api.h

-- 
2.9.3

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


Re: [PATCH libinput] tablet: don't send tip up/button release/prox out events for unknown tools

2016-08-18 Thread Jason Gerecke
On 08/17/2016 10:20 PM, Peter Hutterer wrote:
> If the kernel does not send the MSC_SERIAL information with every event, we
> end up creating a tool with a serial of 0. When the MSC_SERIAL comes in
> later for this tool libinput will think it's a new tool. On proximity out of
> that new tool we send the required release events even though we never sent
> the proximity in/button down/tip down events.
> 
> Simply ditch those events and log a bug message instead. This causes the
> first tool with serial 0 to remain in proximity/down state forever but it's a
> made-up situation anyway, let's deal with that when we have devices other
> than our own test devices triggering this.
> 

Hmmm. It sounds like a tablet PC which uses one of Wacom's "AES"
sensors* might be able to trigger this. It often takes several packets
for the sensor to send a non-zero pen serial number, and continues to
report a serial until the pen leaves prox. I don't know if this
could/should be fixed in the kernel since in some cases the delay from
prox to serial can be several tenths of a second -- large enough that if
the kernel drops events until a serial is seen the user may think
something is malfunctioning.

I've attached an evemu log from an AES tablet I have handy for review.

* Examples include the Dell Venue 10 Pro 5055, HP Envy 8 Note 5000,
Lenovo ThinkPad X1 Yoga, ThinkPad Yoga 260, ThinkPad Yoga 460, etc.

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours

> Signed-off-by: Peter Hutterer 
> ---
>  src/evdev-tablet.c | 58 +++-
>  src/libinput-private.h |  2 ++
>  test/tablet.c  | 72 
> ++
>  3 files changed, 114 insertions(+), 18 deletions(-)
> 
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 8f24555..bc85655 100644
> --- a/src/evdev-tablet.c
> +++ b/src/evdev-tablet.c
> @@ -1198,6 +1198,24 @@ tablet_mark_all_axes_changed(struct tablet_dispatch 
> *tablet,
>  sizeof(tablet->changed_axes));
>  }
>  
> +static inline bool
> +tool_was_in_proximity(struct tablet_dispatch *tablet,
> +   struct libinput_tablet_tool *tool)
> +{
> + if (!tool->in_proximity) {
> + struct libinput *libinput = tablet_libinput_context(tablet);
> + log_bug_kernel(libinput,
> +"%s: prox out for tool type %d tool_id %#x 
> serial %#x, "
> +"but no prox in recorded\n",
> +tablet->device->devname,
> +tool->type,
> +tool->serial,
> +tool->tool_id);
> + }
> +
> + return tool->in_proximity;
> +}
> +
>  static void
>  tablet_update_proximity_state(struct tablet_dispatch *tablet,
> struct evdev_device *device,
> @@ -1295,6 +1313,7 @@ tablet_send_axis_proximity_tip_down_events(struct 
> tablet_dispatch *tablet,
>   LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN,
>   tablet->changed_axes,
>   );
> + tool->in_proximity = true;
>   tablet_unset_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
>   tablet_unset_status(tablet, TABLET_AXES_UPDATED);
>   }
> @@ -1310,12 +1329,13 @@ tablet_send_axis_proximity_tip_down_events(struct 
> tablet_dispatch *tablet,
>   tablet_unset_status(tablet, TABLET_TOOL_ENTERING_CONTACT);
>   tablet_set_status(tablet, TABLET_TOOL_IN_CONTACT);
>   } else if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_CONTACT)) {
> - tablet_notify_tip(>base,
> -   time,
> -   tool,
> -   LIBINPUT_TABLET_TOOL_TIP_UP,
> -   tablet->changed_axes,
> -   >axes);
> + if (tool_was_in_proximity(tablet, tool))
> + tablet_notify_tip(>base,
> +   time,
> +   tool,
> +   LIBINPUT_TABLET_TOOL_TIP_UP,
> +   tablet->changed_axes,
> +   >axes);
>   tablet_unset_status(tablet, TABLET_AXES_UPDATED);
>   tablet_unset_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
>   tablet_unset_status(tablet, TABLET_TOOL_IN_CONTACT);
> @@ -1388,11 +1408,12 @@ tablet_flush(struct tablet_dispatch *tablet,
>  time);
>  
>   if (tablet_has_status(tablet, TABLET_BUTTONS_RELEASED)) {
> - tablet_notify_buttons(tablet,
> -   

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

2016-08-18 Thread Armin Krezović
On 18.08.2016 12:31, Pekka Paalanen wrote:
> On Wed, 17 Aug 2016 19:49:06 +0200
> Armin Krezović  wrote:
> 
>> On 17.08.2016 17:07, Pekka Paalanen wrote:
>>> On Sun, 14 Aug 2016 17:28:17 +0200
>>> Armin Krezović  wrote:

SNIP

 +static int
 +wayland_output_configure_hotplug(struct weston_output *base)
 +{
 +  struct wayland_output *output = to_wayland_output(base);
 +  struct wayland_parent_output *poutput = output->user_data;
  
if (poutput->current_mode) {
 -  mode = poutput->current_mode;
 +  output->poutput_mode = poutput->current_mode;
} else if (poutput->preferred_mode) {
 -  mode = poutput->preferred_mode;
 +  output->poutput_mode = poutput->preferred_mode;
} else if (!wl_list_empty(>mode_list)) {
 -  mode = container_of(poutput->mode_list.next,
 -  struct weston_mode, link);
 -  } else {
 -  weston_log("No valid modes found.  Skipping output\n");
 -  return NULL;
 -  }
 -
 -  if (!wl_list_empty(>compositor->output_list)) {
 -  output = container_of(b->compositor->output_list.prev,
 -struct wayland_output, base.link);
 -  x = output->base.x + output->base.current_mode->width;
 +  output->poutput_mode = container_of(poutput->mode_list.next,
 +  struct weston_mode, link);
} else {
 -  x = 0;
 +  weston_log("No valid modes found. Cannot configure an 
 output.\n");
 +  return -1;
}
  
 -  output = wayland_output_create(b, x, 0, mode->width, mode->height,
 - NULL, 0,
 - WL_OUTPUT_TRANSFORM_NORMAL, 1);
 -  if (!output)
 -  return NULL;
 +  if (wayland_output_configure(>base, output->poutput_mode->width,
 +   output->poutput_mode->height) < 0)  
>>>
>>> If wayland_output_configure() multiplies by scale and applies
>>> transformation, then passing mode->width and mode->height directly here
>>> is wrong.
>>>
>>> The "video mode" is given in output pixels, so it is already multiplied
>>> by scale and rotated by transform.
>>>
>>> I see the old code was equally wrong, particularly if the output was
>>> rotated 90 degrees it would create a window with inverted aspect ratio.
>>> Ok, so if this keeps the old broken behaviour, it's fine.
>>>
>>> Testing the upstream x11-backend, it looks like we expect to put the
>>> logical output size (in global coordinates) in weston.ini, and then
>>> expect the scale and transform to be applied on that to get the output
>>> resolution in output pixels.
>>>   
>>
>> This is for parent output (fs shell and sprawl). You can't change the size
>> here. Scale and transform are also hardcoded to "scale = 1, transform = 
>> WL_OUTPUT_TRANSFORM_NORMAL"
>> (well, they used to be and I let them remain that way).
>>
>> See:
>>
>> https://cgit.freedesktop.org/wayland/weston/tree/libweston/compositor-wayland.c#n1148
>>
>> and:
>>
>> https://github.com/krezovic/weston/blob/gsoc-v10/compositor/main.c#L1545
>>
>> Those values are set just for sake of it, it's not that anything uses them.
> 
> Yes, but ideally we might use also the scale and transform from the
> parent output.
> 

But, if parent output was transformed, wouldn't that display the surface
just as it should be? Applying transform might further scale/rotate it. If
it were to be used for "show off" (in weston-info, for example), we could
do that. But I doubt we want any additional transformations if parent output
is already transformed.

So, for *_for_parent_output case, I've hardcoded transform and scale values
in the backend, just before calls to wayland_output_set_size().

> Those values are no longer hardcoded in this site here, which makes
> things harder to follow, and wayland_output_configure() does use them.
> 
> However, that doesn't really affect this patch. Except maybe needing a
> comment about scale and transform.
> 
> Btw. wayland_output_configure() forgets to apply transform, but that's
> how it was already.
> 

Backend functions don't do that. It's done in libweston, (current) 
weston_output_init, rather.

 +  return -1;
  
output->parent.output = poutput->global;
  
> 
> 
> 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


[PATCH weston] libweston-desktop/xwayland: Do not over-destroy the view

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

With this weston_view_destroy() call, Xwayland popups make Weston freeze
in a busy-loop (probably corrupted wl_list).

Signed-off-by: Quentin Glidic 
---
 libweston-desktop/xwayland.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
index cb08323..bd68bc6 100644
--- a/libweston-desktop/xwayland.c
+++ b/libweston-desktop/xwayland.c
@@ -152,13 +152,11 @@ weston_desktop_xwayland_surface_destroy(struct 
weston_desktop_surface *dsurface,
wl_list_remove(>resource_destroy_listener.link);
 
weston_desktop_surface_unset_relative_to(surface->surface);
-   if (surface->added) {
+   if (surface->added)
weston_desktop_api_surface_removed(surface->desktop,
   surface->surface);
-   } else if (surface->state == XWAYLAND) {
+   else if (surface->state == XWAYLAND)
weston_desktop_surface_unlink_view(surface->view);
-   weston_view_destroy(surface->view);
-   }
 
free(surface);
 }
-- 
2.9.2

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


[PATCH weston] libweston-desktop/xdg_shell_v5: Add surface as needed

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

This way we are sure the compositor is aware of a surface when we
forward a request for said surface.

Signed-off-by: Quentin Glidic 
---
 libweston-desktop/xdg-shell-v5.c | 42 ++--
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index f8943ab..4bb5cdc 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -43,6 +43,7 @@ struct weston_desktop_xdg_surface {
struct wl_resource *resource;
struct weston_desktop_surface *surface;
struct weston_desktop *desktop;
+   bool added;
struct wl_event_source *add_idle;
struct wl_event_source *configure_idle;
uint32_t configure_serial;
@@ -65,6 +66,19 @@ struct weston_desktop_xdg_popup {
struct wl_display *display;
 };
 
+static void
+weston_desktop_xdg_surface_add_if_needed(struct weston_desktop_xdg_surface 
*surface)
+{
+   if (surface->added)
+   return;
+
+   if ( surface->add_idle != NULL )
+   wl_event_source_remove(surface->add_idle);
+   surface->add_idle = NULL;
+   weston_desktop_api_surface_added(surface->desktop, surface->surface);
+   surface->added = true;
+}
+
 static void
 weston_desktop_xdg_surface_send_configure(void *data)
 {
@@ -210,12 +224,7 @@ weston_desktop_xdg_surface_committed(struct 
weston_desktop_surface *dsurface,

surface->next_geometry);
}
 
-   if (surface->add_idle != NULL) {
-   wl_event_source_remove(surface->add_idle);
-   surface->add_idle = NULL;
-   weston_desktop_api_surface_added(surface->desktop,
-  surface->surface);
-   }
+   weston_desktop_xdg_surface_add_if_needed(surface);
weston_desktop_api_committed(surface->desktop, surface->surface,
 sx, sy);
}
@@ -283,7 +292,9 @@ weston_desktop_xdg_surface_destroy(struct 
weston_desktop_surface *dsurface,
 {
struct weston_desktop_xdg_surface *surface = user_data;
 
-   weston_desktop_api_surface_removed(surface->desktop, surface->surface);
+   if (surface->added)
+   weston_desktop_api_surface_removed(surface->desktop,
+  surface->surface);
 
if (surface->add_idle != NULL)
wl_event_source_remove(surface->add_idle);
@@ -307,6 +318,8 @@ weston_desktop_xdg_surface_protocol_set_parent(struct 
wl_client *wl_client,
 
if (parent_resource != NULL)
parent = wl_resource_get_user_data(parent_resource);
+
+   weston_desktop_xdg_surface_add_if_needed(surface);
weston_desktop_api_set_parent(surface->desktop, dsurface, parent);
 }
 
@@ -346,6 +359,7 @@ weston_desktop_xdg_surface_protocol_show_window_menu(struct 
wl_client *wl_client
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
 
+   weston_desktop_xdg_surface_add_if_needed(surface);
weston_desktop_api_show_window_menu(surface->desktop, dsurface, seat, 
x, y);
 }
 
@@ -362,6 +376,7 @@ weston_desktop_xdg_surface_protocol_move(struct wl_client 
*wl_client,
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
 
+   weston_desktop_xdg_surface_add_if_needed(surface);
weston_desktop_api_move(surface->desktop, dsurface, seat, serial);
 }
 
@@ -379,6 +394,7 @@ weston_desktop_xdg_surface_protocol_resize(struct wl_client 
*wl_client,
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
 
+   weston_desktop_xdg_surface_add_if_needed(surface);
weston_desktop_api_resize(surface->desktop, dsurface, seat, serial, 
edges);
 }
 
@@ -425,6 +441,7 @@ weston_desktop_xdg_surface_protocol_set_maximized(struct 
wl_client *wl_client,
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
 
+   weston_desktop_xdg_surface_add_if_needed(surface);
weston_desktop_api_maximized_requested(surface->desktop, dsurface, 
true);
 }
 
@@ -437,6 +454,7 @@ weston_desktop_xdg_surface_protocol_unset_maximized(struct 
wl_client *wl_client,
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
 
+   weston_desktop_xdg_surface_add_if_needed(surface);
weston_desktop_api_maximized_requested(surface->desktop, dsurface, 
false);
 }
 
@@ -454,6 +472,7 @@ weston_desktop_xdg_surface_protocol_set_fullscreen(struct 

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

2016-08-18 Thread Pekka Paalanen
On Sun, 14 Aug 2016 17:28:16 +0200
Armin Krezović  wrote:

> This is a complete port of the RDP backend that uses
> recently added output handling API for output
> configuration.
> 
> Output can be configured at runtime by passing the
> necessary configuration parameters, which can be
> filled in manually or obtained from the command line
> using previously added functionality. It is required
> that the scale and transform values are set using
> the previously added functionality.
> 
> After everything has been set, output needs to be
> enabled manually using weston_output_enable().
> 
> v2:
> 
>  - Rename output_configure() to output_set_size()
>in plugin API and describe it.
>  - Manually fetch parsed_options from wet_compositor.
>  - Call rdp_output_disable() explicitly from
>rdp_output_destroy().
> 
> Signed-off-by: Armin Krezović 
> ---
>  compositor/main.c  |  52 --
>  libweston/compositor-rdp.c | 130 
> +++--
>  libweston/compositor-rdp.h |  24 -
>  3 files changed, 160 insertions(+), 46 deletions(-)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index b26760c..a72c2f9 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -1284,13 +1284,46 @@ load_headless_backend(struct weston_compositor *c,
>  }
>  
>  static void
> +rdp_backend_output_configure(struct wl_listener *listener, void *data)
> +{
> + struct weston_output *output = data;
> + struct wet_compositor *compositor = 
> to_wet_compositor(output->compositor);
> + struct wet_output_config *parsed_options = compositor->parsed_options;
> + const struct weston_rdp_output_api *api = 
> weston_rdp_output_get_api(output->compositor);
> + int width = 640;
> + int height = 480;
> +
> + assert(parsed_options);
> +
> + if (!api) {
> + weston_log("Cannot use weston_rdp_output_api.\n");
> + return;
> + }
> +
> + if (parsed_options->width)
> + width = parsed_options->width;
> +
> + if (parsed_options->height)
> + height = parsed_options->height;
> +
> + weston_output_set_scale(output, 1);
> + weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
> +
> + if (api->output_set_size(output, width, height) < 0) {
> + weston_log("Cannot configure output \"%s\" using 
> weston_rdp_output_api.\n",
> +output->name);
> + return;
> + }
> +
> + weston_output_enable(output);
> +}
> +
> +static void
>  weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
>  {
>   config->base.struct_version = WESTON_RDP_BACKEND_CONFIG_VERSION;
>   config->base.struct_size = sizeof(struct weston_rdp_backend_config);
>  
> - config->width = 640;
> - config->height = 480;
>   config->bind_address = NULL;
>   config->port = 3389;
>   config->rdp_key = NULL;
> @@ -1307,12 +1340,16 @@ load_rdp_backend(struct weston_compositor *c,
>   struct weston_rdp_backend_config config  = {{ 0, }};
>   int ret = 0;
>  
> + struct wet_output_config *parsed_options = wet_init_parsed_options(c);
> + if (!parsed_options)
> + return -1;
> +
>   weston_rdp_backend_config_init();
>  
>   const struct weston_option rdp_options[] = {
>   { WESTON_OPTION_BOOLEAN, "env-socket", 0, _socket },
> - { WESTON_OPTION_INTEGER, "width", 0,  },
> - { WESTON_OPTION_INTEGER, "height", 0,  },
> + { WESTON_OPTION_INTEGER, "width", 0, _options->width },
> + { WESTON_OPTION_INTEGER, "height", 0, _options->height },
>   { WESTON_OPTION_STRING,  "address", 0, _address },
>   { WESTON_OPTION_INTEGER, "port", 0,  },
>   { WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, 
> _clients_resize },
> @@ -1326,10 +1363,17 @@ load_rdp_backend(struct weston_compositor *c,
>   ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP,
>);
>  
> + if (ret < 0)
> + goto out;
> +
> + wet_set_pending_output_handler(c, rdp_backend_output_configure);
> +
> +out:
>   free(config.bind_address);
>   free(config.rdp_key);
>   free(config.server_cert);
>   free(config.server_key);
> +
>   return ret;
>  }
>  

Again, main.c stuff looks good.


> diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
> index 11f5f05..ffa2fdf 100644
> --- a/libweston/compositor-rdp.c
> +++ b/libweston/compositor-rdp.c
> @@ -371,15 +371,6 @@ rdp_output_repaint(struct weston_output *output_base, 
> pixman_region32_t *damage)
>   return 0;
>  }
>  
> -static void
> -rdp_output_destroy(struct weston_output *output_base)
> -{
> - struct rdp_output *output = to_rdp_output(output_base);
> -
> - wl_event_source_remove(output->finish_frame_timer);
> - free(output);
> -}
> -
>  

Re: [PATCH weston 09/12 v2] weston: Port X11 backend to new output handling API

2016-08-18 Thread Pekka Paalanen
On Sun, 14 Aug 2016 17:28:18 +0200
Armin Krezović  wrote:

> 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().
> 
> Signed-off-by: Armin Krezović 
> ---
>  compositor/main.c  | 151 ++-
>  libweston/compositor-x11.c | 295 
> -
>  libweston/compositor-x11.h |  11 --
>  3 files changed, 223 insertions(+), 234 deletions(-)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index 143ee21..a39a954 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c

>  
> - config.base.struct_version = WESTON_X11_BACKEND_CONFIG_VERSION;
> - config.base.struct_size = sizeof(struct weston_x11_backend_config);
> -
> - /* load the actual backend and configure it */
> - ret = weston_compositor_load_backend(c, WESTON_BACKEND_X11,
> -  );
> -
> -out:
> - for (j = 0; j < config.num_outputs; ++j)
> - free(config.outputs[j].name);
> - free(config.outputs);
> + return 0;
>  
> +err:
> + free(parsed_options);

wet_compositor::parsed_options gets stale again.


All the other main.c bits look ok.

>   return ret;
>  }
>  
> diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
> index b900184..5720ddf 100644
> --- a/libweston/compositor-x11.c
> +++ b/libweston/compositor-x11.c
> @@ -59,6 +59,7 @@
>  #include "pixman-renderer.h"
>  #include "presentation-time-server-protocol.h"
>  #include "linux-dmabuf.h"
> +#include "windowed-output-api.h"
>  
>  #define DEFAULT_AXIS_STEP_DISTANCE 10
>  
> @@ -75,6 +76,8 @@ struct x11_backend {
>   struct xkb_keymap   *xkb_keymap;
>   unsigned int has_xkb;
>   uint8_t  xkb_event_base;
> + int  fullscreen;
> + int  no_input;
>   int  use_pixman;
>  
>   int  has_net_wm_state_fullscreen;
> @@ -516,30 +519,6 @@ x11_output_deinit_shm(struct x11_backend *b, struct 
> x11_output *output)
>  }
>  
>  static void
> -x11_output_destroy(struct weston_output *output_base)
> -{
> - struct x11_output *output = to_x11_output(output_base);
> - struct x11_backend *backend =
> - to_x11_backend(output->base.compositor);
> -
> - wl_event_source_remove(output->finish_frame_timer);
> -
> - if (backend->use_pixman) {
> - pixman_renderer_output_destroy(output_base);
> - x11_output_deinit_shm(backend, output);
> - } else
> - gl_renderer->output_destroy(output_base);
> -
> - xcb_destroy_window(backend->conn, output->window);
> -
> - xcb_flush(backend->conn);
> -
> - weston_output_destroy(>base);
> -
> - free(output);
> -}
> -
> -static void
>  x11_output_set_wm_protocols(struct x11_backend *b,
>   struct x11_output *output)
>  {
> @@ -789,20 +768,54 @@ x11_output_init_shm(struct x11_backend *b, struct 
> x11_output *output,
>   return 0;
>  }
>  
> -static struct x11_output *
> -x11_backend_create_output(struct x11_backend *b, int x, int y,
> -  int width, int height, int fullscreen,
> -  int no_input, char *configured_name,
> -  uint32_t transform, int32_t scale)
> +static int
> +x11_output_disable(struct weston_output *base)
> +{
> + struct x11_output *output = to_x11_output(base);
> + struct x11_backend *backend = to_x11_backend(base->compositor);
> +
> + if (!output->base.enabled)
> + return 0;
> +
> + wl_event_source_remove(output->finish_frame_timer);
> +
> + if (backend->use_pixman) {
> + pixman_renderer_output_destroy(>base);
> + x11_output_deinit_shm(backend, output);
> + } else {
> + gl_renderer->output_destroy(>base);
> + }
> +
> 

Re: [PATCH weston 1/2] libweston: Move text_backend_* to weston.h

2016-08-18 Thread Quentin Glidic

On 18/08/2016 11:15, Quentin Glidic wrote:

From: Quentin Glidic 


I forgot to explain it, but these are actually defined in Weston, not 
libweston, so any libweston user trying to use them will fail.




Signed-off-by: Quentin Glidic 
---

This patch should be in the release.

 compositor/weston.h| 8 
 libweston/compositor.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/compositor/weston.h b/compositor/weston.h
index bff5cc1..bb04002 100644
--- a/compositor/weston.h
+++ b/compositor/weston.h
@@ -66,6 +66,14 @@ wet_load_module(const char *name, const char *entrypoint);
 int
 wet_load_xwayland(struct weston_compositor *comp);

+struct text_backend;
+
+struct text_backend *
+text_backend_init(struct weston_compositor *ec);
+
+void
+text_backend_destroy(struct text_backend *text_backend);
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 301bdca..586937d 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1704,14 +1704,6 @@ weston_recorder_stop(struct weston_recorder *recorder);
 struct clipboard *
 clipboard_create(struct weston_seat *seat);

-struct text_backend;
-
-struct text_backend *
-text_backend_init(struct weston_compositor *ec);
-
-void
-text_backend_destroy(struct text_backend *text_backend);
-
 struct weston_view_animation;
 typedefvoid (*weston_view_animation_done_func_t)(struct 
weston_view_animation *animation, void *data);





--

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


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

2016-08-18 Thread Pekka Paalanen
On Thu, 18 Aug 2016 13:31:22 +0300
Pekka Paalanen  wrote:

> On Wed, 17 Aug 2016 19:49:06 +0200
> Armin Krezović  wrote:
> 
> > On 17.08.2016 17:07, Pekka Paalanen wrote:  
> > > On Sun, 14 Aug 2016 17:28:17 +0200
> > > Armin Krezović  wrote:
> > > 
> > >> This is a complete port of the Wayland 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.
> > >>
> > >> 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().
> > >>
> > >> Signed-off-by: Armin Krezović 
> > >> ---
> > >>  compositor/main.c  | 275 +++---
> > >>  libweston/compositor-wayland.c | 327 
> > >> +++--
> > >>  libweston/compositor-wayland.h |  27 +++-
> > >>  3 files changed, 325 insertions(+), 304 deletions(-)
> > >>
> > >> diff --git a/compositor/main.c b/compositor/main.c
> > >> index a72c2f9..143ee21 100644
> > >> --- a/compositor/main.c
> > >> +++ b/compositor/main.c  
> 
> > >> -/*
> > >> - * Append a new output struct at the end of new_config.outputs and 
> > >> return a
> > >> - * pointer to the newly allocated structure or NULL if fail. The 
> > >> allocated
> > >> - * structure is NOT cleared nor set to default values.
> > >> - */
> > >> -static struct weston_wayland_backend_output_config *
> > >> -weston_wayland_backend_config_add_new_output(struct 
> > >> weston_wayland_backend_config *config)
> > >> +wayland_backend_output_configure(struct wl_listener *listener, void 
> > >> *data)
> > >>  {
> > >> -struct weston_wayland_backend_output_config *outputs;
> > >> -const size_t element_size = sizeof(struct 
> > >> weston_wayland_backend_output_config);
> > >> +struct weston_output *output = data;
> > >> +struct wet_output_config defaults = {
> > >> +.width = 1024,
> > >> +.height = 640,
> > >> +.scale = 1,
> > >> +.transform = WL_OUTPUT_TRANSFORM_NORMAL
> > >> +};
> > >>  
> > >> -outputs = realloc(config->outputs,
> > >> -  (config->num_outputs + 1) * element_size);
> > >> -if (!outputs)
> > >> -return NULL;
> > >> -config->num_outputs += 1;
> > >> -config->outputs = outputs;
> > >> -return &(config->outputs[config->num_outputs - 1]);
> > >> +if (wet_configure_windowed_output_from_config(output, 
> > >> ) < 0)
> > >> +weston_log("Cannot configure output \"%s\".\n",
> > >> +   output->name ? output->name : "unnamed");
> > > 
> > > I think wayland_backend_output_configure() is missing a special case
> > > for --fullscreen. That is, desktop shell (windowed api) but asked to be
> > > fullscreen...
> > > 
> > > Actually no, this is fine. It would just need a comment explaining that
> > > the backend will override the size if --fullscreen was given. I see
> > > this would be inconvenient to realize otherwise.
> > > 
> > > 
> > 
> > The backend would only set the surface fullscreen. I don't know what it will
> > do to the size though, the values aren't touched, at least not that I saw 
> > it.  
> 
> Setting fullscreen involves a shell protocol hand-shake to negotiate
> the size. The backend should be doing that already.

Btw. that will be an interesting fact for the output layout work. You
won't know the size until after the negotiation.

Another thing is, it might not make sense to allow the compositor to
set the layout itself if you sprawl all outputs. The outputs are
already arranged somehow, so you might want to use the parent

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

2016-08-18 Thread Pekka Paalanen
On Wed, 17 Aug 2016 19:49:06 +0200
Armin Krezović  wrote:

> On 17.08.2016 17:07, Pekka Paalanen wrote:
> > On Sun, 14 Aug 2016 17:28:17 +0200
> > Armin Krezović  wrote:
> >   
> >> This is a complete port of the Wayland 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.
> >>
> >> 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().
> >>
> >> Signed-off-by: Armin Krezović 
> >> ---
> >>  compositor/main.c  | 275 +++---
> >>  libweston/compositor-wayland.c | 327 
> >> +++--
> >>  libweston/compositor-wayland.h |  27 +++-
> >>  3 files changed, 325 insertions(+), 304 deletions(-)
> >>
> >> diff --git a/compositor/main.c b/compositor/main.c
> >> index a72c2f9..143ee21 100644
> >> --- a/compositor/main.c
> >> +++ b/compositor/main.c

> >> -/*
> >> - * Append a new output struct at the end of new_config.outputs and return 
> >> a
> >> - * pointer to the newly allocated structure or NULL if fail. The allocated
> >> - * structure is NOT cleared nor set to default values.
> >> - */
> >> -static struct weston_wayland_backend_output_config *
> >> -weston_wayland_backend_config_add_new_output(struct 
> >> weston_wayland_backend_config *config)
> >> +wayland_backend_output_configure(struct wl_listener *listener, void *data)
> >>  {
> >> -  struct weston_wayland_backend_output_config *outputs;
> >> -  const size_t element_size = sizeof(struct 
> >> weston_wayland_backend_output_config);
> >> +  struct weston_output *output = data;
> >> +  struct wet_output_config defaults = {
> >> +  .width = 1024,
> >> +  .height = 640,
> >> +  .scale = 1,
> >> +  .transform = WL_OUTPUT_TRANSFORM_NORMAL
> >> +  };
> >>  
> >> -  outputs = realloc(config->outputs,
> >> -(config->num_outputs + 1) * element_size);
> >> -  if (!outputs)
> >> -  return NULL;
> >> -  config->num_outputs += 1;
> >> -  config->outputs = outputs;
> >> -  return &(config->outputs[config->num_outputs - 1]);
> >> +  if (wet_configure_windowed_output_from_config(output, ) < 0)
> >> +  weston_log("Cannot configure output \"%s\".\n",
> >> + output->name ? output->name : "unnamed");  
> > 
> > I think wayland_backend_output_configure() is missing a special case
> > for --fullscreen. That is, desktop shell (windowed api) but asked to be
> > fullscreen...
> > 
> > Actually no, this is fine. It would just need a comment explaining that
> > the backend will override the size if --fullscreen was given. I see
> > this would be inconvenient to realize otherwise.
> > 
> >   
> 
> The backend would only set the surface fullscreen. I don't know what it will
> do to the size though, the values aren't touched, at least not that I saw it.

Setting fullscreen involves a shell protocol hand-shake to negotiate
the size. The backend should be doing that already.


> >>  }
> >>  
> >>  static int
> >> -load_wayland_backend_config(struct weston_compositor *compositor, int 
> >> *argc,
> >> -  char *argv[], struct weston_config *wc,
> >> -  struct weston_wayland_backend_config *config)
> >> +load_wayland_backend(struct weston_compositor *c,
> >> +   int *argc, char **argv, struct weston_config *wc)  
> > 
> > The new load_wayland_backend() looks quite clean, in spite of some
> > mixed code and declarations issue, compared to the old
> > load_wayland_backend_config(). That's nice.
> >   
> >>  {
> >> +  struct weston_wayland_backend_config config = {{ 0, }};


> >> @@ -1038,118 +1043,169 @@ wayland_output_create(struct wayland_backend *b, 
> >> int x, int y,

Re: [PATCH weston 2/2] Makefile.am: Link modules to libweston.la

2016-08-18 Thread Pekka Paalanen
On Thu, 18 Aug 2016 11:15:45 +0200
Quentin Glidic  wrote:

> From: Quentin Glidic 
> 
> Modules are using libweston symbols (at least weston_log) and should
> explicitly link to it.
> 
> This patch also reorders some flags.
> 
> Signed-off-by: Quentin Glidic 
> ---
> 
> It doesn’t allow to build with --no-undefined, but it gets closer to that.
> 
>  Makefile.am | 105 
> ++--
>  1 file changed, 73 insertions(+), 32 deletions(-)
> 

Hi,

both patches
Acked-by: Pekka Paalanen 
for landing before beta.

(Ack does not count as R-b.)


Thanks,
pq


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


Re: [PATCH libinput] touchpad: on a non-clickpad, reset the motion history on nfingers change

2016-08-18 Thread Hans de Goede

Hi,

On 18-08-16 08:02, Peter Hutterer wrote:

The only reason to have more than one finger on a non-clickpad is to tap,
scroll or gesture. In all cases resetting the motion history is a good idea to
avoid jumps moving from 2 to 1 finger.

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

Signed-off-by: Peter Hutterer 


Looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
 src/evdev-mt-touchpad.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 6cebfa3..3baed09 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -957,8 +957,11 @@ tp_need_motion_history_reset(struct tp_dispatch *tp)
 {
bool rc = false;

-   /* semi-mt finger postions may "jump" when nfingers changes */
-   if (tp->semi_mt && tp->nfingers_down != tp->old_nfingers_down)
+   /* Semi-mt finger postions may "jump" when nfingers changes. And on
+* a non-clickpad the only reason to have more than one finger down
+* is scrolling/gesture, so a reset just makes things sane again */
+   if ((tp->semi_mt || !tp->buttons.is_clickpad) &&
+   tp->nfingers_down != tp->old_nfingers_down)
return true;

/* if we're transitioning between slots and fake touches in either


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


[PATCH weston 1/2] libweston: Move text_backend_* to weston.h

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

Signed-off-by: Quentin Glidic 
---

This patch should be in the release.

 compositor/weston.h| 8 
 libweston/compositor.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/compositor/weston.h b/compositor/weston.h
index bff5cc1..bb04002 100644
--- a/compositor/weston.h
+++ b/compositor/weston.h
@@ -66,6 +66,14 @@ wet_load_module(const char *name, const char *entrypoint);
 int
 wet_load_xwayland(struct weston_compositor *comp);
 
+struct text_backend;
+
+struct text_backend *
+text_backend_init(struct weston_compositor *ec);
+
+void
+text_backend_destroy(struct text_backend *text_backend);
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 301bdca..586937d 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1704,14 +1704,6 @@ weston_recorder_stop(struct weston_recorder *recorder);
 struct clipboard *
 clipboard_create(struct weston_seat *seat);
 
-struct text_backend;
-
-struct text_backend *
-text_backend_init(struct weston_compositor *ec);
-
-void
-text_backend_destroy(struct text_backend *text_backend);
-
 struct weston_view_animation;
 typedefvoid (*weston_view_animation_done_func_t)(struct 
weston_view_animation *animation, void *data);
 
-- 
2.9.2

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


[PATCH weston 2/2] Makefile.am: Link modules to libweston.la

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

Modules are using libweston symbols (at least weston_log) and should
explicitly link to it.

This patch also reorders some flags.

Signed-off-by: Quentin Glidic 
---

It doesn’t allow to build with --no-undefined, but it gets closer to that.

 Makefile.am | 105 ++--
 1 file changed, 73 insertions(+), 32 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1e63a58..b746399 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -116,7 +116,9 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES =
\
 lib_LTLIBRARIES += libweston-desktop-@LIBWESTON_MAJOR@.la
 libweston_desktop_@LIBWESTON_MAJOR@_la_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
 libweston_desktop_@LIBWESTON_MAJOR@_la_CFLAGS = $(AM_CFLAGS) 
$(COMPOSITOR_CFLAGS)
-libweston_desktop_@LIBWESTON_MAJOR@_la_LIBADD = libweston-@LIBWESTON_MAJOR@.la 
$(COMPOSITOR_LIBS)
+libweston_desktop_@LIBWESTON_MAJOR@_la_LIBADD =\
+   libweston-@LIBWESTON_MAJOR@.la  \
+   $(COMPOSITOR_LIBS)
 libweston_desktop_@LIBWESTON_MAJOR@_la_LDFLAGS = -version-info 
$(LT_VERSION_INFO)
 
 libweston_desktop_@LIBWESTON_MAJOR@_la_SOURCES =   \
@@ -145,7 +147,7 @@ libweston-desktop-@LIBWESTON_MAJOR@.la 
libweston-desktop/libweston_desktop_@LIBW
 if SYSTEMD_NOTIFY_SUPPORT
 module_LTLIBRARIES += systemd-notify.la
 systemd_notify_la_LDFLAGS = -module -avoid-version
-systemd_notify_la_LIBADD = $(SYSTEMD_DAEMON_LIBS)
+systemd_notify_la_LIBADD = libweston-@LIBWESTON_MAJOR@.la 
$(SYSTEMD_DAEMON_LIBS)
 systemd_notify_la_CFLAGS = \
$(COMPOSITOR_CFLAGS)\
$(SYSTEMD_DAEMON_CFLAGS)\
@@ -216,7 +218,7 @@ libsession_helper_la_SOURCES =  \
libweston/launcher-weston-launch.c  \
libweston/launcher-direct.c
 libsession_helper_la_CFLAGS = $(AM_CFLAGS) $(LIBDRM_CFLAGS) $(PIXMAN_CFLAGS) 
$(COMPOSITOR_CFLAGS)
-libsession_helper_la_LIBADD = $(LIBDRM_LIBS)
+libsession_helper_la_LIBADD = libweston-@LIBWESTON_MAJOR@.la $(LIBDRM_LIBS)
 
 if ENABLE_DBUS
 if HAVE_SYSTEMD_LOGIN
@@ -305,7 +307,10 @@ endif
 if ENABLE_EGL
 libweston_module_LTLIBRARIES += gl-renderer.la
 gl_renderer_la_LDFLAGS = -module -avoid-version
-gl_renderer_la_LIBADD = $(COMPOSITOR_LIBS) $(EGL_LIBS)
+gl_renderer_la_LIBADD =\
+   libweston-@LIBWESTON_MAJOR@.la  \
+   $(EGL_LIBS) \
+   $(COMPOSITOR_LIBS)
 gl_renderer_la_CFLAGS =\
$(COMPOSITOR_CFLAGS)\
$(EGL_CFLAGS)   \
@@ -322,15 +327,18 @@ endif
 if ENABLE_X11_COMPOSITOR
 libweston_module_LTLIBRARIES += x11-backend.la
 x11_backend_la_LDFLAGS = -module -avoid-version
-x11_backend_la_LIBADD = $(COMPOSITOR_LIBS) $(X11_COMPOSITOR_LIBS) \
-   libshared-cairo.la
+x11_backend_la_LIBADD =\
+   libshared-cairo.la  \
+   libweston-@LIBWESTON_MAJOR@.la  \
+   $(X11_COMPOSITOR_LIBS)  \
+   $(COMPOSITOR_LIBS)
 x11_backend_la_CFLAGS =\
+   $(AM_CFLAGS)\
$(COMPOSITOR_CFLAGS)\
$(EGL_CFLAGS)   \
$(PIXMAN_CFLAGS)\
$(CAIRO_CFLAGS) \
-   $(X11_COMPOSITOR_CFLAGS)\
-   $(AM_CFLAGS)
+   $(X11_COMPOSITOR_CFLAGS)
 x11_backend_la_SOURCES =   \
libweston/compositor-x11.c  \
libweston/compositor-x11.h  \
@@ -349,12 +357,13 @@ if ENABLE_DRM_COMPOSITOR
 libweston_module_LTLIBRARIES += drm-backend.la
 drm_backend_la_LDFLAGS = -module -avoid-version
 drm_backend_la_LIBADD =\
+   libsession-helper.la\
+   libweston-@LIBWESTON_MAJOR@.la  \
$(COMPOSITOR_LIBS)  \
$(DRM_COMPOSITOR_LIBS)  \
$(INPUT_BACKEND_LIBS)   \
libshared.la\
-   $(CLOCK_GETTIME_LIBS)   \
-   libsession-helper.la
+   $(CLOCK_GETTIME_LIBS)
 drm_backend_la_CFLAGS =\
$(COMPOSITOR_CFLAGS)\
$(EGL_CFLAGS)   \
@@ -372,6 +381,7 @@ drm_backend_la_SOURCES =\
 if ENABLE_VAAPI_RECORDER
 drm_backend_la_SOURCES += libweston/vaapi-recorder.c libweston/vaapi-recorder.h
 drm_backend_la_LIBADD += $(LIBVA_LIBS)
+drm_backend_la_LDFLAGS += -pthread
 drm_backend_la_CFLAGS += $(LIBVA_CFLAGS)
 endif
 endif
@@ -380,9 +390,10 @@ if ENABLE_WAYLAND_COMPOSITOR
 libweston_module_LTLIBRARIES += wayland-backend.la
 wayland_backend_la_LDFLAGS = -module 

Re: [PATCH] gl-renderer: emit frame_signal after eglSwapBuffers

2016-08-18 Thread Pekka Paalanen
On Wed, 17 Aug 2016 17:10:46 +0200
Fabien DESSENNE  wrote:

> On 08/17/2016 09:42 AM, Pekka Paalanen wrote:
> > On Tue, 16 Aug 2016 14:46:23 +0200
> > Fabien DESSENNE  wrote:
> >  
> >> On 08/16/2016 10:18 AM, Pekka Paalanen wrote:  
> >>> On Fri, 12 Aug 2016 14:11:40 +0200
> >>> Fabien Dessenne  wrote:
> >>> 
>  Emit frame_signal at the end of the GL renderer processing, so the
>  frame_signal clients are informed after the buffer is actually updated.
> 
>  Signed-off-by: Fabien Dessenne 
>  ---
> libweston/gl-renderer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
>  diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
>  index d624453..f4d4a5e 100644
>  --- a/libweston/gl-renderer.c
>  +++ b/libweston/gl-renderer.c
>  @@ -1138,7 +1138,6 @@ gl_renderer_repaint_output(struct weston_output 
>  *output,
>   draw_output_borders(output, border_damage);
> 
>   pixman_region32_copy(>previous_damage, output_damage);
>  -wl_signal_emit(>frame_signal, output);
> 
>   if (gr->swap_buffers_with_damage) {
>   pixman_region32_init(_damage);
>  @@ -1185,6 +1184,7 @@ gl_renderer_repaint_output(struct weston_output 
>  *output,
>   }
> 
>   go->border_status = BORDER_STATUS_CLEAN;
>  +wl_signal_emit(>frame_signal, output);
> }
> 
> static int  
> >>> Hi,
> >>>
> >>> I think this will break screenshooting.
> >>>
> >>> Screenshooter relies on glReadPixels, but if you issue eglSwapBuffers
> >>> first, you no longer know what glReadPixels will return. Therefore the
> >>> signal must be emitted before the swapbuffers.  
> >> Oh, yes, you are right, I missed this part.  
> >>> You forgot to explain what problem this change solves, too.  
> >> I am trying to improve the way to record the display since
> >> glReadPixels() is quite slow: although it works fine for a one frame
> >> capture, the performances are not acceptable for a continuous capture.
> >>
> >> So I am prototyping something between screenshooter and VAAPI recorder
> >> but my problem is that my recorder is always one frame late.
> >>
> >> This issue was solved with my proposed patch, but I agree that it is not
> >> acceptable.
> >>
> >> Now I come to the conclusion that VAAPI recorder has probably the same
> >> 'one frame late' issue, which I unfortunately cannot verify, but reading
> >> the code let me think that there is something wrong there:
> >> drm_output_render_gl() calls:
> >> - output->base.compositor->renderer->repaint_output()
> >> - bo = gbm_surface_lock_front_buffer(output->gbm_surface)
> >> - output->next = drm_fb_get_from_bo(bo, b, output->gbm_format)
> >>
> >> Then, "output->current" is updated with the fresh "output->next" at the
> >> next page_flip_handler() call.
> >>
> >> And before that, VAAPI recorder captures "output->current" (see
> >> recorder_frame_notify) just after repaint_output() is called (triggered
> >> by frame_signal emit).
> >> But at that time, "output->current" is not updated yet, it still refers
> >> to the previous frame (it is updated at the next page_flip)
> >>
> >> Can you let me know your opinion about it?  
> > Hi,
> >
> > I didn't verify your reasoning, but it does sound plausible, yes. You
> > might add a new 'post_frame_signal' perhaps for your purposes, or maybe
> > something DRM-backend specific because of reliance on GBM.  
> Hi,
> 
> This is what I have in mind, I'll give it a try.
> > I can also imagine a reason why you would actually want to be one frame
> > late: might calling into VAAPI cause a compositor stall?
> >
> > If VAAPI was blocking somehow, being a frame late allows you avoid
> > blocking for the client and composite rendering. It's sub-optimal, but
> > I am not familiar with VAAPI. If it doesn't have that issue, then
> > adding a new hook sounds fine.  
> I am not familiar with VAAPI, and have no idea whether it is blocking or 
> not. But you are right, the priority must be given to the rendering, so 
> capturing an outdated frame would be a good workaround if there is 
> something blocking.

Ideally nothing should ever block. The time spent blocking the
compositor means it will not be reading input events, processing page
flip events, servicing clients or doing anything at all, and some of
that work if highly time-critical.

Since I don't know if VAAPI blocks for anything, I assume the worst.
Hence I imagined the case how you can avoid at least blocking while
waiting for rendering jobs to complete as that wait is already async
and signalled by the page flip event.

Btw. depending on your use case, you might want the hook just after
eglSwapBuffers or around the KMS page flip submission, *or* in the page
flip event handler. In the former, the render jobs have 

Weston exported symbols

2016-08-18 Thread Pekka Paalanen
On Wed, 17 Aug 2016 13:14:22 +0100
Emil Velikov  wrote:

> On 15 August 2016 at 17:16, Quentin Glidic
>  wrote:
> > On 15/08/2016 17:31, Emil Velikov wrote:  
> >>
> >> From: Emil Velikov 
> >>
> >> Provides some ease wrt constructing the required version.
> >>
> >> Cc: Quentin Glidic 
> >> Suggested-by: Quentin Glidic 
> >> Signed-off-by: Emil Velikov 
> >> ---
> >>
> >> I've swapped ENCODE with API since it makes comparisons a lot better and
> >> it implies a full version including PATCH/MICRO. Yes, GTK/GDK does not
> >> have have it yet every project that has ENCODE macro on my system:
> >> cairo, pango, nm and json-glib does. Perhaps I have the wrong software
> >> installed for my grep search ;-)  
> >  
> >>
> >>
> >>  #if REQUIRED_foo >= foo(x,y)
> >>
> >> Can bring ENCODE back if people miss it.  
> >
> >
> > SOMETHING_VERSION is often a macro defined to the actual installed version,
> > while SOMETHING_ENCODE_VERSION clearly brings the meaning of its purpose.
> >  
> The user says "I want LIBWESTON_*API_*VERSION x,y" by using the macro.
> The macro is _not_ meant to be read by users.
> Users check LIBWESTON_VERSION which includes MINOR/PATCH that can be
> used as needed.
> 
> Should we can add this somewhere in the documentation/readme(s) ?

Giulio, maybe you can solve the naming stalemate? :-)

> >  
> >> Having a look at the file...
> >>  - wasn't the file meant to be installed alongside the weston binary,
> >> since the latter exports symbols like Xorg and binaries depend on those.  
> >
> >
> > Which binaries depend on it?
> >  
> Not "it" but "those". Let me elaborate:
> The file version.h is used to build (out of tree?) weston modules X
> and Y. The latter of which depend at runtime on the symbols exported
> by Weston.
> 
> And now the not so obvious question:
> Are there (m)any out of tree modules that use weston's version.h and
> that one cares about ?
> If there's none one can cleanup the defines as mentioned below.

Ok, do we need to make a difference between Weston version.h and
libweston version.h?

> >  
> >>  - alternatively should we just rename the defines to LIBWESTON_VERS...
> >>
> >> Personally I'm leaning that the following might be a good idea:
> >>  - move all the exports to libweston, make the compositor(s) expose as
> >> little symbols as possible. there's a few left in weston atm.
> >>  - use LIBWESTON_VERSION... unless there's (m)any open-source users
> >> that depend on the WESTON_VERSION... macros.
> >>
> >> I don't have a strong preference on the route taken, just some ideas.  
> >
> >
> > I think it is fine for Weston-specific modules to use Weston-specific
> > functions exported by Weston. But the less exported by Weston the better.
> >  
> Great !
> 
> Can anyone skim through the list (nm -CD --defined-only is the one I
> use) and mention which symbols
>  - should be moved (even if it's impossible atm) to libweston (or other)
>  - stay
>  - can be hidden.

$ nm -CD --defined-only .libs/weston
00409a00 R _IO_stdin_used
0060e458 B __bss_start
0060e438 D __data_start
004099f0 T __libc_csu_fini
00409990 T __libc_csu_init
0060e458 D _edata
0060e638 B _end
004099f4 T _fini
00402fd0 T _init
00405b70 T _start

Std stuff above I believe.

0060e438 W data_start

What's this?

00406e00 T screenshooter_create

This probably shouldn't be exported.

0060e600 B stderr

Std.

00407fd0 T text_backend_destroy
00408000 T text_backend_init

These maybe shouldn't be exported... oh wait, maybe they are used by
the shells? Maybe they should be built into the shell modules?

004063f0 T weston_client_launch
004065f0 T weston_client_start
00408b80 T weston_config_get_libexec_dir
00408610 T weston_config_get_section
00408ad0 T weston_config_section_get_bool
00408880 T weston_config_section_get_color
004089c0 T weston_config_section_get_double
004086a0 T weston_config_section_get_int
00408a70 T weston_config_section_get_string
004087a0 T weston_config_section_get_uint
00406660 T wet_get_config
00406950 T weston_parse_transform
00406ba0 T weston_transform_to_string
004065e0 T weston_watch_process

These might be used by weston (not libweston) plugins, seem fine to
export.

00406680 T wet_load_module

Not quite sure if Weston plugins should have access... maybe they do.
Ivi-shell?


0060e500 B weston_screenshooter_interface
0060e480 B wl_keyboard_interface
0060e580 B zwp_input_method_context_v1_interface
0060e540 B zwp_input_method_v1_interface
0060e5c0 B zwp_text_input_manager_v1_interface
0060e4c0 B zwp_text_input_v1_interface

The 

Re: [PATCH weston] compositor-drm: Zero drmModeAddFB2 data

2016-08-18 Thread Quentin Glidic

On 18/08/2016 02:37, Yong Bakos wrote:

From: Yong Bakos 

Initialize arrays of data passed to drmModeAddFB2, just as
drm_fb_get_from_bo does.

See https://lists.freedesktop.org/archives/wayland-devel/2016-August/030645.html

Signed-off-by: Yong Bakos 


Thanks, reviewed and pushed:
eb07f36..4b6321f  master -> master

Cheers,



---
 libweston/compositor-drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 4825b46..8319d7c 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -319,7 +319,7 @@ drm_fb_create_dumb(struct drm_backend *b, unsigned width, 
unsigned height,
ret = -1;

if (!b->no_addfb2) {
-   uint32_t handles[4], pitches[4], offsets[4];
+   uint32_t handles[4] = { 0 }, pitches[4] = { 0 }, offsets[4] = { 
0 };

handles[0] = fb->handle;
pitches[0] = fb->stride;




--

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


Re: [PATCH wayland-web] Mention GammaRay in the tools page

2016-08-18 Thread Jonas Ådahl
On Thu, Aug 18, 2016 at 11:02:29AM +0300, Pekka Paalanen wrote:
> On Thu, 18 Aug 2016 09:45:30 +0200
> Giulio Camuffo  wrote:
> 
> > 2016-08-17 23:23 GMT+02:00  :
> > > On 08/17, Jonas Ådahl wrote:  
> > >> Is half a megabyte really a big deal for wayland-web? I find it more
> > >> reasonable to just provide the full resolution image instead of relying
> > >> on the URL to the external image never changing.  
> > >
> > > I think I'd only host a thumbnail on the wayland site, only link to the
> > > gammaray page, and let people find the screenshots through that page.  
> > 
> > The gammaray site doesn't have that screenshot (yet). Also i don't
> > think it makes sense to only keep a thumbnail that links to a site
> > where you have to search for the full image.
> 
> Yeah, IMO the patch is completely fine now. Sorry for starting the
> bikeshedding in the first place.
> 

Both v1 and v2 are fine by me. I misunderstood Pekka's comments so
please ignore my previous mail.


Jonas

> 
> 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


Re: [PATCH wayland-web] Mention GammaRay in the tools page

2016-08-18 Thread Pekka Paalanen
On Thu, 18 Aug 2016 09:45:30 +0200
Giulio Camuffo  wrote:

> 2016-08-17 23:23 GMT+02:00  :
> > On 08/17, Jonas Ådahl wrote:  
> >> Is half a megabyte really a big deal for wayland-web? I find it more
> >> reasonable to just provide the full resolution image instead of relying
> >> on the URL to the external image never changing.  
> >
> > I think I'd only host a thumbnail on the wayland site, only link to the
> > gammaray page, and let people find the screenshots through that page.  
> 
> The gammaray site doesn't have that screenshot (yet). Also i don't
> think it makes sense to only keep a thumbnail that links to a site
> where you have to search for the full image.

Yeah, IMO the patch is completely fine now. Sorry for starting the
bikeshedding in the first place.


Thanks,
pq


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


Re: [PATCH wayland-web] Mention GammaRay in the tools page

2016-08-18 Thread Giulio Camuffo
2016-08-17 23:23 GMT+02:00  :
> On 08/17, Jonas Ådahl wrote:
>> Is half a megabyte really a big deal for wayland-web? I find it more
>> reasonable to just provide the full resolution image instead of relying
>> on the URL to the external image never changing.
>
> I think I'd only host a thumbnail on the wayland site, only link to the
> gammaray page, and let people find the screenshots through that page.

The gammaray site doesn't have that screenshot (yet). Also i don't
think it makes sense to only keep a thumbnail that links to a site
where you have to search for the full image.

> ___
> 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 libinput] touchpad: on a non-clickpad, reset the motion history on nfingers change

2016-08-18 Thread Peter Hutterer
The only reason to have more than one finger on a non-clickpad is to tap,
scroll or gesture. In all cases resetting the motion history is a good idea to
avoid jumps moving from 2 to 1 finger.

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

Signed-off-by: Peter Hutterer 
---
 src/evdev-mt-touchpad.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 6cebfa3..3baed09 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -957,8 +957,11 @@ tp_need_motion_history_reset(struct tp_dispatch *tp)
 {
bool rc = false;
 
-   /* semi-mt finger postions may "jump" when nfingers changes */
-   if (tp->semi_mt && tp->nfingers_down != tp->old_nfingers_down)
+   /* Semi-mt finger postions may "jump" when nfingers changes. And on
+* a non-clickpad the only reason to have more than one finger down
+* is scrolling/gesture, so a reset just makes things sane again */
+   if ((tp->semi_mt || !tp->buttons.is_clickpad) &&
+   tp->nfingers_down != tp->old_nfingers_down)
return true;
 
/* if we're transitioning between slots and fake touches in either
-- 
2.7.4

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