[PATCH xf86-input-libinput 3/3] Apply the capabilities checks on subdevices when applying the config

2018-02-20 Thread Peter Hutterer
Properties are initialized on the correct devices only but on resume we'd just
blindly apply the config from our device. Depending on the resume order, this
would mean we'd apply a previously set config with a default config.

Example:
* pointer device with keyboard subdevice
* pointer device exports natural scrolling, keyboard device does not and
  remains at default (off)
* client enables natural scrolling on the pointer device
* VT switch away, VT switch back
* pointer device gets enabled first, enables natural scrolling on the
  libinput device
* keyboard device gets enabled second, resets to the default value

Reported-by: Yuxuan Shui 
Signed-off-by: Peter Hutterer 
Tested-by: Yuxuan Shui 
---
 src/xf86libinput.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index cb37dab..83ab75d 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -505,6 +505,9 @@ LibinputApplyConfigNaturalScroll(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_scroll_has_natural_scroll(device) &&
libinput_device_config_scroll_set_natural_scroll_enabled(device,
 
driver_data->options.natural_scrolling) != LIBINPUT_CONFIG_STATUS_SUCCESS)
@@ -520,6 +523,9 @@ LibinputApplyConfigAccel(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_accel_is_available(device) &&
libinput_device_config_accel_set_speed(device,
   driver_data->options.speed) 
!= LIBINPUT_CONFIG_STATUS_SUCCESS)
@@ -556,6 +562,9 @@ LibinputApplyConfigTap(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_tap_get_finger_count(device) > 0 &&
libinput_device_config_tap_set_enabled(device,
   
driver_data->options.tapping) != LIBINPUT_CONFIG_STATUS_SUCCESS)
@@ -600,6 +609,9 @@ LibinputApplyConfigCalibration(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_TOUCH|CAP_TABLET))
+   return;
+
if (libinput_device_config_calibration_has_matrix(device) &&
libinput_device_config_calibration_set_matrix(device,
  
driver_data->options.matrix) != LIBINPUT_CONFIG_STATUS_SUCCESS)
@@ -620,6 +632,9 @@ LibinputApplyConfigLeftHanded(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TABLET))
+   return;
+
if (libinput_device_config_left_handed_is_available(device) &&
libinput_device_config_left_handed_set(device,
   
driver_data->options.left_handed) != LIBINPUT_CONFIG_STATUS_SUCCESS)
@@ -635,6 +650,9 @@ LibinputApplyConfigScrollMethod(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_scroll_set_method(device,
 
driver_data->options.scroll_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) {
const char *method;
@@ -671,6 +689,9 @@ LibinputApplyConfigClickMethod(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_click_set_method(device,

driver_data->options.click_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) {
const char *method;
@@ -696,6 +717,9 @@ LibinputApplyConfigMiddleEmulation(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_middle_emulation_is_available(device) &&
libinput_device_config_middle_emulation_set_enabled(device,

driver_data->options.middle_emulation) != LIBINPUT_CONFIG_STATUS_SUCCESS)
@@ -711,6 +735,9 @@ LibinputApplyConfigDisableWhileTyping(DeviceIntPtr dev,
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if 

[PATCH xf86-input-libinput 2/3] Split LibinputDeviceApplyConfig into helper functions

2018-02-20 Thread Peter Hutterer
No functional changes
---
 src/xf86libinput.c | 110 ++---
 1 file changed, 105 insertions(+), 5 deletions(-)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index c5612a8..cb37dab 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -483,13 +483,12 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, 
XIPropertyValuePtr val,
 static void
 LibinputInitProperty(DeviceIntPtr dev);
 
-static inline void
-LibinputApplyConfig(DeviceIntPtr dev)
+static void
+LibinputApplyConfigSendEvents(DeviceIntPtr dev,
+ struct xf86libinput *driver_data,
+ struct libinput_device *device)
 {
InputInfoPtr pInfo = dev->public.devicePrivate;
-   struct xf86libinput *driver_data = pInfo->private;
-   struct libinput_device *device = driver_data->shared_device->device;
-   unsigned int scroll_button;
 
if (libinput_device_config_send_events_get_modes(device) != 
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED &&
libinput_device_config_send_events_set_mode(device,
@@ -497,6 +496,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set SendEventsMode %u\n",
driver_data->options.sendevents);
+}
+
+static void
+LibinputApplyConfigNaturalScroll(DeviceIntPtr dev,
+struct xf86libinput *driver_data,
+struct libinput_device *device)
+{
+   InputInfoPtr pInfo = dev->public.devicePrivate;
 
if (libinput_device_config_scroll_has_natural_scroll(device) &&
libinput_device_config_scroll_set_natural_scroll_enabled(device,
@@ -504,6 +511,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set NaturalScrolling to %d\n",
driver_data->options.natural_scrolling);
+}
+
+static void
+LibinputApplyConfigAccel(DeviceIntPtr dev,
+struct xf86libinput *driver_data,
+struct libinput_device *device)
+{
+   InputInfoPtr pInfo = dev->public.devicePrivate;
 
if (libinput_device_config_accel_is_available(device) &&
libinput_device_config_accel_set_speed(device,
@@ -532,6 +547,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
}
xf86IDrvMsg(pInfo, X_ERROR, "Failed to set profile %s\n", 
profile);
}
+}
+
+static inline void
+LibinputApplyConfigTap(DeviceIntPtr dev,
+  struct xf86libinput *driver_data,
+  struct libinput_device *device)
+{
+   InputInfoPtr pInfo = dev->public.devicePrivate;
 
if (libinput_device_config_tap_get_finger_count(device) > 0 &&
libinput_device_config_tap_set_enabled(device,
@@ -568,6 +591,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set Tapping Drag to %d\n",
driver_data->options.tap_drag);
+}
+
+static void
+LibinputApplyConfigCalibration(DeviceIntPtr dev,
+  struct xf86libinput *driver_data,
+  struct libinput_device *device)
+{
+   InputInfoPtr pInfo = dev->public.devicePrivate;
 
if (libinput_device_config_calibration_has_matrix(device) &&
libinput_device_config_calibration_set_matrix(device,
@@ -580,6 +611,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
driver_data->options.matrix[4], 
driver_data->options.matrix[5],
driver_data->options.matrix[6], 
driver_data->options.matrix[7],
driver_data->options.matrix[8]);
+}
+
+static void
+LibinputApplyConfigLeftHanded(DeviceIntPtr dev,
+  struct xf86libinput *driver_data,
+  struct libinput_device *device)
+{
+   InputInfoPtr pInfo = dev->public.devicePrivate;
 
if (libinput_device_config_left_handed_is_available(device) &&
libinput_device_config_left_handed_set(device,
@@ -587,6 +626,14 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set LeftHanded to %d\n",
driver_data->options.left_handed);
+}
+
+static void
+LibinputApplyConfigScrollMethod(DeviceIntPtr dev,
+   struct xf86libinput *driver_data,
+   struct libinput_device *device)
+{
+   InputInfoPtr pInfo = dev->public.devicePrivate;
 
if (libinput_device_config_scroll_set_method(device,
 
driver_data->options.scroll_method) != LIBINPUT_CONFIG_STATUS_SUCCESS) {
@@ -607,12 +654,22 @@ LibinputApplyConfig(DeviceIntPtr dev)
}
 
if 

[PATCH xf86-input-libinput 1/3] Move the subdevice capabilities check into the properties

2018-02-20 Thread Peter Hutterer
87f9fe3a6fafe60134c6's intention was to not create properties that a subdevice
doesn't have configuration options for (i.e. if you have a pointer+keyboard
device, don't expose tapping configuration on the keyboard subdevice).

The result was messy, the checker function had a confusing triple-negation and
some properties weren't checked - e.g. left-handed was allowed for touch/tablet
but not for pointer, dwt was allowed for any device.

Fix this by moving the check into the property init function directly and
inverting the helper function to be easier to read.

Signed-off-by: Peter Hutterer 
---
 src/xf86libinput.c | 113 ++---
 1 file changed, 72 insertions(+), 41 deletions(-)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index 5727040..c5612a8 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -461,6 +461,22 @@ xf86libinput_set_area_ratio(struct xf86libinput 
*driver_data,
}
 }
 
+/**
+ * returns true if the device has one or more of the given capabilities or
+ * if the device isn't a subdevice
+ */
+static inline bool
+subdevice_has_capabilities(DeviceIntPtr dev, uint32_t capabilities)
+{
+   InputInfoPtr pInfo  = dev->public.devicePrivate;
+   struct xf86libinput *driver_data = pInfo->private;
+
+   if (!xf86libinput_is_subdevice(pInfo))
+   return true;
+
+   return !!(driver_data->capabilities & capabilities);
+}
+
 static int
 LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
  BOOL checkonly);
@@ -4429,6 +4445,9 @@ LibinputInitTapProperty(DeviceIntPtr dev,
 {
BOOL tap = driver_data->options.tapping;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_tap_get_finger_count(device) == 0)
return;
 
@@ -4455,6 +4474,9 @@ LibinputInitTapDragProperty(DeviceIntPtr dev,
 {
BOOL drag = driver_data->options.tap_drag;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_tap_get_finger_count(device) == 0)
return;
 
@@ -4479,6 +4501,9 @@ LibinputInitTapDragLockProperty(DeviceIntPtr dev,
 {
BOOL drag_lock = driver_data->options.tap_drag_lock;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (libinput_device_config_tap_get_finger_count(device) == 0)
return;
 
@@ -4504,6 +4529,9 @@ LibinputInitTapButtonmapProperty(DeviceIntPtr dev,
enum libinput_config_tap_button_map map;
BOOL data[2] = {0};
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
map = driver_data->options.tap_button_map;
 
if (libinput_device_config_tap_get_finger_count(device) == 0)
@@ -4554,6 +4582,9 @@ LibinputInitCalibrationProperty(DeviceIntPtr dev,
 {
float calibration[9];
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TOUCH|CAP_TABLET))
+   return;
+
if (!libinput_device_config_calibration_has_matrix(device))
return;
 
@@ -4591,6 +4622,9 @@ LibinputInitAccelProperty(DeviceIntPtr dev,
enum libinput_config_accel_profile profile;
BOOL profiles[2] = {FALSE};
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (!libinput_device_config_accel_is_available(device) ||
driver_data->capabilities & CAP_TABLET)
return;
@@ -4678,6 +4712,9 @@ LibinputInitNaturalScrollProperty(DeviceIntPtr dev,
 {
BOOL natural_scroll = driver_data->options.natural_scrolling;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
if (!libinput_device_config_scroll_has_natural_scroll(device))
return;
 
@@ -4760,6 +4797,12 @@ LibinputInitLeftHandedProperty(DeviceIntPtr dev,
 {
BOOL left_handed = driver_data->options.left_handed;
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER|CAP_TABLET))
+   return;
+
+   if (prop_left_handed != 0)
+   return;
+
if (!libinput_device_config_left_handed_is_available(device) ||
driver_data->capabilities & CAP_TABLET)
return;
@@ -4787,6 +4830,9 @@ LibinputInitScrollMethodsProperty(DeviceIntPtr dev,
enum libinput_config_scroll_method method;
BOOL methods[3] = {FALSE};
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
scroll_methods = libinput_device_config_scroll_get_methods(device);
if (scroll_methods == LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
return;
@@ -4874,6 +4920,9 @@ LibinputInitClickMethodsProperty(DeviceIntPtr dev,
enum libinput_config_click_method method;
BOOL methods[2] = {FALSE};
 
+   if (!subdevice_has_capabilities(dev, CAP_POINTER))
+   return;
+
   

Re: [PATCH xserver] xwayland: Fix backwards need_rotate logic (v2)

2018-02-20 Thread Adam Jackson
On Tue, 2018-02-20 at 18:48 +0100, Olivier Fourdan wrote:
> Hi,
> 
> On 20 February 2018 at 18:41, Jason Ekstrand  wrote:
> > When xdg_output support was added to Xwayland, need_rotate parameter was
> > added to output_get_new_size where true gave you the old pre-xdg_output
> > behavior and false gave the new behavior.  Unfortunately, the two places
> > where this is called, need_rotate was set backwards.  This caused input
> > get clampped to the wrong dimensions.  Also, the logic for deciding
> > whether or not to flip was wrong because, if need_rotate was false, it
> > would always flip which is not what you want.
> > 
> > v2 (Daniel Stone):
> >  - Fix output_get_new_size so that it doesn't flip the dimensions when
> >need_rotate is false.
> > 
> > Signed-off-by: Jason Ekstrand 
> > Reviewed-by: Daniel Stone 
> > Cc: Olivier Fourdan 
> > 
> Hehe, yes, I was typing my reply pointing toward output_get_new_size() as 
> well but you were faster!
> 
> So v2 is:
> 
> Reviewed-by: Olivier Fourdan 

Merged, thanks:

remote: I: patch #205654 updated using rev 
a054532668cbbb152d0d7acfcce1e03e884bb491.
remote: I: 1 patch(es) updated to state Accepted.
To ssh://git.freedesktop.org/git/xorg/xserver
   343ee7d075..a054532668  master -> master

- ajax
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver] xwayland: Fix backwards need_rotate logic (v2)

2018-02-20 Thread Olivier Fourdan
Hi,

On 20 February 2018 at 18:41, Jason Ekstrand  wrote:

> When xdg_output support was added to Xwayland, need_rotate parameter was
> added to output_get_new_size where true gave you the old pre-xdg_output
> behavior and false gave the new behavior.  Unfortunately, the two places
> where this is called, need_rotate was set backwards.  This caused input
> get clampped to the wrong dimensions.  Also, the logic for deciding
> whether or not to flip was wrong because, if need_rotate was false, it
> would always flip which is not what you want.
>
> v2 (Daniel Stone):
>  - Fix output_get_new_size so that it doesn't flip the dimensions when
>need_rotate is false.
>
> Signed-off-by: Jason Ekstrand 
> Reviewed-by: Daniel Stone 
> Cc: Olivier Fourdan 
> ---
>  hw/xwayland/xwayland-output.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
> index c593896..48faeb1 100644
> --- a/hw/xwayland/xwayland-output.c
> +++ b/hw/xwayland/xwayland-output.c
> @@ -126,7 +126,7 @@ output_get_new_size(struct xwl_output *xwl_output,
>  {
>  int output_width, output_height;
>
> -if (need_rotate && (xwl_output->rotation & (RR_Rotate_0 |
> RR_Rotate_180))) {
> +if (!need_rotate || (xwl_output->rotation & (RR_Rotate_0 |
> RR_Rotate_180))) {
>  output_width = xwl_output->width;
>  output_height = xwl_output->height;
>  } else {
> @@ -220,7 +220,7 @@ apply_output_change(struct xwl_output *xwl_output)
>  xwl_output->xdg_output_done = FALSE;
>
>  /* xdg-output sends output size in compositor space. so already
> rotated */
> -need_rotate = (xwl_output->xdg_output != NULL);
> +need_rotate = (xwl_output->xdg_output == NULL);
>
>  randr_mode = xwayland_cvt(xwl_output->width, xwl_output->height,
>xwl_output->refresh / 1000.0, 0, 0);
> @@ -390,7 +390,7 @@ xwl_output_remove(struct xwl_output *xwl_output)
>  struct xwl_output *it;
>  struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
>  int width = 0, height = 0;
> -Bool need_rotate = (xwl_output->xdg_output != NULL);
> +Bool need_rotate = (xwl_output->xdg_output == NULL);
>
>  RRCrtcDestroy(xwl_output->randr_crtc);
>  RROutputDestroy(xwl_output->randr_output);
> --
> 2.5.0.400.gff86faf
>
> ___
> xorg-devel@lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
>

Hehe, yes, I was typing my reply pointing toward output_get_new_size() as
well but you were faster!

So v2 is:

Reviewed-by: Olivier Fourdan 

Thanks!
Olivier
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] xwayland: Fix backwards need_rotate logic (v2)

2018-02-20 Thread Jason Ekstrand
When xdg_output support was added to Xwayland, need_rotate parameter was
added to output_get_new_size where true gave you the old pre-xdg_output
behavior and false gave the new behavior.  Unfortunately, the two places
where this is called, need_rotate was set backwards.  This caused input
get clampped to the wrong dimensions.  Also, the logic for deciding
whether or not to flip was wrong because, if need_rotate was false, it
would always flip which is not what you want.

v2 (Daniel Stone):
 - Fix output_get_new_size so that it doesn't flip the dimensions when
   need_rotate is false.

Signed-off-by: Jason Ekstrand 
Reviewed-by: Daniel Stone 
Cc: Olivier Fourdan 
---
 hw/xwayland/xwayland-output.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index c593896..48faeb1 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -126,7 +126,7 @@ output_get_new_size(struct xwl_output *xwl_output,
 {
 int output_width, output_height;
 
-if (need_rotate && (xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180))) 
{
+if (!need_rotate || (xwl_output->rotation & (RR_Rotate_0 | 
RR_Rotate_180))) {
 output_width = xwl_output->width;
 output_height = xwl_output->height;
 } else {
@@ -220,7 +220,7 @@ apply_output_change(struct xwl_output *xwl_output)
 xwl_output->xdg_output_done = FALSE;
 
 /* xdg-output sends output size in compositor space. so already rotated */
-need_rotate = (xwl_output->xdg_output != NULL);
+need_rotate = (xwl_output->xdg_output == NULL);
 
 randr_mode = xwayland_cvt(xwl_output->width, xwl_output->height,
   xwl_output->refresh / 1000.0, 0, 0);
@@ -390,7 +390,7 @@ xwl_output_remove(struct xwl_output *xwl_output)
 struct xwl_output *it;
 struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
 int width = 0, height = 0;
-Bool need_rotate = (xwl_output->xdg_output != NULL);
+Bool need_rotate = (xwl_output->xdg_output == NULL);
 
 RRCrtcDestroy(xwl_output->randr_crtc);
 RROutputDestroy(xwl_output->randr_output);
-- 
2.5.0.400.gff86faf

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] xwayland: Fix backwards need_rotate logic

2018-02-20 Thread Jason Ekstrand
When xdg_output support was added to Xwayland, need_rotate parameter was
added to output_get_new_size where true gave you the old pre-xdg_output
behavior and false gave the new behavior.  Unfortunately, the two places
where this is called, need_rotate was set backwards.  This caused input
get clampped to the wrong dimensions.

Signed-off-by: Jason Ekstrand 
Cc: Olivier Fourdan 
Cc: Daniel Stone 
---
 hw/xwayland/xwayland-output.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index c593896..257c3ee 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -220,7 +220,7 @@ apply_output_change(struct xwl_output *xwl_output)
 xwl_output->xdg_output_done = FALSE;
 
 /* xdg-output sends output size in compositor space. so already rotated */
-need_rotate = (xwl_output->xdg_output != NULL);
+need_rotate = (xwl_output->xdg_output == NULL);
 
 randr_mode = xwayland_cvt(xwl_output->width, xwl_output->height,
   xwl_output->refresh / 1000.0, 0, 0);
@@ -390,7 +390,7 @@ xwl_output_remove(struct xwl_output *xwl_output)
 struct xwl_output *it;
 struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
 int width = 0, height = 0;
-Bool need_rotate = (xwl_output->xdg_output != NULL);
+Bool need_rotate = (xwl_output->xdg_output == NULL);
 
 RRCrtcDestroy(xwl_output->randr_crtc);
 RROutputDestroy(xwl_output->randr_output);
-- 
2.5.0.400.gff86faf

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] xwayland: Fix backwards need_rotate logic

2018-02-20 Thread Jason Ekstrand
When xdg_output support was added to Xwayland, need_rotate parameter was
added to output_get_new_size where true gave you the old pre-xdg_output
behavior and false gave the new behavior.  Unfortunately, the two places
where this is called, need_rotate was set backwards.  This caused input
get clampped to the wrong dimensions.

Signed-off-by: Jason Ekstrand 
Cc: Olivier Fourdan 
Cc: Daniel Stone 
---
 hw/xwayland/xwayland-output.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index c593896..257c3ee 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -220,7 +220,7 @@ apply_output_change(struct xwl_output *xwl_output)
 xwl_output->xdg_output_done = FALSE;
 
 /* xdg-output sends output size in compositor space. so already rotated */
-need_rotate = (xwl_output->xdg_output != NULL);
+need_rotate = (xwl_output->xdg_output == NULL);
 
 randr_mode = xwayland_cvt(xwl_output->width, xwl_output->height,
   xwl_output->refresh / 1000.0, 0, 0);
@@ -390,7 +390,7 @@ xwl_output_remove(struct xwl_output *xwl_output)
 struct xwl_output *it;
 struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
 int width = 0, height = 0;
-Bool need_rotate = (xwl_output->xdg_output != NULL);
+Bool need_rotate = (xwl_output->xdg_output == NULL);
 
 RRCrtcDestroy(xwl_output->randr_crtc);
 RROutputDestroy(xwl_output->randr_output);
-- 
2.5.0.400.gff86faf

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver] Xephyr: Avoid calling xcb_shm_detach() twice

2018-02-20 Thread Adam Jackson
On Tue, 2018-02-20 at 18:07 +0300, Alexander Volkov wrote:
> This call was forgotten to be removed in
> 90996f5909aab4bc9aa4011a6a6d0555a7aa3adf in which
> hostx_destroy_shm_segment() was introduced, which
> itself does it.

Merged, thanks:

remote: I: patch #205633 updated using rev 
343ee7d07565a75b90e6489c5c29f772dca79c43.
remote: I: 1 patch(es) updated to state Accepted.
To ssh://git.freedesktop.org/git/xorg/xserver
   5ba0ba93e1..343ee7d075  master -> master

- ajax
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver 5/7] xfree86/modes: Adapt xf86Randr12CrtcComputeGamma() for depth 30.

2018-02-20 Thread Ville Syrjälä
On Tue, Feb 20, 2018 at 05:06:32AM +0100, Mario Kleiner wrote:
> At screen depths > 24 bit, the color palettes passed into
> xf86Randr12CrtcComputeGamma() can have a larger number of slots
> than the crtc's hardware lut. E.g., at depth 30, 1024 palette
> slots vs. 256 hw lut slots. This palette size > crtc gamma size
> case is not handled yet and leads to silent failure, so gamma
> table updates do not happen.
> 
> Add a new subsampling path for this case, which only takes
> every n'th slot from the input palette, e.g., at depth 30,
> every 4th slot for a 1024 slot palette vs. 256 slot hw lut.
> 
> This makes lut updates work again, as tested with the xgamma
> utility (uses XF86VidMode extension) and some RandR based
> gamma ramp animation.
> 
> Signed-off-by: Mario Kleiner 
> ---
>  hw/xfree86/modes/xf86RandR12.c | 99 
> ++
>  1 file changed, 72 insertions(+), 27 deletions(-)
> 
> diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
> index fe8770d..8947622 100644
> --- a/hw/xfree86/modes/xf86RandR12.c
> +++ b/hw/xfree86/modes/xf86RandR12.c
> @@ -1258,40 +1258,85 @@ xf86RandR12CrtcComputeGamma(xf86CrtcPtr crtc, LOCO 
> *palette,
>  
>  for (shift = 0; (gamma_size << shift) < (1 << 16); shift++);
>  
> -gamma_slots = crtc->gamma_size / palette_red_size;
> -for (i = 0; i < palette_red_size; i++) {
> -value = palette[i].red;
> -if (gamma_red)
> -value = gamma_red[value];
> -else
> -value <<= shift;
> +if (crtc->gamma_size >= palette_red_size) {
> +/* Upsampling of smaller palette to larger hw lut size */
> +gamma_slots = crtc->gamma_size / palette_red_size;
> +for (i = 0; i < palette_red_size; i++) {
> +value = palette[i].red;
> +if (gamma_red)
> +value = gamma_red[value];
> +else
> +value <<= shift;
> +
> +for (j = 0; j < gamma_slots; j++)
> +crtc->gamma_red[i * gamma_slots + j] = value;
> +}
> +} else {
> +/* Downsampling of larger palette to smaller hw lut size */
> +gamma_slots = palette_red_size / crtc->gamma_size;
> +for (i = 0; i < crtc->gamma_size; i++) {
> +value = palette[i * gamma_slots].red;

That's not going to reach the max index of the palette, and it'll not
work correctly when the sizes aren't a nice integer multiple of each
other. Eg. intel hw has interpolated gamma modes which have 2^n+1
entries in the LUT.

So I'm thinking we want this instead:
value = palette[i * (palette_size - 1) / (gamma_size - 1)];

-- 
Ville Syrjälä
Intel OTC
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver 2/2] glx: Fix indirect no-config contexts

2018-02-20 Thread Adam Jackson
We would throw BadValue here for the GLX_SCREEN attribute. The upper
dispatch layer already checks this, we can ignore it here.

Signed-off-by: Adam Jackson 
---
 glx/glxdri2.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 25ee9acf92..d402ca860c 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -402,6 +402,9 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned 
num_attribs,
 return FALSE;
 }
 break;
+case GLX_SCREEN:
+/* already checked for us */
+break;
 case GLX_CONTEXT_OPENGL_NO_ERROR_ARB:
 /* ignore */
 break;
-- 
2.14.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver 1/2] glx: Enable GLX_ARB_create_context_no_error (v2)

2018-02-20 Thread Adam Jackson
This is mostly for the client library's convenience, if this extension
is listed then it can know the attribute won't be rejected. Note that we
don't honor this attribute for indirect contexts. That's fine, we don't
want to introduce undefined behavior into a potentially privileged
process.

v2: Remember to ignore the attribute (Eric Anholt)

Signed-off-by: Adam Jackson 
---
 glx/createcontext.c| 4 
 glx/extension_string.c | 1 +
 glx/extension_string.h | 1 +
 glx/glxdri2.c  | 7 ++-
 glx/glxdriswrast.c | 2 ++
 glx/glxserver.h| 4 
 6 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/glx/createcontext.c b/glx/createcontext.c
index 00c23fcddf..7d09c3a1c7 100644
--- a/glx/createcontext.c
+++ b/glx/createcontext.c
@@ -218,6 +218,10 @@ __glXDisp_CreateContextAttribsARB(__GLXclientState * cl, 
GLbyte * pc)
 return BadValue;
 break;
 
+case GLX_CONTEXT_OPENGL_NO_ERROR_ARB:
+/* ignore */
+break;
+
 default:
 if (!req->isDirect)
 return BadValue;
diff --git a/glx/extension_string.c b/glx/extension_string.c
index 102f9dd42b..354ce06f71 100644
--- a/glx/extension_string.c
+++ b/glx/extension_string.c
@@ -74,6 +74,7 @@ static const struct extension_info known_glx_extensions[] = {
 /* *INDENT-OFF* */
 { GLX(ARB_context_flush_control),   VER(0,0), N, },
 { GLX(ARB_create_context),  VER(0,0), N, },
+{ GLX(ARB_create_context_no_error), VER(0,0), N, },
 { GLX(ARB_create_context_profile),  VER(0,0), N, },
 { GLX(ARB_create_context_robustness), VER(0,0), N, },
 { GLX(ARB_fbconfig_float),  VER(0,0), N, },
diff --git a/glx/extension_string.h b/glx/extension_string.h
index f049f58400..eab385a3c7 100644
--- a/glx/extension_string.h
+++ b/glx/extension_string.h
@@ -38,6 +38,7 @@ enum {
 /*   GLX_ARB_get_proc_address is implemented on the client. */
 ARB_context_flush_control_bit = 0,
 ARB_create_context_bit,
+ARB_create_context_no_error_bit,
 ARB_create_context_profile_bit,
 ARB_create_context_robustness_bit,
 ARB_fbconfig_float_bit,
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 6887e199c8..25ee9acf92 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -42,10 +42,10 @@
 #include 
 #include 
 
+#include 
 #include "glxserver.h"
 #include "glxutil.h"
 #include "glxdricommon.h"
-#include 
 
 #include "extension_string.h"
 
@@ -402,6 +402,9 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned 
num_attribs,
 return FALSE;
 }
 break;
+case GLX_CONTEXT_OPENGL_NO_ERROR_ARB:
+/* ignore */
+break;
 default:
 /* If an unknown attribute is received, fail.
  */
@@ -832,6 +835,8 @@ initializeExtensions(__GLXscreen * screen)
 if (dri->dri2->base.version >= 3) {
 __glXEnableExtension(screen->glx_enable_bits,
  "GLX_ARB_create_context");
+__glXEnableExtension(screen->glx_enable_bits,
+ "GLX_ARB_create_context_no_error");
 __glXEnableExtension(screen->glx_enable_bits,
  "GLX_ARB_create_context_profile");
 __glXEnableExtension(screen->glx_enable_bits,
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index caad9a1fe7..2858312de7 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -356,6 +356,8 @@ initializeExtensions(__GLXscreen * screen)
 if (dri->swrast->base.version >= 3) {
 __glXEnableExtension(screen->glx_enable_bits,
  "GLX_ARB_create_context");
+__glXEnableExtension(screen->glx_enable_bits,
+ "GLX_ARB_create_context_no_error");
 __glXEnableExtension(screen->glx_enable_bits,
  "GLX_ARB_create_context_profile");
 __glXEnableExtension(screen->glx_enable_bits,
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 60bdeb00d9..79f4944d05 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -50,6 +50,10 @@
 #include 
 #include 
 
+#ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB
+#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3
+#endif
+
 /*
 ** GLX resources.
 */
-- 
2.14.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] Xephyr: Avoid calling xcb_shm_detach() twice

2018-02-20 Thread Alexander Volkov
This call was forgotten to be removed in
90996f5909aab4bc9aa4011a6a6d0555a7aa3adf in which
hostx_destroy_shm_segment() was introduced, which
itself does it.

Signed-off-by: Alexander Volkov 
---
 hw/kdrive/ephyr/hostx.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 8a69ec1e0..c2f94ed04 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -891,7 +891,6 @@ hostx_screen_init(KdScreenInfo *screen,
  */
 
 if (HostX.have_shm) {
-xcb_shm_detach(HostX.conn, scrpriv->shminfo.shmseg);
 xcb_image_destroy(scrpriv->ximg);
 hostx_destroy_shm_segment(>shminfo, scrpriv->shmsize);
 }
-- 
2.11.0

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: 2018 X.Org Board of Directors Elections Nomination period is NOW

2018-02-20 Thread Rob Clark
Just a reminder, nominations are open for a few more days.  If you
would like to nominate yourself or someone else please send your
nomination to electi...@x.org

BR,
-R

On Fri, Feb 9, 2018 at 9:01 AM, Rob Clark  wrote:
> We are seeking nominations for candidates for election to the X.Org
> Foundation Board of Directors. All X.Org Foundation members are
> eligible for election to the board.
>
> Nominations for the 2018 election are now open and will remain open
> until 23:59 UTC on 23 Feb 2018.
>
> The Board consists of directors elected from the membership. Each
> year, an election is held to bring the total number of directors to
> eight. The four members receiving the highest vote totals will serve
> as directors for two year terms.
>
> The directors who received two year terms starting in 2017 were Rob
> Clark, Martin Peres, Taylor Campbell and Daniel Vetter. They will
> continue to serve until their term ends in 2019. Current directors
> whose term expires in 2018 are Alex Deucher, Egbert Eich, Keith
> Packard and Bryce Harrington.
>
> A director is expected to participate in the fortnightly IRC meeting
> to discuss current business and to attend the annual meeting of the
> X.Org Foundation, which will be held at a location determined in
> advance by the Board of Directors.
>
> A member may nominate themselves or any other member they feel is
> qualified. Nominations should be sent to the Election Committee at
> elections at x.org.
>
> Nominees shall be required to be current members of the X.Org
> Foundation, and submit a personal statement of up to 200 words that
> will be provided to prospective voters. The collected statements,
> along with the statement of contribution to the X.Org Foundation in
> the members account page on http://members.x.org, will be made
> available to all voters to help them make their voting decisions.
>
> Nominations, membership applications or renewals and completed
> personal statements must be received no later than 23:59 UTC on 23 Feb
> 2018.
>
> The slate of candidates will be published 1 Mar 2018 and candidate Q
> will begin then. The deadline for Xorg membership applications and
> renewals is 1 Mar 2018.
>
> Cheers, Rob Clark, on behalf of the X.Org BoD
> https://www.x.org/wiki/BoardOfDirectors/Elections/2018/
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver 2/7] glamor: Fix loose ends in color depth 30 support.

2018-02-20 Thread Antoine Martin
On 20/02/18 11:06, Mario Kleiner wrote:
>  /* XXX handle 2 10 10 10 and 1555 formats; presumably the pixmap private 
> knows this? */
Maybe this comment should now be updated?

Otherwise, everything looks straightforward, so for the whole series:
Reviewed-by: Antoine Martin 

Cheers
Antoine
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel