[PATCH libinput 1/3] Mark some internal log functions as printf-style function

2016-10-23 Thread Peter Hutterer
Fixes the respective clang warnings

Signed-off-by: Peter Hutterer 
---
 src/libinput.c|  6 ++
 test/litest.c | 16 
 test/misc.c   |  7 +++
 tools/event-gui.c |  8 
 tools/shared.c|  7 +++
 5 files changed, 44 insertions(+)

diff --git a/src/libinput.c b/src/libinput.c
index 6958042..ec1c72a 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -163,6 +163,12 @@ static void
 libinput_default_log_func(struct libinput *libinput,
  enum libinput_log_priority priority,
  const char *format, va_list args)
+   LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
+
+static void
+libinput_default_log_func(struct libinput *libinput,
+ enum libinput_log_priority priority,
+ const char *format, va_list args)
 {
const char *prefix;
 
diff --git a/test/litest.c b/test/litest.c
index 4c301b5..940cf79 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -270,6 +270,15 @@ litest_fail_condition(const char *file,
  const char *condition,
  const char *message,
  ...)
+   LIBINPUT_ATTRIBUTE_PRINTF(5, 6);
+
+void
+litest_fail_condition(const char *file,
+ int line,
+ const char *func,
+ const char *condition,
+ const char *message,
+ ...)
 {
litest_log("FAILED: %s\n", condition);
 
@@ -761,6 +770,13 @@ litest_log_handler(struct libinput *libinput,
   enum libinput_log_priority pri,
   const char *format,
   va_list args)
+  LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
+
+static void
+litest_log_handler(struct libinput *libinput,
+  enum libinput_log_priority pri,
+  const char *format,
+  va_list args)
 {
const char *priority = NULL;
 
diff --git a/test/misc.c b/test/misc.c
index 791ebc3..44c4502 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -852,6 +852,13 @@ simple_log_handler(struct libinput *libinput,
   enum libinput_log_priority priority,
   const char *format,
   va_list args)
+  LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
+
+static void
+simple_log_handler(struct libinput *libinput,
+  enum libinput_log_priority priority,
+  const char *format,
+  va_list args)
 {
vfprintf(stderr, format, args);
 }
diff --git a/tools/event-gui.c b/tools/event-gui.c
index b67ca45..e5fb26a 100644
--- a/tools/event-gui.c
+++ b/tools/event-gui.c
@@ -110,6 +110,10 @@ struct window {
 
 static int
 error(const char *fmt, ...)
+   LIBINPUT_ATTRIBUTE_PRINTF(1, 2);
+
+static int
+error(const char *fmt, ...)
 {
va_list args;
fprintf(stderr, "error: ");
@@ -123,6 +127,10 @@ error(const char *fmt, ...)
 
 static void
 msg(const char *fmt, ...)
+   LIBINPUT_ATTRIBUTE_PRINTF(1, 2);
+
+static void
+msg(const char *fmt, ...)
 {
va_list args;
printf("info: ");
diff --git a/tools/shared.c b/tools/shared.c
index 95655ba..f539957 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -70,6 +70,13 @@ log_handler(struct libinput *li,
enum libinput_log_priority priority,
const char *format,
va_list args)
+   LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
+
+static void
+log_handler(struct libinput *li,
+   enum libinput_log_priority priority,
+   const char *format,
+   va_list args)
 {
vprintf(format, args);
 }
-- 
2.9.3

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


[PATCH libinput 2/3] touchpad: switch from fabs() to abs()

2016-10-23 Thread Peter Hutterer
silence clang warning:
evdev-mt-touchpad.c:1017:7: warning: using floating point absolute value
function 'fabs' when argument is of integer type [-Wabsolute-value]

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

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 38b638b..7867122 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1013,8 +1013,8 @@ tp_detect_jumps(const struct tp_dispatch *tp, struct 
tp_touch *t)
/* called before tp_motion_history_push, so offset 0 is the most
 * recent coordinate */
last = tp_motion_history_offset(t, 0);
-   dx = fabs(t->point.x - last->x) / tp->device->abs.absinfo_x->resolution;
-   dy = fabs(t->point.y - last->y) / tp->device->abs.absinfo_y->resolution;
+   dx = 1.0 * abs(t->point.x - last->x) / 
tp->device->abs.absinfo_x->resolution;
+   dy = 1.0 * abs(t->point.y - last->y) / 
tp->device->abs.absinfo_y->resolution;
 
return hypot(dx, dy) > JUMP_THRESHOLD_MM;
 }
-- 
2.9.3

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


Re: [PATCH] [weston, v2] weston.ini: Add natural scroll support to weston.ini

2016-10-23 Thread Peter Hutterer
sorry, I'm getting lost here, which one is the most recent patch now? there
are two labelled v2

Cheers,
   Peter

On Sat, Oct 22, 2016 at 01:31:28PM -0400, Jiayi Zhao wrote:
> This adds support for enabling/disabling natural scrolling
> via a boolean in weston.ini:
> 
> [libinput]
> natural_scroll=true
> 
> CHANGES:
>  - libinput_device_config_scroll_has_natural_scroll() is not longer compared 
> to != 0
> 
> Signed-off-by: Jiayi Zhao 
> ---
>  compositor/main.c | 13 +
>  weston.ini.in |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index 080aa61..abfb55b 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -1095,6 +1095,8 @@ configure_input_device(struct weston_compositor 
> *compositor,
>   struct weston_config *config = wet_get_config(compositor);
>   int enable_tap;
>   int enable_tap_default;
> + int natural_scroll;
> + int natural_scroll_default;
>  
>   s = weston_config_get_section(config,
> "libinput", NULL, NULL);
> @@ -1109,6 +,17 @@ configure_input_device(struct weston_compositor 
> *compositor,
>   libinput_device_config_tap_set_enabled(device,
>  enable_tap);
>   }
> +
> + if (libinput_device_config_scroll_has_natural_scroll(device)) {
> + natural_scroll_default =
> + 
> libinput_device_config_scroll_get_default_natural_scroll_enabled(
> + device);
> + weston_config_section_get_bool(s, "natural_scroll",
> +_scroll,
> +natural_scroll_default);
> + libinput_device_config_scroll_set_natural_scroll_enabled(device,
> +natural_scroll);
> + }
>  }
>  
>  static void
> diff --git a/weston.ini.in b/weston.ini.in
> index d837fb5..c7b8b98 100644
> --- a/weston.ini.in
> +++ b/weston.ini.in
> @@ -60,6 +60,7 @@ path=@libexecdir@/weston-keyboard
>  
>  #[libinput]
>  #enable_tap=true
> +#natural_scroll=false
>  
>  #[touchpad]
>  #constant_accel_factor = 50
> -- 
> 2.7.3
> 
> ___
> 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] [weston] weston.ini: Add natural scroll support to weston.ini

2016-10-23 Thread Peter Hutterer
On Sat, Oct 22, 2016 at 12:23:40PM -0400, Jiayi Zhao wrote:
> Hmm,
> 
> it says here that
> 
> libinput_device_config_scroll_has_natural_scroll()
> 
> returns a zero value if device does not support natural scrolling
> 
> and returns a non-zero value if it does support natural scrolling:
> 
> https://wayland.freedesktop.org/libinput/doc/latest/group__config.html#ga82d1aa961d2bb2f0c72c22e2441a4fc3
> 
> So I don't really know how I else I can program it.

just use

if (libinput_device_config_scroll_has_natural_scroll())
do stuff


instead of the current

if (libinput_device_config_scroll_has_natural_scroll() != 0)
do stuff

Cheers,
   Peter

> 
> On Oct 20, 2016 9:05 PM, "Peter Hutterer"  wrote:
> 
> >
> 
> > >
> 
> > On Thu, Oct 20, 2016 at 08:43:18PM -0400, Jiayi Zhao wrote:
> > > This adds support for enabling/disabling natural scrolling
> > > via a boolean in weston.ini:
> > >
> > > [libinput]
> > > natural_scroll=true
> > >
> > > Signed-off-by: Jiayi Zhao 
> > > ---
> > >  compositor/main.c | 13 +
> > >  weston.ini.in |  1 +
> > >  2 files changed, 14 insertions(+)
> > >
> > > diff --git a/compositor/main.c b/compositor/main.c
> > > index 8028ec3..6cd2a25 100644
> > > --- a/compositor/main.c
> > > +++ b/compositor/main.c
> > > @@ -1095,6 +1095,8 @@ configure_input_device(struct weston_compositor
> *compositor,
> > >   struct weston_config *config = wet_get_config(compositor);
> > >   int enable_tap;
> > >   int enable_tap_default;
> > > + int natural_scroll;
> > > + int natural_scroll_default;
> > >
> > >   s = weston_config_get_section(config,
> > > "libinput", NULL, NULL);
> > > @@ -1109,6 +,17 @@ configure_input_device(struct weston_compositor
> *compositor,
> > >   libinput_device_config_tap_set_enabled(device,
> > >  enable_tap);
> > >   }
> > > +
> > > + if (libinput_device_config_scroll_has_natural_scroll(device) !=
> 0) {
> >
> > libinput's *_has_* API is designed to return a boolean value, IMO you
> > shouldn't use the != 0 here.
> >
> > > + natural_scroll_default =
> > > +
>  libinput_device_config_scroll_get_default_natural_scroll_enabled(
> > > + device);
> > > + weston_config_section_get_bool(s, "natural_scroll",
> > > +_scroll,
> > > +natural_scroll_default);
> > > +
>  libinput_device_config_scroll_set_natural_scroll_enabled(device,
> > > +natural_scroll);
> > > + }
> > >  }
> > >
> > >  static void
> > > diff --git a/weston.ini.in b/weston.ini.in
> > > index 14a4c0c..08f931a 100644
> > > --- a/weston.ini.in
> > > +++ b/weston.ini.in
> > > @@ -59,6 +59,7 @@ path=@libexecdir@/weston-keyboard
> > >
> > >  #[libinput]
> > >  #enable_tap=true
> > > +#natural_scroll=false
> >
> > "enable_natural_scroll" is more precise
> >
> > these are just nitpicks, the code itself looks fine, thanks.
> >
> > Cheers,
> >Peter
> >
> > >
> > >  #[touchpad]
> > >  #constant_accel_factor = 50
> > > --
> > > 2.7.3
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] clients: Make XKB compose support conditional

2016-10-23 Thread Bryce Harrington
On Sat, Oct 22, 2016 at 03:09:24PM +0100, Daniel Stone wrote:
> Debian Jessie's version of libxkbcommon is too old for compose support,
> so rather than force people to upgrade, let's make it conditional.
> 
> Signed-off-by: Daniel Stone 
> Cc: Bryce Harrington 

Reviewed-by: Bryce Harrington 

> ---
>  clients/window.c | 12 
>  configure.ac |  4 
>  2 files changed, 16 insertions(+)
> 
> diff --git a/clients/window.c b/clients/window.c
> index 5e41210..84d585e 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -63,7 +63,9 @@ typedef void *EGLContext;
>  #endif /* no HAVE_CAIRO_EGL */
>  
>  #include 
> +#ifdef HAVE_XKBCOMMON_COMPOSE
>  #include 
> +#endif
>  #include 
>  
>  #include 
> @@ -373,8 +375,10 @@ struct input {
>   struct {
>   struct xkb_keymap *keymap;
>   struct xkb_state *state;
> +#ifdef HAVE_XKBCOMMON_COMPOSE
>   struct xkb_compose_table *compose_table;
>   struct xkb_compose_state *compose_state;
> +#endif
>   xkb_mod_mask_t control_mask;
>   xkb_mod_mask_t alt_mask;
>   xkb_mod_mask_t shift_mask;
> @@ -2982,8 +2986,10 @@ keyboard_handle_keymap(void *data, struct wl_keyboard 
> *keyboard,
>   struct input *input = data;
>   struct xkb_keymap *keymap;
>   struct xkb_state *state;
> +#ifdef HAVE_XKBCOMMON_COMPOSE
>   struct xkb_compose_table *compose_table;
>   struct xkb_compose_state *compose_state;
> +#endif
>   char *locale;
>   char *map_str;
>  
> @@ -3031,6 +3037,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard 
> *keyboard,
>   locale = "C";
>  
>   /* Set up XKB compose table */
> +#ifdef HAVE_XKBCOMMON_COMPOSE
>   compose_table =
>   xkb_compose_table_new_from_locale(input->display->xkb_context,
> locale,
> @@ -3054,6 +3061,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard 
> *keyboard,
>   fprintf(stderr, "could not create XKB compose table for locale 
> '%s'.  "
>   "Disabiling compose\n", locale);
>   }
> +#endif
>  
>   xkb_keymap_unref(input->xkb.keymap);
>   xkb_state_unref(input->xkb.state);
> @@ -3099,6 +3107,7 @@ keyboard_handle_leave(void *data, struct wl_keyboard 
> *keyboard,
>  static xkb_keysym_t
>  process_key_press(xkb_keysym_t sym, struct input *input)
>  {
> +#ifdef HAVE_XKBCOMMON_COMPOSE
>   if (sym == XKB_KEY_NoSymbol)
>   return sym;
>   if (xkb_compose_state_feed(input->xkb.compose_state,
> @@ -3117,6 +3126,9 @@ process_key_press(xkb_keysym_t sym, struct input *input)
>   default:
>   return sym;
>   }
> +#else
> + return sym;
> +#endif
>  }
>  
>  static void
> diff --git a/configure.ac b/configure.ac
> index 37da695..1e251bf 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -146,6 +146,10 @@ AC_ARG_ENABLE(xkbcommon,
>  if test x$enable_xkbcommon = xyes; then
>   AC_DEFINE(ENABLE_XKBCOMMON, [1], [Build Weston with libxkbcommon 
> support])
>   COMPOSITOR_MODULES="$COMPOSITOR_MODULES xkbcommon >= 0.3.0"
> + PKG_CHECK_MODULES(XKBCOMMON_COMPOSE, [xkbcommon >= 0.5.0],
> +   [AC_DEFINE(HAVE_XKBCOMMON_COMPOSE, 1,
> +  [Define if xkbcommon is 0.5.0 or newer])],
> +  true)
>  fi
>  
>  AC_ARG_ENABLE(setuid-install, [  --enable-setuid-install],,
> -- 
> 2.9.3
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] clients: Make XKB compose support conditional

2016-10-23 Thread Daniel Diaz
Hello!


On 22 October 2016 at 09:09, Daniel Stone  wrote:
> Debian Jessie's version of libxkbcommon is too old for compose support,
> so rather than force people to upgrade, let's make it conditional.

Tested on Ubuntu 14.04 with libxkbcommon-dev 0.4.1.


> Signed-off-by: Daniel Stone 
Reviewed-by: Daniel Díaz 

Thanks and greetings!

Daniel Díaz
daniel.d...@linaro.org



> Cc: Bryce Harrington 
> ---
>  clients/window.c | 12 
>  configure.ac |  4 
>  2 files changed, 16 insertions(+)
>
> diff --git a/clients/window.c b/clients/window.c
> index 5e41210..84d585e 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -63,7 +63,9 @@ typedef void *EGLContext;
>  #endif /* no HAVE_CAIRO_EGL */
>
>  #include 
> +#ifdef HAVE_XKBCOMMON_COMPOSE
>  #include 
> +#endif
>  #include 
>
>  #include 
> @@ -373,8 +375,10 @@ struct input {
> struct {
> struct xkb_keymap *keymap;
> struct xkb_state *state;
> +#ifdef HAVE_XKBCOMMON_COMPOSE
> struct xkb_compose_table *compose_table;
> struct xkb_compose_state *compose_state;
> +#endif
> xkb_mod_mask_t control_mask;
> xkb_mod_mask_t alt_mask;
> xkb_mod_mask_t shift_mask;
> @@ -2982,8 +2986,10 @@ keyboard_handle_keymap(void *data, struct wl_keyboard 
> *keyboard,
> struct input *input = data;
> struct xkb_keymap *keymap;
> struct xkb_state *state;
> +#ifdef HAVE_XKBCOMMON_COMPOSE
> struct xkb_compose_table *compose_table;
> struct xkb_compose_state *compose_state;
> +#endif
> char *locale;
> char *map_str;
>
> @@ -3031,6 +3037,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard 
> *keyboard,
> locale = "C";
>
> /* Set up XKB compose table */
> +#ifdef HAVE_XKBCOMMON_COMPOSE
> compose_table =
> xkb_compose_table_new_from_locale(input->display->xkb_context,
>   locale,
> @@ -3054,6 +3061,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard 
> *keyboard,
> fprintf(stderr, "could not create XKB compose table for 
> locale '%s'.  "
> "Disabiling compose\n", locale);
> }
> +#endif
>
> xkb_keymap_unref(input->xkb.keymap);
> xkb_state_unref(input->xkb.state);
> @@ -3099,6 +3107,7 @@ keyboard_handle_leave(void *data, struct wl_keyboard 
> *keyboard,
>  static xkb_keysym_t
>  process_key_press(xkb_keysym_t sym, struct input *input)
>  {
> +#ifdef HAVE_XKBCOMMON_COMPOSE
> if (sym == XKB_KEY_NoSymbol)
> return sym;
> if (xkb_compose_state_feed(input->xkb.compose_state,
> @@ -3117,6 +3126,9 @@ process_key_press(xkb_keysym_t sym, struct input *input)
> default:
> return sym;
> }
> +#else
> +   return sym;
> +#endif
>  }
>
>  static void
> diff --git a/configure.ac b/configure.ac
> index 37da695..1e251bf 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -146,6 +146,10 @@ AC_ARG_ENABLE(xkbcommon,
>  if test x$enable_xkbcommon = xyes; then
> AC_DEFINE(ENABLE_XKBCOMMON, [1], [Build Weston with libxkbcommon 
> support])
> COMPOSITOR_MODULES="$COMPOSITOR_MODULES xkbcommon >= 0.3.0"
> +   PKG_CHECK_MODULES(XKBCOMMON_COMPOSE, [xkbcommon >= 0.5.0],
> + [AC_DEFINE(HAVE_XKBCOMMON_COMPOSE, 1,
> +[Define if xkbcommon is 0.5.0 or 
> newer])],
> +  true)
>  fi
>
>  AC_ARG_ENABLE(setuid-install, [  --enable-setuid-install],,
> --
> 2.9.3
>
> ___
> 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