Re: [PATCH] Fix xf86DeleteDriver and various places that use it

2013-07-25 Thread Christopher James Halse Rogers
On Mon, 2013-07-22 at 11:03 +0200, Mark Kettenis wrote:
  From: christopher.halse.rog...@canonical.com
  Date: Mon, 22 Jul 2013 13:44:46 +1000
  
  From: Maarten Lankhorst maarten.lankho...@canonical.com
  
  Signed-off-by: Christopher James Halse Rogers 
  christopher.halse.rog...@canonical.com
 
 Care to elaborate what's actually broken?
 
 To me this just looks like a somewhat arbitrary change that turns
 xf86DriverList from a sparse array into a non-sparse array at the
 expense of making the implementation more complex.

Hm. When when developing against 1.14 I ran into all sorts of code that
didn't expect a sparse array and SEGVd when deleting a video driver.

But I can't seem to reproduce this now against 1.15, so maybe it got
fixed elsewhere?

I'll investigate further. Maybe this is not needed at all.

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


[PATCH fixesproto] fixesproto v6: Pointer barrier thresholds

2012-07-29 Thread Christopher James Halse Rogers
v2: Use a GenericEvent for BarrierNotify
Add PointerReleased event type
Clarify scope of barrier event-id
Release multiple barriers in a single ReleasePointer call.
v3: Fix trailing whitespace
Remove window parameter from SelectBarrierInput
Align structs to 4-byte boundaries
Clarify when PointerBarriers generate BarrierEvent events

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 configure.ac   |2 +-
 fixesproto.txt |  144 +++-
 xfixesproto.h  |   76 ++
 xfixeswire.h   |   20 +++-
 4 files changed, 238 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index f85b802..07dd29a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.60])
-AC_INIT([FixesProto], [5.0],
+AC_INIT([FixesProto], [6.0],
 [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
diff --git a/fixesproto.txt b/fixesproto.txt
index 5903ac9..8b9cd42 100644
--- a/fixesproto.txt
+++ b/fixesproto.txt
@@ -1,5 +1,5 @@
 The XFIXES Extension
-   Version 5.0
+   Version 6.0
 Document Revision 1
 2010-11-15
Keith Packard
@@ -628,6 +628,13 @@ CreatePointerBarrier
axis travel through a vertical barrier, for example) and excess set
bits are ignored.
 
+   A pointer hitting the barrier results in a BarrierNotify event. A
+   barrier that allows pointer motion due to the bits set in directions
+   is not considered to have been hit and will not generate a
+   BarrierNotify. For example, a barrier with BarrierPositiveX set
+   will not send a BarrierNotify when the pointer passes through it
+   in the positive X direction.
+
If the server supports the X Input Extension version 2 or higher,
the devices element names a set of master device to apply the
barrier to.  If XIAllDevices or XIAllMasterDevices are given, the
@@ -650,6 +657,141 @@ DestroyPointerBarrier
 
Errors: Barrier 
 
+* XFIXES VERSION 6 OR BETTER ***
+
+13. Pointer Barriers Expansion
+
+This update extends pointer barriers to optionally allow the pointer through
+when a threshold is reached.  This can be useful for desktop environments that
+wish to use a large region of the screen, such as an entire edge, to provide a
+casual target while allowing determined movement to pass through.
+
+13.1 Types
+
+   BarrierEvent:   {Hit, ThresholdExceeded, 
PointerReleased}
+   BarrierEventID: CARD32
+   BarrierEventDetails:{ barrier:  BARRIER,
+ type: BarrierEvent,
+ event-id: BarrierEventID }
+
+13.2 Events
+
+BarrierNotify
+
+   type:   BYTE
+   extension:  CARD8
+   sequenceNumber: CARD16
+   length: CARD32
+   evtype: CARD16
+   window: WINDOW
+   x, y:   INT16
+   dx, dy: FP3232
+   raw-dx, raw-dy: FP3232
+   dt: INT16
+   deviceid:   DEVICEID
+   num-details:CARD16
+   details:LISTofBarrierEventDetails
+
+   BarrierNotify uses the X Generic Event extension.  Type is thus always
+   GenericEvent (35), extension is the major opcode of this extension,
+   sequenceNumber is the low 16 bits of the request sequence number,
+   length is how much bigger than 32 bytes the event is, in units of
+   4 bytes. Evtype is the type of this event, which is always
+   BarrierNotify (0).
+
+   (x, y) contain the coordinates of the pointer after restriction by
+   any applicable barriers or server-side clamping (such as to screen
+   edges).
+
+   (dx, dy) and (raw-dx, raw-dy) are the valuators for the input event
+   which caused the BarrierNotify to be emitted, before any clamping
+   (such as to the screen edge, or by a barrier) is applied.
+   (dx, dy) are the values after acceleration, (raw-dx, raw-dy) are the
+   raw values before any acceleration is applied. dt is the server time
+   in milliseconds since the last input event, and deviceid is the id of
+   the input device which triggered the barrier.
+
+   Each item in the details list contains the information for a barrier
+   triggered by this input event. If there are multiple overlapping
+   barriers blocking pointer motion each

[PATCH] dri2: Fix authentication for v8 clients (v2).

2012-06-27 Thread Christopher James Halse Rogers
The legacy logic was embarassingly wrong; AuthMagic should return errno,
so returning FALSE only when AuthMagic returns nonzero is exactly wrong.

v2: Match drmAuthMagic by returning -EINVAL rather than EINVAL
Fix trailing whitespace

https://bugs.freedesktop.org/show_bug.cgi?id=51400
Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---

v2 is not immediately necessary; the sole place that uses this only checks
for zero/non-zero. Matching the rest of the return values will certainly
make it less surprising should this change, however.

 hw/xfree86/dri2/dri2.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d0f1789..d3b3c73 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -,14 +,14 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, 
int *fd,
 return TRUE;
 }
 
-static Bool
+static int
 DRI2AuthMagic (ScreenPtr pScreen, uint32_t magic)
 {
 DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
-return FALSE;
+if (ds == NULL)
+return -EINVAL;
 
-return TRUE;
+return (*ds-LegacyAuthMagic) (ds-fd, magic);
 }
 
 Bool
-- 
1.7.10.4

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


[PATCH] dri2: Fix authentication for v8 clients.

2012-06-25 Thread Christopher James Halse Rogers
The legacy logic was embarassingly wrong; AuthMagic should return errno,
so returning FALSE only when AuthMagic returns nonzero is exactly wrong.

https://bugs.freedesktop.org/show_bug.cgi?id=51400
Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/dri2/dri2.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d0f1789..c171cb5 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -,14 +,14 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, 
int *fd,
 return TRUE;
 }
 
-static Bool
+static int
 DRI2AuthMagic (ScreenPtr pScreen, uint32_t magic)
 {
 DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
-return FALSE;
+if (ds == NULL) 
+return EINVAL;
 
-return TRUE;
+return (*ds-LegacyAuthMagic) (ds-fd, magic);
 }
 
 Bool
-- 
1.7.10.4

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


Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function.

2012-06-19 Thread Christopher James Halse Rogers
On Tue, 2012-06-19 at 14:38 -0400, Kristian Høgsberg wrote:
 On Mon, Jun 18, 2012 at 12:58 PM, Keith Packard kei...@keithp.com wrote:
  Christopher James Halse Rogers christopher.halse.rog...@canonical.com
  writes:
 
  +typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, int fd, uint32_t 
  magic);
 
  Bikeshed -- seems like the 'fd' parameter is not needed in this API?
  I'll note that in the implementation of the wrapper, you pull it from
  the screen private instead of using the provided parameter...
 
 Oh, that is a good point, I like that bikeshed color better.
 

Technically I pull it from the DRI2Srceen private, which the driver
won't have access to, but {intel,nouveau,ati} also store this fd in
their driver private, so it's not a problem for them.

I'll send a blue-painted patch. :)


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function. (v3)

2012-06-19 Thread Christopher James Halse Rogers
xwayland drivers need access to their screen private data to authenticate.
Now that drivers no longer have direct access to the global screen arrays,
this needs to be passed in as function context.

v2: Don't break ABI
v3: Paint the bikeshed blue; drop fd from AuthMagic2ProcPtr prototype

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/dri2/dri2.c |   35 ---
 hw/xfree86/dri2/dri2.h |9 -
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index babf32f..d0f1789 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -104,7 +104,8 @@ typedef struct _DRI2Screen {
 DRI2ScheduleSwapProcPtr ScheduleSwap;
 DRI2GetMSCProcPtr GetMSC;
 DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
-DRI2AuthMagicProcPtr AuthMagic;
+DRI2AuthMagic2ProcPtr AuthMagic;
+DRI2AuthMagicProcPtr LegacyAuthMagic;
 DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
 DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 DRI2GetParamProcPtr GetParam;
@@ -1110,12 +,22 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, 
int *fd,
 return TRUE;
 }
 
+static Bool
+DRI2AuthMagic (ScreenPtr pScreen, uint32_t magic)
+{
+DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
+return FALSE;
+
+return TRUE;
+}
+
 Bool
 DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
 {
 DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
-if (ds == NULL || (*ds-AuthMagic) (ds-fd, magic))
+if (ds == NULL || (*ds-AuthMagic) (pScreen, magic))
 return FALSE;
 
 return TRUE;
@@ -1202,8 +1213,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 cur_minor = 1;
 }
 
+if (info-version = 8) {
+ds-AuthMagic = info-AuthMagic2;
+}
 if (info-version = 5) {
-ds-AuthMagic = info-AuthMagic;
+ds-LegacyAuthMagic = info-AuthMagic;
 }
 
 if (info-version = 6) {
@@ -1218,14 +1232,21 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 
 /*
  * if the driver doesn't provide an AuthMagic function or the info struct
- * version is too low, it relies on the old method (using libdrm) or fail
+ * version is too low, call through LegacyAuthMagic
  */
-if (!ds-AuthMagic)
+if (!ds-AuthMagic) {
+ds-AuthMagic = DRI2AuthMagic;
+/*
+ * If the driver doesn't provide an AuthMagic function
+ * it relies on the old method (using libdrm) or fails
+ */
+if (!ds-LegacyAuthMagic)
 #ifdef WITH_LIBDRM
-ds-AuthMagic = drmAuthMagic;
+ds-LegacyAuthMagic = drmAuthMagic;
 #else
-goto err_out;
+goto err_out;
 #endif
+}
 
 /* Initialize minor if needed and set to minimum provied by DDX */
 if (!dri2_minor || dri2_minor  cur_minor)
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index f849be6..4fd0fbc 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -64,6 +64,7 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
DRI2BufferPtr pSrcBuffer);
 typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
 typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
+typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, uint32_t magic);
 
 /**
  * Schedule a buffer swap
@@ -192,7 +193,7 @@ typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
 /**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 7
+#define DRI2INFOREC_VERSION 8
 
 typedef struct {
 unsigned int version;   /** Version of this struct */
@@ -229,6 +230,12 @@ typedef struct {
 /* added in version 7 */
 
 DRI2GetParamProcPtr GetParam;
+
+/* added in version 8 */
+/* AuthMagic callback which passes extra context */
+/* If this is NULL the AuthMagic callback is used */
+/* If this is non-NULL the AuthMagic callback is ignored */
+DRI2AuthMagic2ProcPtr AuthMagic2;
 } DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
-- 
1.7.10.4

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


[PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function.

2012-06-17 Thread Christopher James Halse Rogers
xwayland drivers need access to their screen private data to authenticate.
Now that drivers no longer have direct access to the global screen arrays,
this needs to be passed in as function context.

v2: Don't break ABI

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/dri2/dri2.c |   35 ---
 hw/xfree86/dri2/dri2.h |9 -
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index babf32f..412feb3 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -104,7 +104,8 @@ typedef struct _DRI2Screen {
 DRI2ScheduleSwapProcPtr ScheduleSwap;
 DRI2GetMSCProcPtr GetMSC;
 DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
-DRI2AuthMagicProcPtr AuthMagic;
+DRI2AuthMagic2ProcPtr AuthMagic;
+DRI2AuthMagicProcPtr LegacyAuthMagic;
 DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
 DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 DRI2GetParamProcPtr GetParam;
@@ -1110,12 +,22 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, 
int *fd,
 return TRUE;
 }
 
+static Bool
+DRI2AuthMagic (ScreenPtr pScreen, int fd, uint32_t magic)
+{
+DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
+return FALSE;
+
+return TRUE;
+}
+
 Bool
 DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
 {
 DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
-if (ds == NULL || (*ds-AuthMagic) (ds-fd, magic))
+if (ds == NULL || (*ds-AuthMagic) (pScreen, ds-fd, magic))
 return FALSE;
 
 return TRUE;
@@ -1202,8 +1213,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 cur_minor = 1;
 }
 
+if (info-version = 8) {
+ds-AuthMagic = info-AuthMagic2;
+}
 if (info-version = 5) {
-ds-AuthMagic = info-AuthMagic;
+ds-LegacyAuthMagic = info-AuthMagic;
 }
 
 if (info-version = 6) {
@@ -1218,14 +1232,21 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 
 /*
  * if the driver doesn't provide an AuthMagic function or the info struct
- * version is too low, it relies on the old method (using libdrm) or fail
+ * version is too low, call through LegacyAuthMagic
  */
-if (!ds-AuthMagic)
+if (!ds-AuthMagic) {
+ds-AuthMagic = DRI2AuthMagic;
+/*
+ * If the driver doesn't provide an AuthMagic function
+ * it relies on the old method (using libdrm) or fails
+ */
+if (!ds-LegacyAuthMagic)
 #ifdef WITH_LIBDRM
-ds-AuthMagic = drmAuthMagic;
+ds-LegacyAuthMagic = drmAuthMagic;
 #else
-goto err_out;
+goto err_out;
 #endif
+}
 
 /* Initialize minor if needed and set to minimum provied by DDX */
 if (!dri2_minor || dri2_minor  cur_minor)
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index f849be6..004d286 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -64,6 +64,7 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
DRI2BufferPtr pSrcBuffer);
 typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
 typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
+typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, int fd, uint32_t 
magic);
 
 /**
  * Schedule a buffer swap
@@ -192,7 +193,7 @@ typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
 /**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 7
+#define DRI2INFOREC_VERSION 8
 
 typedef struct {
 unsigned int version;   /** Version of this struct */
@@ -229,6 +230,12 @@ typedef struct {
 /* added in version 7 */
 
 DRI2GetParamProcPtr GetParam;
+
+/* added in version 8 */
+/* AuthMagic callback which passes extra context */
+/* If this is NULL the AuthMagic callback is used */
+/* If this is non-NULL the AuthMagic callback is ignored */
+DRI2AuthMagic2ProcPtr AuthMagic2;
 } DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
-- 
1.7.10.4

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


[PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic

2012-06-15 Thread Christopher James Halse Rogers
xwayland drivers need access to their screen private data to authenticate.
Now that drivers no longer have direct access to the global screen arrays,
this needs to be passed in as function context. The way it was working
was ugly, anyway.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---

This came up when I got around to fixing the nouveau xwayland patch review
comments; with things no longer meant to access the global xf86Screens array
the authmagic callback needed some other way to access driver private data.

Nouveau patch using this follows; I'll send it upstream once this gets
applied somewhere.

CCd to xorg-devel mainly for sanity review, but could be applied; as Airlied
has pointed out, there's no particular reason for the xwayland branch to
diverge on core infrastructure.


 hw/xfree86/dri2/dri2.c |   40 ++--
 hw/xfree86/dri2/dri2.h |2 +-
 2 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index babf32f..0e79875 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -89,6 +89,8 @@ typedef struct _DRI2Drawable {
 Bool needInvalidate;
 } DRI2DrawableRec, *DRI2DrawablePtr;
 
+typedef int (*DRI2LegacyAuthMagicProcPtr) (int fd, uint32_t magic);
+
 typedef struct _DRI2Screen {
 ScreenPtr screen;
 int refcnt;
@@ -105,6 +107,7 @@ typedef struct _DRI2Screen {
 DRI2GetMSCProcPtr GetMSC;
 DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
 DRI2AuthMagicProcPtr AuthMagic;
+DRI2LegacyAuthMagicProcPtr LegacyAuthMagic;
 DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
 DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 DRI2GetParamProcPtr GetParam;
@@ -1110,12 +1113,22 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, 
int *fd,
 return TRUE;
 }
 
+static Bool
+DRI2AuthMagic (ScreenPtr pScreen, int fd, uint32_t magic)
+{
+DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
+return FALSE;
+
+return TRUE;
+}
+
 Bool
 DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
 {
 DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
-if (ds == NULL || (*ds-AuthMagic) (ds-fd, magic))
+if (ds == NULL || (*ds-AuthMagic) (pScreen, ds-fd, magic))
 return FALSE;
 
 return TRUE;
@@ -1202,9 +1215,17 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 cur_minor = 1;
 }
 
-if (info-version = 5) {
+if (info-version = 7) {
 ds-AuthMagic = info-AuthMagic;
 }
+else if (info-version = 5) {
+/*
+ * This cast is safe; if the driver has provided a V5 or V6 InfoRec
+ * then AuthMagic is of type DRI2LegacyAuthMagicProcPtr, and the C
+ * standard guarantees that we can typecast it back and call it.
+ */
+ds-LegacyAuthMagic = (DRI2LegacyAuthMagicProcPtr)info-AuthMagic;
+}
 
 if (info-version = 6) {
 ds-ReuseBufferNotify = info-ReuseBufferNotify;
@@ -1218,14 +1239,21 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 
 /*
  * if the driver doesn't provide an AuthMagic function or the info struct
- * version is too low, it relies on the old method (using libdrm) or fail
+ * version is too low, call through LegacyAuthMagic
  */
-if (!ds-AuthMagic)
+if (!ds-AuthMagic) {
+ds-AuthMagic = DRI2AuthMagic;
+/*
+ * If the driver doesn't provide an AuthMagic function
+ * it relies on the old method (using libdrm) or fails
+ */
+if (!ds-LegacyAuthMagic)
 #ifdef WITH_LIBDRM
-ds-AuthMagic = drmAuthMagic;
+ds-LegacyAuthMagic = drmAuthMagic;
 #else
-goto err_out;
+goto err_out;
 #endif
+}
 
 /* Initialize minor if needed and set to minimum provied by DDX */
 if (!dri2_minor || dri2_minor  cur_minor)
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index f849be6..90886a9 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -63,7 +63,7 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
DRI2BufferPtr pDestBuffer,
DRI2BufferPtr pSrcBuffer);
 typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
-typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
+typedef int (*DRI2AuthMagicProcPtr) (ScreenPtr pScreen, int fd, uint32_t 
magic);
 
 /**
  * Schedule a buffer swap
-- 
1.7.10.4

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


Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic

2012-06-15 Thread Christopher James Halse Rogers
On Fri, 2012-06-15 at 12:35 +0200, Michel Dänzer wrote:
 On Fre, 2012-06-15 at 19:01 +1000, Christopher James Halse Rogers
 wrote: 
  xwayland drivers need access to their screen private data to authenticate.
  Now that drivers no longer have direct access to the global screen arrays,
  this needs to be passed in as function context. The way it was working
  was ugly, anyway.
  
  Signed-off-by: Christopher James Halse Rogers 
  christopher.halse.rog...@canonical.com
  ---
  
  This came up when I got around to fixing the nouveau xwayland patch review
  comments; with things no longer meant to access the global xf86Screens array
  the authmagic callback needed some other way to access driver private data.
  
  Nouveau patch using this follows; I'll send it upstream once this gets
  applied somewhere.
  
  CCd to xorg-devel mainly for sanity review, but could be applied; as Airlied
  has pointed out, there's no particular reason for the xwayland branch to
  diverge on core infrastructure.
 
 [...]
 
  @@ -1202,9 +1215,17 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
   cur_minor = 1;
   }
   
  -if (info-version = 5) {
  +if (info-version = 7) {
   ds-AuthMagic = info-AuthMagic;
   }
  +else if (info-version = 5) {
  +/*
  + * This cast is safe; if the driver has provided a V5 or V6 InfoRec
  + * then AuthMagic is of type DRI2LegacyAuthMagicProcPtr, and the C
  + * standard guarantees that we can typecast it back and call it.
  + */
  +ds-LegacyAuthMagic = (DRI2LegacyAuthMagicProcPtr)info-AuthMagic;
  +}
 
 This is nifty, but it's an ABI break, as servers without this change
 will treat the version 7 AuthMagic field incorrectly. Wouldn't it be
 easier to add a second AuthMagic field at the end of version 7?

The only way a driver would send a version 7 DRI2InfoPtr would be if it
were built against a server with this code, right? Are drivers generally
expected work against a server *older* than they were built against?

It could easily be an extra field in the InfoPtr, of course.


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH x11proto-fixes (v2)] fixesproto v6: Pointer barrier thresholds

2012-05-21 Thread Christopher James Halse Rogers
v2: Use a GenericEvent for BarrierNotify
Add PointerReleased event type
Clarify scope of barrier event-id
Release multiple barriers in a single ReleasePointer call.
---
 configure.ac   |2 +-
 fixesproto.txt |  132 +++-
 xfixesproto.h  |   64 +++
 xfixeswire.h   |   20 -
 4 files changed, 214 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index f85b802..07dd29a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.60])
-AC_INIT([FixesProto], [5.0],
+AC_INIT([FixesProto], [6.0],
 [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
diff --git a/fixesproto.txt b/fixesproto.txt
index 5903ac9..6035f1d 100644
--- a/fixesproto.txt
+++ b/fixesproto.txt
@@ -1,5 +1,5 @@
 The XFIXES Extension
-   Version 5.0
+   Version 6.0
 Document Revision 1
 2010-11-15
Keith Packard
@@ -650,6 +650,136 @@ DestroyPointerBarrier
 
Errors: Barrier 
 
+* XFIXES VERSION 6 OR BETTER ***
+
+13. Pointer Barriers Expansion
+
+This update extends pointer barriers to optionally allow the pointer through
+when a threshold is reached.  This can be useful for desktop environments that
+wish to use a large region of the screen, such as an entire edge, to provide a
+casual target while allowing determined movement to pass through.
+
+13.1 Types
+
+   BarrierEvent:   {Hit, ThresholdExceeded, 
PointerReleased}
+   BarrierEventID: CARD32
+   BarrierEventDetails:{ barrier:  BARRIER,
+ type: BarrierEvent,
+ event-id: BarrierEventID }
+
+13.2 Events
+
+BarrierNotify
+
+   type:   BYTE
+   extension:  CARD8
+   sequenceNumber: CARD16
+   length: CARD32
+   evtype: CARD16
+   window: WINDOW
+   x, y:   INT16
+   dx, dy: FP3232
+   raw-dx, raw-dy: FP3232
+   dt: INT16
+   deviceid:   DEVICEID
+   details:LISTofBarrierEventDetails
+
+   BarrierNotify uses the X Generic Event extension.  Type is thus always
+   GenericEvent (35), extension is the major opcode of this extension,
+   sequenceNumber is the low 16 bits of the request sequence number,
+   length is how much bigger than 32 bytes the event is, in units of 
+   4 bytes. Evtype is the type of this event, which is always
+   BarrierNotify (0).
+
+   (x, y) contain the coordinates of the pointer after restriction by
+   any applicable barriers or server-side clamping (such as to screen
+   edges).
+
+   (dx, dy) and (raw-dx, raw-dy) are the valuators for the input event
+   which caused the BarrierNotify to be emitted, before any clamping
+   (such as to the screen edge, or by a barrier) is applied.
+   (dx, dy) are the values after acceleration, (raw-dx, raw-dy) are the
+   raw values before any acceleration is applied. dt is the server time
+   in milliseconds since the last input event, and deviceid is the id of
+   the input device which triggered the barrier.
+
+   Each item in the details list contains the information for a barrier
+   triggered by this input event. If there are multiple overlapping
+   barriers blocking pointer motion each one will be represented in
+   this list.
+
+   barrier is the ID of the barrier hit.
+
+   Type indicates the trigger of the event:
+Hit when the barrier has prevented pointer movement.
+ThresholdExceeded when the barrier has been hit but has not
+   prevented pointer movement due to the threshold being exceeded.
+PointerReleased when the barrier would have blocked motion but
+   has been rendered permeable by a BarrierReleasePointer request.
+
+   event-id is an identifier for this barrier event. A barrier event
+   begins when the pointer is first restricted by the barrier and remains
+   valid until the first input event from deviceid which is not
+   restricted by the barrier. The event-id is unique per-barrier.
+
+   Since a barrier event is associated with a deviceid there can be more
+   than one event active for a given barrier simultaneously.
+
+
+13.3 Requests
+
+SelectBarrierInput
+
+   window: WINDOW
+   event-mask: SETofBarrierEvent
+
+ 

Re: [PATCH 03/11] glx: Extend __GLXscreen::createContext to take attributes

2012-05-07 Thread Christopher James Halse Rogers
On Mon, 2012-05-07 at 11:48 -0700, Ian Romanick wrote:
 On 04/18/2012 02:51 AM, Christopher James Halse Rogers wrote:
  On Tue, 2012-04-17 at 08:36 -0700, Ian Romanick wrote:
  On 04/17/2012 03:05 AM, Christopher James Halse Rogers wrote:
  On Fri, 2012-04-13 at 18:11 -0700, Ian Romanick wrote:
  From: Ian Romanickian.d.roman...@intel.com
 
  The attributes will be used for glXCreateContextAttribsARB additions
  in follow-on patches.
 
  Signed-off-by: Ian Romanickian.d.roman...@intel.com
  Reviewed-by: Jesse Barnesjbar...@virtuousgeek.org
  ---
 glx/glxcmds.c  |   12 ++--
 glx/glxdri.c   |   10 +-
 glx/glxdri2.c  |5 -
 glx/glxdriswrast.c |4 +++-
 glx/glxscreens.h   |5 -
 5 files changed, 30 insertions(+), 6 deletions(-)
 
  diff --git a/glx/glxcmds.c b/glx/glxcmds.c
  index 5c70afa..f754104 100644
  --- a/glx/glxcmds.c
  +++ b/glx/glxcmds.c
  @@ -276,8 +276,16 @@ DoCreateContext(__GLXclientState * cl, GLXContextID 
  gcId,
 /*
  ** Allocate memory for the new context
  */
  -if (!isDirect)
  -glxc = pGlxScreen-createContext(pGlxScreen, config, shareglxc);
  +if (!isDirect) {
  +int err;
 
  This variable shadows the err defined at the top of the function, which
  is not used after this point; any reason why you didn't just reuse the
  existing variable?
 
  You're still (as far as I can tell) unnecessarily shadowing the int
  err defined at the top of the function here.
 
 D'oh!  You are totally correct.  I think I just missed that while making 
 the other change.  I've updated my branch with the change.

Thanks :)

I've gone over the other patches in your branch I made comments on in
review; you can add my Reviewed-by for everything that doesn't already
have it in the branch ending with a6e82d220.


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] fixesproto v6: Pointer barrier thresholds

2012-05-03 Thread Christopher James Halse Rogers
On Thu, 2012-05-03 at 16:35 +1000, Peter Hutterer wrote:
 On Thu, May 03, 2012 at 12:40:58PM +1000, Christopher James Halse Rogers 
 wrote:
  On Thu, 2012-05-03 at 11:05 +1000, Peter Hutterer wrote:
   On Tue, Apr 03, 2012 at 01:42:38PM +1000, Christopher James Halse Rogers 
   wrote:
---

I've got a corresponding xserver patch, but it needs updating for the
Great Reindent of '12.  Might as well get support for the protocol 
additions 
before fixing it up.

A slightly different variant of this (it's gone through a number of 
iterations
in conjunction with the Unity team) is used by the Unity shell as 
infrastructure
for the one-launcher-per-display support, so there's evidence that it's 
a usable
protocol.
   
   looks good, a few minor clarifications are needed below. The main change 
   I'd
   like to see is a change to use generic events instead of a standard 
   event..
  
  I'll finish reading up on how to make that happen, then :)
  
   
   we've hit the maximum event number in the past, adding another non-generic
   event can cause us to stretch over the limit.
   http://lists.x.org/archives/xorg-devel/2010-March/006716.html
   
 configure.ac   |2 +-
 fixesproto.txt |   94 

 xfixesproto.h  |   59 +++
 xfixeswire.h   |   23 +++--
 4 files changed, 173 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index f85b802..07dd29a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.60])
-AC_INIT([FixesProto], [5.0],
+AC_INIT([FixesProto], [6.0],
 [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
diff --git a/fixesproto.txt b/fixesproto.txt
index 5903ac9..6f8c705 100644
--- a/fixesproto.txt
+++ b/fixesproto.txt
@@ -650,6 +650,100 @@ DestroyPointerBarrier
 
Errors: Barrier 
 
+* XFIXES VERSION 6 OR BETTER ***
+
+13. Pointer Barriers Expansion
+
+This update extends pointer barriers to optionally allow the pointer 
through
+when a threshold is reached.  This can be useful for desktop 
environments that
+wish to use a large region of the screen, such as an entire edge, to 
provide a
+casual target while allowing determined movement to pass through.
+
+13.1 Types
+
+   BarrierEvent:   {Hit, ThresholdExceeded}
+   BarrierEventID: CARD32
+
+13.2 Events
+
+BarrierNotify
+
+   subtype:BarrierEvent
+   window: WINDOW
+   event-id:   BarrierEventID
+   barrier:BARRIER
+   velocity:   CARD32
+   x, y:   INT16
+   raw-displacement:   FP1616
+   delta-t:INT16
+   deviceid:   INT16
+
+13.3 Requests
+
+SelectBarrierInput
+
+   window: WINDOW
+   event-mask: SETofBarrierEvent
+
+
+   This request directs barrier events to the named window.  
Subtype
+   indicates the trigger of the event, which is Hit when the 
barrier has
+   prevented pointer movement and ThresholdExceeded when the 
barrier has
+   been hit but has not prevented pointer movement due to the 
threshold
+   being exceeded.
+   
+   Barrier is the barrier on which the event was triggered. (x,y) 
contain
+   the coordinates of the pointer after restriction by any 
applicable
+   barriers, and velocity is the unrestricted instantaneous 
velocity
+   of the pointer, perpendicular to the barrier.
   
   how is velocity defined?
   (edit: found it below, this should be either in some common section or
   everywhere. You could just define a VELOCITY type and explain it there)
  
  That makes sense, I'll do so.
  
   
+
+   deviceid is the identifier of the device which caused the 
barrier
+   event, raw-displacement and delta-t are the raw valuator 
(purpendicular
   
   I'm not sure what you raw-displacement here is, can you clarify? 
   
  
  Raw-displacement is exactly the value you'd get if you were subscribed
  to XI 2 raw events and selected the valuator perpendicular to the
  barrier.
  
  It (and delta-t) are here so that a client can get a pre-acceleration
  idea of the velocity and user behaviour if the client desires.  This is
  useful for clients to determine when they want

Re: [PATCH] fixesproto v6: Pointer barrier thresholds

2012-05-02 Thread Christopher James Halse Rogers
On Thu, 2012-05-03 at 11:05 +1000, Peter Hutterer wrote:
 On Tue, Apr 03, 2012 at 01:42:38PM +1000, Christopher James Halse Rogers 
 wrote:
  ---
  
  I've got a corresponding xserver patch, but it needs updating for the
  Great Reindent of '12.  Might as well get support for the protocol 
  additions 
  before fixing it up.
  
  A slightly different variant of this (it's gone through a number of 
  iterations
  in conjunction with the Unity team) is used by the Unity shell as 
  infrastructure
  for the one-launcher-per-display support, so there's evidence that it's a 
  usable
  protocol.
 
 looks good, a few minor clarifications are needed below. The main change I'd
 like to see is a change to use generic events instead of a standard event.

I'll finish reading up on how to make that happen, then :)

 
 we've hit the maximum event number in the past, adding another non-generic
 event can cause us to stretch over the limit.
 http://lists.x.org/archives/xorg-devel/2010-March/006716.html
 
   configure.ac   |2 +-
   fixesproto.txt |   94 
  
   xfixesproto.h  |   59 +++
   xfixeswire.h   |   23 +++--
   4 files changed, 173 insertions(+), 5 deletions(-)
  
  diff --git a/configure.ac b/configure.ac
  index f85b802..07dd29a 100644
  --- a/configure.ac
  +++ b/configure.ac
  @@ -22,7 +22,7 @@ dnl
   dnl Process this file with autoconf to create configure.
   
   AC_PREREQ([2.60])
  -AC_INIT([FixesProto], [5.0],
  +AC_INIT([FixesProto], [6.0],
   [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
   AM_INIT_AUTOMAKE([foreign dist-bzip2])
   AM_MAINTAINER_MODE
  diff --git a/fixesproto.txt b/fixesproto.txt
  index 5903ac9..6f8c705 100644
  --- a/fixesproto.txt
  +++ b/fixesproto.txt
  @@ -650,6 +650,100 @@ DestroyPointerBarrier
   
  Errors: Barrier 
   
  +* XFIXES VERSION 6 OR BETTER ***
  +
  +13. Pointer Barriers Expansion
  +
  +This update extends pointer barriers to optionally allow the pointer 
  through
  +when a threshold is reached.  This can be useful for desktop environments 
  that
  +wish to use a large region of the screen, such as an entire edge, to 
  provide a
  +casual target while allowing determined movement to pass through.
  +
  +13.1 Types
  +
  +   BarrierEvent:   {Hit, ThresholdExceeded}
  +   BarrierEventID: CARD32
  +
  +13.2 Events
  +
  +BarrierNotify
  +
  +   subtype:BarrierEvent
  +   window: WINDOW
  +   event-id:   BarrierEventID
  +   barrier:BARRIER
  +   velocity:   CARD32
  +   x, y:   INT16
  +   raw-displacement:   FP1616
  +   delta-t:INT16
  +   deviceid:   INT16
  +
  +13.3 Requests
  +
  +SelectBarrierInput
  +
  +   window: WINDOW
  +   event-mask: SETofBarrierEvent
  +
  +
  +   This request directs barrier events to the named window.  Subtype
  +   indicates the trigger of the event, which is Hit when the barrier has
  +   prevented pointer movement and ThresholdExceeded when the barrier has
  +   been hit but has not prevented pointer movement due to the threshold
  +   being exceeded.
  +   
  +   Barrier is the barrier on which the event was triggered. (x,y) contain
  +   the coordinates of the pointer after restriction by any applicable
  +   barriers, and velocity is the unrestricted instantaneous velocity
  +   of the pointer, perpendicular to the barrier.
 
 how is velocity defined?
 (edit: found it below, this should be either in some common section or
 everywhere. You could just define a VELOCITY type and explain it there)

That makes sense, I'll do so.

 
  +
  +   deviceid is the identifier of the device which caused the barrier
  +   event, raw-displacement and delta-t are the raw valuator (purpendicular
 
 I'm not sure what you raw-displacement here is, can you clarify? 
 

Raw-displacement is exactly the value you'd get if you were subscribed
to XI 2 raw events and selected the valuator perpendicular to the
barrier.

It (and delta-t) are here so that a client can get a pre-acceleration
idea of the velocity and user behaviour if the client desires.  This is
useful for clients to determine when they want to release the barrier.

 s/valuator/valuators
 typo: purpendicular
 
And I thought I'd spell-checked it.  Oops :).

  +   to the barrier) and time-since-last-input-event for deviceid
  +   respectively.
  +
  +   event-id is an identifier for this barrier event. A barrier event
  +   begins when the pointer is first restricted by the barrier, and ends
  +   with the first mouse event that is not restricted by the barrier.
 
 event-id is unique per-device? per-server? per-something?
 I assume the second, given that device id isn't required

Re: [PATCH] fixesproto v6: Pointer barrier thresholds

2012-05-02 Thread Christopher James Halse Rogers
On Thu, 2012-05-03 at 11:12 +1000, Peter Hutterer wrote:
 On Tue, Apr 03, 2012 at 01:42:38PM +1000, Christopher James Halse Rogers 
 wrote:
  ---
  
  I've got a corresponding xserver patch, but it needs updating for the
  Great Reindent of '12.  Might as well get support for the protocol 
  additions 
  before fixing it up.
  
  A slightly different variant of this (it's gone through a number of 
  iterations
  in conjunction with the Unity team) is used by the Unity shell as 
  infrastructure
  for the one-launcher-per-display support, so there's evidence that it's a 
  usable
  protocol.
  
   configure.ac   |2 +-
   fixesproto.txt |   94 
  
   xfixesproto.h  |   59 +++
   xfixeswire.h   |   23 +++--
   4 files changed, 173 insertions(+), 5 deletions(-)
  
  diff --git a/configure.ac b/configure.ac
  index f85b802..07dd29a 100644
  --- a/configure.ac
  +++ b/configure.ac
  @@ -22,7 +22,7 @@ dnl
   dnl Process this file with autoconf to create configure.
   
   AC_PREREQ([2.60])
  -AC_INIT([FixesProto], [5.0],
  +AC_INIT([FixesProto], [6.0],
   [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
   AM_INIT_AUTOMAKE([foreign dist-bzip2])
   AM_MAINTAINER_MODE
  diff --git a/fixesproto.txt b/fixesproto.txt
  index 5903ac9..6f8c705 100644
  --- a/fixesproto.txt
  +++ b/fixesproto.txt
  @@ -650,6 +650,100 @@ DestroyPointerBarrier
   
  Errors: Barrier 
   
  +* XFIXES VERSION 6 OR BETTER ***
  +
  +13. Pointer Barriers Expansion
  +
  +This update extends pointer barriers to optionally allow the pointer 
  through
  +when a threshold is reached.  This can be useful for desktop environments 
  that
  +wish to use a large region of the screen, such as an entire edge, to 
  provide a
  +casual target while allowing determined movement to pass through.
  +
  +13.1 Types
  +
  +   BarrierEvent:   {Hit, ThresholdExceeded}
  +   BarrierEventID: CARD32
  +
  +13.2 Events
  +
  +BarrierNotify
  +
  +   subtype:BarrierEvent
  +   window: WINDOW
  +   event-id:   BarrierEventID
  +   barrier:BARRIER
  +   velocity:   CARD32
  +   x, y:   INT16
  +   raw-displacement:   FP1616
  +   delta-t:INT16
  +   deviceid:   INT16
  +
  +13.3 Requests
  +
  +SelectBarrierInput
  +
  +   window: WINDOW
  +   event-mask: SETofBarrierEvent
  +
  +
  +   This request directs barrier events to the named window.  Subtype
  +   indicates the trigger of the event, which is Hit when the barrier has
  +   prevented pointer movement and ThresholdExceeded when the barrier has
  +   been hit but has not prevented pointer movement due to the threshold
  +   being exceeded.
  +   
  +   Barrier is the barrier on which the event was triggered. (x,y) contain
  +   the coordinates of the pointer after restriction by any applicable
  +   barriers, and velocity is the unrestricted instantaneous velocity
  +   of the pointer, perpendicular to the barrier.
  +
  +   deviceid is the identifier of the device which caused the barrier
  +   event, raw-displacement and delta-t are the raw valuator (purpendicular
  +   to the barrier) and time-since-last-input-event for deviceid
  +   respectively.
  +
  +   event-id is an identifier for this barrier event. A barrier event
  +   begins when the pointer is first restricted by the barrier, and ends
  +   with the first mouse event that is not restricted by the barrier.
  +
  +   In the case of multiple overlapping barriers an event is sent for each.
 
 are events triggered on barriers without velocity?

Yes. I could make this more obvious by explicitly stating that barriers
without velocity will never send ThresholdExceeded.

 
  +
  +CreatePointerBarrierVelocity
  +
  +   barrier:BARRIER
  +   drawable:   DRAWABLE
  +   x1, y2, x2, y2: INT16
  +   directions: CARD32
  +   velocity:   CARD32
  +   devices:LISTofDEVICEID
  +
  +   Creates a pointer barrier along the line specified by the given
  +   coordinates on the screen associated with the given drawable. This
  +   has identical semantics to CreatePointerBarrier, except that the
  +   barrier created will not block the pointer if the threshold
  +   velocity is exceeded. The velocity is measured in px/sec perpendicular
  +   to the barrier.  
  +
  +   Once the pointer has been stopped by the barrier it will remain blocked
  +   for the duration of the barrier event.
  +   
  +   Errors: IDChoice, Window, Value, Device
  +
  +BarrierReleasePointer
  +
  +   barrier:BARRIER

Re: [PATCH 03/11] glx: Extend __GLXscreen::createContext to take attributes

2012-04-18 Thread Christopher James Halse Rogers
On Tue, 2012-04-17 at 08:36 -0700, Ian Romanick wrote:
 On 04/17/2012 03:05 AM, Christopher James Halse Rogers wrote:
  On Fri, 2012-04-13 at 18:11 -0700, Ian Romanick wrote:
  From: Ian Romanickian.d.roman...@intel.com
 
  The attributes will be used for glXCreateContextAttribsARB additions
  in follow-on patches.
 
  Signed-off-by: Ian Romanickian.d.roman...@intel.com
  Reviewed-by: Jesse Barnesjbar...@virtuousgeek.org
  ---
glx/glxcmds.c  |   12 ++--
glx/glxdri.c   |   10 +-
glx/glxdri2.c  |5 -
glx/glxdriswrast.c |4 +++-
glx/glxscreens.h   |5 -
5 files changed, 30 insertions(+), 6 deletions(-)
 
  diff --git a/glx/glxcmds.c b/glx/glxcmds.c
  index 5c70afa..f754104 100644
  --- a/glx/glxcmds.c
  +++ b/glx/glxcmds.c
  @@ -276,8 +276,16 @@ DoCreateContext(__GLXclientState * cl, GLXContextID 
  gcId,
/*
 ** Allocate memory for the new context
 */
  -if (!isDirect)
  -glxc = pGlxScreen-createContext(pGlxScreen, config, shareglxc);
  +if (!isDirect) {
  +int err;
 
  This variable shadows the err defined at the top of the function, which
  is not used after this point; any reason why you didn't just reuse the
  existing variable?

You're still (as far as I can tell) unnecessarily shadowing the int
err defined at the top of the function here.



signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 07/11] glx: Initialize all context fields together

2012-04-17 Thread Christopher James Halse Rogers
On Fri, 2012-04-13 at 18:11 -0700, Ian Romanick wrote:
 
 @@ -292,26 +292,10 @@ DoCreateContext(__GLXclientState * cl,
 GLXContextID gcId,
  return BadAlloc;
  }
  
 -/*
 - ** Initially, setup the part of the context that could be used
 by
 - ** a GL core that needs windowing information (e.g., Mesa).
 +/* Initialize the GLXcontext structure.
   */
  glxc-pGlxScreen = pGlxScreen;
  glxc-config = config;
 -
 -/*
 - ** Register this context as a resource.
 - */
 -if (!AddResource(gcId, __glXContextRes, (pointer) glxc)) {
 -(*glxc-destroy) (glxc);
 -client-errorValue = gcId;
 -return BadAlloc;
 -}
 -
 -/*
 - ** Finally, now that everything is working, setup the rest of
 the
 - ** context.
 - */
  glxc-id = gcId;
  glxc-share_id = shareList;
  glxc-idExists = GL_TRUE;
 @@ -319,6 +303,14 @@ DoCreateContext(__GLXclientState * cl,
 GLXContextID gcId,
  glxc-isDirect = isDirect;
  glxc-renderMode = GL_RENDER;
  
 +/* Register this context as a resource.
 + */
 +if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) {
 +(*glxc-destroy) (glxc);
 +client-errorValue = gcId;
 +return BadAlloc;
 +}
 +
^^^ git am, being the pedant that it is, complains about this trailing
whitespace.



signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 06/11] glx: Implement GLX SetClientInfoARB protocol

2012-04-17 Thread Christopher James Halse Rogers
On Fri, 2012-04-13 at 18:11 -0700, Ian Romanick wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 Reviewed-by: Dave Airlie airl...@redhat.com
 ---
  glx/clientinfo.c |   49 +++--
  1 files changed, 47 insertions(+), 2 deletions(-)
 
 diff --git a/glx/clientinfo.c b/glx/clientinfo.c
 index 15bbf15..b26ac1a 100644
 --- a/glx/clientinfo.c
 +++ b/glx/clientinfo.c
 @@ -26,17 +26,62 @@
  
  #include glxserver.h
  #include indirect_dispatch.h
 +#include glxbyteorder.h
 +#include unpack.h
  
  int
  __glXDisp_SetClientInfoARB(__GLXclientState * cl, GLbyte * pc)
  {
 -return BadRequest;
 +xGLXSetClientInfoARBReq *req = (xGLXSetClientInfoARBReq *) pc;
 +char *gl_extensions;
 +char *glx_extensions;
 +
 +/* Verify that the size of the packet matches the size inferred from the
 + * sizes specified for the various fields.
 + */
 +const unsigned expected_size = sz_xGLXSetClientInfoARBReq
 ++ (req-numVersions * 8)
 ++ __GLX_PAD(req-numGLExtensionBytes)
 ++ __GLX_PAD(req-numGLXExtensionBytes);
 +
 +if (req-length != (expected_size / 4))
 +return BadLength;
 +
 +/* Verify that the actual length of the GL extension string matches 
 what's
 + * encoded in protocol packet.
 + */
 +gl_extensions = (char *) (req + 1) + (req-numVersions * 8);
 +if (req-numGLExtensionBytes != 0
 + memchr(gl_extensions, 0,
 +  __GLX_PAD(req-numGLExtensionBytes)) == NULL)
 +return BadLength;
 +
 +/* Verify that the actual length of the GLX extension string matches
 + * what's encoded in protocol packet.
 + */
 +glx_extensions = gl_extensions + __GLX_PAD(req-numGLExtensionBytes);
 +if (req-numGLXExtensionBytes != 0
 + memchr(glx_extensions, 0,
 +  __GLX_PAD(req-numGLXExtensionBytes)) == NULL)
 +return BadLength;
 +
 +free(cl-GLClientextensions);
 +cl-GLClientextensions = strdup(gl_extensions);
 +
 +return 0;
  }
  
  int
  __glXDispSwap_SetClientInfoARB(__GLXclientState * cl, GLbyte * pc)
  {
 -return BadRequest;
 +xGLXSetClientInfoARBReq *req = (xGLXSetClientInfoARBReq *) pc;
 +
 +req-length = bswap_16(req-length);
 +req-numVersions = bswap_32(req-numVersions);
 +req-numGLExtensionBytes = bswap_32(req-numGLExtensionBytes);
 +req-numGLXExtensionBytes = bswap_32(req-numGLXExtensionBytes);
 +
 +return __glXDisp_SetClientInfoARB(cl, pc);
  }
  
  int

This should probably also bump the minimum required glproto in
configure.ac


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 00/11] Implement GLX_ARB_create_context

2012-04-17 Thread Christopher James Halse Rogers
On Fri, 2012-04-13 at 18:11 -0700, Ian Romanick wrote:
 This is mostly a re-send of my previous patch series.  I have
 incorporated all (I think?) of the previous review comments, and I
 have (mostly) applied the new indent rules.
 
 I have tested with all of the piglit GLX_ARB_create_context tests.
 There are two failures.  One is a case of returning the wrong error
 code (which may actually be an error in the spec), and the other is a
 client bug.
 
 Once these are applied, patches to implement
 GLX_ARB_create_context_profile and GLX_EXT_create_context_es2_profile
 will follow shortly.
 

With the exception of the (minor) issues on the three patches,
Reviewed-By: Christopher James Halse Rogers
christopher.halse.rog...@canonical.com



signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] fixesproto v6: Pointer barrier thresholds

2012-04-09 Thread Christopher James Halse Rogers
On Tue, 2012-04-03 at 13:42 +1000, Christopher James Halse Rogers wrote:
 ---
 
 I've got a corresponding xserver patch, but it needs updating for the
 Great Reindent of '12.  Might as well get support for the protocol additions 
 before fixing it up.
 
 A slightly different variant of this (it's gone through a number of iterations
 in conjunction with the Unity team) is used by the Unity shell as 
 infrastructure
 for the one-launcher-per-display support, so there's evidence that it's a 
 usable
 protocol.
 
  configure.ac   |2 +-
  fixesproto.txt |   94 
 
  xfixesproto.h  |   59 +++
  xfixeswire.h   |   23 +++--
  4 files changed, 173 insertions(+), 5 deletions(-)
 

Ping?  Anything I can do to help make this more attractive to review?
Send the server and libxfixes implementation patch, work out why xcb
doesn't like fixes v5, promise beer, etc?


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] fixesproto v6: Pointer barrier thresholds

2012-04-09 Thread Christopher James Halse Rogers
On Tue, 2012-04-03 at 13:42 +1000, Christopher James Halse Rogers wrote:
 ---
 
 I've got a corresponding xserver patch, but it needs updating for the
 Great Reindent of '12.  Might as well get support for the protocol additions 
 before fixing it up.
 
 A slightly different variant of this (it's gone through a number of iterations
 in conjunction with the Unity team) is used by the Unity shell as 
 infrastructure
 for the one-launcher-per-display support, so there's evidence that it's a 
 usable
 protocol.
 
  configure.ac   |2 +-
  fixesproto.txt |   94 
 
  xfixesproto.h  |   59 +++
  xfixeswire.h   |   23 +++--
  4 files changed, 173 insertions(+), 5 deletions(-)
 

Ping?  Anything I can do to help make this more attractive to review?
Send the server and libxfixes implementation patch, work out why xcb
doesn't like fixes v5, promise beer, etc?



signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

ErrorF in SIGIO context

2012-04-04 Thread Christopher James Halse Rogers
I've been getting SIGSEGVs in mieqEnqueue while valgrinding the server
hoping to find the source of an Ubuntu crash bug (which doesn't appear
to affect the upstream server).

Upon inspection, it was dying when trying to print the EQ overflowing
message.  Digging down, ErrorF appears to end up calling a whole bunch
of functions that aren't listed as signal-safe - sprintf (which is where
the segfault happens under valgrind), strlen (!?), vsnprintf, fwrite,
and fflush.

Some of those (hello, strlen!) should be signal safe under any
reasonable implementation, but it seems that sprintf isn't, at least
under valgrind.

Is my analysis correct?  What, if anything, should be done about this -
it doesn't seem like anything's terribly broken when running X on glibc.


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] fixesproto v6: Pointer barrier thresholds

2012-04-02 Thread Christopher James Halse Rogers
---

I've got a corresponding xserver patch, but it needs updating for the
Great Reindent of '12.  Might as well get support for the protocol additions 
before fixing it up.

A slightly different variant of this (it's gone through a number of iterations
in conjunction with the Unity team) is used by the Unity shell as infrastructure
for the one-launcher-per-display support, so there's evidence that it's a usable
protocol.

 configure.ac   |2 +-
 fixesproto.txt |   94 
 xfixesproto.h  |   59 +++
 xfixeswire.h   |   23 +++--
 4 files changed, 173 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index f85b802..07dd29a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.60])
-AC_INIT([FixesProto], [5.0],
+AC_INIT([FixesProto], [6.0],
 [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
diff --git a/fixesproto.txt b/fixesproto.txt
index 5903ac9..6f8c705 100644
--- a/fixesproto.txt
+++ b/fixesproto.txt
@@ -650,6 +650,100 @@ DestroyPointerBarrier
 
Errors: Barrier 
 
+* XFIXES VERSION 6 OR BETTER ***
+
+13. Pointer Barriers Expansion
+
+This update extends pointer barriers to optionally allow the pointer through
+when a threshold is reached.  This can be useful for desktop environments that
+wish to use a large region of the screen, such as an entire edge, to provide a
+casual target while allowing determined movement to pass through.
+
+13.1 Types
+
+   BarrierEvent:   {Hit, ThresholdExceeded}
+   BarrierEventID: CARD32
+
+13.2 Events
+
+BarrierNotify
+
+   subtype:BarrierEvent
+   window: WINDOW
+   event-id:   BarrierEventID
+   barrier:BARRIER
+   velocity:   CARD32
+   x, y:   INT16
+   raw-displacement:   FP1616
+   delta-t:INT16
+   deviceid:   INT16
+
+13.3 Requests
+
+SelectBarrierInput
+
+   window: WINDOW
+   event-mask: SETofBarrierEvent
+
+
+   This request directs barrier events to the named window.  Subtype
+   indicates the trigger of the event, which is Hit when the barrier has
+   prevented pointer movement and ThresholdExceeded when the barrier has
+   been hit but has not prevented pointer movement due to the threshold
+   being exceeded.
+   
+   Barrier is the barrier on which the event was triggered. (x,y) contain
+   the coordinates of the pointer after restriction by any applicable
+   barriers, and velocity is the unrestricted instantaneous velocity
+   of the pointer, perpendicular to the barrier.
+
+   deviceid is the identifier of the device which caused the barrier
+   event, raw-displacement and delta-t are the raw valuator (purpendicular
+   to the barrier) and time-since-last-input-event for deviceid
+   respectively.
+
+   event-id is an identifier for this barrier event. A barrier event
+   begins when the pointer is first restricted by the barrier, and ends
+   with the first mouse event that is not restricted by the barrier.
+
+   In the case of multiple overlapping barriers an event is sent for each.
+
+CreatePointerBarrierVelocity
+
+   barrier:BARRIER
+   drawable:   DRAWABLE
+   x1, y2, x2, y2: INT16
+   directions: CARD32
+   velocity:   CARD32
+   devices:LISTofDEVICEID
+
+   Creates a pointer barrier along the line specified by the given
+   coordinates on the screen associated with the given drawable. This
+   has identical semantics to CreatePointerBarrier, except that the
+   barrier created will not block the pointer if the threshold
+   velocity is exceeded. The velocity is measured in px/sec perpendicular
+   to the barrier.  
+
+   Once the pointer has been stopped by the barrier it will remain blocked
+   for the duration of the barrier event.
+   
+   Errors: IDChoice, Window, Value, Device
+
+BarrierReleasePointer
+
+   barrier:BARRIER
+   event-id:   BarrierEventID
+
+   Temporarily allow the pointer to pass through a pointer barrier.
+   This disables the barrier for as long as event-id is valid - that is,
+   as long as the pointer remains in contact with the barrier.
+
+   Requests to release the pointer for an event-id which is not current
+   are silently ignored.
+
+   Errors: 

Re: [PATCH xorg-gtest v2 8/9] Ship xorg-gtest.m4 and Makefile-xorg-gtest.am

2012-03-14 Thread Christopher James Halse Rogers
On Tue, 2012-03-13 at 11:47 -0700, Chase Douglas wrote:
 See README for instructions on how to use them.
 
 Signed-off-by: Chase Douglas chase.doug...@canonical.com
 ---
  Makefile.am|2 +-
  README |   41 +++--
  aclocal/Makefile.am|   27 +++
  aclocal/xorg-gtest.m4  |  105 
 
  configure.ac   |3 +
  src/Makefile-xorg-gtest.am |   61 +
  src/Makefile.am|5 ++-
  xorg-gtest.pc.in   |1 +
  8 files changed, 239 insertions(+), 6 deletions(-)
  create mode 100644 aclocal/Makefile.am
  create mode 100644 aclocal/xorg-gtest.m4
  create mode 100644 src/Makefile-xorg-gtest.am
 
 diff --git a/Makefile.am b/Makefile.am
 index 2542b44..8e0a0c6 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -23,7 +23,7 @@
  # SOFTWARE.
  #
  
 -SUBDIRS = data doc include src examples
 +SUBDIRS = aclocal data doc include src examples
  
  pkgconfigdir = $(libdir)/pkgconfig
  pkgconfig_DATA = xorg-gtest.pc
 diff --git a/README b/README
 index 6b79f05..83c5d38 100644
 --- a/README
 +++ b/README
 @@ -1,4 +1,4 @@
 -X.Org dummy testing environment for Google Test
 +X.Org GTest testing environment for Google Test
  ===
  
  Provides a Google Test environment for starting and stopping
 @@ -7,6 +7,39 @@ environment is defined in header environment.h. Please refer 
 to
  the Google test documentation for information on how to add a custom 
  environment.
  
 -Moreover, a custom main()-function that takes care of setting up the 
 -environment is provided in libxtestingenvironment_main.a. This library can be
 -used as a replacement for libgtest_main.a 
 +Moreover, a custom main() function that takes care of setting up the 
 +environment is provided in xorg-gtest_main.cpp. This can be used as a
 +replacement for libgtest_main.a 
 +
 +Using X.org GTest in a project
 +==
 +
 +The X.org GTest does not provide precompiled libraries. Each project must 
 build
 +the X.org GTest sources. To facilitate this, aclocal and automake include 
 files
 +are provided. Perform the following to integrate xorg-gtest into an 
 autotools-
 +based project.
 +
 +Add the following line to the top level Makefile.am for your project:
 +
 +ACLOCAL_AMFLAGS = -I m4 --install
 +
 +This will ensure the latest xorg-gtest.m4 macro installed on your system is
 +copied into aclocal/. If a user runs autoreconf, they will already have the
 +macro even if they don't have xorg-gtest installed.
 +
 +Call CHECK_XORG_GTEST from configure.ac This will set the value of
 +$have_xorg_gtest and set $(XORG_GTEST_CPPFLAGS) and $(XORG_GTEST_CXXFLAGS).
 +
 +Copy Makefile-xorg-gtest.am into your project.
 +
 +In your test Makefile.am, add:
 +
 +include $(top_srcdir)/path/to/Makefile-xorg-gtest.am
 +
 +Append $(XORG_GTEST_BUILD_LIBS) to check_LIBRARIES.
 +
 +Append CPPFLAGS with $(XORG_GTEST_CPPFLAGS) and CXXFLAGS with
 +$(XORG_GTEST_CXXFLAGS) for any testing source objects.
 +
 +Finally, link against $(XORG_GTEST_LIBS). If you want the xorg-gtest main()
 +integration, link against $(XORG_GTEST_MAIN_LIBS) as well.
 diff --git a/aclocal/Makefile.am b/aclocal/Makefile.am
 new file mode 100644
 index 000..3ea9969
 --- /dev/null
 +++ b/aclocal/Makefile.am
 @@ -0,0 +1,27 @@
 +#
 +# Makefile for the src subdirectory of xorg-gtest
 +#
 +# Copyright (C) 2012 Canonical, Ltd.
 +#
 +# Permission is hereby granted, free of charge, to any person obtaining a 
 copy
 +# of this software and associated documentation files (the Software), to 
 deal
 +# in the Software without restriction, including without limitation the 
 rights
 +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 +# copies of the Software, and to permit persons to whom the Software is
 +# furnished to do so, subject to the following conditions:
 +#
 +# The above copyright notice and this permission notice (including the next
 +# paragraph) shall be included in all copies or substantial portions of the
 +# Software.
 +#
 +# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 FROM,
 +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
 THE
 +# SOFTWARE.
 +#
 +
 +aclocaldir = $(datadir)/aclocal
 +dist_aclocal_DATA = xorg-gtest.m4
 diff --git a/aclocal/xorg-gtest.m4 b/aclocal/xorg-gtest.m4
 new file mode 100644
 index 000..a1ef1cf
 --- /dev/null
 +++ b/aclocal/xorg-gtest.m4
 @@ -0,0 +1,105 @@
 +# serial 1
 +
 +# Copyright (C) 2012 Canonical, Ltd.
 +#
 +# Permission is hereby granted, free of charge, to any person 

Re: [PATCH xorg-gtest v2 0/9] Switch from a precompiled library to a source distribution

2012-03-14 Thread Christopher James Halse Rogers
On Wed, 2012-03-14 at 11:27 -0700, Chase Douglas wrote:
 On 03/14/2012 05:57 AM, Gaetan Nadon wrote:
  On 12-03-14 02:35 AM, Chase Douglas wrote:
  On 03/13/2012 10:39 PM, Chase Douglas wrote:
  On 03/13/2012 07:30 PM, Gaetan Nadon wrote:
  On 12-03-13 08:53 PM, Gaetan Nadon wrote:
  On 12-03-13 02:47 PM, Chase Douglas wrote:
  The major change in this round is to patch 8. Instead of instructing 
  users to
  include an automake snippet installed on the system, the README now 
  says to copy
  the snippet into the project. The snippet needs to be available before
  autoreconf is run. It would be possible to copy the snippet into place 
  in
  autogen.sh, but that would be a very non-standard solution to the 
  problem and
  would require the user to have xorg-gtest installed.
 
  The xorg-gtest.m4 macro now sets BASE_CXXFLAGS and STRICT_CXXFLAGS 
  properly.
 
  The other change is the addition of patch 9. It allows for the Xorg 
  binary to be
  set through a compilation flag. This should make it possible to use 
  xorg-gtest's
  main() with an Xorg server built in the xserver project.
 
  All XORG_MACROS_VERSION calls have been updated to require 1.17 for
  XORG_ENABLE_INTEGRATION_TESTS.
 
  -- Chase
 
  Some quick testing:
 
  Applying: Ship xorg-gtest.m4 and Makefile-xorg-gtest.am
  /home/nadon/xorg/src/test/xorg-gtest/.git/rebase-apply/patch:45:
  trailing whitespace.
  Moreover, a custom main() function that takes care of setting up the
  /home/nadon/xorg/src/test/xorg-gtest/.git/rebase-apply/patch:47:
  trailing whitespace.
  replacement for libgtest_main.a
  warning: 2 lines add whitespace errors.
 
  -
 
  $ make distcheck:
  make[3]: Entering directory
  `/home/nadon/xorg/src/test/xorg-gtest/xorg-gtest-0.1.1/_build/examples'
CXXlibgtest_a-gtest-all.o
CXXlibxorg_gtest_a-xorg-gtest-all.o
CXXlibxorg_gtest_main_a-xorg-gtest_main.o
CXXxorg-gtest-example.o
  In file included from ../../src/device.cpp:28:0,
   from ../../src/xorg-gtest-all.cpp:28:
  ../../include/xorg/gtest/evemu/device.h:36:19: fatal error: evemu.h: No
  Something needs to be conditionally included when evemu package is not
  available.
  such file or directory
  compilation terminated.
  make[3]: *** [libxorg_gtest_a-xorg-gtest-all.o] Error 1
  I hadn't tried make distcheck while libutouch-evemu was not installed.
  This was a simple fix: inside xorg-gtest-all.cpp, wrap #include
  device.cpp in a #ifdef HAVE_EVEMU.
 
  Now it builds and checks without issue with or without utouch-evemu
  installed.
 
  -
 
  *** Update comment as well with 1.17  *** We've all done this :-)
  # Require X.Org macros 1.16 or later for XORG_TESTSET_CFLAG
  m4_ifndef([XORG_MACROS_VERSION],
[m4_fatal([must install xorg-macros 1.16 or later before running
  autoconf/autogen])])
  XORG_MACROS_VERSION(1.17)
 
  -
  Running make all or make clean does not produce anything, no targets
  to build or clean. This is strange as distcheck does find something to
  compile. Sorry, I did not have time to investigate, maybe it is just a
  local problem.
  Ok, 'make check' is the target to invoke. Running 'distcheck' always
  runs 'check'.
  Correct. We don't ship a library anymore, so there's no reason to build
  anything during normal make. Make check can be run to ensure that it
  builds and runs against the installed X server. If you disable
  integration tests, it will not attempt to run the example test.
 
  I have libgtest-dev installed but not libutouch-evemu-dev.
 
 
  I installed evemu lib and the compilation is ok. However the TESTS
  fails, so distcheck fails.
 
  make  check-TESTS
  make[3]: Entering directory
  
  `/home/nadon/xorg/src/test/xorg-gtest/xorg-gtest-0.1.1/_build/examples'
  [==] Running 1 test from 1 test case.
  [--] Global test environment set-up.
  unknown file: Failure
  C++ exception with description Dummy X server failed to start, did
  you run as root? thrown in auxiliary test code (environments or
  event listeners).
  FAIL: xorg-gtest-example
  ==
  1 of 1 test failed
  ==
  make[3]: *** [check-TESTS] Error 1
 
  If the intention was to run integration tests which requires root or
  other special requirements, rather than a module unit testing, this will
  conflict with the purpose of distcheck.
  The exception comment is a little old. With X server 1.12 you don't need
  to be root to run xorg-gtest tests.
 
  I'm not sure why it failed for you. Can you check /tmp/Xorg.GTest.log?
  Do you have the xserver installed?
 
  As for integration tests in xorg-gtest's distcheck, I'm not sure what is
  best, but I am leaning towards checking with the 

[RFC PATCH 1/2] test: Proof of concept xfixes intergration tests.

2012-03-13 Thread Christopher James Halse Rogers
---

This is not intended to be applied as-is; the autofoo will want changing
to match the changes in xorg-gtest recently submitted to the list.

It's posted (a) as a demonstration of what some tests in the server would
look like, and (b) to demonstrate that there's something for the following
fix to fix :)

 configure.ac   |   22 ++
 test/Makefile.am   |6 +
 test/gtest/.gitignore  |1 +
 test/gtest/Makefile.am |   27 ++
 test/gtest/dummy.conf  |4 +
 test/gtest/xfixes_barriers.cpp |  614 
 6 files changed, 674 insertions(+), 0 deletions(-)
 create mode 100644 test/gtest/.gitignore
 create mode 100644 test/gtest/Makefile.am
 create mode 100644 test/gtest/dummy.conf
 create mode 100644 test/gtest/xfixes_barriers.cpp

diff --git a/configure.ac b/configure.ac
index 2693ce7..90abac6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2130,6 +2130,27 @@ AC_SUBST([prefix])
 
 AC_CONFIG_COMMANDS([sdksyms], [touch hw/xfree86/sdksyms.dep])
 
+dnl xorg gtest tests
+AC_PROG_CXX
+
+PKG_CHECK_MODULES(XORG_GTEST, xorg-gtest,
+[have_xorg_gtest=yes],
+[AC_MSG_WARN([xorg-gtest not installed, tests will not be built])])
+AM_CONDITIONAL([HAVE_XORG_GTEST], [test x$have_xorg_gtest = xyes])
+AC_SUBST([XORG_GTEST_CFLAGS])
+AC_SUBST([XORG_GTEST_LIBS])
+
+PKG_CHECK_MODULES([XFIXES], xfixes, [have_xfixes=yes], [have_xfixes=no])
+AM_CONDITIONAL([HAVE_XFIXES], [test x$have_xfixes = xyes])
+AC_SUBST([XFIXES_CFLAGS])
+AC_SUBST([XFIXES_LIBS])
+
+PKG_CHECK_MODULES([XTEST], xtst, [have_xtest=yes], [have_xtest=no])
+AM_CONDITIONAL([HAVE_XTEST], [test x$have_xtest = xyes])
+AC_SUBST([XTEST_CFLAGS])
+AC_SUBST([XTEST_LIBS])
+
+
 AC_OUTPUT([
 Makefile
 glx/Makefile
@@ -2230,6 +2251,7 @@ hw/kdrive/linux/Makefile
 hw/kdrive/src/Makefile
 test/Makefile
 test/xi2/Makefile
+test/gtest/Makefile
 xserver.ent
 xorg-server.pc
 ])
diff --git a/test/Makefile.am b/test/Makefile.am
index b875b75..0b3fe69 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,6 +6,12 @@ if XORG
 # For now, requires xf86 ddx, could be adjusted to use another
 SUBDIRS += xi2
 noinst_PROGRAMS += xkb input xtest misc fixes xfree86
+
+# Xorg-gtest tests
+if HAVE_XORG_GTEST
+SUBDIRS += gtest
+endif
+
 endif
 check_LTLIBRARIES = libxservertest.la
 
diff --git a/test/gtest/.gitignore b/test/gtest/.gitignore
new file mode 100644
index 000..6591cb8
--- /dev/null
+++ b/test/gtest/.gitignore
@@ -0,0 +1 @@
+xfixes_barriers
diff --git a/test/gtest/Makefile.am b/test/gtest/Makefile.am
new file mode 100644
index 000..56e695c
--- /dev/null
+++ b/test/gtest/Makefile.am
@@ -0,0 +1,27 @@
+check_PROGRAMS = xfixes_barriers
+check_DATA = dummy.conf
+
+TESTS=xfixes_barriers
+
+GTEST_SRC_DIR = /usr/src/gtest
+GTEST_SOURCES = $(GTEST_SRC_DIR)/src/gtest-all.cc
+
+xfixes_barriers_CXXFLAGS = $(AM_CXXFLAGS) \
+   -I$(GTEST_SRC_DIR) \
+   $(XORG_GTEST_CFLAGS) \
+   $(XTEST_CFLAGS) \
+   $(XFIXES_CFLAGS) \
+   -DXORG_BINARY=\$(top_builddir)/hw/xfree86/Xorg\ \
+   -DXORG_DUMMY_CONF=\$(abs_srcdir)/dummy.conf\
+
+xfixes_barriers_LDADD = \
+   $(XFIXES_LIBS) \
+   $(XTEST_LIBS) \
+   $(XORG_GTEST_LIBS) \
+   -lpthread
+
+xfixes_barriers_SOURCES = \
+   xfixes_barriers.cpp
+
+nodist_xfixes_barriers_SOURCES = \
+   $(GTEST_SOURCES)
diff --git a/test/gtest/dummy.conf b/test/gtest/dummy.conf
new file mode 100644
index 000..5600991
--- /dev/null
+++ b/test/gtest/dummy.conf
@@ -0,0 +1,4 @@
+Section Device
+Identifier Dummy video device
+Driver dummy
+EndSection
diff --git a/test/gtest/xfixes_barriers.cpp b/test/gtest/xfixes_barriers.cpp
new file mode 100644
index 000..6810dbe
--- /dev/null
+++ b/test/gtest/xfixes_barriers.cpp
@@ -0,0 +1,614 @@
+/*
+
+Copyright (c) 2012, Canonical Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the Software),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+#include iostream
+#include sys/time.h
+#include unistd.h
+#include gtest/gtest.h

Re: [PATCH xorg-gtest v2 0/9] Switch from a precompiled library to a source distribution

2012-03-13 Thread Christopher James Halse Rogers
On Tue, 2012-03-13 at 22:30 -0400, Gaetan Nadon wrote:
 On 12-03-13 08:53 PM, Gaetan Nadon wrote: 
  On 12-03-13 02:47 PM, Chase Douglas wrote:
   The major change in this round is to patch 8. Instead of instructing 
   users to
   include an automake snippet installed on the system, the README now says 
   to copy
   the snippet into the project. The snippet needs to be available before
   autoreconf is run. It would be possible to copy the snippet into place in
   autogen.sh, but that would be a very non-standard solution to the problem 
   and
   would require the user to have xorg-gtest installed.
   
   The xorg-gtest.m4 macro now sets BASE_CXXFLAGS and STRICT_CXXFLAGS 
   properly.
   
   The other change is the addition of patch 9. It allows for the Xorg 
   binary to be
   set through a compilation flag. This should make it possible to use 
   xorg-gtest's
   main() with an Xorg server built in the xserver project.
   
   All XORG_MACROS_VERSION calls have been updated to require 1.17 for
   XORG_ENABLE_INTEGRATION_TESTS.
   
   -- Chase
   
  Some quick testing:
  
  Applying: Ship xorg-gtest.m4 and Makefile-xorg-gtest.am
  /home/nadon/xorg/src/test/xorg-gtest/.git/rebase-apply/patch:45:
  trailing whitespace.
  Moreover, a custom main() function that takes care of setting up the
  /home/nadon/xorg/src/test/xorg-gtest/.git/rebase-apply/patch:47:
  trailing whitespace.
  replacement for libgtest_main.a
  warning: 2 lines add whitespace errors.
  
  -
  
  $ make distcheck:
  make[3]: Entering directory
  `/home/nadon/xorg/src/test/xorg-gtest/xorg-gtest-0.1.1/_build/examples'
CXXlibgtest_a-gtest-all.o
CXXlibxorg_gtest_a-xorg-gtest-all.o
CXXlibxorg_gtest_main_a-xorg-gtest_main.o
CXXxorg-gtest-example.o
  In file included from ../../src/device.cpp:28:0,
   from ../../src/xorg-gtest-all.cpp:28:
  ../../include/xorg/gtest/evemu/device.h:36:19: fatal error: evemu.h: No
 Something needs to be conditionally included when evemu package is not
 available.
  such file or directory
  compilation terminated.
  make[3]: *** [libxorg_gtest_a-xorg-gtest-all.o] Error 1
  
  -
  
  *** Update comment as well with 1.17  *** We've all done this :-)
  # Require X.Org macros 1.16 or later for XORG_TESTSET_CFLAG
  m4_ifndef([XORG_MACROS_VERSION],
[m4_fatal([must install xorg-macros 1.16 or later before running
  autoconf/autogen])])
  XORG_MACROS_VERSION(1.17)
  
  -
  Running make all or make clean does not produce anything, no targets
  to build or clean. This is strange as distcheck does find something to
  compile. Sorry, I did not have time to investigate, maybe it is just a
  local problem.
 Ok, 'make check' is the target to invoke. Running 'distcheck' always
 runs 'check'.
  
  I have libgtest-dev installed but not libutouch-evemu-dev.
  
  
 I installed evemu lib and the compilation is ok. However the TESTS
 fails, so distcheck fails.
 make  check-TESTS
 make[3]: Entering directory
 
 `/home/nadon/xorg/src/test/xorg-gtest/xorg-gtest-0.1.1/_build/examples'
 [==] Running 1 test from 1 test case.
 [--] Global test environment set-up.
 unknown file: Failure
 C++ exception with description Dummy X server failed to
 start, did you run as root? thrown in auxiliary test code
 (environments or event listeners).
 FAIL: xorg-gtest-example
 ==
 1 of 1 test failed
 ==
 make[3]: *** [check-TESTS] Error 1
 If the intention was to run integration tests which requires root or
 other special requirements, rather than a module unit testing, this
 will conflict with the purpose of distcheck.

That error message is probably poor; more likely you don't have
xf86-video-dummy installed, or have a pre-1.12 X server (for the
don't-require-root-for-custom-config-file patch).  With both of in
place, the tests don't require root.



signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [RFC PATCH v2] fixesproto v6: Pointer barrier improvements.

2012-01-26 Thread Christopher James Halse Rogers
 _X_EXPORT RESTYPE PointerBarrierType;
@@ -52,9 +53,27 @@ extern _X_EXPORT int XFixesErrorBase;
 extern _X_EXPORT RegionPtr
 XFixesRegionCopy (RegionPtr pRegion);
 
+typedef struct PointerBarrierEventClient *PointerBarrierEventClientPtr;
+
+struct PointerBarrierEventClient {
+ScreenPtr screen;
+ClientPtr client;
+CARD32eventMask;
+XID window;
+XID resource;
+struct list entry;
+};
+
+  
+
 struct PointerBarrier {
+XIDbarrier;
 CARD16 x1, x2, y1, y2;
 CARD32 directions;
+CARD32 velocity;
+CARD32 barrierEventID;
+CARD32 releaseEventID;
+Bool   hit, lastHit;
 };
 
 
diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h
index 6ba276e..cb00be6 100644
--- a/xfixes/xfixesint.h
+++ b/xfixes/xfixesint.h
@@ -59,6 +59,7 @@
 #include windowstr.h
 #include selection.h
 #include xfixes.h
+#include list.h
 
 extern int		XFixesEventBase;
 
@@ -293,6 +294,26 @@ ProcXFixesDestroyPointerBarrier (ClientPtr client);
 int
 SProcXFixesDestroyPointerBarrier (ClientPtr client);
 
+/* Version 6 */
+
+int
+ProcXFixesSelectBarrierInput (ClientPtr client);
+
+int
+SProcXFixesSelectBarrierInput (ClientPtr client);
+
+int
+ProcXFixesCreatePointerBarrierVelocity (ClientPtr client);
+
+int
+SProcXFixesCreatePointerBarrierVelocity (ClientPtr client);
+
+int
+ProcXFixesBarrierReleasePointer (ClientPtr client);
+
+int
+SProcXFixesBarrierReleasePointer (ClientPtr client);
+
 /* Xinerama */
 extern int (*PanoramiXSaveXFixesVector[XFixesNumberRequests])(ClientPtr);
 void PanoramiXFixesInit (void);
diff --git a/debian/changelog b/debian/changelog
index ee46d5f..3b6baa2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,21 @@
+libxfixes (1:5.0-6~hacking2) precise; urgency=low
+
+  * Hook up event-id  BarrierReleasePointer
+
+ -- Christopher James Halse Rogers r...@ubuntu.com  Wed, 25 Jan 2012 14:42:06 +1100
+
+libxfixes (1:5.0-6~hacking1) precise; urgency=low
+
+  * More and different thresholding
+
+ -- Christopher James Halse Rogers r...@ubuntu.com  Wed, 25 Jan 2012 11:56:16 +1100
+
+libxfixes (1:5.0-5) precise; urgency=low
+
+  * Pointer-barrier-thresholding
+
+ -- Christopher James Halse Rogers r...@ubuntu.com  Wed, 18 Jan 2012 22:09:44 +1100
+
 libxfixes (1:5.0-4) unstable; urgency=low
 
   * Team upload.
diff --git a/debian/control b/debian/control
index a507388..dc27cb8 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,7 @@ Build-Depends:
  debhelper (= 8.1.3),
  dh-autoreconf,
  libx11-dev (= 2:1.3.3-2),
- x11proto-fixes-dev (= 1:5.0),
+ x11proto-fixes-dev (= 1:5.0-5~hacking2~),
  pkg-config,
  quilt,
  xutils-dev (= 1:7.5+4),
diff --git a/debian/libxfixes3.symbols b/debian/libxfixes3.symbols
index 2cedbeb..7f2eabc 100644
--- a/debian/libxfixes3.symbols
+++ b/debian/libxfixes3.symbols
@@ -1,9 +1,11 @@
 libXfixes.so.3 libxfixes3 #MINVER#
+ XFixesBarrierReleasePointer@Base 1:5.0-5~hacking2
  XFixesChangeCursor@Base 0
  XFixesChangeCursorByName@Base 0
  XFixesChangeSaveSet@Base 0
  XFixesCopyRegion@Base 0
  XFixesCreatePointerBarrier@Base 1:5.0
+ XFixesCreatePointerBarrierVelocity@Base 1:5.0-4
  XFixesCreateRegion@Base 0
  XFixesCreateRegionFromBitmap@Base 0
  XFixesCreateRegionFromGC@Base 0
@@ -25,6 +27,7 @@ libXfixes.so.3 libxfixes3 #MINVER#
  XFixesQueryExtension@Base 0
  XFixesQueryVersion@Base 0
  XFixesRegionExtents@Base 0
+ XFixesSelectBarrierInput@Base 1:5.0-4
  XFixesSelectCursorInput@Base 0
  XFixesSelectSelectionInput@Base 0
  XFixesSetCursorName@Base 0
diff --git a/include/X11/extensions/Xfixes.h b/include/X11/extensions/Xfixes.h
index 10a7e2e..9b1e03a 100644
--- a/include/X11/extensions/Xfixes.h
+++ b/include/X11/extensions/Xfixes.h
@@ -259,11 +259,48 @@ XFixesCreatePointerBarrier(Display *dpy, Window w, int x1, int y1,
 			   int x2, int y2, int directions,
 			   int num_devices, int *devices);
 
+PointerBarrier
+XFixesCreatePointerBarrierVelocity(Display *dpy, Window w, int x1, int y1,
+			   int x2, int y2, int directions, int velocity,
+			   int num_devices, int *devices);
+
 void
 XFixesDestroyPointerBarrier(Display *dpy, PointerBarrier b);
 
 #endif /* XFIXES_MAJOR = 5 */
 
+#if XFIXES_MAJOR = 6
+
+typedef int32_t BarrierEventID;
+
+typedef struct {
+int type;			/* event base */
+int subtype;
+unsigned long serial;
+Bool send_event;
+Display *display;
+Window window;
+BarrierEventID event_id;
+int directions;
+PointerBarrier barrier;
+int x;
+int y;
+int velocity;
+Time timestamp;
+} XFixesBarrierNotifyEvent;
+
+void
+XFixesSelectBarrierInput (Display	*dpy,
+			 Window		win,
+			 unsigned long	eventMask);
+
+void
+XFixesBarrierReleasePointer(Display *dpy,
+			PointerBarrier b,
+			BarrierEventID event_id);
+
+#endif
+
 _XFUNCPROTOEND
 
 #endif /* _XFIXES_H_ */
diff --git a/src/Cursor.c b/src/Cursor.c
index 0d656f7..e04422d 100644
--- a/src/Cursor.c
+++ b/src/Cursor.c
@@ -334,3 +334,84 @@ XFixesDestroyPointerBarrier(Display *dpy, PointerBarrier b)
 UnlockDisplay (dpy);
 SyncHandle

[PATCH 1/2] dix: Return BadWindow rather than BadMatch from dixLookupWindow

2012-01-04 Thread Christopher James Halse Rogers
dixLookupWindow uses dixLookupDrawable internally, which returns
BadMatch when the XID matches a non-Window drawable.  Users
of dixLookupWindow don't care about this, just that it's not
a valid Window.

This is a generalised version of the fix for X.Org Bug 23562,
where GetProperty was incorrectly returning BadMatch. Auditing other
window requests, all that I checked would incorrectly return BadMatch
in these circumstances.  An incomplete list of calls that could
incorrectly return BadMatch is: ListProperties, SetSelectionOwner,
{Destroy,Map,Unmap}{,Sub}Window.

None of the callers of dixLookupWindow, except for GetProperty, check
for BadMatch

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 dix/dixutils.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/dix/dixutils.c b/dix/dixutils.c
index 00bbde6..9ff91be 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -225,7 +225,15 @@ dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, 
Mask access)
 {
 int rc;
 rc = dixLookupDrawable((DrawablePtr*)pWin, id, client, M_WINDOW, access);
-return (rc == BadDrawable) ? BadWindow : rc;
+/* dixLookupDrawable returns BadMatch iff id is a valid Drawable
+   but is not a Window. Users of dixLookupWindow expect a BadWindow
+   error in this case; they don't care that it's a valid non-Window XID */
+if (rc == BadMatch)
+   rc = BadWindow;
+/* Similarly, users of dixLookupWindow don't want BadDrawable. */
+if (rc == BadDrawable)
+   rc = BadWindow;
+return rc;
 }
 
 int
-- 
1.7.7.3

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


[PATCH 2/2] Revert dix: don't return BadMatch from GetProperty (#23562)

2012-01-04 Thread Christopher James Halse Rogers
This reverts commit f04fe06ae244b851b38be824b1a80f2f8a030591.

dixLookupWindow no longer returns BadMatch. No other caller was checking
for it, so this problem is now fixed in the utility function.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 dix/property.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dix/property.c b/dix/property.c
index a1ae530..d933d5c 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -474,7 +474,7 @@ ProcGetProperty(ClientPtr client)
 }
 rc = dixLookupWindow(pWin, stuff-window, client, win_mode);
 if (rc != Success)
-   return (rc == BadMatch) ? BadWindow : rc;
+   return rc;
 
 if (!ValidAtom(stuff-property))
 {
-- 
1.7.7.3

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


Re: [PATCH] damage: Remove the 'damage window' resource type

2011-03-30 Thread Christopher James Halse Rogers
On Wed, 2011-03-30 at 15:35 +0200, Soeren Sandmann wrote:
 Adam Jackson a...@redhat.com writes:
 
  This may be more correct in that it cleans up the Damage.  I think it's
  less correct in that you break existing clients.  FreeDamageExtWin()
  deletes the Damage XID, but the spec mentions nothing about magically
  garbage-collecting Damages just because their drawable went away.  From
  a quick check, it looks like mutter pushes an error handler around
  XDamageDestroy(), but compiz and kwin do not.
 
 I think window managers have traditionally just handled all errors at
 all times, but that metacity was written to be more precise about it.
 
 It may be that kwin and compiz are already handling these errors even if
 they don't handle them explicitly.
 

When I was looking at compiz 0.9 recently I was somewhat surprised to
find that it eats *all* X errors silently.  It wouldn't surprise me to
find that earlier versions, and kwin, do likewise.



signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 1/5] glx: Factor out glxProbeDriver function.

2011-03-08 Thread Christopher James Halse Rogers
DRI, DRI2 and swrast all had near-identical driver probing logic.
Pull it into glxdricommon

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
Reviewed-by: Adam Jackson a...@redhat.com
---
 glx/glxdri.c   |   44 +--
 glx/glxdri2.c  |   39 ++
 glx/glxdricommon.c |   57 
 glx/glxdricommon.h |5 
 glx/glxdriswrast.c |   42 +
 5 files changed, 77 insertions(+), 110 deletions(-)

diff --git a/glx/glxdri.c b/glx/glxdri.c
index 7717fcf..3a57337 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -858,8 +858,6 @@ static const __DRIextension *loader_extensions[] = {
 
 
 
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
 static Bool
 glxDRIEnterVT (int index, int flags)
 {
@@ -971,13 +969,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 drm_handle_t  hFB;
 intjunk;
 __GLXDRIscreen *screen;
-char filename[128];
 Bool isCapable;
 size_t buffer_size;
 ScrnInfoPtr pScrn = xf86Screens[pScreen-myNum];
 const __DRIconfig **driConfigs;
-const __DRIextension **extensions;
-int i;
 
 if (!xf86LoaderCheckSymbol(DRIQueryDirectRenderingCapable) ||
!DRIQueryDirectRenderingCapable(pScreen, isCapable) ||
@@ -1052,42 +1047,15 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
goto handle_error;
 }
 
-snprintf(filename, sizeof filename, %s/%s_dri.so,
- dri_driver_path, driverName);
-
-screen-driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+screen-driver = glxProbeDriver(driverName,
+   (void **)screen-core,
+   __DRI_CORE, __DRI_CORE_VERSION,
+   (void **)screen-legacy,
+   __DRI_LEGACY, __DRI_LEGACY_VERSION);
 if (screen-driver == NULL) {
-   LogMessage(X_ERROR, AIGLX error: dlopen of %s failed (%s)\n,
-  filename, dlerror());
 goto handle_error;
 }
-
-extensions = dlsym(screen-driver, __DRI_DRIVER_EXTENSIONS);
-if (extensions == NULL) {
-   LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n,
-  driverName, dlerror());
-   goto handle_error;
-}
 
-for (i = 0; extensions[i]; i++) {
-   if (strcmp(extensions[i]-name, __DRI_CORE) == 0 
-   extensions[i]-version = __DRI_CORE_VERSION) {
-   screen-core = (__DRIcoreExtension *) extensions[i];
-   }
-
-   if (strcmp(extensions[i]-name, __DRI_LEGACY) == 0 
-   extensions[i]-version = __DRI_LEGACY_VERSION) {
-   screen-legacy = (__DRIlegacyExtension *) extensions[i];
-   }
-}
-
-if (screen-core == NULL || screen-legacy == NULL) {
-   LogMessage(X_ERROR,
-  AIGLX error: %s does not export required DRI extension\n,
-  driverName);
-   goto handle_error;
-}
-
 /*
  * Get device-specific info.  pDevPriv will point to a struct
  * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that
@@ -1172,7 +1140,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 pScrn-LeaveVT = glxDRILeaveVT;
 
 LogMessage(X_INFO,
-  AIGLX: Loaded and initialized %s\n, filename);
+  AIGLX: Loaded and initialized %s\n, driverName);
 
 return screen-base;
 
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 8d21c93..18927d7 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -599,8 +599,6 @@ static const __DRIextension *loader_extensions[] = {
 NULL
 };
 
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
 static Bool
 glxDRIEnterVT (int index, int flags)
 {
@@ -702,12 +700,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 {
 const char *driverName, *deviceName;
 __GLXDRIscreen *screen;
-char filename[128];
 size_t buffer_size;
 ScrnInfoPtr pScrn = xf86Screens[pScreen-myNum];
-const __DRIextension **extensions;
 const __DRIconfig **driConfigs;
-int i;
 
 screen = calloc(1, sizeof *screen);
 if (screen == NULL)
@@ -729,40 +724,12 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 
 __glXInitExtensionEnableBits(screen-glx_enable_bits);
 
-snprintf(filename, sizeof filename,
-%s/%s_dri.so, dri_driver_path, driverName);
-
-screen-driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+screen-driver = glxProbeDriver(driverName, (void **)screen-core, 
__DRI_CORE, 1,
+   (void **)screen-dri2, __DRI_DRI2, 1);
 if (screen-driver == NULL) {
-   LogMessage(X_ERROR, AIGLX error: dlopen of %s failed (%s)\n,
-  filename, dlerror());
 goto handle_error;
 }
-
-extensions = dlsym(screen-driver, __DRI_DRIVER_EXTENSIONS);
-if (extensions == NULL) {
-   LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n

[PATCH 2/5] Consolidate all the PATH_MAX handling into misc.h

2011-03-08 Thread Christopher James Halse Rogers
Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/common/xf86Configure.c  |5 +
 hw/xfree86/os-support/xf86_OSlib.h |   11 +++
 hw/xfree86/parser/scan.c   |   11 +++
 include/misc.h |   11 +++
 os/access.c|   19 ---
 os/osinit.c|9 +
 os/utils.c |   11 ---
 7 files changed, 19 insertions(+), 58 deletions(-)

diff --git a/hw/xfree86/common/xf86Configure.c 
b/hw/xfree86/common/xf86Configure.c
index 883c48c..c712df7 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -39,6 +39,7 @@
 #include xf86Bus.h
 #include xf86Sbus.h
 #endif
+#include misc.h
 
 typedef struct _DevToConfig {
 GDevRec GDev;
@@ -514,10 +515,6 @@ configureDDCMonitorSection (int screennum)
 return ptr;
 }
 
-#if !defined(PATH_MAX)
-# define PATH_MAX 1024
-#endif
-
 void
 DoConfigure(void)
 {
diff --git a/hw/xfree86/os-support/xf86_OSlib.h 
b/hw/xfree86/os-support/xf86_OSlib.h
index 147a201..24c92fb 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -370,6 +370,9 @@
 
 #include sys/wait.h  /* May need to adjust this for other OSs */
 
+/* For PATH_MAX */
+#include misc.h
+
 /* 
  * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
  * and it's safe, so just do it.
@@ -390,14 +393,6 @@
 # undef _POSIX_SOURCE
 #endif /* _POSIX_SOURCE */
 
-#if !defined(PATH_MAX)
-# if defined(MAXPATHLEN)
-#  define PATH_MAX MAXPATHLEN
-# else
-#  define PATH_MAX 1024
-# endif /* MAXPATHLEN */
-#endif /* !PATH_MAX */
-
 
 #ifndef DEV_MEM
 #define DEV_MEM /dev/mem
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index e4fce30..1cff3bc 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -77,18 +77,13 @@
 #undef _POSIX_SOURCE
 #endif /* _POSIX_SOURCE */
 
-#if !defined(PATH_MAX)
-#if defined(MAXPATHLEN)
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif /* MAXPATHLEN */
-#endif /* !PATH_MAX */
-
 #if !defined(MAXHOSTNAMELEN)
 #define MAXHOSTNAMELEN 32
 #endif /* !MAXHOSTNAMELEN */
 
+/* For PATH_MAX */
+#include misc.h
+
 #include Configint.h
 #include xf86tokens.h
 
diff --git a/include/misc.h b/include/misc.h
index 62d813e..9ab96ac 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -180,6 +180,17 @@ typedef struct _xReq *xReqPtr;
 
 #endif
 
+#ifndef PATH_MAX
+#include sys/param.h
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif 
+
 /**
  * Calculate the number of bytes needed to hold bits.
  * @param bits The minimum number of bits needed.
diff --git a/os/access.c b/os/access.c
index eb1a21d..3856e60 100644
--- a/os/access.c
+++ b/os/access.c
@@ -165,17 +165,6 @@ SOFTWARE.
 
 #endif /* WIN32 */
 
-#ifndef PATH_MAX
-#include sys/param.h
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-#endif 
-
 
 #define X_INCLUDE_NETDB_H
 #include X11/Xos_r.h
@@ -185,14 +174,6 @@ SOFTWARE.
 
 #include xace.h
 
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
 Bool defeatAccessControl = FALSE;
 
 #define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
diff --git a/os/osinit.c b/os/osinit.c
index 018e404..45d202d 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -63,17 +63,10 @@ SOFTWARE.
 #include execinfo.h
 #endif
 
+#include misc.h
 
 #include dixstruct.h
 
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
 
 #if !defined(SYSV)  !defined(WIN32) 
 #include sys/resource.h
diff --git a/os/utils.c b/os/utils.c
index 18fd911..a365aca 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -231,17 +231,6 @@ OsSignal(int sig, OsSigHandlerPtr handler)
 #define LOCK_PREFIX /.X
 #define LOCK_SUFFIX -lock
 
-#ifndef PATH_MAX
-#include sys/param.h
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-#endif
-
 static Bool StillLocking = FALSE;
 static char LockFile[PATH_MAX];
 static Bool nolock = FALSE;
-- 
1.7.4.1

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


[PATCH 1/5] glx: Factor out glxProbeDriver function.

2011-03-08 Thread Christopher James Halse Rogers
DRI, DRI2 and swrast all had near-identical driver probing logic.
Pull it into glxdricommon

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
Reviewed-by: Adam Jackson a...@redhat.com
---
 glx/glxdri.c   |   44 +--
 glx/glxdri2.c  |   39 ++
 glx/glxdricommon.c |   57 
 glx/glxdricommon.h |5 
 glx/glxdriswrast.c |   42 +
 5 files changed, 77 insertions(+), 110 deletions(-)

diff --git a/glx/glxdri.c b/glx/glxdri.c
index 7717fcf..3a57337 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -858,8 +858,6 @@ static const __DRIextension *loader_extensions[] = {
 
 
 
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
 static Bool
 glxDRIEnterVT (int index, int flags)
 {
@@ -971,13 +969,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 drm_handle_t  hFB;
 intjunk;
 __GLXDRIscreen *screen;
-char filename[128];
 Bool isCapable;
 size_t buffer_size;
 ScrnInfoPtr pScrn = xf86Screens[pScreen-myNum];
 const __DRIconfig **driConfigs;
-const __DRIextension **extensions;
-int i;
 
 if (!xf86LoaderCheckSymbol(DRIQueryDirectRenderingCapable) ||
!DRIQueryDirectRenderingCapable(pScreen, isCapable) ||
@@ -1052,42 +1047,15 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
goto handle_error;
 }
 
-snprintf(filename, sizeof filename, %s/%s_dri.so,
- dri_driver_path, driverName);
-
-screen-driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+screen-driver = glxProbeDriver(driverName,
+   (void **)screen-core,
+   __DRI_CORE, __DRI_CORE_VERSION,
+   (void **)screen-legacy,
+   __DRI_LEGACY, __DRI_LEGACY_VERSION);
 if (screen-driver == NULL) {
-   LogMessage(X_ERROR, AIGLX error: dlopen of %s failed (%s)\n,
-  filename, dlerror());
 goto handle_error;
 }
-
-extensions = dlsym(screen-driver, __DRI_DRIVER_EXTENSIONS);
-if (extensions == NULL) {
-   LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n,
-  driverName, dlerror());
-   goto handle_error;
-}
 
-for (i = 0; extensions[i]; i++) {
-   if (strcmp(extensions[i]-name, __DRI_CORE) == 0 
-   extensions[i]-version = __DRI_CORE_VERSION) {
-   screen-core = (__DRIcoreExtension *) extensions[i];
-   }
-
-   if (strcmp(extensions[i]-name, __DRI_LEGACY) == 0 
-   extensions[i]-version = __DRI_LEGACY_VERSION) {
-   screen-legacy = (__DRIlegacyExtension *) extensions[i];
-   }
-}
-
-if (screen-core == NULL || screen-legacy == NULL) {
-   LogMessage(X_ERROR,
-  AIGLX error: %s does not export required DRI extension\n,
-  driverName);
-   goto handle_error;
-}
-
 /*
  * Get device-specific info.  pDevPriv will point to a struct
  * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that
@@ -1172,7 +1140,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 pScrn-LeaveVT = glxDRILeaveVT;
 
 LogMessage(X_INFO,
-  AIGLX: Loaded and initialized %s\n, filename);
+  AIGLX: Loaded and initialized %s\n, driverName);
 
 return screen-base;
 
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 8d21c93..18927d7 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -599,8 +599,6 @@ static const __DRIextension *loader_extensions[] = {
 NULL
 };
 
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
 static Bool
 glxDRIEnterVT (int index, int flags)
 {
@@ -702,12 +700,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 {
 const char *driverName, *deviceName;
 __GLXDRIscreen *screen;
-char filename[128];
 size_t buffer_size;
 ScrnInfoPtr pScrn = xf86Screens[pScreen-myNum];
-const __DRIextension **extensions;
 const __DRIconfig **driConfigs;
-int i;
 
 screen = calloc(1, sizeof *screen);
 if (screen == NULL)
@@ -729,40 +724,12 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 
 __glXInitExtensionEnableBits(screen-glx_enable_bits);
 
-snprintf(filename, sizeof filename,
-%s/%s_dri.so, dri_driver_path, driverName);
-
-screen-driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+screen-driver = glxProbeDriver(driverName, (void **)screen-core, 
__DRI_CORE, 1,
+   (void **)screen-dri2, __DRI_DRI2, 1);
 if (screen-driver == NULL) {
-   LogMessage(X_ERROR, AIGLX error: dlopen of %s failed (%s)\n,
-  filename, dlerror());
 goto handle_error;
 }
-
-extensions = dlsym(screen-driver, __DRI_DRIVER_EXTENSIONS);
-if (extensions == NULL) {
-   LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n

[PATCH 3/5] glx: Use PATH_MAX as size of filename buffer

2011-03-08 Thread Christopher James Halse Rogers
Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 glx/glxdricommon.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index 5569ab7..16f6588 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -215,7 +215,7 @@ glxProbeDriver(const char *driverName,
 {
 int i;
 void *driver;
-char filename[128];
+char filename[PATH_MAX];
 const __DRIextension **extensions;
 
 snprintf(filename, sizeof filename, %s/%s_dri.so,
-- 
1.7.4.1

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


[RFC PATCHv2 4/5] glx: Search for DRI drivers in colon-delimited list of paths.

2011-03-08 Thread Christopher James Halse Rogers
This matches the behaviour of mesa libGL.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
Upon investigating more closely what mesa libGL does to find DRI drivers,
the extra work handling drivers where driCreateScreen fails isn't needed.

 configure.ac   |8 +-
 glx/glxdricommon.c |   75 ---
 2 files changed, 48 insertions(+), 35 deletions(-)

diff --git a/configure.ac b/configure.ac
index 681f9d9..58e1ba0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1243,7 +1243,13 @@ AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, 
[Default PCI text file ID path]
 AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous 
config path])
 AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path])
 dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
-AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
+drisearchdirs=`$PKG_CONFIG --variable=drisearchdirs dri`
+if test -n $drisearchdirs ; then
+   AC_DEFINE_DIR(DRI_DRIVER_PATH, drisearchdirs,
+ [Default DRI search paths])
+else
+   AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
+fi
 AC_DEFINE_UNQUOTED(XVENDORNAME, [$VENDOR_NAME], [Vendor name])
 AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, [$VENDOR_NAME_SHORT], [Short vendor 
name])
 AC_DEFINE_UNQUOTED(XORG_DATE, [$RELEASE_DATE], [Vendor release])
diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index 16f6588..0b250e1 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -217,47 +217,54 @@ glxProbeDriver(const char *driverName,
 void *driver;
 char filename[PATH_MAX];
 const __DRIextension **extensions;
+char *driDriverPath;
+const char *pathStart = dri_driver_path;
+const char *pathEnd = strchr(pathStart, ':');
 
-snprintf(filename, sizeof filename, %s/%s_dri.so,
- dri_driver_path, driverName);
+for (; *pathStart; pathEnd = strchr(pathStart, ':')) {
+   driDriverPath = strndup(pathStart,
+   pathEnd ? pathEnd - pathStart : sizeof 
filename);
+   snprintf(filename, sizeof filename, %s/%s_dri.so,
+driDriverPath, driverName);
+   free(driDriverPath);
+   pathStart = pathEnd ? pathEnd + 1 : pathStart + strlen(pathStart);
 
-driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
-if (driver == NULL) {
-   LogMessage(X_ERROR, AIGLX error: dlopen of %s failed (%s)\n,
-  filename, dlerror());
-   goto cleanup_failure;
-}
+   driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+   if (driver == NULL) {
+   LogMessage(X_INFO, AIGLX: dlopen of %s failed (%s)\n,
+  filename, dlerror());
+   continue;
+   }
 
-extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
-if (extensions == NULL) {
-   LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n,
-  driverName, dlerror());
-   goto cleanup_failure;
-}
-
-for (i = 0; extensions[i]; i++) {
-   if (strcmp(extensions[i]-name, coreName) == 0 
-   extensions[i]-version = coreVersion) {
-   *coreExt = extensions[i];
+   extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
+   if (extensions == NULL) {
+   LogMessage(X_INFO, AIGLX: %s exports no extensions (%s)\n,
+  driverName, dlerror());
+   dlclose(driver);
+   continue;
}
+
+   for (i = 0; extensions[i]; i++) {
+   if (strcmp(extensions[i]-name, coreName) == 0 
+   extensions[i]-version = coreVersion) {
+   *coreExt = (void *)extensions[i];
+   }
 
-   if (strcmp(extensions[i]-name, renderName) == 0 
-   extensions[i]-version = renderVersion) {
-   *renderExt = extensions[i];
+   if (strcmp(extensions[i]-name, renderName) == 0 
+   extensions[i]-version = renderVersion) {
+   *renderExt = (void *)extensions[i];
+   }
}
-}
 
-if (*coreExt == NULL || *renderExt == NULL) {
-   LogMessage(X_ERROR,
-  AIGLX error: %s does not export required DRI extension\n,
-  driverName);
-   goto cleanup_failure;
+   if (*coreExt == NULL || *renderExt == NULL) {
+   LogMessage(X_INFO,
+  AIGLX: %s does not export required DRI extension\n,
+  driverName);
+   *coreExt = *renderExt = NULL;
+   dlclose(driver);
+   continue;
+   }
+   return driver;
 }
-return driver;
-
-cleanup_failure:
-if (driver)
-   dlclose(driver);
-*coreExt = *renderExt = NULL;
 return NULL;
 }
-- 
1.7.4.1

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

[PATCH 5/5] glx: Use GLX rather than AIGLX in ouput strings.

2011-03-08 Thread Christopher James Halse Rogers
If swrast is being used there's nothing “Accelerated” about it

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 glx/glxdri.c   |   36 ++--
 glx/glxdri2.c  |   22 +++---
 glx/glxdricommon.c |6 +++---
 glx/glxdriswrast.c |4 ++--
 4 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/glx/glxdri.c b/glx/glxdri.c
index 3a57337..84a1c4a 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -866,7 +866,7 @@ glxDRIEnterVT (int index, int flags)
 __GLXDRIscreen *screen = (__GLXDRIscreen *) 
glxGetScreen(screenInfo.screens[index]);
 
-LogMessage(X_INFO, AIGLX: Resuming AIGLX clients after VT switch\n);
+LogMessage(X_INFO, GLX: Resuming GLX clients after VT switch\n);
 
 scrn-EnterVT = screen-enterVT;
 
@@ -890,7 +890,7 @@ glxDRILeaveVT (int index, int flags)
 __GLXDRIscreen *screen = (__GLXDRIscreen *)
glxGetScreen(screenInfo.screens[index]);
 
-LogMessage(X_INFO, AIGLX: Suspending AIGLX clients for VT switch\n);
+LogMessage(X_INFO, GLX: Suspending GLX clients for VT switch\n);
 
 glxSuspendClients();
 
@@ -914,7 +914,7 @@ initializeExtensions(__GLXDRIscreen *screen)
__glXEnableExtension(screen-glx_enable_bits,
 GLX_SGI_make_current_read);

-   LogMessage(X_INFO, AIGLX: enabled GLX_SGI_make_current_read\n);
+   LogMessage(X_INFO, GLX: enabled GLX_SGI_make_current_read\n);
}
 #endif
 
@@ -924,7 +924,7 @@ initializeExtensions(__GLXDRIscreen *screen)
__glXEnableExtension(screen-glx_enable_bits,
 GLX_MESA_copy_sub_buffer);

-   LogMessage(X_INFO, AIGLX: enabled GLX_MESA_copy_sub_buffer\n);
+   LogMessage(X_INFO, GLX: enabled GLX_MESA_copy_sub_buffer\n);
}
 #endif
 
@@ -936,14 +936,14 @@ initializeExtensions(__GLXDRIscreen *screen)
__glXEnableExtension(screen-glx_enable_bits,
 GLX_MESA_swap_control);

-   LogMessage(X_INFO, AIGLX: enabled GLX_SGI_swap_control and 
GLX_MESA_swap_control\n);
+   LogMessage(X_INFO, GLX: enabled GLX_SGI_swap_control and 
GLX_MESA_swap_control\n);
}
 #endif
 
 #ifdef __DRI_TEX_OFFSET
if (strcmp(extensions[i]-name, __DRI_TEX_OFFSET) == 0) {
screen-texOffset = (__DRItexOffsetExtension *) extensions[i];
-   LogMessage(X_INFO, AIGLX: enabled GLX_texture_from_pixmap with 
driver support\n);
+   LogMessage(X_INFO, GLX: enabled GLX_texture_from_pixmap with 
driver support\n);
}
 #endif
/* Ignore unknown extensions */
@@ -978,7 +978,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
!DRIQueryDirectRenderingCapable(pScreen, isCapable) ||
!isCapable) {
LogMessage(X_INFO,
-  AIGLX: Screen %d is not DRI capable\n, pScreen-myNum);
+  GLX: Screen %d is not DRI capable\n, pScreen-myNum);
return NULL;
 }
 
@@ -1000,20 +1000,20 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 dri_version.patch = XF86DRI_PATCH_VERSION;
 
 if (!DRIOpenConnection(pScreen, hSAREA, BusID)) {
-   LogMessage(X_ERROR, AIGLX error: DRIOpenConnection failed\n);
+   LogMessage(X_ERROR, GLX error: DRIOpenConnection failed\n);
goto handle_error;
 }
 
 fd = drmOpenOnce(NULL, BusID, newlyopened);
 
 if (fd  0) {
-   LogMessage(X_ERROR, AIGLX error: drmOpenOnce failed (%s)\n,
+   LogMessage(X_ERROR, GLX error: drmOpenOnce failed (%s)\n,
   strerror(-fd));
goto handle_error;
 }
 
 if (drmGetMagic(fd, magic)) {
-   LogMessage(X_ERROR, AIGLX error: drmGetMagic failed\n);
+   LogMessage(X_ERROR, GLX error: drmGetMagic failed\n);
goto handle_error;
 }
 
@@ -1031,7 +1031,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 }
 
 if (newlyopened  !DRIAuthConnection(pScreen, magic)) {
-   LogMessage(X_ERROR, AIGLX error: DRIAuthConnection failed\n);
+   LogMessage(X_ERROR, GLX error: DRIAuthConnection failed\n);
goto handle_error;
 }
 
@@ -1043,7 +1043,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
ddx_version.minor,
ddx_version.patch,
driverName)) {
-   LogMessage(X_ERROR, AIGLX error: DRIGetClientDriverName failed\n);
+   LogMessage(X_ERROR, GLX error: DRIGetClientDriverName failed\n);
goto handle_error;
 }
 
@@ -1065,7 +1065,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 if (!DRIGetDeviceInfo(pScreen, hFB, junk,
  framebuffer.size, framebuffer.stride,
  framebuffer.dev_priv_size, framebuffer.dev_priv)) {
-   LogMessage(X_ERROR, AIGLX error: XF86DRIGetDeviceInfo failed\n);
+   LogMessage(X_ERROR, GLX error: XF86DRIGetDeviceInfo failed\n);
goto handle_error

[PATCH 2/3] glx: Use PATH_MAX as size for filename buffer

2011-03-06 Thread Christopher James Halse Rogers
Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 glx/glxdricommon.c |   13 -
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index 5569ab7..f9f7f5b 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -40,6 +40,17 @@
 #include glxscreens.h
 #include glxdricommon.h
 
+#ifndef PATH_MAX
+#include sys/param.h
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif 
+
 static int
 getUST(int64_t *ust)
 {
@@ -215,7 +226,7 @@ glxProbeDriver(const char *driverName,
 {
 int i;
 void *driver;
-char filename[128];
+char filename[PATH_MAX];
 const __DRIextension **extensions;
 
 snprintf(filename, sizeof filename, %s/%s_dri.so,
-- 
1.7.4.1

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


[PATCH 1/3] glx: Factor out glxProbeDriver function.

2011-03-06 Thread Christopher James Halse Rogers
DRI, DRI2 and swrast all had near-identical driver probing logic.
Pull it into glxdricommon

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 glx/glxdri.c   |   44 +--
 glx/glxdri2.c  |   39 ++
 glx/glxdricommon.c |   57 
 glx/glxdricommon.h |5 
 glx/glxdriswrast.c |   42 +
 5 files changed, 77 insertions(+), 110 deletions(-)

diff --git a/glx/glxdri.c b/glx/glxdri.c
index 7717fcf..3a57337 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -858,8 +858,6 @@ static const __DRIextension *loader_extensions[] = {
 
 
 
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
 static Bool
 glxDRIEnterVT (int index, int flags)
 {
@@ -971,13 +969,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 drm_handle_t  hFB;
 intjunk;
 __GLXDRIscreen *screen;
-char filename[128];
 Bool isCapable;
 size_t buffer_size;
 ScrnInfoPtr pScrn = xf86Screens[pScreen-myNum];
 const __DRIconfig **driConfigs;
-const __DRIextension **extensions;
-int i;
 
 if (!xf86LoaderCheckSymbol(DRIQueryDirectRenderingCapable) ||
!DRIQueryDirectRenderingCapable(pScreen, isCapable) ||
@@ -1052,42 +1047,15 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
goto handle_error;
 }
 
-snprintf(filename, sizeof filename, %s/%s_dri.so,
- dri_driver_path, driverName);
-
-screen-driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+screen-driver = glxProbeDriver(driverName,
+   (void **)screen-core,
+   __DRI_CORE, __DRI_CORE_VERSION,
+   (void **)screen-legacy,
+   __DRI_LEGACY, __DRI_LEGACY_VERSION);
 if (screen-driver == NULL) {
-   LogMessage(X_ERROR, AIGLX error: dlopen of %s failed (%s)\n,
-  filename, dlerror());
 goto handle_error;
 }
-
-extensions = dlsym(screen-driver, __DRI_DRIVER_EXTENSIONS);
-if (extensions == NULL) {
-   LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n,
-  driverName, dlerror());
-   goto handle_error;
-}
 
-for (i = 0; extensions[i]; i++) {
-   if (strcmp(extensions[i]-name, __DRI_CORE) == 0 
-   extensions[i]-version = __DRI_CORE_VERSION) {
-   screen-core = (__DRIcoreExtension *) extensions[i];
-   }
-
-   if (strcmp(extensions[i]-name, __DRI_LEGACY) == 0 
-   extensions[i]-version = __DRI_LEGACY_VERSION) {
-   screen-legacy = (__DRIlegacyExtension *) extensions[i];
-   }
-}
-
-if (screen-core == NULL || screen-legacy == NULL) {
-   LogMessage(X_ERROR,
-  AIGLX error: %s does not export required DRI extension\n,
-  driverName);
-   goto handle_error;
-}
-
 /*
  * Get device-specific info.  pDevPriv will point to a struct
  * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that
@@ -1172,7 +1140,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 pScrn-LeaveVT = glxDRILeaveVT;
 
 LogMessage(X_INFO,
-  AIGLX: Loaded and initialized %s\n, filename);
+  AIGLX: Loaded and initialized %s\n, driverName);
 
 return screen-base;
 
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 8d21c93..18927d7 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -599,8 +599,6 @@ static const __DRIextension *loader_extensions[] = {
 NULL
 };
 
-static const char dri_driver_path[] = DRI_DRIVER_PATH;
-
 static Bool
 glxDRIEnterVT (int index, int flags)
 {
@@ -702,12 +700,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 {
 const char *driverName, *deviceName;
 __GLXDRIscreen *screen;
-char filename[128];
 size_t buffer_size;
 ScrnInfoPtr pScrn = xf86Screens[pScreen-myNum];
-const __DRIextension **extensions;
 const __DRIconfig **driConfigs;
-int i;
 
 screen = calloc(1, sizeof *screen);
 if (screen == NULL)
@@ -729,40 +724,12 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 
 __glXInitExtensionEnableBits(screen-glx_enable_bits);
 
-snprintf(filename, sizeof filename,
-%s/%s_dri.so, dri_driver_path, driverName);
-
-screen-driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+screen-driver = glxProbeDriver(driverName, (void **)screen-core, 
__DRI_CORE, 1,
+   (void **)screen-dri2, __DRI_DRI2, 1);
 if (screen-driver == NULL) {
-   LogMessage(X_ERROR, AIGLX error: dlopen of %s failed (%s)\n,
-  filename, dlerror());
 goto handle_error;
 }
-
-extensions = dlsym(screen-driver, __DRI_DRIVER_EXTENSIONS);
-if (extensions == NULL) {
-   LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n,
-  driverName, dlerror());
-   goto

[RFC PATCH 3/3] glx: Support a colon-separated list of DRI search paths.

2011-03-06 Thread Christopher James Halse Rogers
Mesa's libGL searches a list of paths to find the DRI drivers to load.
It's reasonable for GLX to search in the same paths.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
This obviously requires a mesa change to actually export mesa's list of search
paths.  I'll send that to mesa-dev after discussion here.

This is a bit over-engineered in that it also handles the case where a
matching DRI2 driver is found but createNewScreen fails, and a DRI driver
later in the search path would suceed.

This can be useful for situations like r300 where the default mesa driver
requires KMS but the classic driver supports UMS.

 configure.ac   |8 -
 glx/glxdri.c   |3 +-
 glx/glxdri2.c  |   35 ---
 glx/glxdricommon.c |   78 ---
 glx/glxdricommon.h |2 +-
 glx/glxdriswrast.c |3 +-
 6 files changed, 73 insertions(+), 56 deletions(-)

diff --git a/configure.ac b/configure.ac
index 681f9d9..58e1ba0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1243,7 +1243,13 @@ AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, 
[Default PCI text file ID path]
 AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous 
config path])
 AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path])
 dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
-AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
+drisearchdirs=`$PKG_CONFIG --variable=drisearchdirs dri`
+if test -n $drisearchdirs ; then
+   AC_DEFINE_DIR(DRI_DRIVER_PATH, drisearchdirs,
+ [Default DRI search paths])
+else
+   AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
+fi
 AC_DEFINE_UNQUOTED(XVENDORNAME, [$VENDOR_NAME], [Vendor name])
 AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, [$VENDOR_NAME_SHORT], [Short vendor 
name])
 AC_DEFINE_UNQUOTED(XORG_DATE, [$RELEASE_DATE], [Vendor release])
diff --git a/glx/glxdri.c b/glx/glxdri.c
index 3a57337..4414fa2 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -973,6 +973,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 size_t buffer_size;
 ScrnInfoPtr pScrn = xf86Screens[pScreen-myNum];
 const __DRIconfig **driConfigs;
+void *cookie = NULL;
 
 if (!xf86LoaderCheckSymbol(DRIQueryDirectRenderingCapable) ||
!DRIQueryDirectRenderingCapable(pScreen, isCapable) ||
@@ -1047,7 +1048,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
goto handle_error;
 }
 
-screen-driver = glxProbeDriver(driverName,
+screen-driver = glxProbeDriver(driverName, cookie,
(void **)screen-core,
__DRI_CORE, __DRI_CORE_VERSION,
(void **)screen-legacy,
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 18927d7..9024ff1 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -699,6 +699,7 @@ static __GLXscreen *
 __glXDRIscreenProbe(ScreenPtr pScreen)
 {
 const char *driverName, *deviceName;
+void *cookie = NULL;
 __GLXDRIscreen *screen;
 size_t buffer_size;
 ScrnInfoPtr pScrn = xf86Screens[pScreen-myNum];
@@ -724,24 +725,24 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 
 __glXInitExtensionEnableBits(screen-glx_enable_bits);
 
-screen-driver = glxProbeDriver(driverName, (void **)screen-core, 
__DRI_CORE, 1,
-   (void **)screen-dri2, __DRI_DRI2, 1);
-if (screen-driver == NULL) {
-goto handle_error;
-}
+do {
+   screen-driver = glxProbeDriver(driverName, cookie,
+   (void **)screen-core, __DRI_CORE, 1,
+   (void **)screen-dri2, __DRI_DRI2, 1);
+   if (screen-driver == NULL) {
+   goto handle_error;
+   }
 
-screen-driScreen =
-   (*screen-dri2-createNewScreen)(pScreen-myNum,
-screen-fd,
-loader_extensions,
-driConfigs,
-screen);
-
-if (screen-driScreen == NULL) {
-   LogMessage(X_ERROR,
-  AIGLX error: Calling driver entry point failed\n);
-   goto handle_error;
-}
+   screen-driScreen =
+   (*screen-dri2-createNewScreen)(pScreen-myNum,
+screen-fd,
+loader_extensions,
+driConfigs,
+screen);
+   if (screen-driScreen == NULL)
+   LogMessage(X_INFO,
+  AIGLX: Calling driver entry point failed\n);
+} while (screen-driScreen == NULL);
 
 initializeExtensions(screen);
 
diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index f9f7f5b..c2ebe6e 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -220,7 +220,7

Re: [PATCH v3 11/11] glx: Cleanup DRI2Drawable

2011-02-27 Thread Christopher James Halse Rogers
On Wed, 2011-02-16 at 12:21 +0200, Pauli wrote:
 From: Pauli Nieminen ext-pauli.niemi...@nokia.com
 
 glx should cleanup DRI2Drawable when GLXDrawable is destroyed.
 
 v3:
 * Fix resource destruction order between GLX and DRI2 when client
   disconnects.
 
 Signed-off-by: Pauli Nieminen ext-pauli.niemi...@nokia.com
 ---
  glx/glxdri2.c  |   12 
  hw/xfree86/dri2/dri2.c |   18 ++
  hw/xfree86/dri2/dri2.h |   18 ++
  3 files changed, 48 insertions(+), 0 deletions(-)

For the series:
Reviewed-By: Christopher James Halse Rogers
christopher.halse.rog...@canonical.com


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 2/9] dri2: Refactor interface to take DRI2DrawablePtr

2011-02-03 Thread Christopher James Halse Rogers
 = vals_to_card64(stuff-remainder_lo, stuff-remainder_hi);
  
 -status = DRI2WaitMSC(client, pDrawable, target, divisor, remainder);
 +status = DRI2WaitMSC(client, pPriv, target, divisor, remainder);
  if (status != Success)
   return status;
  
 @@ -502,18 +530,18 @@ static int
  ProcDRI2SwapInterval(ClientPtr client)
  {
  REQUEST(xDRI2SwapIntervalReq);
 -DrawablePtr pDrawable;
 +DRI2DrawablePtr pPriv;
  int status;
  
  /* FIXME: in restart case, client may be gone at this point */
  
  REQUEST_SIZE_MATCH(xDRI2SwapIntervalReq);
  
 -if (!validDrawable(client, stuff-drawable, DixReadAccess | 
 DixWriteAccess,
 -pDrawable, status))
 +if (!validDRI2Drawable(client, stuff-drawable, DixReadAccess | 
 DixWriteAccess,
 +pPriv, status))
   return status;
  
 -DRI2SwapInterval(pDrawable, stuff-interval);
 +DRI2SwapInterval(pPriv, stuff-interval);
  
  return Success;
  }
 @@ -522,18 +550,18 @@ static int
  ProcDRI2WaitSBC(ClientPtr client)
  {
  REQUEST(xDRI2WaitSBCReq);
 -DrawablePtr pDrawable;
 +DRI2DrawablePtr pPriv;
  CARD64 target;
  int status;
  
  REQUEST_SIZE_MATCH(xDRI2WaitSBCReq);
  
 -if (!validDrawable(client, stuff-drawable, DixReadAccess, pDrawable,
 +if (!validDRI2Drawable(client, stuff-drawable, DixReadAccess, pPriv,
  status))
   return status;
  
  target = vals_to_card64(stuff-target_sbc_lo, stuff-target_sbc_hi);
 -status = DRI2WaitSBC(client, pDrawable, target);
 +status = DRI2WaitSBC(client, pPriv, target);
  
  return status;
  }

Other than the minor comment quibble,
Reviewed-By: Christopher James Halse Rogers
christopher.halse.rog...@canonical.com


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 3/9] dri2: Change driver interface to support DRI2Drawable

2011-02-03 Thread Christopher James Halse Rogers
On Thu, 2011-02-03 at 19:48 +0200, Pauli wrote:
 From: Pauli Nieminen ext-pauli.niemi...@nokia.com
 
 To let DRI2Drawable exists longer than Drawable driver has to use
 DRI2DrawablePtr to complete swaps and MSC waits. This allows DRI2 to
 clean up after all operations complete without accessing the freed
 DrawablePtr.
 
 Signed-off-by: Pauli Nieminen ext-pauli.niemi...@nokia.com
 ---
  hw/xfree86/dri2/dri2.c |   69 +++
  hw/xfree86/dri2/dri2.h |   14 +++--
  2 files changed, 45 insertions(+), 38 deletions(-)
 
 diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
 index 91ae1a0..f564822 100644
 --- a/hw/xfree86/dri2/dri2.c
 +++ b/hw/xfree86/dri2/dri2.c
 @@ -137,6 +137,12 @@ DRI2DrawableGetDrawable(DRI2DrawablePtr pPriv)
  return pPriv-drawable;
  }
  
 +ScreenPtr
 +DRI2DrawableGetScreen(DRI2DrawablePtr pPriv)
 +{
 +return pPriv-dri2_screen-screen;
 +}
 +
  static unsigned long
  DRI2DrawableSerial(DrawablePtr pDraw)
  {
 @@ -323,6 +329,14 @@ static int DRI2DrawableGone(pointer p, XID id)
   return Success;
  
  pDraw = pPriv-drawable;
 +
 +if (pPriv-buffers != NULL) {
 + for (i = 0; i  pPriv-bufferCount; i++)
 + (*ds-DestroyBuffer)(pPriv, pPriv-buffers[i]);
 +
 + free(pPriv-buffers);
 +}
 +
  if (pDraw-type == DRAWABLE_WINDOW) {
   pWin = (WindowPtr) pDraw;
   dixSetPrivate(pWin-devPrivates, dri2WindowPrivateKey, NULL);
 @@ -331,13 +345,6 @@ static int DRI2DrawableGone(pointer p, XID id)
   dixSetPrivate(pPixmap-devPrivates, dri2PixmapPrivateKey, NULL);
  }
  
 -if (pPriv-buffers != NULL) {
 - for (i = 0; i  pPriv-bufferCount; i++)
 - (*ds-DestroyBuffer)(pDraw, pPriv-buffers[i]);
 -
 - free(pPriv-buffers);
 -}
 -

I can't see any reason to move the buffer-destruction loop?  If there
isn't, not moving it would make the functional part of this diff more
obvious.

  free(pPriv);
  
  return Success;
 @@ -394,7 +401,7 @@ update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, 
 DrawablePtr pDraw,
  if (pPriv-buffers != NULL) {
   for (i = 0; i  pPriv-bufferCount; i++) {
   if (pPriv-buffers[i] != NULL) {
 - (*ds-DestroyBuffer)(pDraw, pPriv-buffers[i]);
 + (*ds-DestroyBuffer)(pPriv, pPriv-buffers[i]);
   }
   }
  
 @@ -531,7 +538,7 @@ err_out:
  
  for (i = 0; i  count; i++) {
   if (buffers[i] != NULL)
 - (*ds-DestroyBuffer)(pDraw, buffers[i]);
 + (*ds-DestroyBuffer)(pPriv, buffers[i]);
  }
  
  free(buffers);
 @@ -684,14 +691,10 @@ DRI2CanExchange(DrawablePtr pDraw)
  }
  
  void
 -DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
 +DRI2WaitMSCComplete(ClientPtr client, DRI2DrawablePtr pPriv, int frame,
   unsigned int tv_sec, unsigned int tv_usec)
  {
 -DRI2DrawablePtr pPriv;
  
 -pPriv = DRI2GetDrawable(pDraw);
 -if (pPriv == NULL)
 - return;
  
  ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 100) + tv_usec,
frame, pPriv-swap_count);
 @@ -740,33 +743,29 @@ DRI2WakeClient(ClientPtr client, DRI2DrawablePtr pPriv, 
 int frame,
  }
  
  void
 -DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
 +DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr pPriv, int frame,
  unsigned int tv_sec, unsigned int tv_usec, int type,
  DRI2SwapEventPtr swap_complete, void *swap_data)
  {
 -ScreenPtrpScreen = pDraw-pScreen;
 -DRI2DrawablePtr pPriv;
 +DrawablePtr pDraw = pPriv-drawable;
  CARD64  ust = 0;
 -BoxRec  box;
 -RegionRec   region;
 -
 -pPriv = DRI2GetDrawable(pDraw);
 -if (pPriv == NULL) {
 -xf86DrvMsg(pScreen-myNum, X_ERROR,
 -[DRI2] %s: bad drawable\n, __func__);
 - return;
 -}
  
  pPriv-swapsPending--;
  pPriv-swap_count++;
  
 -box.x1 = 0;
 -box.y1 = 0;
 -box.x2 = pDraw-width;
 -box.y2 = pDraw-height;
 -RegionInit(region, box, 0);
 -DRI2CopyRegion(pPriv, region, DRI2BufferFakeFrontLeft,
 -DRI2BufferFrontLeft);
 +
 +if (pDraw) {
 + BoxRec  box;
 + RegionRec   region;
 +
 + box.x1 = 0;
 + box.y1 = 0;
 + box.x2 = pDraw-width;
 + box.y2 = pDraw-height;
 + RegionInit(region, box, 0);
 + DRI2CopyRegion(pPriv, region, DRI2BufferFakeFrontLeft,
 +DRI2BufferFrontLeft);
 +}
  
  ust = ((CARD64)tv_sec * 100) + tv_usec;
  if (swap_complete)
 @@ -839,7 +838,7 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, 
 CARD64 target_msc,
   pPriv-swapsPending++;
  
   (*ds-CopyRegion)(pDraw, region, pDestBuffer, pSrcBuffer);
 - DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
 + DRI2SwapComplete(client, pPriv, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
func, data);
   

Re: [PATCH 4/9] dri2: Add reference counting to DRI2

2011-02-03 Thread Christopher James Halse Rogers
, target_msc, 0, 0);
 @@ -959,8 +983,10 @@ DRI2WaitMSC(ClientPtr client, DRI2DrawablePtr pPriv, 
 CARD64 target_msc,
  }
  
  ret = (*ds-ScheduleWaitMSC)(client, pDraw, target_msc, divisor, 
 remainder);
 -if (!ret)
 +if (!ret) {
 + pPriv-refcnt--;
   return BadDrawable;
 +}
  
  return Success;
  }

Reviewed-By: Christopher James Halse Rogers
christopher.halse.rog...@canonical.com


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 5/9] dri2: Keep DRI2Drawable resource allocated until creator frees it

2011-02-03 Thread Christopher James Halse Rogers
 = DRI2LookupDrawableComplex(client, id, pTmp);
  *status = rc;
  if (rc != Success)
   return FALSE;

Reviewed-By: Christopher James Halse Rogers
christopher.halse.rog...@canonical.com


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 7/9] dri2: Send events only to known clients

2011-02-03 Thread Christopher James Halse Rogers
On Thu, 2011-02-03 at 19:48 +0200, Pauli wrote:
 From: Pauli Nieminen ext-pauli.niemi...@nokia.com
 
 If client disconnects and new client gets same id DRI2 events may end to
 wrong client. DRI2 reference list can be checked to see if the client
 still owns the DRI2Drawable.
 
 Signed-off-by: Pauli Nieminen ext-pauli.niemi...@nokia.com
 ---
  hw/xfree86/dri2/dri2.c |   25 +
  1 files changed, 17 insertions(+), 8 deletions(-)
 
 diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
 index b50206e..12c1f72 100644
 --- a/hw/xfree86/dri2/dri2.c
 +++ b/hw/xfree86/dri2/dri2.c
 @@ -255,7 +255,8 @@ DRI2LookupClientDrawableRef(DRI2DrawablePtr pPriv, 
 ClientPtr client, XID id)
  DRI2DrawableRefPtr ref;
  
  list_for_each_entry(ref, pPriv-reference_list, link) {
 - if (CLIENT_ID(ref-dri2_id) == client-index  ref-id == id)
 + if (CLIENT_ID(ref-dri2_id) == client-index 

If the client has gone then this isn't this a potential use-after-free?

 + (id == 0 || ref-id == id))
   return ref;
  }
  return NULL;
 @@ -739,21 +740,24 @@ void
  DRI2WaitMSCComplete(ClientPtr client, DRI2DrawablePtr pPriv, int frame,
   unsigned int tv_sec, unsigned int tv_usec)
  {
 +DRI2DrawableRefPtr ref = DRI2LookupClientDrawableRef(pPriv, client, 0);
 +ClientPtr blockedClient = pPriv-blockedClient;
 +
 +pPriv-blockedClient = NULL;
 +pPriv-blockedOnMsc = FALSE;
  pPriv-refcnt--;
  
 -if (pPriv-refcnt == 0) {
 - DRI2DrawableGone(pPriv, 0);
 +if (ref == NULL) {
 + if (pPriv-refcnt == 0)
 + DRI2DrawableGone(pPriv, 0);
   return;
  }
  
  ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 100) + tv_usec,
frame, pPriv-swap_count);
  
 -if (pPriv-blockedClient)
 - AttendClient(pPriv-blockedClient);
 -
 -pPriv-blockedClient = NULL;
 -pPriv-blockedOnMsc = FALSE;
 +if (blockedClient)
 + AttendClient(blockedClient);
  }
  
  static void
 @@ -806,6 +810,7 @@ DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr pPriv, 
 int frame,
  DRI2SwapEventPtr swap_complete, void *swap_data)
  {
  DRI2SwapCompleteDataPtr pSwapData = swap_data;
 +DRI2DrawableRefPtr ref = DRI2LookupClientDrawableRef(pPriv, client, 0);
  DrawablePtr pDraw = pPriv-drawable;
  CARD64  ust = 0;
  
 @@ -813,6 +818,9 @@ DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr pPriv, 
 int frame,
  pPriv-swap_count++;
  pPriv-refcnt--;
  
 +if (ref == NULL)
 + goto out;
 +
  if (pDraw) {
   BoxRec  box;
   RegionRec   region;
 @@ -836,6 +844,7 @@ DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr pPriv, 
 int frame,
  
  DRI2WakeClient(client, pPriv, frame, tv_sec, tv_usec);
  
 +out:
  free_swap_complete_data(pPriv, pSwapData);
  
  if (pPriv-refcnt == 0)




signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 8/9] dri2: copy front to fake front in SwapBuffers

2011-02-03 Thread Christopher James Halse Rogers
On Thu, 2011-02-03 at 19:48 +0200, Pauli wrote:
 From: Pauli Nieminen ext-pauli.niemi...@nokia.com
 
 DRI2SwapComplete is too late for front to fake front copy if swap is
 completed asynchronously. Client could be able to use fake front already
 before swap completes.
 
 Moving front to fake front solves the problem but requires that driver
 is capable to copy from new front to fake front immediately after
 ScheduleSwap hook returns.
 
 Signed-off-by: Pauli Nieminen ext-pauli.niemi...@nokia.com
 ---
  hw/xfree86/dri2/dri2.c |   34 --
  1 files changed, 20 insertions(+), 14 deletions(-)
 
 diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
 index 12c1f72..604930c 100644
 --- a/hw/xfree86/dri2/dri2.c
 +++ b/hw/xfree86/dri2/dri2.c
 @@ -811,7 +811,6 @@ DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr pPriv, 
 int frame,
  {
  DRI2SwapCompleteDataPtr pSwapData = swap_data;
  DRI2DrawableRefPtr ref = DRI2LookupClientDrawableRef(pPriv, client, 0);
 -DrawablePtr pDraw = pPriv-drawable;
  CARD64  ust = 0;
  
  pPriv-swapsPending--;
 @@ -821,19 +820,6 @@ DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr 
 pPriv, int frame,
  if (ref == NULL)
   goto out;
  
 -if (pDraw) {
 - BoxRec  box;
 - RegionRec   region;
 -
 - box.x1 = 0;
 - box.y1 = 0;
 - box.x2 = pDraw-width;
 - box.y2 = pDraw-height;
 - RegionInit(region, box, 0);
 - DRI2CopyRegion(pPriv, region, DRI2BufferFakeFrontLeft,
 -DRI2BufferFrontLeft);
 -}
 -
  ust = ((CARD64)tv_sec * 100) + tv_usec;
  if (swap_complete)
   swap_complete(client, pSwapData-data, type, ust, frame,
 @@ -868,6 +854,23 @@ DRI2WaitSwap(ClientPtr client, DRI2DrawablePtr pPriv)
  return FALSE;
  }
  
 +static void
 +DRI2CopyFrontToFakeFront(DrawablePtr pDraw, DRI2DrawablePtr pPriv)
 +{
 +if (pDraw) {
 + BoxRec  box;
 + RegionRec   region;
 +
 + box.x1 = 0;
 + box.y1 = 0;
 + box.x2 = pDraw-width;
 + box.y2 = pDraw-height;
 + RegionInit(region, box, 0);
 + DRI2CopyRegion(pPriv, region, DRI2BufferFakeFrontLeft,
 +DRI2BufferFrontLeft);
 +}
 +}
 +
  int
  DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, CARD64 target_msc,
   CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
 @@ -933,6 +936,8 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, 
 CARD64 target_msc,
   (*ds-CopyRegion)(pDraw, region, pDestBuffer, pSrcBuffer);
   DRI2SwapComplete(client, pPriv, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
func, pSwapData);
 +
 + DRI2CopyFrontToFakeFront(pDraw, pPriv);

It doesn't make any functional difference, but wouldn't it make more
sense to copy to the fake front before calling SwapComplete?

   return Success;
  }
  
 @@ -991,6 +996,7 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, 
 CARD64 target_msc,
  
  DRI2InvalidateDrawable(pPriv);
  
 +DRI2CopyFrontToFakeFront(pDraw, pPriv);
  return Success;
  }
  

Reviewed-By: Christopher James Halse Rogers
christopher.halse.rog...@canonical.com


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 9/9] glx: Cleanup DRI2Drawable

2011-02-03 Thread Christopher James Halse Rogers
On Thu, 2011-02-03 at 19:48 +0200, Pauli wrote:
 From: Pauli Nieminen ext-pauli.niemi...@nokia.com
 
 glx should cleanup DRI2Drawable when GLXDrawable is destroyed.
 
 Signed-off-by: Pauli Nieminen ext-pauli.niemi...@nokia.com
 ---
  glx/glxdri2.c |6 ++
  1 files changed, 6 insertions(+), 0 deletions(-)
 
 diff --git a/glx/glxdri2.c b/glx/glxdri2.c
 index 027615a..79d7f55 100644
 --- a/glx/glxdri2.c
 +++ b/glx/glxdri2.c
 @@ -89,6 +89,8 @@ struct __GLXDRIdrawable {
  __DRIdrawable*driDrawable;
  __GLXDRIscreen   *screen;
  DRI2DrawablePtr pDRI2Draw;
 +XID id;
 +ClientPtr   client;
  
  /* Dimensions as last reported by DRI2GetBuffers. */
  int width;
 @@ -102,6 +104,8 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable)
  {
  __GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
  const __DRIcoreExtension *core = private-screen-core;
 +
 +DRI2DestroyDrawable(private-client, private-pDRI2Draw, private-id);
  
  (*core-destroyDrawable)(private-driDrawable);
  
 @@ -479,6 +483,8 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
  }
  
  private-pDRI2Draw = DRI2GetDrawable(pDraw);
 +private-id= drawId;
 +private-client= client;
  
  private-driDrawable =
   (*driScreen-dri2-createNewDrawable)(driScreen-driScreen,

Reviewed-By: Christopher James Halse Rogers
christopher.halse.rog...@canonical.com


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] randr: Add additional cursor confinement hook in the ScreenRec

2010-12-20 Thread Christopher James Halse Rogers
On Mon, 2010-11-15 at 16:23 -0500, Adam Jackson wrote:
 And use it to confine cursor motion to within the bounds of a single
 CRTC, iff all the CRTCs within a ScreenRec are reachable from each
 other.  If not you get the same cursor floats within the bounding rect
 behaviour you get now.
 
 v2:
 - Fix a read-from-uninitialized typo in crtcs_adjacent
 - Silence a warning from crtc_bounds
 - Avoid over-exposing miPointerRec to the rest of DIX
 - Replace clever matrix math with simple depthi-first-search code from
   Mikhail Gusarov
 
 Signed-off-by: Adam Jackson a...@redhat.com
 ---
  include/scrnintstr.h |4 +
  mi/mipointer.c   |3 +
  randr/randr.c|2 +
  randr/randrstr.h |4 +
  randr/rrcrtc.c   |  154 
 ++
  5 files changed, 167 insertions(+), 0 deletions(-)
 

git chokes with conflicts with Keith's RandR 1.4 stuff on master,
although it's trivial to unconfuse it.

 diff --git a/include/scrnintstr.h b/include/scrnintstr.h
 index cd4fb70..ddd564d 100644
 --- a/include/scrnintstr.h
 +++ b/include/scrnintstr.h
 @@ -453,6 +453,9 @@ typedefvoid (* DeviceCursorCleanupProcPtr)(
  DeviceIntPtr /* pDev */,
  ScreenPtr/* pScreen */);
  
 +typedef void (*ConstrainCursorHarderProcPtr)(
 +   DeviceIntPtr, ScreenPtr, int *, int *);
 +
  typedef struct _Screen {
  int  myNum;  /* index of this instance in Screens[] 
 */
  ATOM id;
 @@ -533,6 +536,7 @@ typedef struct _Screen {
  /* Cursor Procedures */
  
  ConstrainCursorProcPtr   ConstrainCursor;
 +ConstrainCursorHarderProcPtr ConstrainCursorHarder;
  CursorLimitsProcPtr  CursorLimits;
  DisplayCursorProcPtr DisplayCursor;
  RealizeCursorProcPtr RealizeCursor;
 diff --git a/mi/mipointer.c b/mi/mipointer.c
 index 554397a..9bfabb7 100644
 --- a/mi/mipointer.c
 +++ b/mi/mipointer.c
 @@ -529,6 +529,9 @@ miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y)
  if (*y = pPointer-limits.y2)
   *y = pPointer-limits.y2 - 1;
  
 +if (pScreen-ConstrainCursorHarder)
 +   pScreen-ConstrainCursorHarder(pDev, pScreen, x, y);
 +
  if (pPointer-x == *x  pPointer-y == *y  
  pPointer-pScreen == pScreen) 
  return;
 diff --git a/randr/randr.c b/randr/randr.c
 index 6077705..d337129 100644
 --- a/randr/randr.c
 +++ b/randr/randr.c
 @@ -270,6 +270,8 @@ Bool RRScreenInit(ScreenPtr pScreen)
  
  wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen);
  
 +pScreen-ConstrainCursorHarder = RRConstrainCursorHarder;
 +
  pScrPriv-numOutputs = 0;
  pScrPriv-outputs = NULL;
  pScrPriv-numCrtcs = 0;
 diff --git a/randr/randrstr.h b/randr/randrstr.h
 index 7ea6080..048e827 100644
 --- a/randr/randrstr.h
 +++ b/randr/randrstr.h
 @@ -297,6 +297,7 @@ typedef struct _rrScrPriv {
  int  rate;
  int  size;
  #endif
 +Bool   discontiguous;
  } rrScrPrivRec, *rrScrPrivPtr;
  
  extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec;
 @@ -700,6 +701,9 @@ ProcRRGetPanning (ClientPtr client);
  int
  ProcRRSetPanning (ClientPtr client);
  
 +void
 +RRConstrainCursorHarder (DeviceIntPtr, ScreenPtr, int *, int *);
 +
  /* rrdispatch.c */
  extern _X_EXPORT Bool
  RRClientKnowsRates (ClientPtrpClient);
 diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
 index 98206a2..9af4a38 100644
 --- a/randr/rrcrtc.c
 +++ b/randr/rrcrtc.c
 @@ -1,5 +1,6 @@
  /*
   * Copyright © 2006 Keith Packard
 + * Copyright 2010 Red Hat, Inc
   *
   * Permission to use, copy, modify, distribute, and sell this software and 
 its
   * documentation for any purpose is hereby granted without fee, provided that
 @@ -22,6 +23,7 @@
  
  #include randrstr.h
  #include swaprep.h
 +#include mipointer.h
  
  RESTYPE  RRCrtcType;
  
 @@ -292,6 +294,91 @@ RRCrtcPendingProperties (RRCrtcPtr crtc)
  return FALSE;
  }
  
 +static void
 +crtc_bounds(RRCrtcPtr crtc, int *left, int *right, int *top, int *bottom)
 +{
 +*left = crtc-x;
 +*top = crtc-y;
 +
 +switch (crtc-rotation) {
 +case RR_Rotate_0:
 +case RR_Rotate_180:
 +default:
 +   *right = crtc-x + crtc-mode-mode.width;
 +   *bottom = crtc-y + crtc-mode-mode.height;
 +   return;
 +case RR_Rotate_90:
 +case RR_Rotate_270:
 +   *right = crtc-x + crtc-mode-mode.height;
 +   *bottom = crtc-y + crtc-mode-mode.width;
 +   return;
 +}
 +}
 +
 +/* overlapping counts as adjacent */
 +static Bool
 +crtcs_adjacent(const RRCrtcPtr a, const RRCrtcPtr b)
 +{
 +int al, ar, at, ab;
 +int bl, br, bt, bb;
 +int cl, cr, ct, cb;

The purpose of al, ar, bl, br etc are relatively from the nameing, but
the cl etc aren't.  It's a short function and staring at it for a moment
makes these clear, but maybe these could get more descriptive names to
save us poor hard-of-thinking folks?

 +
 +crtc_bounds(a, al, ar, at, ab);
 +  

Re: Reviewed patches from the Ubuntu tree

2010-12-19 Thread Christopher James Halse Rogers
On Tue, 2010-12-14 at 14:55 -0500, Adam Jackson wrote:
 On Mon, 2010-12-06 at 11:23 +1100, Christopher James Halse Rogers wrote:
  I've been cleaning up the Ubuntu X packages, and I've run across some 
  patches
  that have been reviewed some time ago but aren't yet in master.
  
  Resending them, since I've clearly dropped them on the floor at one point.
 
 Keith, please merge.

Ping?  The sync fixes resolve some fairly visible and annoying behaviour
with an uninterruptible fade in gnome-screensaver.


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 1/2] DRI2: Reference count buffers across SwapBuffers

2010-12-08 Thread Christopher James Halse Rogers
On Wed, 2010-12-08 at 17:47 +0200, Pauli Nieminen wrote:
 On 08/12/10 07:56 +0100, ext Christopher James Halse Rogers wrote:
  The SwapBuffers request requires that we trigger the swap at some point
  in the future.  Sane drivers implement this by passing this request to
  something that will trigger a callback with the buffer pointers
  at the appropriate time.
  
  The client can cause those buffers to be freed in X before the trigger
  occurs, most easily by quitting.  This leads to a server crash in
  the driver when trying to do the swap.
  
  See http://bugs.freedesktop.org/show_bug.cgi?id=29065 for Radeon and
  https://bugs.freedesktop.org/show_bug.cgi?id=28080 for Intel.
  
 
 Could this reference counting be applied to DRI2Drawable instead of per
 buffer?

I don't think so.  The life cycle of a buffer isn't the same as that of
its parent DRI2Drawable - client requests can cause a buffer attached to
a living DRI2Drawable to be freed.

This patch means we potentially do the unuseful work of swapping buffers
which will immediately be freed if the client schedules a swap then
causes the buffers to be reallocated.

With more invasive API changes we could give drivers an opportunity to
handle this by marking existing swap requests as invalid, so it could
bail early.

 
 But in any case this looks like good idea. I didn't yet have to have detailed
 look what is inside the patch.
 
  Signed-off-by: Christopher James Halse Rogers 
  christopher.halse.rog...@canonical.com
  ---
   hw/xfree86/dri2/dri2.c |   98 
  ++-
   hw/xfree86/dri2/dri2.h |1 +
   2 files changed, 80 insertions(+), 19 deletions(-)
  
  diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
  index e4693d9..6da2e17 100644
  --- a/hw/xfree86/dri2/dri2.c
  +++ b/hw/xfree86/dri2/dri2.c
  @@ -107,12 +107,41 @@ typedef struct _DRI2Screen {
   ConfigNotifyProcPtr ConfigNotify;
   } DRI2ScreenRec;
   
  +typedef struct _DRI2SwapCompleteDataRec {
  +DRI2BufferPtr  src;
  +DRI2BufferPtr  dest;
  +void * data;
  +} DRI2SwapCompleteDataRec, *DRI2SwapCompleteDataPtr;
  +
   static DRI2ScreenPtr
   DRI2GetScreen(ScreenPtr pScreen)
   {
   return dixLookupPrivate(pScreen-devPrivates, dri2ScreenPrivateKey);
   }
   
  +static void
  +buffer_ref(DRI2BufferPtr buffer)
  +{
  +buffer-refcnt++;
  +}
  +
  +static void
  +buffer_unref(DrawablePtr pDraw, DRI2BufferPtr buffer)
  +{
  +DRI2ScreenPtr ds;
  +if (buffer-refcnt == 0) {
  +   xf86DrvMsg(pDraw-pScreen-myNum, X_ERROR,
  +   [DRI2] Attempt to unreference already freed buffer ignored\n);
  +   return;
  +}
  +
  +buffer-refcnt--;
  +if (buffer-refcnt == 0) {
  +   ds = DRI2GetScreen(pDraw-pScreen);
  +   (*ds-DestroyBuffer)(pDraw, buffer);
  +}
  +}
  +
   static DRI2DrawablePtr
   DRI2GetDrawable(DrawablePtr pDraw)
   {
  @@ -261,7 +290,6 @@ DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, 
  XID id,
   static int DRI2DrawableGone(pointer p, XID id)
   {
   DRI2DrawablePtr pPriv = p;
  -DRI2ScreenPtr   ds = pPriv-dri2_screen;
   DRI2DrawableRefPtr ref, next;
   WindowPtr pWin;
   PixmapPtr pPixmap;
  @@ -300,7 +328,7 @@ static int DRI2DrawableGone(pointer p, XID id)
   
   if (pPriv-buffers != NULL) {
  for (i = 0; i  pPriv-bufferCount; i++)
  -   (*ds-DestroyBuffer)(pDraw, pPriv-buffers[i]);
  +   buffer_unref(pDraw, pPriv-buffers[i]);
   
  free(pPriv-buffers);
   }
  @@ -341,6 +369,7 @@ allocate_or_reuse_buffer(DrawablePtr pDraw, 
  DRI2ScreenPtr ds,
  || !dimensions_match
  || (pPriv-buffers[old_buf]-format != format)) {
  *buffer = (*ds-CreateBuffer)(pDraw, attachment, format);
  +   buffer_ref(*buffer);
  pPriv-serialNumber = DRI2DrawableSerial(pDraw);
  return TRUE;
   
  @@ -355,13 +384,12 @@ static void
   update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
   DRI2BufferPtr *buffers, int *out_count, int 
  *width, int *height)
   {
  -DRI2ScreenPtr   ds = DRI2GetScreen(pDraw-pScreen);
   int i;
   
   if (pPriv-buffers != NULL) {
  for (i = 0; i  pPriv-bufferCount; i++) {
  if (pPriv-buffers[i] != NULL) {
  -   (*ds-DestroyBuffer)(pDraw, pPriv-buffers[i]);
  +   buffer_unref(pDraw, pPriv-buffers[i]);
  }
  }
   
  @@ -498,7 +526,7 @@ err_out:
   
   for (i = 0; i  count; i++) {
  if (buffers[i] != NULL)
  -   (*ds-DestroyBuffer)(pDraw, buffers[i]);
  +   buffer_unref(pDraw, buffers[i]);
   }
   
   free(buffers);
  @@ -708,21 +736,31 @@ DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, 
  int frame,
   }
   }
   
  +static void
  +free_swap_complete_data (DrawablePtr pDraw, DRI2SwapCompleteDataPtr 
  pSwapData)
  +{
  +buffer_unref(pDraw, pSwapData-src);
  +buffer_unref(pDraw, pSwapData-dest);
  +free(pSwapData);
  +}
  +
   void

Factor out drivers' DRI2 buffer counting logic

2010-12-07 Thread Christopher James Halse Rogers
The DRI2 SwapBuffers request requires drivers to defer the swap work
until some point in the future.  It's entirely possible for the client
that requested the swap to go away before that trigger occurs, resulting
in DRI2 buffers being freed in DRI2DrawableGone and then the swap
event crashing the server trying to access the freed buffers.

The relevant (fixed) crasher bugs are
Intel: https://bugs.freedesktop.org/show_bug.cgi?id=28080
Radeon: http://bugs.freedesktop.org/show_bug.cgi?id=29065

I haven't tested nouveau's new pageflipping support, but it looks like
it suffers the same problem.

Since the big three drivers all suffer this problem, and all
need to solve it in the same way, it might as well be done
in DRI2 itself.

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


[PATCH 1/2] DRI2: Reference count buffers across SwapBuffers

2010-12-07 Thread Christopher James Halse Rogers
The SwapBuffers request requires that we trigger the swap at some point
in the future.  Sane drivers implement this by passing this request to
something that will trigger a callback with the buffer pointers
at the appropriate time.

The client can cause those buffers to be freed in X before the trigger
occurs, most easily by quitting.  This leads to a server crash in
the driver when trying to do the swap.

See http://bugs.freedesktop.org/show_bug.cgi?id=29065 for Radeon and
https://bugs.freedesktop.org/show_bug.cgi?id=28080 for Intel.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/dri2/dri2.c |   98 ++-
 hw/xfree86/dri2/dri2.h |1 +
 2 files changed, 80 insertions(+), 19 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index e4693d9..6da2e17 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -107,12 +107,41 @@ typedef struct _DRI2Screen {
 ConfigNotifyProcPtr ConfigNotify;
 } DRI2ScreenRec;
 
+typedef struct _DRI2SwapCompleteDataRec {
+DRI2BufferPtr  src;
+DRI2BufferPtr  dest;
+void * data;
+} DRI2SwapCompleteDataRec, *DRI2SwapCompleteDataPtr;
+
 static DRI2ScreenPtr
 DRI2GetScreen(ScreenPtr pScreen)
 {
 return dixLookupPrivate(pScreen-devPrivates, dri2ScreenPrivateKey);
 }
 
+static void
+buffer_ref(DRI2BufferPtr buffer)
+{
+buffer-refcnt++;
+}
+
+static void
+buffer_unref(DrawablePtr pDraw, DRI2BufferPtr buffer)
+{
+DRI2ScreenPtr ds;
+if (buffer-refcnt == 0) {
+   xf86DrvMsg(pDraw-pScreen-myNum, X_ERROR,
+   [DRI2] Attempt to unreference already freed buffer ignored\n);
+   return;
+}
+
+buffer-refcnt--;
+if (buffer-refcnt == 0) {
+   ds = DRI2GetScreen(pDraw-pScreen);
+   (*ds-DestroyBuffer)(pDraw, buffer);
+}
+}
+
 static DRI2DrawablePtr
 DRI2GetDrawable(DrawablePtr pDraw)
 {
@@ -261,7 +290,6 @@ DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID 
id,
 static int DRI2DrawableGone(pointer p, XID id)
 {
 DRI2DrawablePtr pPriv = p;
-DRI2ScreenPtr   ds = pPriv-dri2_screen;
 DRI2DrawableRefPtr ref, next;
 WindowPtr pWin;
 PixmapPtr pPixmap;
@@ -300,7 +328,7 @@ static int DRI2DrawableGone(pointer p, XID id)
 
 if (pPriv-buffers != NULL) {
for (i = 0; i  pPriv-bufferCount; i++)
-   (*ds-DestroyBuffer)(pDraw, pPriv-buffers[i]);
+   buffer_unref(pDraw, pPriv-buffers[i]);
 
free(pPriv-buffers);
 }
@@ -341,6 +369,7 @@ allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr 
ds,
|| !dimensions_match
|| (pPriv-buffers[old_buf]-format != format)) {
*buffer = (*ds-CreateBuffer)(pDraw, attachment, format);
+   buffer_ref(*buffer);
pPriv-serialNumber = DRI2DrawableSerial(pDraw);
return TRUE;
 
@@ -355,13 +384,12 @@ static void
 update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
 DRI2BufferPtr *buffers, int *out_count, int 
*width, int *height)
 {
-DRI2ScreenPtr   ds = DRI2GetScreen(pDraw-pScreen);
 int i;
 
 if (pPriv-buffers != NULL) {
for (i = 0; i  pPriv-bufferCount; i++) {
if (pPriv-buffers[i] != NULL) {
-   (*ds-DestroyBuffer)(pDraw, pPriv-buffers[i]);
+   buffer_unref(pDraw, pPriv-buffers[i]);
}
}
 
@@ -498,7 +526,7 @@ err_out:
 
 for (i = 0; i  count; i++) {
if (buffers[i] != NULL)
-   (*ds-DestroyBuffer)(pDraw, buffers[i]);
+   buffer_unref(pDraw, buffers[i]);
 }
 
 free(buffers);
@@ -708,21 +736,31 @@ DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int 
frame,
 }
 }
 
+static void
+free_swap_complete_data (DrawablePtr pDraw, DRI2SwapCompleteDataPtr pSwapData)
+{
+buffer_unref(pDraw, pSwapData-src);
+buffer_unref(pDraw, pSwapData-dest);
+free(pSwapData);
+}
+
 void
 DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
   unsigned int tv_sec, unsigned int tv_usec, int type,
   DRI2SwapEventPtr swap_complete, void *swap_data)
 {
-ScreenPtr  pScreen = pDraw-pScreen;
-DRI2DrawablePtr pPriv;
-CARD64  ust = 0;
-BoxRec  box;
-RegionRec   region;
+ScreenPtr  pScreen = pDraw-pScreen;
+DRI2DrawablePtr pPriv;
+CARD64  ust = 0;
+BoxRec  box;
+RegionRec   region;
+DRI2SwapCompleteDataPtr pSwapData = swap_data;
 
 pPriv = DRI2GetDrawable(pDraw);
 if (pPriv == NULL) {
 xf86DrvMsg(pScreen-myNum, X_ERROR,
   [DRI2] %s: bad drawable\n, __func__);
+   free_swap_complete_data(pDraw, pSwapData);
return;
 }
 
@@ -739,12 +777,15 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int 
frame,
 
 ust = ((CARD64)tv_sec * 100) + tv_usec

[PATCH 2/2] DRI2: Track clients' outstanding swap requests.

2010-12-07 Thread Christopher James Halse Rogers
Clients can terminate with pending SwapBuffers requests waiting
for the trigger, potentially a long way in the future.
Track these requests so we don't end up delivering
SwapBuffersComplete to an entirely unrelated client.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/dri2/dri2.c |   54 +--
 1 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 6da2e17..37648bd 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -60,6 +60,9 @@ static DevPrivateKeyRec dri2WindowPrivateKeyRec;
 static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
 #define dri2PixmapPrivateKey (dri2PixmapPrivateKeyRec)
 
+static DevPrivateKeyRec dri2ClientPrivateKeyRec;
+#define dri2ClientPrivateKey (dri2ClientPrivateKeyRec)
+
 static RESTYPE   dri2DrawableRes;
 
 typedef struct _DRI2Screen *DRI2ScreenPtr;
@@ -111,8 +114,16 @@ typedef struct _DRI2SwapCompleteDataRec {
 DRI2BufferPtr  src;
 DRI2BufferPtr  dest;
 void * data;
+Bool   clientGone;
+struct listlink;
 } DRI2SwapCompleteDataRec, *DRI2SwapCompleteDataPtr;
 
+static struct list *
+DRI2GetClientEventList(ClientPtr client)
+{
+return dixLookupPrivate(client-devPrivates, dri2ClientPrivateKey);
+}
+
 static DRI2ScreenPtr
 DRI2GetScreen(ScreenPtr pScreen)
 {
@@ -739,6 +750,7 @@ DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int 
frame,
 static void
 free_swap_complete_data (DrawablePtr pDraw, DRI2SwapCompleteDataPtr pSwapData)
 {
+list_del(pSwapData-link);
 buffer_unref(pDraw, pSwapData-src);
 buffer_unref(pDraw, pSwapData-dest);
 free(pSwapData);
@@ -776,15 +788,16 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int 
frame,
   DRI2BufferFrontLeft);
 
 ust = ((CARD64)tv_sec * 100) + tv_usec;
-if (swap_complete)
+if (swap_complete  !pSwapData-clientGone)
swap_complete(client, pSwapData-data, type, ust, frame,
  pPriv-swap_count);
 
 pPriv-last_swap_msc = frame;
 pPriv-last_swap_ust = ust;
 
-DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
-
+if (!pSwapData-clientGone)
+   DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
+
 free_swap_complete_data(pDraw, pSwapData);
 }
 
@@ -817,6 +830,7 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 
target_msc,
 DRI2DrawablePtr pPriv;
 DRI2BufferPtr   pDestBuffer = NULL, pSrcBuffer = NULL;
 DRI2SwapCompleteDataPtr pSwapData;
+struct list *  clientEvents = DRI2GetClientEventList(client);
 int ret, i;
 CARD64  ust, current_msc;
 
@@ -855,6 +869,8 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 
target_msc,
 pSwapData-src = pSrcBuffer;
 pSwapData-dest = pDestBuffer;
 pSwapData-data = data;
+pSwapData-clientGone = FALSE;
+list_add (pSwapData-link, clientEvents);
 
 /* Old DDX or no swap interval, just blit */
 if (!ds-ScheduleSwap || !pPriv-swap_interval) {
@@ -1137,6 +1153,9 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 if (!dixRegisterPrivateKey(dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
return FALSE;
 
+if (!dixRegisterPrivateKey(dri2ClientPrivateKeyRec, PRIVATE_CLIENT, 
sizeof (struct list)))
+   return FALSE;
+
 ds = calloc(1, sizeof *ds);
 if (!ds)
return FALSE;
@@ -1226,6 +1245,34 @@ DRI2CloseScreen(ScreenPtr pScreen)
 dixSetPrivate(pScreen-devPrivates, dri2ScreenPrivateKey, NULL);
 }
 
+static void
+DRI2ClientCallback(CallbackListPtr *ClientStateCallback, pointer closure, 
pointer calldata)
+{
+NewClientInfoRec *clientinfo = calldata;
+ClientPtr pClient = clientinfo-client;
+struct list *clientEvents = DRI2GetClientEventList(pClient);
+DRI2SwapCompleteDataPtr ref, next;
+
+switch (pClient-clientState) {
+   case ClientStateInitial:
+   list_init(clientEvents);
+   break;
+   case ClientStateRunning:
+   break;
+   case ClientStateRetained:
+   case ClientStateGone:
+   if (clientEvents) {
+   list_for_each_entry_safe(ref, next, clientEvents, link) {
+   ref-clientGone = TRUE;
+   list_del(ref-link);
+   }
+   }
+   break;
+   default:
+   break;
+}
+}
+
 extern ExtensionModule dri2ExtensionModule;
 
 static pointer
@@ -1238,6 +1285,7 @@ DRI2Setup(pointer module, pointer opts, int *errmaj, int 
*errmin)
 if (!setupDone)
 {
setupDone = TRUE;
+   AddCallback(ClientStateCallback, DRI2ClientCallback, NULL);
LoadExtension(dri2ExtensionModule, FALSE);
 }
 else
-- 
1.7.2.3

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

[PATCH 3/3] Add EDID quirk for HP Compaq nc8430.

2010-12-05 Thread Christopher James Halse Rogers
From: Jörn Horstmann launch...@planetxml.de

Like some other LPL panels, this one reports the vertical size in cm rather
than mm.
Patch taken from Launchpad bug #380009 https://launchpad.net/bugs/380009

X.Org Bug 28414 https://bugs.freedesktop.org/show_bug.cgi?id=28414

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
Reviewed-by: Adam Jackson a...@redhat.com
---
 hw/xfree86/modes/xf86EdidModes.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 3d51b1d..d9ece7a 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -145,6 +145,11 @@ static Bool quirk_detailed_v_in_cm (int scrnIndex, 
xf86MonPtr DDC)
DDC-vendor.prod_id == 0x2a00)
return TRUE;
 
+/* Bug #28414: HP Compaq NC8430 LP154W01-TLA8 */
+if (memcmp (DDC-vendor.name, LPL, 4) == 0 
+   DDC-vendor.prod_id == 5750)
+   return TRUE;
+
 /* Bug #21750: Samsung Syncmaster 2333HD */
 if (memcmp (DDC-vendor.name, SAM, 4) == 0 
DDC-vendor.prod_id == 1157)
-- 
1.7.2.3

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

[PATCH 2/3] IDLETIME: Fix edge-case in IdleTimeBlockHandler

2010-12-05 Thread Christopher James Halse Rogers
Ensure that if we're called exactly on the threshold of a
NegativeTransition trigger that we reshedule to pick up
an idle time over the threshold.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
Reviewed-by: Adam Jackson a...@redhat.com
---
 Xext/sync.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index fc7c462..93aee37 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2292,6 +2292,14 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, 
pointer LastSelectMask)
break;
}
}
+   /* 
+* We've been called exactly on the idle time, but we have a
+* NegativeTransition trigger which requires a transition from an
+* idle time greater than this.  Schedule a wakeup for the next
+* millisecond so we won't miss a transition.
+*/
+   if (XSyncValueEqual (idle, *pIdleTimeValueLess))
+   AdjustWaitForDelay(wt, 1);
 }
 else if (pIdleTimeValueGreater)
 {
-- 
1.7.2.3

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


[PATCH 1/3] Xext: Fix edge case with {Positive, Negative}Transition triggers.

2010-12-05 Thread Christopher James Halse Rogers
The {Positive,Negative}Transition triggers only fire when the counter
goes from strictly {below,above} the threshold.  If
SyncComputeBracketValues gets called exactly at this threshold we may update
the bracket values so that the counter is not updated past the threshold.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
Reviewed-by: Adam Jackson a...@redhat.com
---
 Xext/sync.c |   22 ++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index f23df6c..fc7c462 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -929,6 +929,17 @@ SyncComputeBracketValues(SyncCounter *pCounter)
{
psci-bracket_less = pTrigger-test_value;
pnewltval = psci-bracket_less;
+   } else if (XSyncValueEqual(pCounter-value, pTrigger-test_value) 
+  XSyncValueLessThan(pTrigger-test_value,
+ psci-bracket_greater))
+   {
+   /*
+* The value is exactly equal to our threshold.  We want one
+* more event in the positive direction to ensure we pick up
+* when the value *exceeds* this threshold.
+*/
+   psci-bracket_greater = pTrigger-test_value;
+   pnewgtval = psci-bracket_greater;
}
}
 else if (pTrigger-test_type == XSyncPositiveTransition 
@@ -939,6 +950,17 @@ SyncComputeBracketValues(SyncCounter *pCounter)
{
psci-bracket_greater = pTrigger-test_value;
pnewgtval = psci-bracket_greater;
+   } else if (XSyncValueEqual(pCounter-value, pTrigger-test_value) 
+  XSyncValueGreaterThan(pTrigger-test_value,
+psci-bracket_less))
+   {
+   /*
+* The value is exactly equal to our threshold.  We want one
+* more event in the negative direction to ensure we pick up
+* when the value is less than this threshold.
+*/
+   psci-bracket_less = pTrigger-test_value;
+   pnewltval = psci-bracket_less;
}
}
 } /* end for each trigger */
-- 
1.7.2.3

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


Reviewed patches from the Ubuntu tree

2010-12-05 Thread Christopher James Halse Rogers
I've been cleaning up the Ubuntu X packages, and I've run across some patches
that have been reviewed some time ago but aren't yet in master.

Resending them, since I've clearly dropped them on the floor at one point.

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


[PATCH] Fix some edgecases in SYNC

2010-08-23 Thread Christopher James Halse Rogers
In recent X servers gnome-screensaver's fade-to-screensaver has lost the
ability to be interrupted.  Tim Taiwanese Liim's analysis on the Fedora bug¹
lead to an edge case in the SYNC extension.

If the WakeupHandler is called exactly on the threshold of a NegativeTransition
trigger then SyncComputeBracketValues can unset the upper bracket bound,
resulting in the idle counter not being updated past the threshold.  Since
a NegativeTransition is only triggered in the transition from strictly greater
than to below the threshold, this results in the NegativeTransition not firing.

Bug references:
[1] Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=612620 about 
Ubuntu: http://bugs.launchpad.net/bugs/59

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

[PATCH 1/2] Xext: Fix edge case with {Positive, Negative}Transition triggers.

2010-08-23 Thread Christopher James Halse Rogers
The {Positive,Negative}Transition triggers only fire when the counter
goes from strictly {below,above} the threshold.  If
SyncComputeBracketValues gets called exactly at this threshold we may update
the bracket values so that the counter is not updated past the threshold.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 Xext/sync.c |   22 ++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index a51262a..c00e692 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -959,6 +959,17 @@ SyncComputeBracketValues(SyncCounter *pCounter)
{
psci-bracket_less = pTrigger-test_value;
pnewltval = psci-bracket_less;
+   } else if (XSyncValueEqual(pCounter-value, pTrigger-test_value) 
+  XSyncValueLessThan(pTrigger-test_value,
+ psci-bracket_greater))
+   {
+   /*
+* The value is exactly equal to our threshold.  We want one
+* more event in the positive direction to ensure we pick up
+* when the value *exceeds* this threshold.
+*/
+   psci-bracket_greater = pTrigger-test_value;
+   pnewgtval = psci-bracket_greater;
}
}
 else if (pTrigger-test_type == XSyncPositiveTransition 
@@ -969,6 +980,17 @@ SyncComputeBracketValues(SyncCounter *pCounter)
{
psci-bracket_greater = pTrigger-test_value;
pnewgtval = psci-bracket_greater;
+   } else if (XSyncValueEqual(pCounter-value, pTrigger-test_value) 
+  XSyncValueGreaterThan(pTrigger-test_value,
+psci-bracket_less))
+   {
+   /*
+* The value is exactly equal to our threshold.  We want one
+* more event in the negative direction to ensure we pick up
+* when the value is less than this threshold.
+*/
+   psci-bracket_less = pTrigger-test_value;
+   pnewltval = psci-bracket_less;
}
}
 } /* end for each trigger */
-- 
1.7.1

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


[PATCH 2/2] IDLETIME: Fix edge-case in IdleTimeBlockHandler

2010-08-23 Thread Christopher James Halse Rogers
Ensure that if we're called exactly on the threshold of a
NegativeTransition trigger that we reshedule to pick up
an idle time over the threshold.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 Xext/sync.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index c00e692..314b63e 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2322,6 +2322,14 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, 
pointer LastSelectMask)
break;
}
}
+   /* 
+* We've been called exactly on the idle time, but we have a
+* NegativeTransition trigger which requires a transition from an
+* idle time greater than this.  Schedule a wakeup for the next
+* millisecond so we won't miss a transition.
+*/
+   if (XSyncValueEqual (idle, *pIdleTimeValueLess))
+   AdjustWaitForDelay(wt, 1);
 }
 else if (pIdleTimeValueGreater)
 {
-- 
1.7.1

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


[PATCH] qxl: Fix build against video ABI 8

2010-08-10 Thread Christopher James Halse Rogers
PaintWindowBackground and PaintWindowBorder haven't been
used in a while and have been removed from the Screen
struct in Xserver 1.9.

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 src/qxl.h|2 ++
 src/qxl_driver.c |7 ++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/qxl.h b/src/qxl.h
index cf25ee4..73b3bc2 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -509,8 +509,10 @@ struct _qxl_screen_t
 CreateScreenResourcesProcPtr create_screen_resources;
 CloseScreenProcPtr close_screen;
 CreateGCProcPtrcreate_gc;
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION)  8
 PaintWindowProcPtr paint_window_background;
 PaintWindowProcPtr paint_window_border;
+#endif
 CopyWindowProcPtr  copy_window;
 
 DamagePtr  damage;
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 187e581..36cec6e 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -873,6 +873,7 @@ qxl_fill_region_solid (DrawablePtr pDrawable, RegionPtr 
pRegion, Pixel pixel)
   fbReplicatePixel (pixel, pDrawable-bitsPerPixel));
 }
 
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION)  8
 static void
 qxl_paint_window(WindowPtr pWin, RegionPtr pRegion, int what)
 {
@@ -893,6 +894,7 @@ qxl_paint_window(WindowPtr pWin, RegionPtr pRegion, int 
what)
 
 qxl-paint_window_border (pWin, pRegion, what);
 }
+#endif
 
 static void
 qxl_copy_window (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
@@ -1036,11 +1038,14 @@ qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int 
argc, char **argv)
 qxl-create_gc = pScreen-CreateGC;
 pScreen-CreateGC = qxl_create_gc;
 
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION)  8
 qxl-paint_window_background = pScreen-PaintWindowBackground;
 qxl-paint_window_border = pScreen-PaintWindowBorder;
-qxl-copy_window = pScreen-CopyWindow;
 pScreen-PaintWindowBackground = qxl_paint_window;
 pScreen-PaintWindowBorder = qxl_paint_window;
+#endif
+
+qxl-copy_window = pScreen-CopyWindow;
 pScreen-CopyWindow = qxl_copy_window;
 
 miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
-- 
1.7.1

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


Re: Running X as an unprivileged user

2010-06-27 Thread Christopher James Halse Rogers
On Fri, 2010-06-25 at 15:04 +0100, Daniel Stone wrote:
 On Fri, Jun 25, 2010 at 11:12:49PM +1000, Christopher James Halse Rogers 
 wrote:
  It seems that almost all of the work required to run X without root
  privileges has been done, and there are just a couple of loose ends to
  tie up before it can work - at least for KMS drivers.
  
  Apart from opening /proc/mtrr for writing, which isn't used by any of
  the drivers I've inspected and certainly by none of the KMS drivers, it
  seems the last problem is backlight handling which requires
  prodding /sys/class/backlight/*/brightness.  It seems that the way to
  deal with this would be to get a /dev/backlight device interface for
  which udev could set appropriate permissions.  This would also clean the
  Intel DDX code somewhat as it wouldn't have to iterate over the list of
  possible /sys paths.
 
 Why not just have ConsoleKit set the ownership, presumably as you'd have
 it doing for /dev/input?

I've got a note here that ConsoleKit won't do what we want, but looking
at it again I'm not sure why.  I'll look again!

  That still doesn't solve the revoke() problem
 though (i.e. what happens when you switch to another session - the
 original server could still have its /dev/input FDs open, leaking all
 your passwords).

Right.  This prevents us from running X as the user who is logging in
and changing the /dev/input ownership to that user.  We can mitigate
this by running all X servers as a dedicated system user, though.  That
leaves the session-switch situation the same as we currently have it
with multiple X servers running as root.

That's not as ideal as having X running as the logged-in user with the
input devices owned by the local console + a working revoke() syscall,
but I don't think it's worse than the status quo in terms of password
snooping and limits some of the damage a broken or compromised X could
do.


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Running X as an unprivileged user

2010-06-25 Thread Christopher James Halse Rogers
It seems that almost all of the work required to run X without root
privileges has been done, and there are just a couple of loose ends to
tie up before it can work - at least for KMS drivers.

Apart from opening /proc/mtrr for writing, which isn't used by any of
the drivers I've inspected and certainly by none of the KMS drivers, it
seems the last problem is backlight handling which requires
prodding /sys/class/backlight/*/brightness.  It seems that the way to
deal with this would be to get a /dev/backlight device interface for
which udev could set appropriate permissions.  This would also clean the
Intel DDX code somewhat as it wouldn't have to iterate over the list of
possible /sys paths.

Once this is in place, I'd write a patch to check on X startup whether
a) KMS is in use
b) /dev/backlight exists, with appropriate permissions
c) /dev/input/* have appropriate permissions
and in this case drop root privileges.

Does this idea look sane?  Are there any obvious pitfalls that I've
missed here?  What would a good /dev/backlight interface look like?



signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xfree86/modes] Add EDID quirk for HP Compaq nc8430.

2010-06-06 Thread Christopher James Halse Rogers
From: Jörn Horstmann launch...@planetxml.de

Like some other LPL panels, this one reports the vertical size in cm rather 
than mm.
Patch taken from Launchpad bug #380009 https://launchpad.net/bugs/380009

X.Org Bug 28414 https://bugs.freedesktop.org/show_bug.cgi?id=28414

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/modes/xf86EdidModes.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 8f4d04f..538bfd1 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -145,6 +145,11 @@ static Bool quirk_detailed_v_in_cm (int scrnIndex, 
xf86MonPtr DDC)
DDC-vendor.prod_id == 0x2a00)
return TRUE;
 
+/* Bug #28414: HP Compaq NC8430 LP154W01-TLA8 */
+if (memcmp (DDC-vendor.name, LPL, 4) == 0 
+   DDC-vendor.prod_id == 5750)
+   return TRUE;
+
 /* Bug #21750: Samsung Syncmaster 2333HD */
 if (memcmp (DDC-vendor.name, SAM, 4) == 0 
DDC-vendor.prod_id == 1157)
-- 
1.7.0.4

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