[PATCH xserver 02/14 v2] dix: Incroduce CursorConfinedTo vfunc in Screen

2016-09-13 Thread Jonas Ådahl
This function will be called when a pointer is grabbed non-root window
set as the 'confineTo'. This will enable the ddx to handle the
confinement their own way.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 dix/events.c | 5 +
 include/scrnintstr.h | 5 +
 2 files changed, 10 insertions(+)

diff --git a/dix/events.c b/dix/events.c
index 87f080e..cc26ba5 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -882,6 +882,8 @@ ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, 
Bool generateEvents,
 SyntheticMotion(pDev, pSprite->hot.x, pSprite->hot.y);
 }
 else {
+ScreenPtr pScreen = pWin->drawable.pScreen;
+
 #ifdef PANORAMIX
 if (!noPanoramiXExtension) {
 XineramaConfineCursorToWindow(pDev, pWin, generateEvents);
@@ -893,6 +895,9 @@ ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, 
Bool generateEvents,
 : NullRegion;
 CheckPhysLimits(pDev, pSprite->current, generateEvents,
 confineToScreen, pWin->drawable.pScreen);
+
+if (*pScreen->CursorConfinedTo)
+(*pScreen->CursorConfinedTo) (pDev, pScreen, pWin);
 }
 }
 
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index b3228f8..b342685 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -241,6 +241,10 @@ typedef void (*CursorWarpedToProcPtr) (DeviceIntPtr /* 
pDev */ ,
int /*x */ ,
int /*y */ );
 
+typedef void (*CurserConfinedToProcPtr) (DeviceIntPtr /* pDev */ ,
+ ScreenPtr /*pScreen */ ,
+ WindowPtr /*pWindow */ );
+
 typedef Bool (*CreateGCProcPtr) (GCPtr /*pGC */ );
 
 typedef Bool (*CreateColormapProcPtr) (ColormapPtr /*pColormap */ );
@@ -545,6 +549,7 @@ typedef struct _Screen {
 RecolorCursorProcPtr RecolorCursor;
 SetCursorPositionProcPtr SetCursorPosition;
 CursorWarpedToProcPtr CursorWarpedTo;
+CurserConfinedToProcPtr CursorConfinedTo;
 
 /* GC procedures */
 
-- 
2.7.4

___
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 03/14 v2] dix: Add valuator_mask_set_absolute_unaccelerated

2016-09-13 Thread Jonas Ådahl
Add a valuator mask setter for setting absolute coordinate combined
with unaccelerated motion deltas. This will later be used by Xwayland
to combine a wl_pointer.motion() event with the unaccelerated delta of
a wp_relative_pointer.relative_motion() event.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 dix/inpututils.c | 13 +
 include/input.h  |  5 -
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dix/inpututils.c b/dix/inpututils.c
index 5b7da3a..6bff9ef 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -636,6 +636,19 @@ valuator_mask_drop_unaccelerated(ValuatorMask *mask)
 mask->has_unaccelerated = FALSE;
 }
 
+void
+valuator_mask_set_absolute_unaccelerated(ValuatorMask *mask,
+ int valuator,
+ int absolute,
+ double unaccel)
+{
+BUG_WARN_MSG(mask->last_bit != -1 && !mask->has_unaccelerated,
+ "Do not mix valuator types, zero mask first\n");
+_valuator_mask_set_double(mask, valuator, absolute);
+mask->has_unaccelerated = TRUE;
+mask->unaccelerated[valuator] = unaccel;
+}
+
 /**
  * Set both accelerated and unaccelerated value for this mask.
  */
diff --git a/include/input.h b/include/input.h
index e0f6b9b..c7b1e91 100644
--- a/include/input.h
+++ b/include/input.h
@@ -675,12 +675,15 @@ extern _X_EXPORT Bool valuator_mask_fetch(const 
ValuatorMask *mask,
   int valnum, int *val);
 extern _X_EXPORT Bool valuator_mask_fetch_double(const ValuatorMask *mask,
  int valnum, double *val);
-
 extern _X_EXPORT Bool valuator_mask_has_unaccelerated(const ValuatorMask 
*mask);
 extern _X_EXPORT void valuator_mask_set_unaccelerated(ValuatorMask *mask,
   int valuator,
   double accel,
   double unaccel);
+extern _X_EXPORT void valuator_mask_set_absolute_unaccelerated(ValuatorMask 
*mask,
+   int valuator,
+   int absolute,
+   double unaccel);
 extern _X_EXPORT double valuator_mask_get_accelerated(const ValuatorMask *mask,
   int valuator);
 extern _X_EXPORT double valuator_mask_get_unaccelerated(const ValuatorMask 
*mask,
-- 
2.7.4

___
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 07/14 v1] xwayland: Move pointer button initialization into helper

2016-09-13 Thread Jonas Ådahl
We'll later use this for initializing buttons for the relative pointer
since they need to be the same.

Signed-off-by: Jonas Ådahl 
---
 hw/xwayland/xwayland-input.c | 44 +++-
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index f194cf1..4ff9e18 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -52,31 +52,44 @@ xwl_pointer_control(DeviceIntPtr device, PtrCtrl *ctrl)
 /* Nothing to do, dix handles all settings */
 }
 
-static int
-xwl_pointer_proc(DeviceIntPtr device, int what)
+static Bool
+init_pointer_buttons(DeviceIntPtr device)
 {
 #define NBUTTONS 10
-#define NAXES 4
 BYTE map[NBUTTONS + 1];
 int i = 0;
 Atom btn_labels[NBUTTONS] = { 0 };
+
+for (i = 1; i <= NBUTTONS; i++)
+map[i] = i;
+
+btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+/* don't know about the rest */
+
+if (!InitButtonClassDeviceStruct(device, NBUTTONS, btn_labels, map))
+return FALSE;
+
+return TRUE;
+}
+
+static int
+xwl_pointer_proc(DeviceIntPtr device, int what)
+{
+#define NAXES 4
 Atom axes_labels[NAXES] = { 0 };
 
 switch (what) {
 case DEVICE_INIT:
 device->public.on = FALSE;
 
-for (i = 1; i <= NBUTTONS; i++)
-map[i] = i;
-
-btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
-btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
-btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
-btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
-btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
-btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
-btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
-/* don't know about the rest */
+if (!init_pointer_buttons(device))
+return BadValue;
 
 axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
 axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
@@ -103,9 +116,6 @@ xwl_pointer_proc(DeviceIntPtr device, int what)
 if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control))
 return BadValue;
 
-if (!InitButtonClassDeviceStruct(device, NBUTTONS, btn_labels, map))
-return BadValue;
-
 return Success;
 
 case DEVICE_ON:
-- 
2.7.4

___
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 01/14 v2] dix: Introduce CursorWarpedTo vfunc in Screen

2016-09-13 Thread Jonas Ådahl
This new vfunc will be called, if set, after a client has issued a
WarpPointer request. This is necessary for implementing pointer warp
emulation in Xwayland.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 dix/events.c | 3 +++
 include/scrnintstr.h | 9 +
 2 files changed, 12 insertions(+)

diff --git a/dix/events.c b/dix/events.c
index 6610b91..87f080e 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3609,6 +3609,9 @@ ProcWarpPointer(ClientPtr client)
 else if (!PointerConfinedToScreen(dev)) {
 NewCurrentScreen(dev, newScreen, x, y);
 }
+if (*newScreen->CursorWarpedTo)
+(*newScreen->CursorWarpedTo) (dev, newScreen, client,
+  dest, pSprite, x, y);
 return Success;
 }
 
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 5330714..b3228f8 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -233,6 +233,14 @@ typedef Bool (*SetCursorPositionProcPtr) (DeviceIntPtr /* 
pDev */ ,
   int /*y */ ,
   Bool /*generateEvent */ );
 
+typedef void (*CursorWarpedToProcPtr) (DeviceIntPtr /* pDev */ ,
+   ScreenPtr /*pScreen */ ,
+   ClientPtr /*pClient */ ,
+   WindowPtr /*pWindow */ ,
+   SpritePtr /*pSprite */ ,
+   int /*x */ ,
+   int /*y */ );
+
 typedef Bool (*CreateGCProcPtr) (GCPtr /*pGC */ );
 
 typedef Bool (*CreateColormapProcPtr) (ColormapPtr /*pColormap */ );
@@ -536,6 +544,7 @@ typedef struct _Screen {
 UnrealizeCursorProcPtr UnrealizeCursor;
 RecolorCursorProcPtr RecolorCursor;
 SetCursorPositionProcPtr SetCursorPosition;
+CursorWarpedToProcPtr CursorWarpedTo;
 
 /* GC procedures */
 
-- 
2.7.4

___
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 06/14 v2] xwayland: Split up device class init/release into functions

2016-09-13 Thread Jonas Ådahl
Put device class initialization in init_[device_class](xwl_seat) and
releasing in release_[device class](xwl_seat). The purpose is to make
it easier to add more type of initialization here later, without making
the function too large.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 hw/xwayland/xwayland-input.c | 143 +++
 1 file changed, 90 insertions(+), 53 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 785f56b..f194cf1 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -769,74 +769,111 @@ add_device(struct xwl_seat *xwl_seat,
 }
 
 static void
+init_pointer(struct xwl_seat *xwl_seat)
+{
+xwl_seat->wl_pointer = wl_seat_get_pointer(xwl_seat->seat);
+wl_pointer_add_listener(xwl_seat->wl_pointer,
+&pointer_listener, xwl_seat);
+
+if (xwl_seat->pointer == NULL) {
+xwl_seat_set_cursor(xwl_seat);
+xwl_seat->pointer =
+add_device(xwl_seat, "xwayland-pointer", xwl_pointer_proc);
+ActivateDevice(xwl_seat->pointer, TRUE);
+}
+EnableDevice(xwl_seat->pointer, TRUE);
+}
+
+static void
+release_pointer(struct xwl_seat *xwl_seat)
+{
+wl_pointer_release(xwl_seat->wl_pointer);
+xwl_seat->wl_pointer = NULL;
+
+if (xwl_seat->pointer)
+DisableDevice(xwl_seat->pointer, TRUE);
+}
+
+static void
+init_keyboard(struct xwl_seat *xwl_seat)
+{
+DeviceIntPtr master;
+
+xwl_seat->wl_keyboard = wl_seat_get_keyboard(xwl_seat->seat);
+wl_keyboard_add_listener(xwl_seat->wl_keyboard,
+ &keyboard_listener, xwl_seat);
+
+if (xwl_seat->keyboard == NULL) {
+xwl_seat->keyboard =
+add_device(xwl_seat, "xwayland-keyboard", xwl_keyboard_proc);
+ActivateDevice(xwl_seat->keyboard, TRUE);
+}
+EnableDevice(xwl_seat->keyboard, TRUE);
+xwl_seat->keyboard->key->xkbInfo->checkRepeat = keyboard_check_repeat;
+master = GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD);
+if (master)
+master->key->xkbInfo->checkRepeat = keyboard_check_repeat;
+}
+
+static void
+release_keyboard(struct xwl_seat *xwl_seat)
+{
+wl_keyboard_release(xwl_seat->wl_keyboard);
+xwl_seat->wl_keyboard = NULL;
+
+if (xwl_seat->keyboard) {
+remove_sync_pending(xwl_seat->keyboard);
+DisableDevice(xwl_seat->keyboard, TRUE);
+}
+}
+
+static void
+init_touch(struct xwl_seat *xwl_seat)
+{
+xwl_seat->wl_touch = wl_seat_get_touch(xwl_seat->seat);
+wl_touch_add_listener(xwl_seat->wl_touch,
+  &touch_listener, xwl_seat);
+
+if (xwl_seat->touch)
+EnableDevice(xwl_seat->touch, TRUE);
+else {
+xwl_seat->touch =
+add_device(xwl_seat, "xwayland-touch", xwl_touch_proc);
+}
+}
+
+static void
+release_touch(struct xwl_seat *xwl_seat)
+{
+wl_touch_release(xwl_seat->wl_touch);
+xwl_seat->wl_touch = NULL;
+
+if (xwl_seat->touch)
+DisableDevice(xwl_seat->touch, TRUE);
+}
+
+static void
 seat_handle_capabilities(void *data, struct wl_seat *seat,
  enum wl_seat_capability caps)
 {
 struct xwl_seat *xwl_seat = data;
-DeviceIntPtr master;
 
 if (caps & WL_SEAT_CAPABILITY_POINTER && xwl_seat->wl_pointer == NULL) {
-xwl_seat->wl_pointer = wl_seat_get_pointer(seat);
-wl_pointer_add_listener(xwl_seat->wl_pointer,
-&pointer_listener, xwl_seat);
-
-if (xwl_seat->pointer == NULL) {
-xwl_seat_set_cursor(xwl_seat);
-xwl_seat->pointer =
-add_device(xwl_seat, "xwayland-pointer", xwl_pointer_proc);
-ActivateDevice(xwl_seat->pointer, TRUE);
-}
-EnableDevice(xwl_seat->pointer, TRUE);
+init_pointer(xwl_seat);
 } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && xwl_seat->wl_pointer) {
-wl_pointer_release(xwl_seat->wl_pointer);
-xwl_seat->wl_pointer = NULL;
-
-if (xwl_seat->pointer)
-DisableDevice(xwl_seat->pointer, TRUE);
+release_pointer(xwl_seat);
 }
 
 if (caps & WL_SEAT_CAPABILITY_KEYBOARD && xwl_seat->wl_keyboard == NULL) {
-xwl_seat->wl_keyboard = wl_seat_get_keyboard(seat);
-wl_keyboard_add_listener(xwl_seat->wl_keyboard,
- &keyboard_listener, xwl_seat);
-
-if (xwl_seat->keyboard == NULL) {
-xwl_seat->keyboard =
-add_device(xwl_seat, "xwayland-keyboard", xwl_keyboard_proc);
-ActivateDevice(xwl_seat->keyboard, TRUE);
-}
-EnableDevice(xwl_seat->keyboard, TRUE);
-xwl_seat->keyboard->key->xkbInfo->checkRepeat = keyboard_check_repeat;
-master = GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD);
-if (master)
-master->key->xkbInfo->checkRepeat = keyboard_check_repeat;
+init_keyboard(xwl_sea

[PATCH xserver 04/14 v2] Bump ABI versions

2016-09-13 Thread Jonas Ådahl
Bump both the xinput and videodrv versions. The xinput due to the added
valuator mask setter, and videodrv due to the added vfuncs to the
Screen struct.

Signed-off-by: Jonas Ådahl 
---

No changes since v1.

 hw/xfree86/common/xf86Module.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index e0212cf..8470ab4 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -79,8 +79,8 @@ typedef enum {
  * mask is 0x.
  */
 #define ABI_ANSIC_VERSION  SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION   SET_ABI_VERSION(23, 0)
-#define ABI_XINPUT_VERSION SET_ABI_VERSION(24, 1)
+#define ABI_VIDEODRV_VERSION   SET_ABI_VERSION(24, 0)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(25, 0)
 #define ABI_EXTENSION_VERSION  SET_ABI_VERSION(10, 0)
 
 #define MODINFOSTRING1 0xef23fdc5
-- 
2.7.4

___
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 09/14 v2] xwayland: Dispatch pointer motion events on wl_pointer.frame if possible

2016-09-13 Thread Jonas Ådahl
Wait until wl_pointer.frame with dispatching the pointer motion event,
if wl_pointer.frame is supported by the compositor. This will later be
used to combine unaccelerated motion deltas with the absolute motion
delta.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 hw/xwayland/xwayland-input.c | 75 
 hw/xwayland/xwayland.h   |  6 
 2 files changed, 68 insertions(+), 13 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 1eae8f5..174db83 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -353,27 +353,47 @@ pointer_handle_leave(void *data, struct wl_pointer 
*pointer,
 }
 
 static void
+dispatch_pointer_event(struct xwl_seat *xwl_seat)
+{
+ValuatorMask mask;
+
+if (xwl_seat->pending_pointer_event.has_absolute) {
+int sx;
+int sy;
+int dx;
+int dy;
+
+sx = wl_fixed_to_int(xwl_seat->pending_pointer_event.x);
+sy = wl_fixed_to_int(xwl_seat->pending_pointer_event.y);
+dx = xwl_seat->focus_window->window->drawable.x;
+dy = xwl_seat->focus_window->window->drawable.y;
+
+valuator_mask_zero(&mask);
+valuator_mask_set(&mask, 0, dx + sx);
+valuator_mask_set(&mask, 1, dy + sy);
+
+QueuePointerEvents(xwl_seat->pointer, MotionNotify, 0,
+   POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+}
+
+xwl_seat->pending_pointer_event.has_absolute = FALSE;
+}
+
+static void
 pointer_handle_motion(void *data, struct wl_pointer *pointer,
   uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
 {
 struct xwl_seat *xwl_seat = data;
-int32_t dx, dy;
-int sx = wl_fixed_to_int(sx_w);
-int sy = wl_fixed_to_int(sy_w);
-ValuatorMask mask;
 
 if (!xwl_seat->focus_window)
 return;
 
-dx = xwl_seat->focus_window->window->drawable.x;
-dy = xwl_seat->focus_window->window->drawable.y;
-
-valuator_mask_zero(&mask);
-valuator_mask_set(&mask, 0, dx + sx);
-valuator_mask_set(&mask, 1, dy + sy);
+xwl_seat->pending_pointer_event.has_absolute = TRUE;
+xwl_seat->pending_pointer_event.x = sx_w;
+xwl_seat->pending_pointer_event.y = sy_w;
 
-QueuePointerEvents(xwl_seat->pointer, MotionNotify, 0,
-   POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+if (wl_proxy_get_version((struct wl_proxy *) xwl_seat->wl_pointer) < 5)
+dispatch_pointer_event(xwl_seat);
 }
 
 static void
@@ -433,12 +453,41 @@ pointer_handle_axis(void *data, struct wl_pointer 
*pointer,
 QueuePointerEvents(xwl_seat->pointer, MotionNotify, 0, POINTER_RELATIVE, 
&mask);
 }
 
+static void
+pointer_handle_frame(void *data, struct wl_pointer *wl_pointer)
+{
+struct xwl_seat *xwl_seat = data;
+
+dispatch_pointer_event(xwl_seat);
+}
+
+static void
+pointer_handle_axis_source(void *data, struct wl_pointer *wl_pointer, uint32_t 
axis_source)
+{
+}
+
+static void
+pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer,
+ uint32_t time, uint32_t axis)
+{
+}
+
+static void
+pointer_handle_axis_discrete(void *data, struct wl_pointer *wl_pointer,
+ uint32_t axis, int32_t discrete)
+{
+}
+
 static const struct wl_pointer_listener pointer_listener = {
 pointer_handle_enter,
 pointer_handle_leave,
 pointer_handle_motion,
 pointer_handle_button,
 pointer_handle_axis,
+pointer_handle_frame,
+pointer_handle_axis_source,
+pointer_handle_axis_stop,
+pointer_handle_axis_discrete,
 };
 
 static void
@@ -990,7 +1039,7 @@ create_input_device(struct xwl_screen *xwl_screen, 
uint32_t id, uint32_t version
 
 xwl_seat->seat =
 wl_registry_bind(xwl_screen->registry, id,
- &wl_seat_interface, min(version, 4));
+ &wl_seat_interface, min(version, 5));
 xwl_seat->id = id;
 
 xwl_seat->cursor = wl_compositor_create_surface(xwl_screen->compositor);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index f78f464..1fbae15 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -145,6 +145,12 @@ struct xwl_seat {
 struct wl_surface *keyboard_focus;
 
 struct xorg_list sync_pending;
+
+struct {
+Bool has_absolute;
+wl_fixed_t x;
+wl_fixed_t y;
+} pending_pointer_event;
 };
 
 struct xwl_output {
-- 
2.7.4

___
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 08/14 v2] xwayland: Add a new input device used for pointer warping/locking

2016-09-13 Thread Jonas Ådahl
From: Krzysztof Sobiecki 

Generating relative and absolute movement events from the same input
device is problematic, because an absolute pointer device doesn't
expect to see any relative motion events. To be able to generate
relative pointer motion events including unaccelerated deltas, create a
secondary pointer device 'xwayland-relative-pointer', and use that for
emitting relative motion events.

Signed-off-by: Krzysztof Sobiecki 
Signed-off-by: Jonas Ådahl 
---

Changes since v1:

The relative pointer now initializes the buttons.


 hw/xwayland/xwayland-input.c | 73 
 hw/xwayland/xwayland.h   |  1 +
 2 files changed, 74 insertions(+)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 4ff9e18..1eae8f5 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -134,6 +134,58 @@ xwl_pointer_proc(DeviceIntPtr device, int what)
 #undef NAXES
 }
 
+static int
+xwl_pointer_proc_relative(DeviceIntPtr device, int what)
+{
+#define NAXES 2
+Atom axes_labels[NAXES] = { 0 };
+
+switch (what) {
+case DEVICE_INIT:
+device->public.on = FALSE;
+
+axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+/*
+ * We'll never send buttons, but XGetPointerMapping might in certain
+ * situations make the client think we have no buttons.
+ */
+if (!init_pointer_buttons(device))
+return BadValue;
+
+if (!InitValuatorClassDeviceStruct(device, NAXES, axes_labels,
+   GetMotionHistorySize(), Relative))
+return BadValue;
+
+/* Valuators */
+InitValuatorAxisStruct(device, 0, axes_labels[0],
+   NO_AXIS_LIMITS, NO_AXIS_LIMITS, 1, 0, 1, 
Relative);
+InitValuatorAxisStruct(device, 1, axes_labels[1],
+   NO_AXIS_LIMITS, NO_AXIS_LIMITS, 1, 0, 1, 
Relative);
+
+if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control))
+return BadValue;
+
+device->button = NULL;
+
+return Success;
+
+case DEVICE_ON:
+device->public.on = TRUE;
+return Success;
+
+case DEVICE_OFF:
+case DEVICE_CLOSE:
+device->public.on = FALSE;
+return Success;
+}
+
+return BadMatch;
+
+#undef NAXES
+}
+
 static void
 xwl_keyboard_control(DeviceIntPtr device, KeybdCtrl *ctrl)
 {
@@ -805,6 +857,25 @@ release_pointer(struct xwl_seat *xwl_seat)
 }
 
 static void
+init_relative_pointer(struct xwl_seat *xwl_seat)
+{
+if (xwl_seat->relative_pointer == NULL) {
+xwl_seat->relative_pointer =
+add_device(xwl_seat, "xwayland-relative-pointer",
+   xwl_pointer_proc_relative);
+ActivateDevice(xwl_seat->relative_pointer, TRUE);
+}
+EnableDevice(xwl_seat->relative_pointer, TRUE);
+}
+
+static void
+release_relative_pointer(struct xwl_seat *xwl_seat)
+{
+if (xwl_seat->relative_pointer)
+DisableDevice(xwl_seat->relative_pointer, TRUE);
+}
+
+static void
 init_keyboard(struct xwl_seat *xwl_seat)
 {
 DeviceIntPtr master;
@@ -870,8 +941,10 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
 
 if (caps & WL_SEAT_CAPABILITY_POINTER && xwl_seat->wl_pointer == NULL) {
 init_pointer(xwl_seat);
+init_relative_pointer(xwl_seat);
 } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && xwl_seat->wl_pointer) {
 release_pointer(xwl_seat);
+release_relative_pointer(xwl_seat);
 }
 
 if (caps & WL_SEAT_CAPABILITY_KEYBOARD && xwl_seat->wl_keyboard == NULL) {
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 2d19133..f78f464 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -119,6 +119,7 @@ struct xwl_touch {
 
 struct xwl_seat {
 DeviceIntPtr pointer;
+DeviceIntPtr relative_pointer;
 DeviceIntPtr keyboard;
 DeviceIntPtr touch;
 struct xwl_screen *xwl_screen;
-- 
2.7.4

___
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 12/14 v2] xwayland: Bind pointer constraints global

2016-09-13 Thread Jonas Ådahl
Will be used by the pointer warp emulator.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 hw/xwayland/.gitignore   |  2 ++
 hw/xwayland/Makefile.am  |  9 -
 hw/xwayland/xwayland-input.c | 13 +
 hw/xwayland/xwayland.h   |  2 ++
 4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/hw/xwayland/.gitignore b/hw/xwayland/.gitignore
index 6e4e54d..38ada56 100644
--- a/hw/xwayland/.gitignore
+++ b/hw/xwayland/.gitignore
@@ -1,5 +1,7 @@
 Xwayland
 drm-client-protocol.h
 drm-protocol.c
+pointer-constraints-unstable-v1-client-protocol.h
+pointer-constraints-unstable-v1-protocol.c
 relative-pointer-unstable-v1-client-protocol.h
 relative-pointer-unstable-v1-protocol.c
diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index 75b8ead..a3c9fce 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -54,7 +54,9 @@ endif
 
 Xwayland_built_sources +=  \
relative-pointer-unstable-v1-client-protocol.h  \
-   relative-pointer-unstable-v1-protocol.c
+   relative-pointer-unstable-v1-protocol.c \
+   pointer-constraints-unstable-v1-client-protocol.h   \
+   pointer-constraints-unstable-v1-protocol.c
 
 nodist_Xwayland_SOURCES = $(Xwayland_built_sources)
 CLEANFILES = $(Xwayland_built_sources)
@@ -72,6 +74,11 @@ relative-pointer-unstable-v1-protocol.c : 
$(WAYLAND_PROTOCOLS_DATADIR)/unstable/
 relative-pointer-unstable-v1-client-protocol.h : 
$(WAYLAND_PROTOCOLS_DATADIR)/unstable/relative-pointer/relative-pointer-unstable-v1.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
 
+pointer-constraints-unstable-v1-protocol.c : 
$(WAYLAND_PROTOCOLS_DATADIR)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
+   $(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
+pointer-constraints-unstable-v1-client-protocol.h : 
$(WAYLAND_PROTOCOLS_DATADIR)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
+   $(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
+
 %-protocol.c : %.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
 
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index bc83d92..a6c816f 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -1145,6 +1145,17 @@ init_relative_pointer_manager(struct xwl_screen 
*xwl_screen,
  1);
 }
 
+static void
+init_pointer_constraints(struct xwl_screen *xwl_screen,
+ uint32_t id, uint32_t version)
+{
+xwl_screen->pointer_constraints =
+wl_registry_bind(xwl_screen->registry, id,
+ &zwp_pointer_constraints_v1_interface,
+ 1);
+}
+
+static void
 input_handler(void *data, struct wl_registry *registry, uint32_t id,
   const char *interface, uint32_t version)
 {
@@ -1155,6 +1166,8 @@ input_handler(void *data, struct wl_registry *registry, 
uint32_t id,
 xwl_screen->expecting_event++;
 } else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) {
 init_relative_pointer_manager(xwl_screen, id, version);
+} else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0) {
+init_pointer_constraints(xwl_screen, id, version);
 }
 }
 
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 24b3e91..a5d5d91 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -43,6 +43,7 @@
 #include 
 
 #include "relative-pointer-unstable-v1-client-protocol.h"
+#include "pointer-constraints-unstable-v1-client-protocol.h"
 
 struct xwl_screen {
 int width;
@@ -78,6 +79,7 @@ struct xwl_screen {
 struct wl_shm *shm;
 struct wl_shell *shell;
 struct zwp_relative_pointer_manager_v1 *relative_pointer_manager;
+struct zwp_pointer_constraints_v1 *pointer_constraints;
 
 uint32_t serial;
 
-- 
2.7.4

___
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 05/14 v2] xwayland: Bind the relative pointer manager

2016-09-13 Thread Jonas Ådahl
Will be used for getting unaccelerated motion events and later for
relative motions used by a pointer warp emulator.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 configure.ac |  4 +++-
 hw/xwayland/.gitignore   |  2 ++
 hw/xwayland/Makefile.am  | 21 +
 hw/xwayland/xwayland-input.c | 11 +++
 hw/xwayland/xwayland.h   |  3 +++
 5 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index e206e0f..443de35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2504,7 +2504,7 @@ AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && 
test "x$XFAKE" = xyes])
 
 dnl Xwayland DDX
 
-XWAYLANDMODULES="wayland-client >= 1.3.0 libdrm epoxy"
+XWAYLANDMODULES="wayland-client >= 1.3.0 wayland-protocols >= 1.1 libdrm epoxy"
 if test "x$XF86VIDMODE" = xyes; then
XWAYLANDMODULES="$XWAYLANDMODULES $VIDMODEPROTO"
 fi
@@ -2533,6 +2533,8 @@ if test "x$XWAYLAND" = xyes; then
WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client`
AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],,
 [${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH])
+
+   AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, `$PKG_CONFIG --variable=pkgdatadir 
wayland-protocols`)
 fi
 
 
diff --git a/hw/xwayland/.gitignore b/hw/xwayland/.gitignore
index c54ba2d..6e4e54d 100644
--- a/hw/xwayland/.gitignore
+++ b/hw/xwayland/.gitignore
@@ -1,3 +1,5 @@
 Xwayland
 drm-client-protocol.h
 drm-protocol.c
+relative-pointer-unstable-v1-client-protocol.h
+relative-pointer-unstable-v1-protocol.c
diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index 34fd633..75b8ead 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -30,6 +30,7 @@ Xwayland_LDADD =  \
$(XSERVER_SYS_LIBS)
 Xwayland_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 
+Xwayland_built_sources =
 
 if GLAMOR_EGL
 Xwayland_SOURCES +=\
@@ -39,13 +40,11 @@ Xwayland_SOURCES += \
xwayland-glamor-xv.c
 endif
 
-nodist_Xwayland_SOURCES =  \
+glamor_built_sources = \
drm-client-protocol.h   \
drm-protocol.c
 
-CLEANFILES = $(nodist_Xwayland_SOURCES)
-
-xwayland-glamor.c : $(nodist_Xwayland_SOURCES)
+Xwayland_built_sources += $(glamor_built_sources)
 
 glamor_lib = $(top_builddir)/glamor/libglamor.la
 
@@ -53,12 +52,26 @@ Xwayland_LDADD += $(GLAMOR_LIBS) $(GBM_LIBS) -lEGL -lGL
 Xwayland_DEPENDENCIES = $(glamor_lib) $(XWAYLAND_LIBS)
 endif
 
+Xwayland_built_sources +=  \
+   relative-pointer-unstable-v1-client-protocol.h  \
+   relative-pointer-unstable-v1-protocol.c
+
+nodist_Xwayland_SOURCES = $(Xwayland_built_sources)
+CLEANFILES = $(Xwayland_built_sources)
+
 EXTRA_DIST = drm.xml
 
 
+$(Xwayland_SOURCES): $(Xwayland_built_sources)
+
 relink:
$(AM_V_at)rm -f Xwayland$(EXEEXT) && $(MAKE) Xwayland$(EXEEXT)
 
+relative-pointer-unstable-v1-protocol.c : 
$(WAYLAND_PROTOCOLS_DATADIR)/unstable/relative-pointer/relative-pointer-unstable-v1.xml
+   $(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
+relative-pointer-unstable-v1-client-protocol.h : 
$(WAYLAND_PROTOCOLS_DATADIR)/unstable/relative-pointer/relative-pointer-unstable-v1.xml
+   $(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
+
 %-protocol.c : %.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
 
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 32cfb35..785f56b 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -907,6 +907,15 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat)
 }
 
 static void
+init_relative_pointer_manager(struct xwl_screen *xwl_screen,
+  uint32_t id, uint32_t version)
+{
+xwl_screen->relative_pointer_manager =
+wl_registry_bind(xwl_screen->registry, id,
+ &zwp_relative_pointer_manager_v1_interface,
+ 1);
+}
+
 input_handler(void *data, struct wl_registry *registry, uint32_t id,
   const char *interface, uint32_t version)
 {
@@ -915,6 +924,8 @@ input_handler(void *data, struct wl_registry *registry, 
uint32_t id,
 if (strcmp(interface, "wl_seat") == 0 && version >= 3) {
 create_input_device(xwl_screen, id, version);
 xwl_screen->expecting_event++;
+} else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) {
+init_relative_pointer_manager(xwl_screen, id, version);
 }
 }
 
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index db3dd0b..2d19133 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -42,6 +42,8 @@
 #include 
 #include 
 
+#include "relative-pointer-unstable-v1-client-protocol.h"
+
 struct xwl_screen {
 int width;
 int height;
@@ -75,6 +77,7 @@ struct xwl_screen {
 struct wl_compo

[PATCH xserver 11/14 v2] xwayland: Put getting a xwl_window from a Window in a helper

2016-09-13 Thread Jonas Ådahl
Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 hw/xwayland/xwayland.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 847321e..5ceab0f 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -102,6 +102,12 @@ static DevPrivateKeyRec xwl_window_private_key;
 static DevPrivateKeyRec xwl_screen_private_key;
 static DevPrivateKeyRec xwl_pixmap_private_key;
 
+static struct xwl_window *
+xwl_window_get(WindowPtr window)
+{
+return dixLookupPrivate(&window->devPrivates, &xwl_window_private_key);
+}
+
 struct xwl_screen *
 xwl_screen_get(ScreenPtr screen)
 {
@@ -334,8 +340,7 @@ xwl_unrealize_window(WindowPtr window)
 xwl_screen->UnrealizeWindow = screen->UnrealizeWindow;
 screen->UnrealizeWindow = xwl_unrealize_window;
 
-xwl_window =
-dixLookupPrivate(&window->devPrivates, &xwl_window_private_key);
+xwl_window = xwl_window_get(window);
 if (!xwl_window)
 return ret;
 
-- 
2.7.4

___
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 13/14 v2] xwayland: Translate a pointer grab with confineTo to pointer confinement

2016-09-13 Thread Jonas Ådahl
Translate grabbing a pointer device with confineTo set to a window into
confining the Wayland pointer using the pointer constraints protocol.
This makes clients that depend on the pointer not going outside of the
window region, such as certain games and virtual machines viewers, to
function more properly.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 hw/xwayland/xwayland-input.c | 41 ++
 hw/xwayland/xwayland.c   | 53 
 hw/xwayland/xwayland.h   |  7 ++
 3 files changed, 101 insertions(+)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index a6c816f..48aadc7 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -1254,6 +1254,47 @@ xwl_seat_clear_touch(struct xwl_seat *xwl_seat, 
WindowPtr window)
 }
 
 void
+xwl_seat_confine_pointer(struct xwl_seat *xwl_seat,
+ struct xwl_window *xwl_window)
+{
+struct zwp_pointer_constraints_v1 *pointer_constraints =
+xwl_seat->xwl_screen->pointer_constraints;
+
+if (!pointer_constraints)
+return;
+
+if (xwl_seat->cursor_confinement_window == xwl_window)
+return;
+
+xwl_seat_unconfine_pointer(xwl_seat);
+
+xwl_seat->cursor_confinement_window = xwl_window;
+
+xwl_seat->confined_pointer =
+zwp_pointer_constraints_v1_confine_pointer(pointer_constraints,
+   xwl_window->surface,
+   xwl_seat->wl_pointer,
+   NULL,
+   
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
+}
+
+static void
+xwl_seat_destroy_confined_pointer(struct xwl_seat *xwl_seat)
+{
+zwp_confined_pointer_v1_destroy(xwl_seat->confined_pointer);
+xwl_seat->confined_pointer = NULL;
+}
+
+void
+xwl_seat_unconfine_pointer(struct xwl_seat *xwl_seat)
+{
+xwl_seat->cursor_confinement_window = NULL;
+
+if (xwl_seat->confined_pointer)
+xwl_seat_destroy_confined_pointer(xwl_seat);
+}
+
+void
 InitInput(int argc, char *argv[])
 {
 ScreenPtr pScreen = screenInfo.screens[0];
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 5ceab0f..d22aba3 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -139,6 +139,54 @@ xwl_close_screen(ScreenPtr screen)
 return screen->CloseScreen(screen);
 }
 
+static struct xwl_window *
+xwl_window_from_window(WindowPtr window)
+{
+struct xwl_window *xwl_window;
+
+while (window) {
+xwl_window = xwl_window_get(window);
+if (xwl_window)
+return xwl_window;
+
+window = window->parent;
+}
+
+return NULL;
+}
+
+static struct xwl_seat *
+xwl_screen_get_default_seat(struct xwl_screen *xwl_screen)
+{
+return container_of(xwl_screen->seat_list.prev,
+struct xwl_seat,
+link);
+}
+
+static void
+xwl_cursor_confined_to(DeviceIntPtr device,
+   ScreenPtr screen,
+   WindowPtr window)
+{
+struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+struct xwl_seat *xwl_seat = device->public.devicePrivate;
+struct xwl_window *xwl_window;
+
+if (!xwl_seat)
+xwl_seat = xwl_screen_get_default_seat(xwl_screen);
+
+if (window == screen->root) {
+xwl_seat_unconfine_pointer(xwl_seat);
+return;
+}
+
+xwl_window = xwl_window_from_window(window);
+if (!xwl_window)
+return;
+
+xwl_seat_confine_pointer(xwl_seat, xwl_window);
+}
+
 static void
 damage_report(DamagePtr pDamage, RegionPtr pRegion, void *data)
 {
@@ -332,6 +380,9 @@ xwl_unrealize_window(WindowPtr window)
 xwl_seat->focus_window = NULL;
 if (xwl_seat->last_xwindow == window)
 xwl_seat->last_xwindow = NullWindow;
+if (xwl_seat->cursor_confinement_window &&
+xwl_seat->cursor_confinement_window->window == window)
+xwl_seat_unconfine_pointer(xwl_seat);
 xwl_seat_clear_touch(xwl_seat, window);
 }
 
@@ -731,6 +782,8 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
 xwl_screen->CloseScreen = pScreen->CloseScreen;
 pScreen->CloseScreen = xwl_close_screen;
 
+pScreen->CursorConfinedTo = xwl_cursor_confined_to;
+
 return ret;
 }
 
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index a5d5d91..d62f49a 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -149,6 +149,9 @@ struct xwl_seat {
 
 struct xorg_list sync_pending;
 
+struct xwl_window *cursor_confinement_window;
+struct zwp_confined_pointer_v1 *confined_pointer;
+
 struct {
 Bool has_absolute;
 wl_fixed_t x;
@@ -187,6 +190,10 @@ void xwl_seat_destroy(struct xwl_seat *xwl_seat);
 
 void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr win

[PATCH xserver 10/14 v2] xwayland: Set unaccelerated pointer motion delta if available

2016-09-13 Thread Jonas Ådahl
If there was an relative pointer motion within the same frame as an
absolute pointer motion, provide both the absolute coordinate and the
unaccelerated delta when setting the valuator mask.

If a frame contained only a relative motion, queue an absolute motion
with an unchanged position, but still pass the unaccelerated motion
event.

If the wl_seat advertised by the compositor is not new enough, assume
each relative and absolute pointer motion arrives within their own
separate frames.

Signed-off-by: Jonas Ådahl 
Reviewed-by: Peter Hutterer 
---

No changes since v1.

 hw/xwayland/xwayland-input.c | 90 
 hw/xwayland/xwayland.h   |  7 
 2 files changed, 82 insertions(+), 15 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 174db83..bc83d92 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -353,30 +353,47 @@ pointer_handle_leave(void *data, struct wl_pointer 
*pointer,
 }
 
 static void
-dispatch_pointer_event(struct xwl_seat *xwl_seat)
+dispatch_pointer_motion_event(struct xwl_seat *xwl_seat)
 {
 ValuatorMask mask;
 
-if (xwl_seat->pending_pointer_event.has_absolute) {
-int sx;
-int sy;
-int dx;
-int dy;
-
-sx = wl_fixed_to_int(xwl_seat->pending_pointer_event.x);
-sy = wl_fixed_to_int(xwl_seat->pending_pointer_event.y);
-dx = xwl_seat->focus_window->window->drawable.x;
-dy = xwl_seat->focus_window->window->drawable.y;
+if (xwl_seat->pending_pointer_event.has_absolute ||
+xwl_seat->pending_pointer_event.has_relative) {
+int x;
+int y;
+
+if (xwl_seat->pending_pointer_event.has_absolute) {
+int sx = wl_fixed_to_int(xwl_seat->pending_pointer_event.x);
+int sy = wl_fixed_to_int(xwl_seat->pending_pointer_event.y);
+int dx = xwl_seat->focus_window->window->drawable.x;
+int dy = xwl_seat->focus_window->window->drawable.y;
+
+x = dx + sx;
+y = dy + sy;
+} else {
+miPointerGetPosition(xwl_seat->pointer, &x, &y);
+}
 
 valuator_mask_zero(&mask);
-valuator_mask_set(&mask, 0, dx + sx);
-valuator_mask_set(&mask, 1, dy + sy);
+if (xwl_seat->pending_pointer_event.has_relative) {
+double dx_unaccel;
+double dy_unaccel;
+
+dx_unaccel = xwl_seat->pending_pointer_event.dx_unaccel;
+dy_unaccel = xwl_seat->pending_pointer_event.dy_unaccel;
+valuator_mask_set_absolute_unaccelerated(&mask, 0, x, dx_unaccel);
+valuator_mask_set_absolute_unaccelerated(&mask, 1, y, dy_unaccel);
+} else {
+valuator_mask_set(&mask, 0, x);
+valuator_mask_set(&mask, 1, y);
+}
 
 QueuePointerEvents(xwl_seat->pointer, MotionNotify, 0,
POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
 }
 
 xwl_seat->pending_pointer_event.has_absolute = FALSE;
+xwl_seat->pending_pointer_event.has_relative = FALSE;
 }
 
 static void
@@ -393,7 +410,7 @@ pointer_handle_motion(void *data, struct wl_pointer 
*pointer,
 xwl_seat->pending_pointer_event.y = sy_w;
 
 if (wl_proxy_get_version((struct wl_proxy *) xwl_seat->wl_pointer) < 5)
-dispatch_pointer_event(xwl_seat);
+dispatch_pointer_motion_event(xwl_seat);
 }
 
 static void
@@ -458,7 +475,7 @@ pointer_handle_frame(void *data, struct wl_pointer 
*wl_pointer)
 {
 struct xwl_seat *xwl_seat = data;
 
-dispatch_pointer_event(xwl_seat);
+dispatch_pointer_motion_event(xwl_seat);
 }
 
 static void
@@ -491,6 +508,32 @@ static const struct wl_pointer_listener pointer_listener = 
{
 };
 
 static void
+relative_pointer_handle_relative_motion(void *data,
+struct zwp_relative_pointer_v1 
*zwp_relative_pointer_v1,
+uint32_t utime_hi,
+uint32_t utime_lo,
+wl_fixed_t dxf,
+wl_fixed_t dyf,
+wl_fixed_t dx_unaccelf,
+wl_fixed_t dy_unaccelf)
+{
+struct xwl_seat *xwl_seat = data;
+
+xwl_seat->pending_pointer_event.has_relative = TRUE;
+xwl_seat->pending_pointer_event.dx = wl_fixed_to_double(dxf);
+xwl_seat->pending_pointer_event.dy = wl_fixed_to_double(dyf);
+xwl_seat->pending_pointer_event.dx_unaccel = 
wl_fixed_to_double(dx_unaccelf);
+xwl_seat->pending_pointer_event.dy_unaccel = 
wl_fixed_to_double(dy_unaccelf);
+
+if (wl_proxy_get_version((struct wl_proxy *) xwl_seat->wl_pointer) < 5)
+dispatch_pointer_motion_event(xwl_seat);
+}
+
+static const struct zwp_relative_pointer_v1_listener relative_pointer_listener 
= {
+relative_pointer_handle_relative_motion,
+};
+
+static void
 keyboard_

[PATCH xserver 14/14 v2] xwayland: Add pointer warp emulator

2016-09-13 Thread Jonas Ådahl
Emulate pointer warps by locking the pointer and sending relative
motion events instead of absolute. X will keep track of the "fake"
pointer cursor position given the relative motion events, and the
client warping the cursor will warp the faked cursor position.

Various requirements need to be met for the pointer warp emulator to
enable:

The cursor must be invisible: since it would not be acceptable that a
fake cursor position would be different from the visual representation
of the cursor, emulation can only be done when there is no visual
representation done by the Wayland compositor. Thus, for the emulator
to enable, the cursor must be hidden, and would the cursor be displayed
while the emulator is active, the emulator would be destroyed.

The window that is warped within must be likely to have pointer focus.
For example, warping outside of the window region will be ignored.

The pointer warp emulator will disable itself once the fake cursor
position leaves the window region, or the cursor is made visible.

This makes various games depending on pointer warping (such as 3D
first-person shooters and stategy games using click-to-drag-map like
things) work.

Signed-off-by: Jonas Ådahl 
---

Changes since v1:

Used y coordinate when supposed to.

Use __func__ instead of spelling it out manually.

NULL check focus window before calling set_fake_pos. We might still have our
emulator at that point.

Properly reconfine pointer on emulator destruction if needed.


 hw/xwayland/xwayland-cursor.c |   7 ++
 hw/xwayland/xwayland-input.c  | 273 +-
 hw/xwayland/xwayland.c|  27 +
 hw/xwayland/xwayland.h|  17 +++
 4 files changed, 322 insertions(+), 2 deletions(-)

diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
index 7d14a3d..20ddf6e 100644
--- a/hw/xwayland/xwayland-cursor.c
+++ b/hw/xwayland/xwayland-cursor.c
@@ -168,12 +168,19 @@ xwl_set_cursor(DeviceIntPtr device,
ScreenPtr screen, CursorPtr cursor, int x, int y)
 {
 struct xwl_seat *xwl_seat;
+Bool cursor_visibility_changed;
 
 xwl_seat = device->public.devicePrivate;
 if (xwl_seat == NULL)
 return;
 
+cursor_visibility_changed = !!xwl_seat->x_cursor ^ !!cursor;
+
 xwl_seat->x_cursor = cursor;
+
+if (cursor_visibility_changed)
+xwl_seat_cursor_visibility_changed(xwl_seat);
+
 xwl_seat_set_cursor(xwl_seat);
 }
 
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 48aadc7..57abb05 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -47,6 +47,21 @@ struct sync_pending {
 };
 
 static void
+xwl_pointer_warp_emulator_handle_motion(struct xwl_pointer_warp_emulator 
*warp_emulator,
+double dx,
+double dy,
+double dx_unaccel,
+double dy_unaccel);
+static void
+xwl_pointer_warp_emulator_maybe_lock(struct xwl_pointer_warp_emulator 
*warp_emulator,
+ struct xwl_window *xwl_window,
+ SpritePtr sprite,
+ int x, int y);
+
+static void
+xwl_seat_destroy_confined_pointer(struct xwl_seat *xwl_seat);
+
+static void
 xwl_pointer_control(DeviceIntPtr device, PtrCtrl *ctrl)
 {
 /* Nothing to do, dix handles all settings */
@@ -337,6 +352,12 @@ pointer_handle_enter(void *data, struct wl_pointer 
*pointer,
 xwl_seat->cursor_frame_cb = NULL;
 xwl_seat_set_cursor(xwl_seat);
 }
+
+if (xwl_seat->pointer_warp_emulator) {
+xwl_pointer_warp_emulator_maybe_lock(xwl_seat->pointer_warp_emulator,
+ xwl_seat->focus_window,
+ NULL, 0, 0);
+}
 }
 
 static void
@@ -357,8 +378,22 @@ dispatch_pointer_motion_event(struct xwl_seat *xwl_seat)
 {
 ValuatorMask mask;
 
-if (xwl_seat->pending_pointer_event.has_absolute ||
+if (xwl_seat->pointer_warp_emulator &&
 xwl_seat->pending_pointer_event.has_relative) {
+double dx;
+double dy;
+double dx_unaccel;
+double dy_unaccel;
+
+dx = xwl_seat->pending_pointer_event.dx;
+dy = xwl_seat->pending_pointer_event.dy;
+dx_unaccel = xwl_seat->pending_pointer_event.dx_unaccel;
+dy_unaccel = xwl_seat->pending_pointer_event.dy_unaccel;
+
xwl_pointer_warp_emulator_handle_motion(xwl_seat->pointer_warp_emulator,
+dx, dy,
+dx_unaccel, dy_unaccel);
+} else if (xwl_seat->pending_pointer_event.has_absolute ||
+   xwl_seat->pending_pointer_event.has_relative) {
 int x;
 int y;
 
@@ -1253,6 +1288,236 @@ xwl_seat_clear_touch(struct xwl_seat *xwl_seat, 
WindowPtr window)
 }
 

Re: [PATCH xserver v9] xf86Cursor: Deal with rotation on GPU screens using a hw-cursor

2016-09-13 Thread Michel Dänzer
On 13/09/16 09:51 AM, Michel Dänzer wrote:
> On 12/09/16 08:24 PM, Hans de Goede wrote:
>> When a slave-output is rotated the transformation is done on the blit
>> from master to slave GPU, so crtc->transform_in_use is not set, but we
>> still need to adjust the mouse position for things to work.
>>
>> This commit modifies xf86_crtc_transform_cursor_position to not rely
>> on crtc->f_framebuffer_to_crtc, so that it can be used with GPU screens
>> to and always calls it for cursors on GPU screens.
>>
>> Note not using crtc->f_framebuffer_to_crtc means that crtc->transform
>> will not be taken into account, that is ok, because when we've a transform
>> active hw-cursors are not used and xf86_crtc_transform_cursor_position
>> will never get called.
>>
>> Signed-off-by: Hans de Goede 
>> ---
>> Changes in v9:
>> -Write out the cursor coordinate conversion instead of playing tricks
>>  with (ab)using xf86_crtc_rotate_coord_back.

Reviewed-and-Tested-by: Michel Dänzer 


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer



signature.asc
Description: OpenPGP digital signature
___
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: weird Xwayland and compositor deadlock issue [WAS: [PATCH xserver v2] xwayland: handle EAGAIN and EINTR gracefully]

2016-09-13 Thread Olivier Fourdan
Hi all

- Original Message -
> wl_display_flush() can fail with EAGAIN and Xwayland would make this a
> fatal error.
> 
> Handle the usual EAGAIN and EINTR gracefully so that Xwayland doesn't
> die for so little.

Right, I am running out of ideas...

So the approach of using poll() to wait for the Wayland file descriptor to 
become writeable again leads straight to a deadlock apparently...

Reason for this is the compositor (gnome-shell/mutter) is itself waiting for 
data on the X file descriptor:

Backtrace of gnome-shell while we hit the EAGAIN case on the Wayland fd on the 
Xwayland side:

#0  0x7f86d1cd400d in poll () at /lib64/libc.so.6
#1  0x7f86d1537d10 in _xcb_conn_wait () at /lib64/libxcb.so.1
#2  0x7f86d1539aa9 in xcb_wait_for_event () at /lib64/libxcb.so.1
#3  0x7f86d21fe03b in _XReadEvents (dpy=dpy@entry=0x55f956633000) at 
xcb_io.c:401
#4  0x7f86d21e562e in XIfEvent (dpy=0x55f956633000, event=0x7ffe30c28eb0, 
predicate=, arg=0x55f956761100)
at IfEvent.c:68
#5  0x7f86d8031ddb in meta_display_get_current_time_roundtrip () at 
/lib64/libmutter.so.0
#6  0x7f86d805ac49 in handle_other_xevent () at /lib64/libmutter.so.0
#7  0x7f86d805b95b in xevent_filter () at /lib64/libmutter.so.0
#8  0x7f86d73b98f1 in gdk_event_apply_filters () at /lib64/libgdk-3.so.0
#9  0x7f86d73b9cf2 in _gdk_x11_display_queue_events () at 
/lib64/libgdk-3.so.0
#10 0x7f86d7380f19 in gdk_display_get_event () at /lib64/libgdk-3.so.0
#11 0x7f86d73b9962 in gdk_event_source_dispatch () at /lib64/libgdk-3.so.0
#12 0x7f86d37d0f22 in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
#13 0x7f86d37d12a0 in g_main_context_iterate.isra () at 
/lib64/libglib-2.0.so.0
#14 0x7f86d37d15c2 in g_main_loop_run () at /lib64/libglib-2.0.so.0
#15 0x7f86d803c00c in meta_run () at /lib64/libmutter.so.0
#16 0x55f953220657 in main ()

i.e gnome-shell is stuck in meta_display_get_current_time_roundtrip():

  https://git.gnome.org/browse/mutter/tree/src/core/display.c#n1300

While at the same time, Xwayland is trying to write to the Wayland file 
descriptor with wl_display_flush() and gets an EAGAIN in the block_handler():

  
https://cgit.freedesktop.org/xorg/xserver/tree/hw/xwayland/xwayland.c?h=server-1.18-branch#n483

I tried to poll() the Wayland fd with a timeout prior to wl_display_flush() to 
make sure to wl_display_flush() only when writable, to see if that would help 
unblocking mutter waiting for its PropertyNotify event but that did not work, 
the Wayland fd still remains in EAGAIN forever and gnome-shell/mutter remains 
stuck waiting for the PropertyNotify event...

I am a bit puzzled, why is gnome-shell/mutter/xcb waiting for the 
PropertyNotify, where is that event gone?

Any ideas?

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

[xserver PULL master] Prime hw cursor support

2016-09-13 Thread Hans de Goede

Hi Adam, Keith,

Here is a pull-req for the prime hw-cursor support patch-set,
which I've been working on getting ready for 1.19 for the
last 2 weeks, and which is fully reviewed / acked now.

I've also included some (trivial) modesetting driver fixes
from me which also all have been reviewed and have been around
for a while now, but have not yet been picked up.

Many thanks to Michel Danzer for his help with getting the
hw-cursor patches ready and for all his reviews.

The following changes since commit 527c6baa294d17c5eca1d87ac941844872e90dac:

  xkb: fix check for appending '|' character when applying rules (2016-09-07 
15:16:13 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~jwrdegoede/xserver prime-hw-cursor-support

for you to fetch changes up to 35c4e96ed1d372dd161480be8cddcd2d4549e449:

  randr: Fix crtc_bounds when using rotation combined with reflection 
(2016-09-13 10:27:30 +0200)


Dave Airlie (3):
  dix: Add dixPrivatesCreated helper function
  xf86Cursor: Add xf86CheckHWCursor() helper function
  xf86Cursor: Add hw cursor support for prime

Hans de Goede (10):
  glamor: Add glamor_shareable_fd_from_pixmap()
  modesetting: Fix msSharePixmapBacking returning a non-linear bo
  modesetting: ms_covering_crtc: Remove unused arguments, make static
  modesetting: Remove some dead code
  glamor: Fix crash when master gpu is using glamor and another gpu is 
hotplugged
  randr: Add RRHasScanoutPixmap helper function
  xf86Cursor: Fix xf86CurrentCursor to work on slave GPU Screens
  xf86Cursor: Fix xf86_crtc_rotate_coord using width/height wrongly
  xf86Cursor: Deal with rotation on GPU screens using a hw-cursor
  randr: Fix crtc_bounds when using rotation combined with reflection

 dix/dispatch.c  | 10 
 dix/privates.c  |  9 
 glamor/glamor.c | 20 
 glamor/glamor.h | 20 
 glamor/glamor_egl.c | 10 
 hw/xfree86/drivers/modesetting/dri2.c   |  2 -
 hw/xfree86/drivers/modesetting/driver.c |  3 +-
 hw/xfree86/drivers/modesetting/driver.h |  2 -
 hw/xfree86/drivers/modesetting/vblank.c | 23 +++--
 hw/xfree86/modes/xf86Cursors.c  | 55 +++-
 hw/xfree86/ramdac/xf86Cursor.c  | 20 +++-
 hw/xfree86/ramdac/xf86CursorPriv.h  |  1 +
 hw/xfree86/ramdac/xf86HWCurs.c  | 90 +++--
 include/privates.h  |  3 ++
 randr/randrstr.h|  6 +++
 randr/rrcrtc.c  | 21 +++-
 16 files changed, 244 insertions(+), 51 deletions(-)

Regards,

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

[xserver PULL master] Modesetting driver prime fixes (unreviewed)

2016-09-13 Thread Hans de Goede

Hi Adam, Keith,

Here is a pull-req for 4 modesetting driver prime fixes, which
I've had ready for quite a while now. I've asked various people
at various time to review these, but I've failed to get anyone
to look at them.

So now I'm asking you to merge these unreviewed and trust me
that these are good (I've tested them extensively). Getting
these into 1.19 is important for a number of reasons:

1) Debian and Ubuntu are moving to using the modesetting
driver instead of the intel driver for all recent Intel
iGPUs, without these patches users of hybrid gfx laptops
will see a regression (DRI2 prime offload will not work),
also not that Fedora has already moved to the modesetting
driver for skylake and newer since F24, so the same goes
for Fedora users with skylake.

2) The nouveau ddx does not support the latest 2 generations
of NVidia GPUs so people with these get the modesetting driver,
without these fixes opengl apps on slave outputs on such
NVidia GPUs will run at 1 fps.

3) Ben Skeggs is working on displayport mst for the nouveau
kms driver this will hopefully be ready soon, since the
nouveau ddx does not support mst the plan is to switch to
the modesetting driver for all mst capable NVidia GPUs
with a nouveau ddx update in the near future. Triggering
2) on a wider range of devices.

Note these patches sit on top of my hw-cursor pull-req,
they depend on some of the modesetting fixes / cleanups
in there, so this pull-req must be merged after the
hw-cursor pull-req.

The following changes since commit 35c4e96ed1d372dd161480be8cddcd2d4549e449:

  randr: Fix crtc_bounds when using rotation combined with reflection 
(2016-09-13 10:27:30 +0200)

are available in the git repository at:

  git://people.freedesktop.org/~jwrdegoede/xserver modesetting-prime-fixes

for you to fetch changes up to 08cfeecd524729589cd6b7c6e6fe65211b268dae:

  modesetting: Fall back to primary crtc for vblank for drawables on slave 
outputs (2016-09-13 12:40:13 +0200)


Hans de Goede (4):
  modesetting: ms_dri2_create_buffer: check screen of existing front buffers
  modesetting: Implement DRI2InfoRec version 9 callbacks
  modesetting: ms_covering_crtc: Allow calling on non modesetting Screens
  modesetting: Fall back to primary crtc for vblank for drawables on slave 
outputs

 hw/xfree86/drivers/modesetting/dri2.c   | 84 -
 hw/xfree86/drivers/modesetting/vblank.c | 38 +--
 2 files changed, 97 insertions(+), 25 deletions(-)

Regards,

Hans
___
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: [xserver PULL master] Modesetting driver prime fixes (unreviewed)

2016-09-13 Thread Hans de Goede

Hi,

On 13-09-16 12:53, Hans de Goede wrote:

Hi Adam, Keith,

Here is a pull-req for 4 modesetting driver prime fixes, which
I've had ready for quite a while now. I've asked various people
at various time to review these, but I've failed to get anyone
to look at them.

So now I'm asking you to merge these unreviewed and trust me
that these are good (I've tested them extensively). Getting
these into 1.19 is important for a number of reasons:

1) Debian and Ubuntu are moving to using the modesetting
driver instead of the intel driver for all recent Intel
iGPUs, without these patches users of hybrid gfx laptops
will see a regression (DRI2 prime offload will not work),
also not that Fedora has already moved to the modesetting
driver for skylake and newer since F24, so the same goes
for Fedora users with skylake.

2) The nouveau ddx does not support the latest 2 generations
of NVidia GPUs so people with these get the modesetting driver,
without these fixes opengl apps on slave outputs on such
NVidia GPUs will run at 1 fps.

3) Ben Skeggs is working on displayport mst for the nouveau
kms driver this will hopefully be ready soon, since the
nouveau ddx does not support mst the plan is to switch to
the modesetting driver for all mst capable NVidia GPUs
with a nouveau ddx update in the near future. Triggering
2) on a wider range of devices.


Erm, correction, the issues are actually the other way
around using modesetting driver on a slave gpu leads
to (DRI2 prime offloading not working), using it on
a master GPU leads to opengl apps on slave outputs
running at 1 fps.

This does not change that both are serious problems
which impact some users now and likely a lot more users
in the future.

Regards,

Hans
___
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: weird Xwayland and compositor deadlock issue [WAS: [PATCH xserver v2] xwayland: handle EAGAIN and EINTR gracefully]

2016-09-13 Thread Pekka Paalanen
On Tue, 13 Sep 2016 06:13:16 -0400 (EDT)
Olivier Fourdan  wrote:

> Hi all
> 
> - Original Message -
> > wl_display_flush() can fail with EAGAIN and Xwayland would make this a
> > fatal error.
> > 
> > Handle the usual EAGAIN and EINTR gracefully so that Xwayland doesn't
> > die for so little.  
> 
> Right, I am running out of ideas...
> 
> So the approach of using poll() to wait for the Wayland file descriptor to 
> become writeable again leads straight to a deadlock apparently...
> 
> Reason for this is the compositor (gnome-shell/mutter) is itself waiting for 
> data on the X file descriptor:
> 
> Backtrace of gnome-shell while we hit the EAGAIN case on the Wayland fd on 
> the Xwayland side:
> 
> #0  0x7f86d1cd400d in poll () at /lib64/libc.so.6
> #1  0x7f86d1537d10 in _xcb_conn_wait () at /lib64/libxcb.so.1
> #2  0x7f86d1539aa9 in xcb_wait_for_event () at /lib64/libxcb.so.1
> #3  0x7f86d21fe03b in _XReadEvents (dpy=dpy@entry=0x55f956633000) at 
> xcb_io.c:401
> #4  0x7f86d21e562e in XIfEvent (dpy=0x55f956633000, event=0x7ffe30c28eb0, 
> predicate=, arg=0x55f956761100)
> at IfEvent.c:68
> #5  0x7f86d8031ddb in meta_display_get_current_time_roundtrip () at 
> /lib64/libmutter.so.0
> #6  0x7f86d805ac49 in handle_other_xevent () at /lib64/libmutter.so.0
> #7  0x7f86d805b95b in xevent_filter () at /lib64/libmutter.so.0
> #8  0x7f86d73b98f1 in gdk_event_apply_filters () at /lib64/libgdk-3.so.0
> #9  0x7f86d73b9cf2 in _gdk_x11_display_queue_events () at 
> /lib64/libgdk-3.so.0
> #10 0x7f86d7380f19 in gdk_display_get_event () at /lib64/libgdk-3.so.0
> #11 0x7f86d73b9962 in gdk_event_source_dispatch () at /lib64/libgdk-3.so.0
> #12 0x7f86d37d0f22 in g_main_context_dispatch () at 
> /lib64/libglib-2.0.so.0
> #13 0x7f86d37d12a0 in g_main_context_iterate.isra () at 
> /lib64/libglib-2.0.so.0
> #14 0x7f86d37d15c2 in g_main_loop_run () at /lib64/libglib-2.0.so.0
> #15 0x7f86d803c00c in meta_run () at /lib64/libmutter.so.0
> #16 0x55f953220657 in main ()
> 
> i.e gnome-shell is stuck in meta_display_get_current_time_roundtrip():
> 
>   https://git.gnome.org/browse/mutter/tree/src/core/display.c#n1300
> 
> While at the same time, Xwayland is trying to write to the Wayland file 
> descriptor with wl_display_flush() and gets an EAGAIN in the block_handler():
> 
>   
> https://cgit.freedesktop.org/xorg/xserver/tree/hw/xwayland/xwayland.c?h=server-1.18-branch#n483
> 
> I tried to poll() the Wayland fd with a timeout prior to wl_display_flush() 
> to make sure to wl_display_flush() only when writable, to see if that would 
> help unblocking mutter waiting for its PropertyNotify event but that did not 
> work, the Wayland fd still remains in EAGAIN forever and gnome-shell/mutter 
> remains stuck waiting for the PropertyNotify event...
> 
> I am a bit puzzled, why is gnome-shell/mutter/xcb waiting for the 
> PropertyNotify, where is that event gone?

Hi Olivier,

I don't have any solution for you. The interactions between the Wayland
compositor and Xwayland are known to be very easily deadlockable IIRC. I
believe the only thing you can do is ensure no such case can ever
occur, which is very painful. That is, never do a blocking roundtrip at
least from one side.

Have the recent modifications caused a significant increase of Wayland
requests from Xwayland? If Xwayland needs to send an amount of data
bigger than bufferable, *any* blocking roundtrip via X11 from the
Wayland compositor is prone to deadlock. It will be waiting for a reply
via X11, while Xwayland is blocked on flushing, since the Wayland
compositor is not consuming requests.

It can also trivially happen if both sides do a blocking roundtrip at
the same time. Or just a wait for an event.

Either server needs to be able to return to its main loop to process the
protocol stream it is the server for. Preferably both, I think.

You could check how Weston's XWM works. I highly suspect that after
Xwayland launch it avoids doing any blocking roundtrips via X11.

I'd assume Xwayland also tries to avoid blocking on Wayland events, but
if nothing else, I believe Mesa via GLAMOR may block on
wl_buffer.release events... or maybe not if GLAMOR is smart with its
throttling. Anyway, since your flush is hitting EAGAIN, that doesn't
seem to be the cause.

I wonder if making wl_display_flush() block immediately like in your
patch could be replaced by adding the wl_display fd to the main poll
loop, so that it would get flushed ASAP but still service X11 requests
in the mean time? It does run the risk of overflowing the Wayland send
buffer in Xwayland. Any way to prioritize the Wayland compositor's X11
connection in Xwayland?


Thanks,
pq


pgp4idxEu7tuc.pgp
Description: OpenPGP digital signature
___
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 v3] xwayland: Add a new input device used for pointer warping/locking

2016-09-13 Thread Jonas Ådahl
From: Krzysztof Sobiecki 

Generating relative and absolute movement events from the same input
device is problematic, because an absolute pointer device doesn't
expect to see any relative motion events. To be able to generate
relative pointer motion events including unaccelerated deltas, create a
secondary pointer device 'xwayland-relative-pointer', and use that for
emitting relative motion events.

Signed-off-by: Krzysztof Sobiecki 
Signed-off-by: Jonas Ådahl 
---

Changes since v2:

Don't reset device->button to NULL after initializing it.



 hw/xwayland/xwayland-input.c | 71 
 hw/xwayland/xwayland.h   |  1 +
 2 files changed, 72 insertions(+)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 4ff9e18..f44e636 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -134,6 +134,56 @@ xwl_pointer_proc(DeviceIntPtr device, int what)
 #undef NAXES
 }
 
+static int
+xwl_pointer_proc_relative(DeviceIntPtr device, int what)
+{
+#define NAXES 2
+Atom axes_labels[NAXES] = { 0 };
+
+switch (what) {
+case DEVICE_INIT:
+device->public.on = FALSE;
+
+axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+/*
+ * We'll never send buttons, but XGetPointerMapping might in certain
+ * situations make the client think we have no buttons.
+ */
+if (!init_pointer_buttons(device))
+return BadValue;
+
+if (!InitValuatorClassDeviceStruct(device, NAXES, axes_labels,
+   GetMotionHistorySize(), Relative))
+return BadValue;
+
+/* Valuators */
+InitValuatorAxisStruct(device, 0, axes_labels[0],
+   NO_AXIS_LIMITS, NO_AXIS_LIMITS, 1, 0, 1, 
Relative);
+InitValuatorAxisStruct(device, 1, axes_labels[1],
+   NO_AXIS_LIMITS, NO_AXIS_LIMITS, 1, 0, 1, 
Relative);
+
+if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control))
+return BadValue;
+
+return Success;
+
+case DEVICE_ON:
+device->public.on = TRUE;
+return Success;
+
+case DEVICE_OFF:
+case DEVICE_CLOSE:
+device->public.on = FALSE;
+return Success;
+}
+
+return BadMatch;
+
+#undef NAXES
+}
+
 static void
 xwl_keyboard_control(DeviceIntPtr device, KeybdCtrl *ctrl)
 {
@@ -805,6 +855,25 @@ release_pointer(struct xwl_seat *xwl_seat)
 }
 
 static void
+init_relative_pointer(struct xwl_seat *xwl_seat)
+{
+if (xwl_seat->relative_pointer == NULL) {
+xwl_seat->relative_pointer =
+add_device(xwl_seat, "xwayland-relative-pointer",
+   xwl_pointer_proc_relative);
+ActivateDevice(xwl_seat->relative_pointer, TRUE);
+}
+EnableDevice(xwl_seat->relative_pointer, TRUE);
+}
+
+static void
+release_relative_pointer(struct xwl_seat *xwl_seat)
+{
+if (xwl_seat->relative_pointer)
+DisableDevice(xwl_seat->relative_pointer, TRUE);
+}
+
+static void
 init_keyboard(struct xwl_seat *xwl_seat)
 {
 DeviceIntPtr master;
@@ -870,8 +939,10 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
 
 if (caps & WL_SEAT_CAPABILITY_POINTER && xwl_seat->wl_pointer == NULL) {
 init_pointer(xwl_seat);
+init_relative_pointer(xwl_seat);
 } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && xwl_seat->wl_pointer) {
 release_pointer(xwl_seat);
+release_relative_pointer(xwl_seat);
 }
 
 if (caps & WL_SEAT_CAPABILITY_KEYBOARD && xwl_seat->wl_keyboard == NULL) {
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 2d19133..f78f464 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -119,6 +119,7 @@ struct xwl_touch {
 
 struct xwl_seat {
 DeviceIntPtr pointer;
+DeviceIntPtr relative_pointer;
 DeviceIntPtr keyboard;
 DeviceIntPtr touch;
 struct xwl_screen *xwl_screen;
-- 
2.7.4

___
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: [PULL] XQuartz {Add,Remove}EnabledDevice build fixes and other cleanup

2016-09-13 Thread Adam Jackson
On Sun, 2016-09-11 at 00:03 -0700, Jeremy Huddleston Sequoia wrote:

>   os/connection: Improve abstraction for launchd secure sockets

Mmm, not a huge fan of this one. You're not requiring that $DISPLAY be
an absolute path, so now server startup might fail if there's a file in
cwd named ":0.0". Unlikely I admit but still a dumb reason to fail, and
I can't think of a good reason to want relative paths to work here.

- 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: [xserver PULL master] Prime hw cursor support

2016-09-13 Thread Adam Jackson
On Tue, 2016-09-13 at 12:39 +0200, Hans de Goede wrote:

> The following changes since commit 527c6baa294d17c5eca1d87ac941844872e90dac:
> 
>    xkb: fix check for appending '|' character when applying rules (2016-09-07 
> 15:16:13 +1000)
> 
> are available in the git repository at:
> 
>    git://people.freedesktop.org/~jwrdegoede/xserver prime-hw-cursor-support
> 
> for you to fetch changes up to 35c4e96ed1d372dd161480be8cddcd2d4549e449:
> 
>    randr: Fix crtc_bounds when using rotation combined with reflection 
> (2016-09-13 10:27:30 +0200)

remote: I: patch #106849 updated using rev 
a74d553cb97d545148bd2f81b7bd021cca94e076.
remote: I: patch #106850 updated using rev 
cb7b145a25452de8b549e8c8e9ec3bcc752e55dc.
remote: I: patch #107787 updated using rev 
dfa295b29c20b174f80ab823eef41e5211a6a921.
remote: I: patch #105351 updated using rev 
1075af8a6c26009c04db30a6d6d1f10070568ab1.
remote: I: patch #109400 updated using rev 
3fe4107643ba029dd48e3d12ec9bc97d07112300.
remote: I: patch #108946 updated using rev 
a52530a655438f03919d47f6edd11287efff47bb.
remote: I: patch #108947 updated using rev 
2eefb53f58854ef9d34859583207ec37d3c3047a.
remote: I: patch #109175 updated using rev 
71fecc84e9ceb11ff61c912bdaa3fc959ec36bef.
remote: I: patch #108949 updated using rev 
b0b04cb266a62675dd7cde97111ebe7c1552db9a.
remote: I: patch #109424 updated using rev 
f82fd47016628e8bcdcba3aab506a919fe8c49d8.
remote: I: patch #110014 updated using rev 
df88008f92f85ef96d9fe48ac509d027570424eb.
remote: E: failed to find patch for rev 
7b634067c13045671685a9f00bfbac626ed68f94.
remote: I: patch #110013 updated using rev 
35c4e96ed1d372dd161480be8cddcd2d4549e449.
remote: I: 12 patch(es) updated to state Accepted.
To ssh://git.freedesktop.org/git/xorg/xserver
   527c6ba..35c4e96  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

[PATCH xserver] modesetting: allow switching from software to hardware cursors.

2016-09-13 Thread Michael Thayer
Currently if modesetting ever fails to set a hardware cursor it will switch
to using a software cursor and never go back.  Change this to try a hardware
cursor first every time a new one is set.  This is needed because hardware
may be able to handle some cursors in harware and others not, or virtual
hardware may be able to handle hardware cursors at some times and not others.

Signed-off-by: Michael Thayer 
---
Checked the current git source and this change is still needed.  This is an
updated patch which takes into account changes in the driver source since
the original patch was created.  Note that other than building I have not
had a chance to test that the updated patch still works, but the difference
against the original is pretty minimal.

 hw/xfree86/drivers/modesetting/drmmode_display.c | 36 +---
 hw/xfree86/drivers/modesetting/drmmode_display.h |  1 -
 2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c 
b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 6b933e4..ad39f76 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -756,33 +756,23 @@ drmmode_set_cursor(xf86CrtcPtr crtc)
 drmmode_ptr drmmode = drmmode_crtc->drmmode;
 uint32_t handle = drmmode_crtc->cursor_bo->handle;
 modesettingPtr ms = modesettingPTR(crtc->scrn);
+CursorPtr cursor = xf86CurrentCursor(crtc->scrn->pScreen);
 int ret;
 
-if (!drmmode_crtc->set_cursor2_failed) {
-CursorPtr cursor = xf86CurrentCursor(crtc->scrn->pScreen);
-
-ret =
-drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-  handle, ms->cursor_width, ms->cursor_height,
-  cursor->bits->xhot, cursor->bits->yhot);
-if (!ret)
-return TRUE;
-
-drmmode_crtc->set_cursor2_failed = TRUE;
-}
-
-ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 
handle,
-   ms->cursor_width, ms->cursor_height);
+ret =
+drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+  handle, ms->cursor_width, ms->cursor_height,
+  cursor->bits->xhot, cursor->bits->yhot);
+if (!ret)
+return TRUE;
 
-if (ret) {
-xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+/* -EINVAL can mean bad cursor parameters or Cursor2 API not supported. */
+if (ret == -EINVAL)
+ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 
handle,
+   ms->cursor_width, ms->cursor_height);
 
-cursor_info->MaxWidth = cursor_info->MaxHeight = 0;
-drmmode_crtc->drmmode->sw_cursor = TRUE;
-/* fallback to swcursor */
-return FALSE;
-}
+if (ret)
+return FALSE; /* fallback to swcursor */
 return TRUE;
 }
 
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h 
b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 50976b8..5170bf5 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -92,7 +92,6 @@ typedef struct {
 int dpms_mode;
 struct dumb_bo *cursor_bo;
 Bool cursor_up;
-Bool set_cursor2_failed;
 Bool first_cursor_load_done;
 uint16_t lut_r[256], lut_g[256], lut_b[256];
 
-- 
2.9.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

Re: [xserver PULL master] Modesetting driver prime fixes (unreviewed)

2016-09-13 Thread Adam Jackson
On Tue, 2016-09-13 at 12:53 +0200, Hans de Goede wrote:

> The following changes since commit 35c4e96ed1d372dd161480be8cddcd2d4549e449:
> 
>    randr: Fix crtc_bounds when using rotation combined with reflection 
> (2016-09-13 10:27:30 +0200)
> 
> are available in the git repository at:
> 
>    git://people.freedesktop.org/~jwrdegoede/xserver modesetting-prime-fixes
> 
> for you to fetch changes up to 08cfeecd524729589cd6b7c6e6fe65211b268dae:
> 
>    modesetting: Fall back to primary crtc for vblank for drawables on slave 
> outputs (2016-09-13 12:40:13 +0200)

Reviewed and merged:

remote: I: patch #105350 updated using rev 
03a7c50202f61030830ff639fccf52091e02156c.
remote: I: patch #105352 updated using rev 
238248d67e6a422f31e8864c0b15d693a658cdac.
remote: I: patch #107096 updated using rev 
7ade8ba10e1e767bb510343c86573bc5d4804b92.
remote: I: patch #107269 updated using rev 
d8e05c04758cbcd7b5c11362cb28ce017d50098b.
remote: I: 4 patch(es) updated to state Accepted.
To ssh://git.freedesktop.org/git/xorg/xserver
   35c4e96..d8e05c0  master -> master

But if I may ask:

> 
> Hans de Goede (4):
>    modesetting: ms_dri2_create_buffer: check screen of existing front 
> buffers

This change doesn't look like it can hurt, but I'm wondering why it's
necessary. How does this come up?

>    modesetting: Fall back to primary crtc for vblank for drawables on 
> slave outputs

Also we really need to come up with better terminology here.

- 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: weird Xwayland and compositor deadlock issue [WAS: [PATCH xserver v2] xwayland: handle EAGAIN and EINTR gracefully]

2016-09-13 Thread Olivier Fourdan
Hi Pekka,

- Original Message -
> Hi Olivier,
> 
> I don't have any solution for you. The interactions between the Wayland
> compositor and Xwayland are known to be very easily deadlockable IIRC. I
> believe the only thing you can do is ensure no such case can ever
> occur, which is very painful. That is, never do a blocking roundtrip at
> least from one side.
> 
> Have the recent modifications caused a significant increase of Wayland
> requests from Xwayland? If Xwayland needs to send an amount of data
> bigger than bufferable, *any* blocking roundtrip via X11 from the
> Wayland compositor is prone to deadlock. It will be waiting for a reply
> via X11, while Xwayland is blocked on flushing, since the Wayland
> compositor is not consuming requests.
> 
> It can also trivially happen if both sides do a blocking roundtrip at
> the same time. Or just a wait for an event.
> 
> Either server needs to be able to return to its main loop to process the
> protocol stream it is the server for. Preferably both, I think.

Unfortunately, any XSync (like, for example, called in gdk_error_trap_pop() in 
gdk) will issue a blocking roundtrip, and window managers tend to do that quite 
a lot (some more than others) so I don't think we can easily chaneg that in 
window managers to avoid blocking rountrips on X11 side.

> You could check how Weston's XWM works. I highly suspect that after
> Xwayland launch it avoids doing any blocking roundtrips via X11.

Yet sometimes some X calls are blocking, e.g. XShapeGetRectangles() or even 
XGetWindowAttributes() which is invoked by mutter each time the a new window is 
mapped. mutter still uses Xlib and not xcb.

> I'd assume Xwayland also tries to avoid blocking on Wayland events, but
> if nothing else, I believe Mesa via GLAMOR may block on
> wl_buffer.release events... or maybe not if GLAMOR is smart with its
> throttling. Anyway, since your flush is hitting EAGAIN, that doesn't
> seem to be the cause.
> 
> I wonder if making wl_display_flush() block immediately like in your
> patch could be replaced by adding the wl_display fd to the main poll
> loop, so that it would get flushed ASAP but still service X11 requests
> in the mean time? It does run the risk of overflowing the Wayland send
> buffer in Xwayland. Any way to prioritize the Wayland compositor's X11
> connection in Xwayland?

If I don't make EAGAIN a FatalError() and wait for the Wayland display file 
descriptor to become writable again, Xwayland eventually dies with another 
error "(EE) request could not be marshaled: can't send file descriptor" from 
libwayland directly (in copy_fds_to_connection()).

So I am at lost...

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

Re: [PULL] XQuartz {Add,Remove}EnabledDevice build fixes and other cleanup

2016-09-13 Thread Jeremy Huddleston Sequoia

> On Sep 13, 2016, at 07:48, Adam Jackson  wrote:
> 
> On Sun, 2016-09-11 at 00:03 -0700, Jeremy Huddleston Sequoia wrote:
> 
>>   os/connection: Improve abstraction for launchd secure sockets
> 
> Mmm, not a huge fan of this one. You're not requiring that $DISPLAY be
> an absolute path, so now server startup might fail if there's a file in
> cwd named ":0.0". Unlikely I admit but still a dumb reason to fail, and
> I can't think of a good reason to want relative paths to work here.

Whoops, I didn't mean to include that one in the pull request as I hadn't 
received review feedback from it yet.  Sorry about that.  I've removed it from 
the PR (updated below to also include 2 patches that I got review on over the 
weekend).

Regarding the change in question, it's not requiring DISPLAY to be an absolute 
path.  If it isn't a path at all, it falls through to the "not a path" case.

Yes, if it is a relative path, things might not go the way we want them to, so 
that's a good point.  The related logic in libxcb has the same issue.  If this 
is something we want to squash, we should do it in both places by changing 'if 
(display_env)' to 'if (display_env && *display_env == '/')'

Would that make you feel more comfortable?



The updated PR without that change is:


The following changes since commit d8e05c04758cbcd7b5c11362cb28ce017d50098b:

  modesetting: Fall back to primary crtc for vblank for drawables on slave 
outputs (2016-09-13 11:18:43 -0400)

are available in the git repository at:

  https://github.com/XQuartz/xorg-server.git 

for you to fetch changes up to 6c0641c7e843182d860c593bf48a88f38bedb291:

  os/inputthread: Fix setting of cloexec on file descriptors (2016-09-13 
10:00:51 -0700)


Jeremy Huddleston Sequoia (5):
  XQuartz: Fix the issue where the h key could be come "stuck" after hiding 
XQuartz with cmd-h
  XQuartz: Cleanup CPPFLAGS that are no longer necessary on darwin
  Xquartz: Update for removal of AddEnabledDevice and RemoveEnabledDevice
  Xext/shm: Fix usage of F_GETFD to match standard
  os/inputthread: Fix setting of cloexec on file descriptors

 Xext/shm.c |  3 ++-
 hw/xquartz/X11Application.m|  9 +
 hw/xquartz/darwin.c| 17 +++--
 hw/xquartz/pbproxy/Makefile.am |  5 ++---
 os/inputthread.c   | 15 +--
 5 files changed, 37 insertions(+), 12 deletions(-)




smime.p7s
Description: S/MIME cryptographic signature
___
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: [PULL] XQuartz {Add,Remove}EnabledDevice build fixes and other cleanup

2016-09-13 Thread Adam Jackson
On Tue, 2016-09-13 at 10:09 -0700, Jeremy Huddleston Sequoia wrote:

> Yes, if it is a relative path, things might not go the way we want
> them to, so that's a good point.  The related logic in libxcb has the
> same issue.  If this is something we want to squash, we should do it
> in both places by changing 'if (display_env)' to 'if (display_env &&
> *display_env == '/')'
> 
> Would that make you feel more comfortable?

Yeah. Maybe if we wanted relative paths we'd want to do
strchr(display_env, '/'), but like I say, having a hard time coming up
with a good reason to want that.

- 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: [PULL] XQuartz {Add,Remove}EnabledDevice build fixes and other cleanup

2016-09-13 Thread Adam Jackson
On Tue, 2016-09-13 at 10:09 -0700, Jeremy Huddleston Sequoia wrote:

> The following changes since commit d8e05c04758cbcd7b5c11362cb28ce017d50098b:
> 
>   modesetting: Fall back to primary crtc for vblank for drawables on slave 
> outputs (2016-09-13 11:18:43 -0400)
> 
> are available in the git repository at:
> 
> >   https://github.com/XQuartz/xorg-server.git 
> 
> for you to fetch changes up to 6c0641c7e843182d860c593bf48a88f38bedb291:
> 
>   os/inputthread: Fix setting of cloexec on file descriptors (2016-09-13 
> 10:00:51 -0700)

Merged:

remote: E: failed to find patch for rev 
33d595255d4206df0d136014de33100817cbe344.
remote: E: failed to find patch for rev 
4f4ecd0f41cf1c710d3ef1626b747847e6184f4c.
remote: E: failed to find patch for rev 
7def2fea30060d47780dc1eedc91fada5ae1934f.
remote: I: patch #109979 updated using rev 
a5769de0f5399053e9864b753fa9755220d65ae0.
remote: E: failed to find patch for rev 
065eb6612492bacf4d7caaad90e35dafc2cbf7ea.
remote: I: 1 patch(es) updated to state Accepted.
To ssh://git.freedesktop.org/git/xorg/xserver
   d8e05c0..065eb66  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] OsSigHandler should not show rtld errors for unrelated signals

2016-09-13 Thread Adam Jackson
On Sat, 2016-09-10 at 21:08 -0700, Alan Coopersmith wrote:
> If RTLD_DI_SETSIGNAL is set to let us turn runtime linker/loader errors
> into catchable signals, then we should only show the errors when catching
> that signal, instead of tossing out red herrings to distract people with
> unrelated crashes long after their last failed symbol lookup (especially
> when using drivers built to support multiple API's by checking which
> symbols are available before calling them).
> 
> Signed-off-by: Alan Coopersmith 

Merged (with a minor touchup to the commit message):

remote: I: patch #109927 updated using rev 
75c1d04650f63464263c159d2e95364482be724f.
remote: I: 1 patch(es) updated to state Accepted.
To ssh://git.freedesktop.org/git/xorg/xserver
   065eb66..75c1d04  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] Use pthread_setname_np to set thread names if available

2016-09-13 Thread Adam Jackson
On Sat, 2016-09-10 at 21:14 -0700, Alan Coopersmith wrote:
> Autoconf logic borrowed from glib
> 
> Signed-off-by: Alan Coopersmith 

Merged:

remote: E: failed to find patch for rev 
c4799f186b31e579721f5874c897f3f46db6ad0a.
remote: I: 0 patch(es) updated to state Accepted.
To ssh://git.freedesktop.org/git/xorg/xserver
   75c1d04..c4799f1  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: weird Xwayland and compositor deadlock issue [WAS: [PATCH xserver v2] xwayland: handle EAGAIN and EINTR gracefully]

2016-09-13 Thread Adam Jackson
On Tue, 2016-09-13 at 06:13 -0400, Olivier Fourdan wrote:

> I tried to poll() the Wayland fd with a timeout prior to
> wl_display_flush() to make sure to wl_display_flush() only when
> writable, to see if that would help unblocking mutter waiting for its
> PropertyNotify event but that did not work, the Wayland fd still
> remains in EAGAIN forever and gnome-shell/mutter remains stuck
> waiting for the PropertyNotify event...
> 
> I am a bit puzzled, why is gnome-shell/mutter/xcb waiting for the
> PropertyNotify, where is that event gone?

If I had to guess: it hasn't gone anywhere, because it hasn't been
generated yet. The request that would generate it is enqueued to
xserver, which hasn't processed it yet, because it's trying to flush
the wayland socket... you see where this is going.

The way that mutter tries to be both wayland server and X wm is sort of
fundamentally broken. When I complained to Owen about this, his opinion
was that wl_display_flush should just allocate and queue if writes
would return EAGAIN. My personal opinion is that mallocing your way out
of a deadlock is not, in fact, a fix. But it would probably work well
enough, and we could probably implement it entirely inside xserver if
libwayland-client didn't want to implement that feature (and I wouldn't
really blame them if they didn't).

Short of that, we have to consider xserver as a potentially very
aggressive wayland application, and keep it from generating so much
wayland protocol that we drown the compositor. A giant-sledgehammer
technique would be to set dispatchException |= DE_PRIORITYCHANGE in
wakeup_handler, which would force us into the block handler between
every X request (and thus flush out whatever just happened), so
_hopefully_ that would cap the amount of wl protocol we generate. It
would also force us to poll between every request, which should be a
hint to the scheduler to hand off our timeslice. It would /completely
suck/ for performance, but.

- 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

[PATCH 1/1] os/connection: Improve abstraction for launchd secure sockets

2016-09-13 Thread Jeremy Huddleston Sequoia
This changes away from hard-coding the /tmp/launch-* path to now
supporting a generic [.]
format for $DISPLAY.

cf-libxcb: d978a4f69b30b630f28d07f1003cf290284d24d8

Signed-off-by: Jeremy Huddleston Sequoia 
CC: Adam Jackson 
---
 os/connection.c | 31 ++-
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/os/connection.c b/os/connection.c
index a901ebf..0d42184 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -79,6 +79,8 @@ SOFTWARE.
 #include 
 #include 
 
+#include 
+
 #ifndef WIN32
 #include 
 
@@ -1112,15 +1114,34 @@ MakeClientGrabPervious(ClientPtr client)
 void
 ListenOnOpenFD(int fd, int noxauth)
 {
-char port[256];
+char port[PATH_MAX];
 XtransConnInfo ciptr;
 const char *display_env = getenv("DISPLAY");
 
-if (display_env && (strncmp(display_env, "/tmp/launch", 11) == 0)) {
-/* Make the path the launchd socket if our DISPLAY is set right */
-strcpy(port, display_env);
+/* First check if display_env matches a [.] scheme (eg: launchd) */
+if (display_env && display_env[0] == '/') {
+struct stat sbuf;
+
+strlcpy(port, display_env, sizeof(port));
+
+/* If the path exists, we don't have do do anything else.
+ * If it doesn't, we need to check for a . to strip off 
and recheck.
+ */
+if (0 != stat(port, &sbuf)) {
+char *dot = strrchr(port, '.');
+if (dot) {
+*dot = '\0';
+
+if (0 != stat(port, &sbuf)) {
+display_env = NULL;
+}
+} else {
+display_env = NULL;
+}
+}
 }
-else {
+
+if (!display_env) {
 /* Just some default so things don't break and die. */
 snprintf(port, sizeof(port), ":%d", atoi(display));
 }
-- 
2.10.0 (Apple Git-99)

___
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: Proposed X server 1.19 schedule

2016-09-13 Thread Timo Aaltonen
On 09.09.2016 20:18, Aaron Plattner wrote:
> On 09/06/2016 12:27 PM, Keith Packard wrote:
>> Adam Jackson  writes:
>>
>>> ... move the non-critical bug deadline to 2016-10-01? Still leaves
>>> three weeks for critical fixes. Either way, looks plausible to me. I
>>> don't personally have any non-bug changes I want to land before 1.19.
>>
>> Yeah, sounds good. We don't usually get many changes during the critical
>> bug window anyways.
> 
> When do you want to freeze the ABI? It would be good to get Alex's prime
> sync changes in an official ABI and run through our QA test cycle before
> the release.

that was merged on Jun 28th.


-- 
t
___
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] config: fix GPUDevice fail when AutoAddGPU off + BusID

2016-09-13 Thread Michel Dänzer
On 08/09/16 10:24 PM, Qiang Yu wrote:
> This fix is for the following xorg.conf can work:
> 
> Section "ServerFlags"
> Option  "AutoAddGPU" "off"
> EndSection
> 
> Section "Device"
> Identifier "Amd"
> Driver "ati"
> BusID "PCI:1:0:0"
> EndSection
> 
> Section "Device"
> Identifier "Intel"
> Driver "modesetting"
> BusID "pci:0:2:0"
> EndSection
> 
> Section "Screen"
> Identifier "Screen0"
> Device "Intel"
> GPUDevice "Amd"
> EndSection
> 
> Without AutoAddGPU off, modesetting DDX will also be loaded
> for GPUDevice.
> 
> Signed-off-by: Qiang Yu 
> ---
>  hw/xfree86/common/xf86platformBus.c | 18 +++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/xfree86/common/xf86platformBus.c 
> b/hw/xfree86/common/xf86platformBus.c
> index 96895a6..03fd931 100644
> --- a/hw/xfree86/common/xf86platformBus.c
> +++ b/hw/xfree86/common/xf86platformBus.c
> @@ -418,6 +418,19 @@ probeSingleDevice(struct xf86_platform_device *dev, 
> DriverPtr drvp, GDevPtr gdev
>  return foundScreen;
>  }
>  
> +static Bool
> +isGPUDevice(GDevPtr gdev)
> +{
> +int i;
> +
> +for (i = 0; i < gdev->myScreenSection->num_gpu_devices; i++) {
> +if (gdev == gdev->myScreenSection->gpu_devices[i])
> +return TRUE;
> +}
> +
> +return FALSE;
> +}
> +
>  int
>  xf86platformProbeDev(DriverPtr drvp)
>  {
> @@ -450,9 +463,8 @@ xf86platformProbeDev(DriverPtr drvp)
>  if (j == xf86_num_platform_devices)
>   continue;
>  
> -foundScreen = probeSingleDevice(&xf86_platform_devices[j], drvp, 
> devList[i], 0);
> -if (!foundScreen)
> -continue;
> +foundScreen = probeSingleDevice(&xf86_platform_devices[j], drvp, 
> devList[i],
> +isGPUDevice(devList[i]) ? 
> PLATFORM_PROBE_GPU_SCREEN : 0);

The last line is a bit long, maybe move "PLATFORM_PROBE_GPU_SCREEN : 0"
to the next line. Either way,

Reviewed-by: Michel Dänzer 


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
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