Re: [PATCH] test: write some event → XI1 conversion tests.

2011-02-21 Thread Daniel Stone
On Mon, Feb 21, 2011 at 03:44:31PM +1000, Peter Hutterer wrote:
 These tests don't test everything, but hey, life is short and I'm trying to
 have one.
 
 Signed-off-by: Peter Hutterer peter.hutte...@who-t.net

Reviewed-by: Daniel Stone dan...@fooishbar.org


signature.asc
Description: Digital signature
___
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] dix: a valuator count of 0 is valid (#34510)

2011-02-21 Thread Timo Aaltonen
On 21.02.2011 07:39, Peter Hutterer wrote:
 For all but motion and proximity events, having no valuators is ok.
 Regression from 1.9, keyboard events are not converted to protocol events.
 
 X.Org Bug 34510 http://bugs.freedesktop.org/show_bug.cgi?id=34510
 
 Signed-off-by: Peter Hutterer peter.hutte...@who-t.net

Thanks! Mumble works now.

Tested-by: Timo Aaltonen timo.aalto...@canonical.com
___
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] exa/mixed: Partially restore deferred pixmap handling for frontbuffer.

2011-02-21 Thread Michel Dänzer
On Fre, 2011-02-18 at 14:23 +0100, Maarten Maathuis wrote: 
 2011/2/11 Maarten Maathuis madman2...@gmail.com:
  2011/2/11 Michel Dänzer mic...@daenzer.net:
  On Don, 2011-02-10 at 20:44 +0100, Maarten Maathuis wrote:
  2011/2/10 Michel Dänzer mic...@daenzer.net:
   On Don, 2011-02-10 at 20:15 +0100, Maarten Maathuis wrote:
   - It turns out that part of the problem was actually on the driver 
   side.
   - The performance loss is not worth the small visual improvement.
   - This should ensure low latency at low throughput.
   - Performance loss seems about 5% instead of the previous 33%.
  
   As you've lowered the performance loss number again, I assume you mean
   'high throughput' above. :)
 
  I really mean low latency at low throughput (typing for example), [...]
 
  That was always covered by the BlockHandler. Your problem was only due
  to the BlockHandler not getting called for a long time (and/or the
  driver not flushing properly in its own BlockHandler).
 
  Even before i read this i got the idea if i shouldn't triple check if
  I'm trying to solve a problem that doesn't exist anymore. So i'll do
  some more testing. Maybe a revert is even in order. I made a mistake
  once, i don't want to make a second one on top of that :)
 
 It seems that the appearance of large amounts of text scrolling over
 the screen depends on how high the throughput is, it seems a bit
 stupid to slow things down for the sake of appearance, plus it's very
 possible other people won't see it like I do due to a slightly faster
 or slower system. I'll probably sent a revert later today or tomorrow.

Well, unless I'm missing something, a client bombing the server with
rendering requests could in theory prevent the BlockHandler from getting
called indefinitely, so if those all ended up being software fallbacks
on the screen pixmap, the visible screen contents would never get
updated. So it might be nice to have some kind of timeout.

That said, I think the same problem should also affect all unaccelerated
drivers using miext/shadow for deferred screen updates, but there
haven't seemed to be any complaints in all these years. So the revert
should be fine for now.


-- 
Earthling Michel Dänzer   |http://www.vmware.com
Libre software enthusiast |  Debian, X and DRI developer
___
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] exa/mixed: Partially restore deferred pixmap handling for frontbuffer.

2011-02-21 Thread Ferry Huberts


On 02/21/2011 01:11 PM, Michel D�nzer wrote:
 On Fre, 2011-02-18 at 14:23 +0100, Maarten Maathuis wrote: 
 2011/2/11 Maarten Maathuis madman2...@gmail.com:
 2011/2/11 Michel Dänzer mic...@daenzer.net:
 On Don, 2011-02-10 at 20:44 +0100, Maarten Maathuis wrote:
 2011/2/10 Michel Dänzer mic...@daenzer.net:
 On Don, 2011-02-10 at 20:15 +0100, Maarten Maathuis wrote:
 - It turns out that part of the problem was actually on the driver side.
 - The performance loss is not worth the small visual improvement.
 - This should ensure low latency at low throughput.
 - Performance loss seems about 5% instead of the previous 33%.

 As you've lowered the performance loss number again, I assume you mean
 'high throughput' above. :)

 I really mean low latency at low throughput (typing for example), [...]

 That was always covered by the BlockHandler. Your problem was only due
 to the BlockHandler not getting called for a long time (and/or the
 driver not flushing properly in its own BlockHandler).

 Even before i read this i got the idea if i shouldn't triple check if
 I'm trying to solve a problem that doesn't exist anymore. So i'll do
 some more testing. Maybe a revert is even in order. I made a mistake
 once, i don't want to make a second one on top of that :)

 It seems that the appearance of large amounts of text scrolling over
 the screen depends on how high the throughput is, it seems a bit
 stupid to slow things down for the sake of appearance, plus it's very
 possible other people won't see it like I do due to a slightly faster
 or slower system. I'll probably sent a revert later today or tomorrow.
 
 Well, unless I'm missing something, a client bombing the server with
 rendering requests could in theory prevent the BlockHandler from getting
 called indefinitely, so if those all ended up being software fallbacks
 on the screen pixmap, the visible screen contents would never get
 updated. So it might be nice to have some kind of timeout.
 

How about doing something simple like 'as soon as there are outstanding
rendering requests, start a single shot timer, and once it triggers (like
after a second), call the BlockHandler if there are still outstanding
rendering requests. If after the BlockHandler completes there are still
outstanding/new rending requests: repeat this procedure'.

that would guarantee a screen update at least once a second when the
server is overloaded with rendering requests.


grtz

-- 
Ferry Huberts
___
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

[PULL] XI1 keyboard conversion fix

2011-02-21 Thread Peter Hutterer
Keith, please pull those two into 1.10. the tests don't matter much, the
first patch is a release blocker though (regression from 1.9, XI1 on
keyboard events is broken).

The following changes since commit b4ef34d4664e0eaac7211f7a22a2025958aa1527:

  Revert exa/mixed: Exclude frontbuffer from deferred pixmap handling. 
(2011-02-20 08:44:38 -0800)

are available in the git repository at:
  git://people.freedesktop.org/~whot/xserver.git for-keith

Peter Hutterer (2):
  dix: a valuator number of 0 is valid (#34510)
  test: write some event → XI1 conversion tests.

 dix/eventconvert.c |   16 +-
 test/input.c   |  139 
 2 files changed, 153 insertions(+), 2 deletions(-)
___
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: [PULL] XI1 keyboard conversion fix

2011-02-21 Thread Keith Packard
On Tue, 22 Feb 2011 08:58:12 +1000, Peter Hutterer peter.hutte...@who-t.net 
wrote:

 Peter Hutterer (2):
   dix: a valuator number of 0 is valid (#34510)
   test: write some event → XI1 conversion tests.

Merged
   b4ef34d..93a7399  master - master

-- 
keith.pack...@intel.com


pgpFcWdrTTl3U.pgp
Description: PGP signature
___
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:xdm 2/5] Add echoPasswdChar resource to set character to display

2011-02-21 Thread Alan Coopersmith
On 02/20/11 03:24 AM, Mark Kettenis wrote:
 From: Alan Coopersmith alan.coopersm...@oracle.com
 Date: Sat, 19 Feb 2011 22:36:38 -0800

 Stop hardcoding it to '*'.   Allows setting a resource with no value to
 display   to advance the cursor without drawing text.
 
 What's the motivation for this change?  Giving users more knobs to
 play with isn't necessarily going to make them happier.

Patches 2  3 in that series were motivated by solving
https://bugs.freedesktop.org/show_bug.cgi?id=32794 and
giving users a choice of usability vs. shoulder-surfing risk.
(I'd also hoped to give a choice of a nicer looking character
 than '*', but the code is very much hardcoded to single-byte
 characters at the moment, so can't take utf-8 values such as
 '●' or '•' yet.)

I've reworked them a bit and will repost soon.

-- 
-Alan Coopersmith-alan.coopersm...@oracle.com
 Oracle Solaris Platform Engineering: X Window System

___
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 v2 1/5] greeter: inline valueMask for xpm window to avoid shadowing argument

2011-02-21 Thread Alan Coopersmith
The Realize function names one of its arguments valueMask, and the
valueMask variable in the inner scope is just used as a static set
of mask flags, so just pass them directly to the function to reduce
confusion and clear the gcc -Wshadow warning:

Login.c: In function `Realize':
Login.c:1901: warning: declaration of 'valueMask' shadows a parameter
Login.c:1871: warning: shadowed declaration is here

Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
---

Modified as suggested by Mark Kettenis

 greeter/Login.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/greeter/Login.c b/greeter/Login.c
index 2a73a9e..020bfd4 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -1899,7 +1899,6 @@ static void Realize (
  * Create pixmap window
  */
 {
-unsigned long valueMask = CWBackPixel | CWBackPixmap;
 XSetWindowAttributes windowAttributes = { 0 };
 
 windowAttributes.background_pixel = w-core.background_pixel;
@@ -1912,7 +1911,7 @@ static void Realize (
 (w-core.height - w-login.logoHeight) /2,
 w-login.logoWidth, w-login.logoHeight, 0,
 CopyFromParent, InputOutput, CopyFromParent,
-valueMask, windowAttributes);
+CWBackPixel | CWBackPixmap, windowAttributes);
 }
 
 /*
-- 
1.7.3.2

___
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 v2 2/5] greeter: Add echoPasswdChar resource to set character to display

2011-02-21 Thread Alan Coopersmith
Stop hardcoding it to '*'.   Allows setting a resource with no value to
to advance the cursor without drawing text (as was previously the default).

Resolves https://bugs.freedesktop.org/show_bug.cgi?id=32794

Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
---

Replaces patch 2/5  3/5 of the previous series, making the empty value
activate the former 1-pixel-per-character cursor advancement.

 greeter/Login.c  |   26 ++
 greeter/Login.h  |2 ++
 greeter/LoginP.h |4 +++-
 man/xdm.man  |8 ++--
 4 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/greeter/Login.c b/greeter/Login.c
index 020bfd4..9fd07c4 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -217,7 +217,9 @@ static XtResource resources[] = {
 {XtNallowRootLogin, XtCAllowRootLogin, XtRBoolean, sizeof(Boolean),
offset(allow_root_login), XtRImmediate, (XtPointer) True},
 {XtNechoPasswd, XtCEchoPasswd, XtRBoolean, sizeof(Boolean),
-   offset(echo_passwd), XtRImmediate, (XtPointer) False}
+   offset(echo_passwd), XtRImmediate, (XtPointer) False},
+{XtNechoPasswdChar, XtCEchoPasswdChar, XtRString,  sizeof (char *),
+   offset(echo_passwd_char), XtRString, (XtPointer) * }
 };
 
 #undef offset
@@ -370,7 +372,7 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC 
gc)
 
while (i  length)
{
-   text[i++] = '*';
+   text[i++] = w-login.echo_passwd_char[0];
}
 
text[i] = 0;
@@ -488,16 +490,16 @@ realizeCursor (LoginWidget w, GC gc)
break;
 case LOGIN_PROMPT_ECHO_OFF:
if (w-login.echo_passwd == True) {
-   int len = PROMPT_CURSOR(w, w-login.activePrompt) -
-   VALUE_SHOW_START(w, w-login.activePrompt);
+   if (w-login.echo_passwd_char[0] != 0) {
+   int len = PROMPT_CURSOR(w, w-login.activePrompt) -
+   VALUE_SHOW_START(w, w-login.activePrompt);
 
-   x += len*TEXT_WIDTH(text, *, 1);
-   }
-   else
-   {
-   /* Move cursor one pixel per character to give some feedback
-  without giving away the password length */
-   x += PROMPT_CURSOR(w, w-login.activePrompt);
+   x += len*TEXT_WIDTH(text, w-login.echo_passwd_char, 1);
+   } else {
+   /* Move cursor one pixel per character to give some feedback
+  without giving away the password length */
+   x += PROMPT_CURSOR(w, w-login.activePrompt);
+   }
}
break;
 }
diff --git a/greeter/Login.h b/greeter/Login.h
index 22529a5..9b5212c 100644
--- a/greeter/Login.h
+++ b/greeter/Login.h
@@ -101,6 +101,7 @@ from The Open Group.
 # define XtNallowNullPasswdallowNullPasswd
 # define XtNallowRootLogin allowRootLogin
 # define XtNechoPasswd echoPasswd
+# define XtNechoPasswdChar echoPasswdChar
 
 # define XtNface   face
 # define XtCFace   Face
@@ -142,6 +143,7 @@ from The Open Group.
 # define XtCAllowNullPasswdAllowNullPasswd
 # define XtCAllowRootLogin AllowRootLogin
 # define XtCEchoPasswd EchoPasswd
+# define XtCEchoPasswdChar EchoPasswdChar
 
 # define XtNchangePasswdMessagechangePasswdMessage
 # define XtCChangePasswdMessageChangePasswdMessage
diff --git a/greeter/LoginP.h b/greeter/LoginP.h
index 3279110..ef2151d 100644
--- a/greeter/LoginP.h
+++ b/greeter/LoginP.h
@@ -130,8 +130,10 @@ typedef struct {
Boolean allow_access;   /* disable access control on login */
Boolean allow_null_passwd; /* allow null password on login */
Boolean allow_root_login; /* allow root login */
-   /* show password as asterisks, i.e. '**...' */
+   /* option to display characters such as asterisks, i.e. '**...'
+  for no-echo prompts like passwords */
Boolean echo_passwd;
+   char *  echo_passwd_char;
XIC xic;/* input method of input context */
loginPromptData prompts[NUM_PROMPTS];
time_t  msgTimeout;
diff --git a/man/xdm.man b/man/xdm.man
index 721dade..3c4b385 100644
--- a/man/xdm.man
+++ b/man/xdm.man
@@ -1062,9 +1062,13 @@ if the account does not require a password at all.
 The default is ``false'', so only users that have passwords assigned can
 log in.
 .IP \fBxlogin.Login.echoPasswd\fP
-If set to ``true'', stars will be rendered instead of the password itself,
-i.e. '***...'.
+If set to ``true'', a placeholder character (echoPasswdChar) will be shown
+for fields normally set to not echo, such as password input.
 The default is ``false''.
+.IP \fBxlogin.Login.echoPasswdChar\fP
+Character to display if echoPasswd is true.  The default is ``*''.
+If set to an empty value, the cursor will advance for each character input,
+but no text will be drawn.
 .IP \fBxlogin.Login.translations\fP
 This specifies the translations used for the login widget.  

[PATCH v2 3/5] greeter: Make sure text input areas stay inside the lines

2011-02-21 Thread Alan Coopersmith
Regression introduced by f8585c60831a8e5ddebce18bdd7e78d217a822c5
broke bounds checking for text displayed in input fields.

Since this makes each TEXT_WIDTH value only be used once, just use
them directly instead of storing the result in a variable.

Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
---

New in v2 of this series.

 greeter/Login.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/greeter/Login.c b/greeter/Login.c
index 9fd07c4..f448991 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -404,24 +404,21 @@ realizeValue (LoginWidget w, int cursor, int promptNum, 
GC gc)
 } else if ((state == LOGIN_PROMPT_ECHO_ON) || (state == LOGIN_TEXT_INFO) ||
   ((state == LOGIN_PROMPT_ECHO_OFF)  (w-login.echo_passwd == 
True)))
 {
-   int textwidth;
int offset = max(cursor, VALUE_SHOW_START(w, promptNum));
int textlen = strlen (text + offset);
 
-   textwidth = TEXT_WIDTH (text, text + offset, textlen);
-
-   if (textwidth  (width - curoff)) {
+   if (TEXT_WIDTH (text, text + offset, textlen)  (width - curoff)) {
/* Recalculate amount of text that can fit in field */
offset = VALUE_SHOW_START(w, promptNum);
textlen = strlen (text + offset);
 
-   while ((textlen  0)  (textwidth  width))
+   while ((textlen  0) 
+  (TEXT_WIDTH (text, text + offset, textlen)  width))
{
if (offset  PROMPT_CURSOR(w, promptNum)) {
offset++;
}
textlen--;
-   textwidth = TEXT_WIDTH (text, text + offset, textlen);
}
 
VALUE_SHOW_START(w, promptNum) = offset;
-- 
1.7.3.2

___
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 v2 4/5] greeter: Replace several #ifdef XPM blocks with LOGO_W macro

2011-02-21 Thread Alan Coopersmith
Refactor code assuming compiler is smart enough to optimize out any
that reduce to + 0 or - 0 if building without XPM defined.

Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
---

New in v2 of this series.   Simplifies things a little for patch 5/5.

 greeter/Login.c |   39 +--
 1 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/greeter/Login.c b/greeter/Login.c
index f448991..545f937 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -292,7 +292,12 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 
*string, int len);
 
 #define STRING_WIDTH(f, s) TEXT_WIDTH (f, s, strlen(s))
 
-
+/* Padded width of logo image, if compiled with XPM support */
+#ifdef XPM
+# define LOGO_W(w) ((w)-login.logoWidth + ((w)-login.logoPadding * 2))
+#else
+# define LOGO_W(w) 0
+#endif
 
 #define TEXT_PROMPT_W(w, m) (STRING_WIDTH(prompt, m) + w-login.inframeswidth)
 
@@ -307,14 +312,10 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 
*string, int len);
 #define GREET_X(w) ((int)((w-core.width - \
STRING_WIDTH (greet, GREETING(w))) / 2))
 #define GREET_Y(w) (GREETING(w)[0] ? 2 * GREET_Y_INC (w) : 0)
-#ifndef XPM
-# define GREET_W(w)(max (STRING_WIDTH (greet, w-login.greeting), \
- STRING_WIDTH (greet, w-login.unsecure_greet)))
-#else
-# define GREET_W(w)(max (STRING_WIDTH (greet, w-login.greeting), \
+#define GREET_W(w) (max (STRING_WIDTH (greet, w-login.greeting), \
  STRING_WIDTH (greet, w-login.unsecure_greet)) \
-+ w-login.logoWidth + (2*w-login.logoPadding))
-#endif /* XPM */
++ LOGO_W(w))
+
 #define PROMPT_X(w)(2 * PROMPT_X_INC(w))
 #define PROMPT_Y(w,n)  ((GREET_Y(w) + GREET_Y_INC(w) +\
  F_ASCENT(greet) + Y_INC(w)) + \
@@ -328,12 +329,7 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 
*string, int len);
 #define FAIL_X(w)  ERROR_X(w, w-login.fail)
 #define FAIL_Y(w)  (PROMPT_Y(w,1) + 2 * FAIL_Y_INC (w) + F_ASCENT(fail))
 
-#ifndef XPM
-# define ERROR_W(w,m)  STRING_WIDTH (fail, m)
-#else
-# define ERROR_W(w,m)  (STRING_WIDTH (fail, m) \
-+ w-login.logoWidth + (2*w-login.logoPadding))
-#endif /* XPM */
+#define ERROR_W(w,m)   (STRING_WIDTH (fail, m) + LOGO_W(w))
 
 #define FAIL_W(w)  max(ERROR_W(w, w-login.failMsg), \
ERROR_W(w, w-login.passwdChangeMsg))
@@ -381,14 +377,9 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC 
gc)
 x = VALUE_X (w,promptNum);
 y = PROMPT_Y (w,promptNum);
 
-height = PROMPT_H(w);
-width = PROMPT_W(w) - x - 3;
+height = PROMPT_H(w) - (w-login.inframeswidth * 2);
+width = PROMPT_W(w) - x - 3 - (w-login.inframeswidth * 2) - LOGO_W(w);
 
-height -= (w-login.inframeswidth * 2);
-width -= (w-login.inframeswidth * 2);
-#ifdef XPM
-width -= (w-login.logoWidth + (w-login.logoPadding * 2));
-#endif
 if (cursor  VALUE_SHOW_START(w, promptNum))
curoff = TEXT_WIDTH (text, text, cursor);
 else
@@ -739,15 +730,11 @@ draw_it (LoginWidget w)
int in_frame_y
= PROMPT_Y(w,p) - w-login.inframeswidth - 1 - TEXT_Y_INC(w);
 
-   int in_width = PROMPT_W(w) - VALUE_X(w,p);
+   int in_width = PROMPT_W(w) - VALUE_X(w,p) - LOGO_W(w);
int in_height = PROMPT_H(w) + w-login.inframeswidth + 2;
 
GC topLeftGC, botRightGC;
 
-#ifdef XPM
-   in_width -= (w-login.logoWidth + 2*(w-login.logoPadding));
-#endif /* XPM */
-
if ((PROMPT_STATE(w, p) == LOGIN_PROMPT_ECHO_ON) ||
(PROMPT_STATE(w, p) == LOGIN_PROMPT_ECHO_OFF)) {
topLeftGC = w-login.shdGC;
-- 
1.7.3.2

___
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 v2 5/5] greeter: Make sure cursor stays in bounds too

2011-02-21 Thread Alan Coopersmith
Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
---

New in v2 of this series.

 greeter/Login.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/greeter/Login.c b/greeter/Login.c
index 545f937..90b72fc 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -323,6 +323,9 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 
*string, int len);
 #define PROMPT_W(w)(w-core.width - (2 * TEXT_X_INC(w)))
 #define PROMPT_H(w)(3 * Y_INC(w) / 2)
 #define VALUE_X(w,n)   (PROMPT_X(w) + CUR_PROMPT_W(w,n))
+#define CURSOR_W   5
+#define MAX_VALUE_W(w,n) (PROMPT_W(w) - VALUE_X (w,n) - CURSOR_W - 1 - \
+ (w-login.inframeswidth * 2) - LOGO_W(w))
 #define PROMPT_SPACE_Y(w)  (10 * Y_INC(w) / 5)
 
 #define ERROR_X(w,m)   ((int)(w-core.width - STRING_WIDTH (fail, m)) / 2)
@@ -378,7 +381,7 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC 
gc)
 y = PROMPT_Y (w,promptNum);
 
 height = PROMPT_H(w) - (w-login.inframeswidth * 2);
-width = PROMPT_W(w) - x - 3 - (w-login.inframeswidth * 2) - LOGO_W(w);
+width = MAX_VALUE_W(w,promptNum);
 
 if (cursor  VALUE_SHOW_START(w, promptNum))
curoff = TEXT_WIDTH (text, text, cursor);
@@ -486,7 +489,11 @@ realizeCursor (LoginWidget w, GC gc)
} else {
/* Move cursor one pixel per character to give some feedback
   without giving away the password length */
-   x += PROMPT_CURSOR(w, w-login.activePrompt);
+   if (PROMPT_CURSOR(w, w-login.activePrompt) 
+   MAX_VALUE_W(w, w-login.activePrompt))
+   x += PROMPT_CURSOR(w, w-login.activePrompt);
+   else
+   x += MAX_VALUE_W(w, w-login.activePrompt);
}
}
break;
-- 
1.7.3.2

___
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: Spinning in _XReply

2011-02-21 Thread Jeremy Huddleston
So... what should we do about this?  I just got another report about IDL not 
working with the new libX11 (http://xquartz.macosforge.org/trac/ticket/469), 
and my hunch is that the user will provide me with a spindump that points to 
this issue again.


On Jan 29, 2011, at 19:24, Pat Kane wrote:

  28 __XReply + 512 (in libX11.6.dylib) [0x6d50c0]
  ...
  11 __XReply + 240 (in libX11.6.dylib) 
 [0x6d4fb0]
 
 I just took a quick look at xcb_io.c to see what _XReply is doing,
 and I doubt that it is reentrant.
 The only way to break out of that while(1) loop is if req == current.
 
 I wonder why the  test at the top:
   if(dpy-flags  XlibDisplayIOError)
   return 0;
 did not work.
 
 Pat
 ---
 
 
 
 On Sat, Jan 29, 2011 at 11:54 AM, Jeremy Huddleston jerem...@apple.com 
 wrote:
 I'm trying to figure out a spin that an XQuartz user reported seeing in 
 emacs.  The problem seems to boil down to two things:
 
 1) XLoadQueryFont() is erroring for some reason (probably related to 
 https://bugs.freedesktop.org/show_bug.cgi?id=28803)
 
 2) emacs' error handler seems bugged.  Is it legal to call XSync() within 
 the error handler?  It certainly seems like it shouldn't.  Did we used to 
 actually support this with the xtrans version of libX11?
 
 Why are we spinning in _XReply rather than entering a deadlock here?  It 
 seems to me that we shouldn't wake from this ConditionWait because the 
 _XReply we're nested in won't ever ConditionBroadcast()... so why is he 
 seeing us spin through _XReply?  It's almost as if this ConditionWait() is a 
 no-op:
 
while(1)
{
PendingRequest *req = dpy-xcb-pending_requests;
xcb_generic_reply_t *response;
 
if(req != current  req-reply_waiter)
{
ConditionWait(dpy, dpy-xcb-reply_notify);
/* Another thread got this reply. */
continue;}
 
 
 Here's the top of the backtrace:
 
 28 _XtCreateWidget + 168 (in libXt.6.dylib) [0x569288]
  28 __XtCreateWidget + 700 (in libXt.6.dylib) [0x5691cc]
28 _xtCreate + 372 (in libXt.6.dylib) [0x568b14]
  28 __XtGetResources + 324 (in libXt.6.dylib) [0x582124]
28 _GetResources + 2368 (in libXt.6.dylib) [0x581a60]
  28 __XtConvert + 844 (in libXt.6.dylib) [0x562f2c]
28 _CallConverter + 872 (in libXt.6.dylib) [0x562958]
  28 _XtCvtStringToFontStruct + 156 (in libXt.6.dylib) [0x56592c]
28 _XLoadQueryFont + 424 (in libX11.6.dylib) [0x6b2dd8]
  28 __XQueryFont + 228 (in libX11.6.dylib) [0x6b1b74]
28 __XReply + 512 (in libX11.6.dylib) [0x6d50c0]
  28 _handle_response + 148 (in libX11.6.dylib) [0x6d45e4]
28 _handle_error + 136 (in libX11.6.dylib) [0x6d42f8]
  28 __XError + 264 (in libX11.6.dylib) [0x6d7b38]
28 _x_error_handler + 84 (in emacs-24.0.50.1) 
 [0x105444]
  28 _x_error_quitter + 112 (in emacs-24.0.50.1) 
 [0x1053d0]
28 _x_connection_closed + 252 (in 
 emacs-24.0.50.1) [0x10500c]
  28 _XSync + 160 (in libX11.6.dylib) 
 [0x6d00a0]
11 __XReply + 240 (in libX11.6.dylib) 
 [0x6d4fb0]
5 __XReply + 236 (in libX11.6.dylib) 
 [0x6d4fac]
5 __XReply + 248 (in libX11.6.dylib) 
 [0x6d4fb8]
3 __XReply + 224 (in libX11.6.dylib) 
 [0x6d4fa0]
3 __XReply + 228 (in libX11.6.dylib) 
 [0x6d4fa4]
1 __XReply + 252 (in libX11.6.dylib) 
 [0x6d4fbc]
 
 
 
 On Jan 29, 2011, at 02:23, Peter Dyballa wrote:
 
 
 Am 29.01.2011 um 05:50 schrieb Jeremy Huddleston:
 
 Ok, well give me a spindump when your libXaw3d version is in this state.
 
 
 Here it is:
 
 emacs-24.0.50.1_26454.sample.txt
 
 --
 Greetings
 
  Pete
 
 Inside every small problem is a large problem struggling to get out.
   – Second Law of Blissful Ignorance
 
 
 ___
 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
 
 ___
 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

___
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: Spinning in _XReply

2011-02-21 Thread Pat Kane
  On Mon, Feb 21, 2011 at 7:51 PM, Jeremy Huddleston jerem...@apple.com wrote:
   So... what should we do about this?

A good first step would be to try come up with a small-ish test case,
or to at least
figure out how to reproduce the problem on another system.   I use
EMACS on my RHEL6
and Ubuntu 10.10 systems a lot, and have not see the problem.  What is IDL?

The only Mac that I have access to is a Mac Mini that I bought for my
lovely wife
two years ago, but she does not really like me getting too near to it.

A work-around would be to increment a static count in the code that is looping
and break out, with an ugly warning message when the count gets too high.
But then your users might complain about some other thing being borked...

Pat
---
___
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] test: add some tests for basic list manipulation.

2011-02-21 Thread Peter Hutterer
This has less purpose as a test but more as documentation on how to actually
use the differnent list calls.

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 test/Makefile.am |3 +-
 test/list.c  |  176 ++
 2 files changed, 178 insertions(+), 1 deletions(-)
 create mode 100644 test/list.c

diff --git a/test/Makefile.am b/test/Makefile.am
index 456221e..be54e5f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,6 +1,6 @@
 if UNITTESTS
 SUBDIRS= . xi2
-check_PROGRAMS = xkb input xtest
+check_PROGRAMS = xkb input xtest list
 check_LTLIBRARIES = libxservertest.la
 
 TESTS=$(check_PROGRAMS)
@@ -16,6 +16,7 @@ endif
 xkb_LDADD=$(TEST_LDADD)
 input_LDADD=$(TEST_LDADD)
 xtest_LDADD=$(TEST_LDADD)
+list_LDADD=$(TEST_LDADD)
 
 libxservertest_la_LIBADD = \
 $(XSERVER_LIBS) \
diff --git a/test/list.c b/test/list.c
new file mode 100644
index 000..a87d2db
--- /dev/null
+++ b/test/list.c
@@ -0,0 +1,176 @@
+/**
+ * Copyright © 2011 Red Hat, Inc.
+ *
+ *  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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include dix-config.h
+#endif
+
+#include X11/Xlib.h
+#include list.h
+#include string.h
+#include glib.h
+
+struct parent {
+int a;
+struct list children;
+int b;
+};
+
+struct child {
+int foo;
+int bar;
+struct list node;
+};
+
+static void
+test_list_init(void)
+{
+struct parent parent, tmp;
+
+memset(parent, 0, sizeof(parent));
+parent.a = 0xa5a5a5;
+parent.b = ~0xa5a5a5;
+
+tmp = parent;
+
+list_init(parent.children);
+
+/* test we haven't touched anything else. */
+g_assert(parent.a == tmp.a);
+g_assert(parent.b == tmp.b);
+
+g_assert(list_is_empty(parent.children));
+}
+
+static void
+test_list_add(void)
+{
+struct parent parent = {0};
+struct child child[3];
+struct child *c;
+
+list_init(parent.children);
+
+list_add(child[0].node, parent.children);
+g_assert(!list_is_empty(parent.children));
+
+c = list_first_entry(parent.children, struct child, node);
+g_assert(memcmp(c, child[0], sizeof(struct child)) == 0);
+
+/* note: list_add prepends */
+list_add(child[1].node, parent.children);
+c = list_first_entry(parent.children, struct child, node);
+g_assert(memcmp(c, child[1], sizeof(struct child)) == 0);
+
+list_add(child[2].node, parent.children);
+c = list_first_entry(parent.children, struct child, node);
+g_assert(memcmp(c, child[2], sizeof(struct child)) == 0);
+};
+
+static void
+test_list_del(void)
+{
+struct parent parent = {0};
+struct child child[3];
+struct child *c;
+
+list_init(parent.children);
+
+list_add(child[0].node, parent.children);
+g_assert(!list_is_empty(parent.children));
+
+list_del(parent.children);
+g_assert(list_is_empty(parent.children));
+
+list_add(child[0].node, parent.children);
+list_del(child[0].node);
+g_assert(list_is_empty(parent.children));
+
+list_add(child[0].node, parent.children);
+list_add(child[1].node, parent.children);
+
+c = list_first_entry(parent.children, struct child, node);
+g_assert(memcmp(c, child[1], sizeof(struct child)) == 0);
+
+/* delete first node */
+list_del(child[1].node);
+g_assert(!list_is_empty(parent.children));
+g_assert(list_is_empty(child[1].node));
+c = list_first_entry(parent.children, struct child, node);
+g_assert(memcmp(c, child[0], sizeof(struct child)) == 0);
+
+/* delete last node */
+list_add(child[1].node, parent.children);
+list_del(child[0].node);
+c = list_first_entry(parent.children, struct child, node);
+g_assert(memcmp(c, child[1], sizeof(struct child)) == 0);
+
+/* delete list head */
+list_add(child[0].node, parent.children);
+list_del(parent.children);
+g_assert(list_is_empty(parent.children));
+

[PATCH] include: document list interface.

2011-02-21 Thread Peter Hutterer
Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 include/list.h |  182 +++-
 1 files changed, 180 insertions(+), 2 deletions(-)

diff --git a/include/list.h b/include/list.h
index 4ce20a8..3c8c754 100644
--- a/include/list.h
+++ b/include/list.h
@@ -26,11 +26,102 @@
 #ifndef _LIST_H_
 #define _LIST_H_
 
-/* classic doubly-link circular list */
+/**
+ * @file Classic doubly-link circular list implementation.
+ *
+ * Example:
+ * We need to keep a list of struct foo in the parent struct bar, i.e. what
+ * we want is something like this.
+ *
+ * struct bar {
+ *  ...
+ *  struct foo *foos; - struct foo {}, struct foo {}, struct foo{}
+ *  ...
+ * }
+ *
+ * We need one list head in bar and a list element in all foos (both are of
+ * data type 'struct list').
+ *
+ * struct bar {
+ *  ...
+ *  struct list foos;
+ *  ...
+ * }
+ *
+ * struct foo {
+ *  ...
+ *  struct list entry;
+ *  ...
+ * }
+ *
+ * Now we initilise the list head:
+ *
+ * struct bar bar;
+ * ...
+ * list_init(bar.foos);
+ *
+ * Then we create the first element and add it to this list:
+ *
+ * struct foo *foo = malloc(...);
+ * 
+ * list_add(foo-entry, bar.foos);
+ *
+ * Repeat the above for each element you want to add to the list. Deleting
+ * works with the element itself.
+ *  list_del(foo-entry);
+ *  free(foo);
+ *
+ * Note: calling list_del(bar.foos) will set in bar.foos to an empty
+ * list again.
+ *
+ * Looping through the list requires a 'struct foo' as iterator and the
+ * name of the field the subnodes use.
+ *
+ * struct foo *iterator;
+ * list_for_each_entry(iterator, bar.foos, entry) {
+ *  if (iterator-something == ...)
+ * ...
+ * }
+ *
+ * Note: You must not call list_del() on the iterator if you continue the
+ * loop. You need to run the safe for-each loop instead:
+ *
+ * struct foo *iterator, *next;
+ * list_for_each_entry(iterator, next, bar.foos, entry) {
+ *  if (...)
+ *  list_del(iterator-entry);
+ * }
+ *
+ */
+
+/**
+ * The linkage struct for list nodes. This struct must be part of your
+ * to-be-linked struct.
+ *
+ * Example:
+ * struct foo {
+ *  int a;
+ *  void *b;
+ *  struct list *mylist;
+ * }
+ *
+ * Position and name of the struct list field is irrelevant.
+ * There are no requirements that elements of a list are of the same type.
+ * There are no requirements for a list head, any struct list can be a list
+ * head.
+ */
 struct list {
 struct list *next, *prev;
 };
 
+/**
+ * Initialize the list as an empty list.
+ *
+ * Example:
+ * list_init(foo-mylist);
+ *
+ * @param The list to initialized.
+ */
 static void
 list_init(struct list *list)
 {
@@ -48,6 +139,20 @@ __list_add(struct list *entry,
 prev-next = entry;
 }
 
+/**
+ * Insert a new element after the given list head.
+ * The list changes from:
+ *  head → some element → ...
+ * to
+ *  head → new element → older element → ...
+ *
+ * Example:
+ * struct foo *newfoo = malloc(...);
+ * list_add(newfoo-mylist, foo-mylist);
+ *
+ * @param entry The new element to prepend to the list.
+ * @param head The existing list.
+ */
 static inline void
 list_add(struct list *entry, struct list *head)
 {
@@ -61,6 +166,20 @@ __list_del(struct list *prev, struct list *next)
 prev-next = next;
 }
 
+/**
+ * Remove the element from the list it is in. Using this function will reset
+ * the pointers to-fro this element so it is removed from the list. It does
+ * NOT free the element itself or manipulate it otherwise.
+ *
+ * Using list_del on a pure list head (like in the example at the top of
+ * this file) will NOT remove the first element from
+ * the list but rather reset the list as empty list.
+ *
+ * Example:
+ * list_del(newfoo-mylist);
+ *
+ * @param entry The element to remove.
+ */
 static inline void
 list_del(struct list *entry)
 {
@@ -68,32 +187,91 @@ list_del(struct list *entry)
 list_init(entry);
 }
 
+/**
+ * Check if the list is empty.
+ *
+ * Example:
+ * list_is_empty(foo-mylist);
+ *
+ * @return True if the list contains one or more elements or False otherwise.
+ */
 static inline Bool
 list_is_empty(struct list *head)
 {
 return head-next == head;
 }
 
+/**
+ * Returns a pointer to the container of this list element.
+ *
+ * Example:
+ * struct foo* f;
+ * f = container_of(foo-mylist, struct foo, mylist);
+ * assert(f == foo);
+ *
+ * @param ptr Pointer to the struct list.
+ * @param type Data type of the list element.
+ * @param member Member name of the struct list field in the list element.
+ * @return A pointer to the data struct containing the list head.
+ */
 #ifndef container_of
 #define container_of(ptr, type, member) \
 (type *)((char *)(ptr) - (char *) ((type *)0)-member)
 #endif
 
+/**
+ * Alias of container_of
+ */
 #define list_entry(ptr, type, member) \
 

Re: Spinning in _XReply

2011-02-21 Thread Jeremy Huddleston

On Feb 21, 2011, at 19:03, Pat Kane wrote:

  On Mon, Feb 21, 2011 at 7:51 PM, Jeremy Huddleston jerem...@apple.com 
 wrote:
 So... what should we do about this?
 
 A good first step would be to try come up with a small-ish test case,
 or to at least
 figure out how to reproduce the problem on another system.   I use
 EMACS on my RHEL6
 and Ubuntu 10.10 systems a lot, and have not see the problem.  What is IDL?

IDL is a data visualization package used a lot by astrophysicists 
(http://www.ittvis.com/ProductServices/IDL.aspx)

 The only Mac that I have access to is a Mac Mini that I bought for my
 lovely wife
 two years ago, but she does not really like me getting too near to it.

Well it has nothing to do with Mac.  It's a re-entrancy issue with _XReply.

 A work-around would be to increment a static count in the code that is looping
 and break out, with an ugly warning message when the count gets too high.
 But then your users might complain about some other thing being borked...

That's not exactly elegant.  My original question was never really answered.  
Should we actualy support calling _XReply from an error handler?  If not, then 
this seems like an issue for third parties to fix (although it does raise 
binary compatibility concerns)
___
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 0/8] Pointer barriers

2011-02-21 Thread Peter Hutterer

This patchset adds support for Pointer Barriers in the server (albeit
without per-device support).

Branch is available on cgit:
http://cgit.freedesktop.org/~whot/xserver/log/?h=pointer-barriers

Ajax already sent out the protocol/libXfixes patches a while ago, these 
are required for this branch to build.

Notes on the PB support in general:
- having a pointer barrier specify which direction it doesn't work is very
  confusing. Both from the client-side and whithin the server it was
  counter-intuitive.

  I'd prefer an interface like this
 barrier = XFixesCreatePointerBarrier(dpy, DefaultRootWindow(dpy),
100, 0, 100, 200,
PointerBarrierPositiveX);
  to block movement from left to right. The above call would currently block
  all directions but let left-to-right movement through.

- The barrier itself is an elevated barrier, i.e. you cannot get onto the
  pixel the barrier represents (from the blocking directions). This is
  necessary to avoid trapped cursors when the barrier blocks both
  directions. This needs to be either added to the protocol or I need to
  spend the time to implement the exact protocol spec (top/left edge of the
  pixel). The latter would result in x = barrier or x = barrier + 1,
  depending on where you're coming from.

Cheers,
  Peter
___
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/8] dix: Add IsFloating(device) wrapper.

2011-02-21 Thread Peter Hutterer
Simplifies check for floating devices.

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 dix/events.c  |7 +++
 include/dix.h |1 +
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/dix/events.c b/dix/events.c
index 07f8b05..d2be84f 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -328,6 +328,13 @@ IsMaster(DeviceIntPtr dev)
 return dev-type == MASTER_POINTER || dev-type == MASTER_KEYBOARD;
 }
 
+Bool
+IsFloating(DeviceIntPtr dev)
+{
+return GetMaster(dev, MASTER_KEYBOARD) == NULL;
+}
+
+
 /**
  * Max event opcode.
  */
diff --git a/include/dix.h b/include/dix.h
index 12e4b59..3f99098 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -570,6 +570,7 @@ extern Bool _X_EXPORT IsPointerDevice( DeviceIntPtr dev);
 extern Bool _X_EXPORT IsKeyboardDevice(DeviceIntPtr dev);
 extern Bool IsPointerEvent(InternalEvent *event);
 extern _X_EXPORT Bool IsMaster(DeviceIntPtr dev);
+extern _X_EXPORT Bool IsFloating(DeviceIntPtr dev);
 
 extern _X_HIDDEN void CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
 extern _X_HIDDEN int CorePointerProc(DeviceIntPtr dev, int what);
-- 
1.7.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 2/8] Add mode field to pointer movement hooks.

2011-02-21 Thread Peter Hutterer
Preparation work for pointer barriers.

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 dix/getevents.c |   12 +---
 mi/mipointer.c  |   19 ++-
 mi/mipointer.h  |1 +
 3 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index 794df42..70f8728 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -812,7 +812,11 @@ accelPointer(DeviceIntPtr dev, int first, int num, int 
*valuators, CARD32 ms)
  * miPointerSetPosition() and then scale back into device coordinates (if
  * needed). miPSP will change x/y if the screen was crossed.
  *
+ * The coordinates provided are always absolute. The parameter mode whether
+ * it was relative or absolute movement that landed us at those coordinates.
+ *
  * @param dev The device to be moved.
+ * @param mode Movement mode (Absolute or Relative)
  * @param x Pointer to current x-axis value, may be modified.
  * @param y Pointer to current y-axis value, may be modified.
  * @param x_frac Fractional part of current x-axis value, may be modified.
@@ -824,7 +828,8 @@ accelPointer(DeviceIntPtr dev, int first, int num, int 
*valuators, CARD32 ms)
  * @param screeny_frac Fractional part of screen y coordinate, as above.
  */
 static void
-positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac,
+positionSprite(DeviceIntPtr dev, int mode,
+   int *x, int *y, float x_frac, float y_frac,
ScreenPtr scr, int *screenx, int *screeny, float *screenx_frac, 
float *screeny_frac)
 {
 int old_screenx, old_screeny;
@@ -863,7 +868,7 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float 
x_frac, float y_frac,
 old_screeny = *screeny;
 /* This takes care of crossing screens for us, as well as clipping
  * to the current screen. */
-miPointerSetPosition(dev, screenx, screeny);
+miPointerSetPosition(dev, mode, screenx, screeny);
 
 if (dev-u.master) {
 dev-u.master-last.valuators[0] = *screenx;
@@ -1193,7 +1198,8 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, 
int type, int buttons,
 
 set_raw_valuators(raw, mask, raw-valuators.data);
 
-positionSprite(pDev, x, y, x_frac, y_frac, scr, cx, cy, cx_frac, 
cy_frac);
+positionSprite(pDev, (flags  POINTER_ABSOLUTE) ? Absolute : Relative,
+   x, y, x_frac, y_frac, scr, cx, cy, cx_frac, cy_frac);
 updateHistory(pDev, mask, ms);
 
 /* Update the valuators with the true value sent to the client*/
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 554397a..0ecd915 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -483,8 +483,25 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen,
 pPointer-pScreen = pScreen;
 }
 
+/**
+ * Set the devices' cursor position to the given x/y position.
+ *
+ * This function is called during the pointer update path in
+ * GetPointerEvents and friends (and the same in the xwin DDX).
+ *
+ * The coordinates provided are always absolute. The parameter mode whether
+ * it was relative or absolute movement that landed us at those coordinates.
+ *
+ * @param pDev The device to move
+ * @param mode Movement mode (Absolute or Relative)
+ * @param[in,out] x The x coordiante in screen coordinates (in regards to total
+ * desktop size)
+ * @param[in,out] y The y coordiante in screen coordinates (in regards to total
+ * desktop size)
+ */
+
 void
-miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y)
+miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
 {
 miPointerScreenPtr pScreenPriv;
 ScreenPtr  pScreen;
diff --git a/mi/mipointer.h b/mi/mipointer.h
index 3c86110..539096e 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -133,6 +133,7 @@ extern _X_EXPORT void miPointerGetPosition(
  * x and y are modified in-place. */
 extern _X_EXPORT void miPointerSetPosition(
 DeviceIntPtr pDev,
+int mode,
 int *x,
 int *y);
 
-- 
1.7.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 3/8] mi: document miPointerSetCursorPosition

2011-02-21 Thread Peter Hutterer
Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 mi/mipointer.c |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/mi/mipointer.c b/mi/mipointer.c
index 0ecd915..250d26b 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -222,6 +222,30 @@ miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr 
pScreen, CursorPtr pCursor,
 
 static Bool GenerateEvent;
 
+/**
+ * Set the device's cursor position to the x/y position on the given screen.
+ * Generates and event if required.
+ *
+ * This function is called from:
+ *- sprite init code to place onto initial position
+ *- the various WarpPointer implementations (core, XI, Xinerama, dmx,…)
+ *- during the cursor update path in CheckMotion
+ *- in the Xinerama part of NewCurrentScreen
+ *- when a RandR/RandR1.2 mode was applied (it may have moved the pointer, 
so
+ *  it's set back to the original pos)
+ *
+ * This pointer movement is always absolute.
+ *
+ * @param pDev The device to move
+ * @param pScreen The screen the device is on
+ * @param x The x coordinate in per-screen coordinates
+ * @param y The y coordinate in per-screen coordinates
+ * @param generateEvent True if the pointer movement should generate an
+ * event.
+ *
+ * @return TRUE in all cases
+ */
+
 static Bool
 miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen,
int x, int y, Bool generateEvent)
-- 
1.7.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 4/8] Add mode field to ConstrainCursorHarder.

2011-02-21 Thread Peter Hutterer
For Pointer Barriers, the movement mode is important and must be passed
through.

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 include/scrnintstr.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 9f4fbf3..a9357e8 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -404,7 +404,7 @@ typedefvoid (* DeviceCursorCleanupProcPtr)(
 ScreenPtr/* pScreen */);
 
 typedef void (*ConstrainCursorHarderProcPtr)(
-   DeviceIntPtr, ScreenPtr, int *, int *);
+   DeviceIntPtr, ScreenPtr, int, int *, int *);
 
 typedef struct _Screen {
 intmyNum;  /* index of this instance in Screens[] 
*/
-- 
1.7.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 5/8] mi: Call pScreen-ConstrainCursorHarder from the position update path

2011-02-21 Thread Peter Hutterer
From: Adam Jackson a...@redhat.com

v2: Cover more paths, spotted by Daniel Stone.
v3: pass down the mode field for movement mode.

Reviewed-by: Daniel Stone dan...@fooishbar.org
Signed-off-by: Adam Jackson a...@redhat.com
Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 mi/mipointer.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/mi/mipointer.c b/mi/mipointer.c
index 250d26b..466600f 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -253,6 +253,10 @@ miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr 
pScreen,
 SetupScreen (pScreen);
 
 GenerateEvent = generateEvent;
+
+if (pScreen-ConstrainCursorHarder)
+   pScreen-ConstrainCursorHarder(pDev, pScreen, Absolute, x, y);
+
 /* device dependent - must pend signal and call miPointerWarpCursor */
 (*pScreenPriv-screenFuncs-WarpCursor) (pDev, pScreen, x, y);
 if (!generateEvent)
@@ -570,6 +574,9 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, 
int *y)
 if (*y = pPointer-limits.y2)
*y = pPointer-limits.y2 - 1;
 
+if (pScreen-ConstrainCursorHarder)
+   pScreen-ConstrainCursorHarder(pDev, pScreen, mode, x, y);
+
 if (pPointer-x == *x  pPointer-y == *y  
 pPointer-pScreen == pScreen) 
 return;
-- 
1.7.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 6/8] randr: Add RRConstrainCursorHarder

2011-02-21 Thread Peter Hutterer
From: Adam Jackson a...@redhat.com

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.

v3:
- Incorporate review feedback from Christopher James Halse Rogers
v4:
- Add mode field.

Signed-off-by: Adam Jackson a...@redhat.com
Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 randr/randr.c|2 +
 randr/randrstr.h |5 ++-
 randr/rrcrtc.c   |  155 ++
 3 files changed, 161 insertions(+), 1 deletions(-)

diff --git a/randr/randr.c b/randr/randr.c
index c22657e..6b3af0f 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -273,6 +273,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 7c553f2..70e64d3 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -371,7 +371,7 @@ typedef struct _rrScrPriv {
 intrate;
 intsize;
 #endif
-
+Bool   discontiguous;
 } rrScrPrivRec, *rrScrPrivPtr;
 
 extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec;
@@ -831,6 +831,9 @@ ProcRRGetCrtcSpriteTransform (ClientPtr client);
 int
 ProcRRSetCrtcConfigs (ClientPtr client);
 
+void
+RRConstrainCursorHarder (DeviceIntPtr, ScreenPtr, int, int *, int *);
+
 /* rrdispatch.c */
 extern _X_EXPORT Bool
 RRClientKnowsRates (ClientPtr  pClient);
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 5fe6900..e19ac02 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
 
 RESTYPERRCrtcType;
 
@@ -312,6 +314,92 @@ 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)
+{
+/* left, right, top, bottom... */
+int al, ar, at, ab;
+int bl, br, bt, bb;
+int cl, cr, ct, cb; /* the overlap, if any */
+
+crtc_bounds(a, al, ar, at, ab);
+crtc_bounds(b, bl, br, bt, bb);
+
+cl = max(al, bl);
+cr = min(ar, br);
+ct = max(at, bt);
+cb = min(ab, bb);
+
+return (cl = cr)  (ct = cb);
+}
+
+/* Depth-first search and mark all CRTCs reachable from cur */
+static void
+mark_crtcs (rrScrPrivPtr pScrPriv, int *reachable, int cur)
+{
+int i;
+reachable[cur] = TRUE;
+for (i = 0; i  pScrPriv-numCrtcs; ++i) {
+if (reachable[i] || !pScrPriv-crtcs[i]-mode)
+continue;
+if (crtcs_adjacent(pScrPriv-crtcs[cur], pScrPriv-crtcs[i]))
+mark_crtcs(pScrPriv, reachable, i);
+}
+}
+
+static void
+RRComputeContiguity (ScreenPtr pScreen)
+{
+rrScrPriv(pScreen);
+Bool discontiguous = TRUE;
+int i, n = pScrPriv-numCrtcs;
+
+int *reachable = calloc(n, sizeof(int));
+if (!reachable)
+goto out;
+
+/* Find first enabled CRTC and start search for reachable CRTCs from it */
+for (i = 0; i  n; ++i) {
+if (pScrPriv-crtcs[i]-mode) {
+mark_crtcs(pScrPriv, reachable, i);
+break;
+}
+}
+
+/* Check that all enabled CRTCs were marked as reachable */
+for (i = 0; i  n; ++i)
+if (pScrPriv-crtcs[i]-mode  !reachable[i])
+goto out;
+
+discontiguous = FALSE;
+
+out:
+free(reachable);
+pScrPriv-discontiguous = discontiguous;
+}
+
 /*
  * Request that the Crtc be reconfigured
  */
@@ -327,6 +415,7 @@ RRCrtcSet (RRCrtcPtrcrtc,
 {
 ScreenPtr  pScreen = crtc-pScreen;
 Bool   ret = FALSE;
+Bool   recompute = TRUE;
 rrScrPriv(pScreen);
 
 /* See if nothing changed */
@@ -340,6 +429,7 @@ RRCrtcSet (RRCrtcPtrcrtc,
!RRCrtcPendingTransform (crtc) 
crtc-scanoutPixmap == scanout_pixmap)
 {
+   recompute = FALSE;
ret = TRUE;
 }
 else
@@ -403,6 +493,10 @@ RRCrtcSet (RRCrtcPtrcrtc,
RRPostPendingProperties 

[PATCH 7/8] fixes: add support for Pointer Barriers

2011-02-21 Thread Peter Hutterer
From: Adam Jackson a...@redhat.com

Pointer barriers block the movement of a pointer past a certain line,
specified by the barrier. Movement through the barrier may be permitted for
certain directions of movement.

Algorithm used:
For each movement, find the nearest-to-origin-of-movement barrier that
blocks this movement. If found, clamp to that barrier and re-evaluate from
this new origin.

Co-authored-by: Peter Hutterer peter.hutte...@who-t.net
Signed-off-by: Adam Jackson a...@redhat.com
Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 include/protocol-versions.h |2 +-
 test/Makefile.am|3 +-
 test/fixes.c|  304 ++
 xfixes/cursor.c |  386 ++-
 xfixes/xfixes.c |   22 ++-
 xfixes/xfixes.h |   16 ++
 xfixes/xfixesint.h  |   16 ++
 7 files changed, 737 insertions(+), 12 deletions(-)
 create mode 100644 test/fixes.c

diff --git a/include/protocol-versions.h b/include/protocol-versions.h
index c8c7f5f..7be1af3 100644
--- a/include/protocol-versions.h
+++ b/include/protocol-versions.h
@@ -126,7 +126,7 @@
 #define SERVER_XF86VIDMODE_MINOR_VERSION   2
 
 /* Fixes */
-#define SERVER_XFIXES_MAJOR_VERSION4
+#define SERVER_XFIXES_MAJOR_VERSION5
 #define SERVER_XFIXES_MINOR_VERSION0
 
 /* X Input */
diff --git a/test/Makefile.am b/test/Makefile.am
index be54e5f..ccdb859 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,6 +1,6 @@
 if UNITTESTS
 SUBDIRS= . xi2
-check_PROGRAMS = xkb input xtest list
+check_PROGRAMS = xkb input xtest list fixes
 check_LTLIBRARIES = libxservertest.la
 
 TESTS=$(check_PROGRAMS)
@@ -17,6 +17,7 @@ xkb_LDADD=$(TEST_LDADD)
 input_LDADD=$(TEST_LDADD)
 xtest_LDADD=$(TEST_LDADD)
 list_LDADD=$(TEST_LDADD)
+fixes_LDADD=$(TEST_LDADD)
 
 libxservertest_la_LIBADD = \
 $(XSERVER_LIBS) \
diff --git a/test/fixes.c b/test/fixes.c
new file mode 100644
index 000..d319dab
--- /dev/null
+++ b/test/fixes.c
@@ -0,0 +1,304 @@
+/**
+ * Copyright © 2011 Red Hat, Inc.
+ *
+ *  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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include dix-config.h
+#endif
+
+#include stdio.h
+#include stdlib.h
+#include X11/X.h
+#include xfixesint.h
+#include X11/extensions/xfixeswire.h
+
+#include glib.h
+
+static void
+_fixes_test_direction(struct PointerBarrier *barrier, int d[4], int permitted)
+{
+BOOL blocking;
+int i, j;
+int dir = barrier_get_direction(d[0], d[1], d[2], d[3]);
+
+barrier-directions = 0;
+blocking = barrier_is_blocking_direction(barrier, dir);
+g_assert(blocking);
+
+for (j = 0; j = BarrierNegativeY; j++)
+{
+barrier-directions = 1  i;
+for (i = 0; i = BarrierNegativeY; i++)
+{
+barrier-directions |= 1  i;
+blocking = barrier_is_blocking_direction(barrier, dir);
+g_assert((barrier-directions  permitted) == permitted ? 
!blocking : blocking);
+}
+}
+
+}
+
+static void
+fixes_pointer_barrier_direction_test(void)
+{
+struct PointerBarrier barrier;
+
+int x = 100;
+int y = 100;
+
+int directions[8][4] = {
+{ x, y, x, y + 100},/* S  */
+{ x + 50, y, x - 50, y + 100},  /* SW */
+{ x + 100, y, x, y},/* W  */
+{ x + 100, y + 50, x, y - 50},  /* NW */
+{ x, y + 100, x, y},/* N  */
+{ x - 50, y + 100, x + 50, y},  /* NE */
+{ x, y, x + 100, y},/* E  */
+{ x, y - 50, x + 100, y + 50},  /* SE */
+};
+
+barrier.x1 = x;
+barrier.x2 = x;
+barrier.y1 = y - 50;
+barrier.y2 = y + 49;
+
+
+_fixes_test_direction(barrier, directions[0], BarrierPositiveY);
+_fixes_test_direction(barrier, directions[1], BarrierPositiveY | 
BarrierNegativeX);
+

[PATCH 8/8] xfixes: use struct list for pointer barriers.

2011-02-21 Thread Peter Hutterer
Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 xfixes/cursor.c |   20 +---
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 3cafc24..1be6e18 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -116,7 +116,7 @@ typedef struct PointerBarrierClient 
*PointerBarrierClientPtr;
 struct PointerBarrierClient {
 ScreenPtr screen;
 struct PointerBarrier barrier;
-PointerBarrierClientPtr next;
+struct list entry;
 };
 
 /*
@@ -128,7 +128,7 @@ typedef struct _CursorScreen {
 CloseScreenProcPtr CloseScreen;
 ConstrainCursorHarderProcPtr ConstrainCursorHarder;
 CursorHideCountPtr  pCursorHideCounts;
-PointerBarrierClientPtrbarriers;
+struct list barriers;
 } CursorScreenRec, *CursorScreenPtr;
 
 #define GetCursorScreen(s) 
((CursorScreenPtr)dixLookupPrivate((s)-devPrivates, CursorScreenPrivateKey))
@@ -1175,7 +1175,7 @@ barrier_find_nearest(CursorScreenPtr cs, int dir,
 struct PointerBarrier *nearest = NULL;
 double min_distance = INT_MAX; /* can't get higher than that in X anyway */
 
-for (c = cs-barriers; c; c = c-next) {
+list_for_each_entry(c, cs-barriers, entry) {
struct PointerBarrier *b = c-barrier;
double distance;
 
@@ -1229,7 +1229,7 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr 
screen, int mode, int *x
 {
 CursorScreenPtr cs = GetCursorScreen(screen);
 
-if (cs-barriers  !IsFloating(dev)  mode == Relative) {
+if (!list_is_empty(cs-barriers)  !IsFloating(dev)  mode == Relative) 
{
int ox, oy;
int dir;
struct PointerBarrier *nearest = NULL;
@@ -1286,8 +1286,7 @@ CreatePointerBarrierClient(ScreenPtr screen, ClientPtr 
client,
ret-barrier.y1 = stuff-y1;
ret-barrier.y2 = stuff-y2;
ret-barrier.directions = stuff-directions  0x0f;
-   ret-next = cs-barriers;
-   cs-barriers = ret;
+   list_add(ret-entry, cs-barriers);
 }
 
 return ret;
@@ -1363,11 +1362,9 @@ CursorFreeBarrier(void *data, XID id)
 cs = GetCursorScreen(screen);
 
 /* find and unlink from the screen private */
-if (cs-barriers == barrier)
-   cs-barriers = cs-barriers-next;
-else for (b = cs-barriers; b; b = b-next) {
-   if (b-next == barrier) {
-   b-next = b-next-next;
+list_for_each_entry(b, cs-barriers, entry) {
+   if (b == barrier) {
+   list_del(b-entry);
break;
}
 }
@@ -1428,6 +1425,7 @@ XFixesCursorInit (void)
cs = (CursorScreenPtr) calloc(1, sizeof (CursorScreenRec));
if (!cs)
return FALSE;
+   list_init(cs-barriers);
Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
Wrap (cs, pScreen, ConstrainCursorHarder, CursorConstrainCursorHarder);
-- 
1.7.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: Spinning in _XReply

2011-02-21 Thread Pat Kane
On Mon, Feb 21, 2011 at 9:38 PM, Jeremy Huddleston jerem...@apple.com wrote:

  IDL is a data visualization package used a lot by astrophysicists \
(http://www.ittvis.com/ProductServices/IDL.aspx)
Thanks, I'll take a look at IDL.

  Should we actualy support calling _XReply from an error handler?

I do not think so, we should have an early exit if we detect recursion,
but as my high school Latin teacher says:  Ignotum per ignotius
___
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 evdev] Export device node as property.

2011-02-21 Thread Peter Hutterer
On Tue, Feb 08, 2011 at 07:42:31AM +0100, Lennart Poettering wrote:
 On Mon, 07.02.11 23:12, Daniel Stone (dan...@fooishbar.org) wrote:
 
  Hi,
  
  On Tue, Feb 08, 2011 at 08:32:16AM +1000, Peter Hutterer wrote:
   CC'ing Lennart, he can contribute more details I supposed.
   
   On Mon, Feb 07, 2011 at 08:58:22AM +1000, Daniel Stone wrote:
On Wed, Feb 02, 2011 at 03:32:54PM +1000, Peter Hutterer wrote:
 There is currently no mapping between XI devices and physical devices 
 other
 than what can be extracted by parsing the Xorg logfile. Add new 
 property
 Device Node to the driver to export the open device file.
 
 The client is responsible for detecting if the device is on the same 
 host
 and converting the data into a more useful format (e.g. sysfs path).

So, er, why?
   
   We expose a few features of the physical device through the X driver, but
   other information is available only through the kernel directly. There is 
   no
   way of associating an input device with the X device it spawned off short 
   of
   parsing the X.log.
  
  To be honest, it's not really the sort of thing I want to encourage; is
  there anything in particular missing from Xi 2.1? Telling clients to
  just mix and match the two and hope they haven't screwed up local vs.
  remote, et al, sounds a tad unfortunate.  Not to mention that they
  probably don't have access to the devices.
 
 For a long time we wanted to be able to match up X input devices such as
 the HID keyboards built into USB speakers or USB headsets with their
 particular sound cards, so that pressing the volume button on the device
 actually changes the volume on that one device instead of whatever has
 been chosen as the default sound card. XI2 now finally allows us to
 track from which input device an input event came, but we don't have any
 way to then somehow match this up with a specific audio device although
 sysfs and the information exposed by the kernel would actually allow us
 to do that.
 
 A volume applet would use this information as a hint only: if no
 matching device is found (which is the very likely default case for the
 vol knobs on most mm keyboards) it would silently fall back to the
 current algorithm of just using the default device.
 
 Similar use cases exist for the various other USB devices which combine
 HID keyboards with some other functionality: USB scanners with a scan
 now button, webcams with a take photo button, rfkill key events, jack
 events, brightness keys, ... (of course, some of these would probably be
 handled better by code accessing the linux input layer directly, but at
 least the usb scanner, webcam and audio keys really should be routed
 through X)
 
 And there are more uses: it would be a good idea to be able to trace
 back the yubikey keypresses to the yubikey used, and then issue
 additional commands to it, and also know that those keys are primarily
 useful in the context of authentication.

Daniel, Peter, any comments on this? Yay or nay?

Cheers,
  Peter
___
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 v2 setxkbmap] man: multiple layouts can be specified (#34118)

2011-02-21 Thread Peter Hutterer
Same applies to variant.

X.Org Bug 34118 http://bugs.freedesktop.org/show_bug.cgi?id=34118

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
I guess the matching should be explained with an example somewhere, but for
now this will do

 man/setxkbmap.man |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/man/setxkbmap.man b/man/setxkbmap.man
index 1c0b87a..4548a02 100644
--- a/man/setxkbmap.man
+++ b/man/setxkbmap.man
@@ -61,8 +61,8 @@ a keyboard layout.
 .TP 8
 .B \-layout \fIname\fP
 Specifies the name of the layout used to determine the components which
-make up the keyboard description.  Only one layout may be specified on
-the command line.
+make up the keyboard description. The \fI-layout\fP option may only be used
+once. Multiple layouts can be specified as a comma-separated list.
 .TP 8
 .B \-model \fIname\fP
 Specifies the name of the keyboard model used to determine the components
@@ -106,8 +106,10 @@ a keyboard layout.
 .TP 8
 .B \-variant \fIname\fP
 Specifies which variant of the keyboard layout should be used to determine
-the components which make up the keyboard description.  Only one variant
-may be specified on the command line.
+the components which make up the keyboard description. The \fI-variant\fP
+option may only be used once. Multiple variants can be specified as a
+comma-separated list and will be matched with the layouts specified with
+\fI-layout\fP.
 .TP 8
 .B \-verbose|\-v [\fIlevel\fP]
 Specifies level of verbosity in output messages.  Valid levels range from
-- 
1.7.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 setxkbmap] Set of macros converted to enum type.

2011-02-21 Thread Peter Hutterer
On Fri, Feb 18, 2011 at 11:00:55PM +0300, Lev Nezhdanov wrote:
 Signed-off-by: Van de Bugger van.de.bug...@gmail.com

merged, thanks.

for future patches, if you re-send a modified patch please use a prefix of 
[PATCH v2 setxkbmap] etc. so it is easier to find on a glance which one the
most current patch is.

new patch versions should also include a short changelog of what has changed
in respect to the previous version, it makes reviewing a lot easier.

Cheers,
  Peter
 ---
  setxkbmap.c |   26 ++
  1 files changed, 14 insertions(+), 12 deletions(-)
 
 diff --git a/setxkbmap.c b/setxkbmap.c
 index 0c43be5..07e9267 100644
 --- a/setxkbmap.c
 +++ b/setxkbmap.c
 @@ -57,15 +57,17 @@
  #define DFLT_XKB_MODEL pc105
  #endif
  
 -/* Values used in svSrc to state how a value was obtained. The order of these
 +/* Constants to state how a value was obtained. The order of these
   * is important, the bigger the higher the priority.
   * e.g. FROM_CONFIG overrides FROM_SERVER */
 -#define UNDEFINED   0
 -#define FROM_SERVER 1   /* retrieved from server at runtime */
 -#define FROM_RULES  2   /* xkb rules file */
 -#define FROM_CONFIG 3   /* command-line specified config file */
 -#define FROM_CMD_LINE   4   /* specified at the cmdline */
 -#define NUM_SOURCES 5
 +enum source { 
 +UNDEFINED = 0,
 +FROM_SERVER,  /* Retrieved from server at runtime. */
 +FROM_RULES,   /* Xkb rules file. */
 +FROM_CONFIG,  /* Command-line specified config file. */
 +FROM_CMD_LINE,/* Specified at the cmdline. */
 +NUM_SOURCES 
 +};
  
  /******/
  static Bool print = False;
 @@ -86,7 +88,7 @@ static char *srcName[NUM_SOURCES] = {
  struct setting {
  char const * name;  /* Human-readable setting name. Used for error 
 reporting. */
  char *   value; /* Holds the value. */
 -int  src;   /* Holds the source. */
 +enum source  src;   /* Holds the source. */
  };
  
  typedef struct setting setting_t;
 @@ -173,8 +175,8 @@ static int deviceSpec = XkbUseCoreKbd;
  Bool addToList(list_t * list, char *newVal);
  void usage(int argc, char **argv);
  void dumpNames(Bool wantRules, Bool wantCNames);
 -void trySetString(setting_t * setting, char *newVal, int src);
 -Bool setOptString(int *arg, int argc, char **argv, setting_t * setting, int 
 src);
 +void trySetString(setting_t * setting, char *newVal, enum source src);
 +Bool setOptString(int *arg, int argc, char **argv, setting_t * setting, enum 
 source src);
  int parseArgs(int argc, char **argv);
  Bool getDisplay(int argc, char **argv);
  Bool getServerValues(void);
 @@ -311,7 +313,7 @@ dumpNames(Bool wantRules, Bool wantCNames)
   * @param which What value is it (one of RULES_NDX, CONFIG_NDX, ...)
   */
  void
 -trySetString(setting_t * setting, char *newVal, int src)
 +trySetString(setting_t * setting, char *newVal, enum source src)
  {
  if (setting-value != NULL)
  {
 @@ -337,7 +339,7 @@ trySetString(setting_t * setting, char *newVal, int src)
  }
  
  Bool
 -setOptString(int *arg, int argc, char **argv, setting_t * setting, int src)
 +setOptString(int *arg, int argc, char **argv, setting_t * setting, enum 
 source src)
  {
  int ndx;
  char *opt;
 -- 
 1.7.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 setxkbmap 1/2] Removed unused arg subdir in function findFileInPath()

2011-02-21 Thread Alexandr Shadchin
Signed-off-by: Alexandr Shadchin alexandr.shadc...@gmail.com
---
 setxkbmap.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/setxkbmap.c b/setxkbmap.c
index 0c43be5..1c9c89e 100644
--- a/setxkbmap.c
+++ b/setxkbmap.c
@@ -178,7 +178,7 @@ Bool setOptString(int *arg, int argc, char **argv, 
setting_t * setting, int src)
 int parseArgs(int argc, char **argv);
 Bool getDisplay(int argc, char **argv);
 Bool getServerValues(void);
-FILE *findFileInPath(char *name, char *subdir);
+FILE *findFileInPath(char *name);
 Bool addStringToOptions(char *opt_str, list_t * opts);
 char *stringFromOptions(char *orig, list_t * newOpts);
 Bool applyConfig(char *name);
@@ -622,7 +622,7 @@ getServerValues(void)
 /******/
 
 FILE *
-findFileInPath(char *name, char *subdir)
+findFileInPath(char *name)
 {
 register int i;
 char buf[PATH_MAX];
@@ -637,11 +637,11 @@ findFileInPath(char *name, char *subdir)
 }
 for (i = 0; (i  inclPath.num); i++)
 {
-if (snprintf(buf, PATH_MAX, %s/%s%s, inclPath.item[i], subdir, name) 
=
+if (snprintf(buf, PATH_MAX, %s/%s, inclPath.item[i], name) =
 PATH_MAX)
 {
-VMSG3(0, Path too long (%s/%s%s). Ignored.\n, inclPath.item[i],
-  subdir, name);
+VMSG2(0, Path too long (%s/%s). Ignored.\n, inclPath.item[i],
+  name);
 continue;
 }
 fp = fopen(buf, r);
@@ -739,7 +739,7 @@ applyConfig(char *name)
 FILE *fp;
 Bool ok;
 
-if ((fp = findFileInPath(name, )) == NULL)
+if ((fp = findFileInPath(name)) == NULL)
 return False;
 ok = XkbCFParse(fp, XkbCFDflts, NULL, cfgResult);
 fclose(fp);
-- 
1.7.3.5

___
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 setxkbmap 2/2] Removed unneeded arg name in applyConfig()

2011-02-21 Thread Alexandr Shadchin
Signed-off-by: Alexandr Shadchin alexandr.shadc...@gmail.com
---
 setxkbmap.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/setxkbmap.c b/setxkbmap.c
index 1c9c89e..6c678ff 100644
--- a/setxkbmap.c
+++ b/setxkbmap.c
@@ -181,7 +181,7 @@ Bool getServerValues(void);
 FILE *findFileInPath(char *name);
 Bool addStringToOptions(char *opt_str, list_t * opts);
 char *stringFromOptions(char *orig, list_t * newOpts);
-Bool applyConfig(char *name);
+Bool applyConfig(void);
 Bool applyRules(void);
 Bool applyComponentNames(void);
 void printKeymap(void);
@@ -734,18 +734,19 @@ stringFromOptions(char *orig, list_t * newOpts)
 /******/
 
 Bool
-applyConfig(char *name)
+applyConfig(void)
 {
 FILE *fp;
 Bool ok;
 
-if ((fp = findFileInPath(name)) == NULL)
+if ((fp = findFileInPath(settings.config.value)) == NULL)
 return False;
 ok = XkbCFParse(fp, XkbCFDflts, NULL, cfgResult);
 fclose(fp);
 if (!ok)
 {
-ERR1(Couldn't find configuration file \%s\\n, name);
+ERR1(Couldn't find configuration file \%s\\n,
+ settings.config.value);
 return False;
 }
 if (cfgResult.rules_file)
@@ -1057,7 +1058,7 @@ main(int argc, char **argv)
 VMSG1(7, locale is %s\n, settings.locale.value);
 if (dpy)
 getServerValues();
-if (settings.config.value  (!applyConfig(settings.config.value)))
+if (settings.config.value  (!applyConfig()))
 exit(-3);
 if (!applyRules())
 exit(-4);
-- 
1.7.3.5

___
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 setxkbap] Minor style fixes.

2011-02-21 Thread Peter Hutterer
On Fri, Feb 18, 2011 at 11:21:34PM +0300, Van de Bugger wrote:
 Few tabs replaced with spaces; pointers are written as
 list_t *list (no space between asterisk and variable name).
 ---

merged, thanks.

Cheers,
  Peter

  setxkbmap.c |   28 ++--
  1 files changed, 14 insertions(+), 14 deletions(-)
 
 diff --git a/setxkbmap.c b/setxkbmap.c
 index 07e9267..cb385f9 100644
 --- a/setxkbmap.c
 +++ b/setxkbmap.c
 @@ -86,8 +86,8 @@ static char *srcName[NUM_SOURCES] = {
  };
  
  struct setting {
 -char const * name;  /* Human-readable setting name. Used for error 
 reporting. */
 -char *   value; /* Holds the value. */
 +char const  *name;  /* Human-readable setting name. Used for error 
 reporting. */
 +char*value; /* Holds the value. */
  enum source  src;   /* Holds the source. */
  };
  
 @@ -135,9 +135,9 @@ static XkbRF_VarDefsRec rdefs;
  static Bool clearOptions = False;
  
  struct list {
 - char ** item;   /* Array of items. */
 - int sz; /* Size of array. */
 - int num;/* Number of used elements. */
 +char  **item;   /* Array of items. */
 +int sz; /* Size of array. */
 +int num;/* Number of used elements. */
  };
  
  typedef struct list list_t;
 @@ -172,17 +172,17 @@ static int deviceSpec = XkbUseCoreKbd;
  
  /******/
  
 -Bool addToList(list_t * list, char *newVal);
 +Bool addToList(list_t *list, char *newVal);
  void usage(int argc, char **argv);
  void dumpNames(Bool wantRules, Bool wantCNames);
  void trySetString(setting_t * setting, char *newVal, enum source src);
 -Bool setOptString(int *arg, int argc, char **argv, setting_t * setting, enum 
 source src);
 +Bool setOptString(int *arg, int argc, char **argv, setting_t *setting, enum 
 source src);
  int parseArgs(int argc, char **argv);
  Bool getDisplay(int argc, char **argv);
  Bool getServerValues(void);
  FILE *findFileInPath(char *name, char *subdir);
 -Bool addStringToOptions(char *opt_str, list_t * opts);
 -char *stringFromOptions(char *orig, list_t * newOpts);
 +Bool addStringToOptions(char *opt_str, list_t *opts);
 +char *stringFromOptions(char *orig, list_t *newOpts);
  Bool applyConfig(char *name);
  Bool applyRules(void);
  Bool applyComponentNames(void);
 @@ -196,7 +196,7 @@ void printKeymap(void);
  */
  
  Bool
 -addToList(list_t * list, char *newVal)
 +addToList(list_t *list, char *newVal)
  {
  register int i;
  
 @@ -313,7 +313,7 @@ dumpNames(Bool wantRules, Bool wantCNames)
   * @param which What value is it (one of RULES_NDX, CONFIG_NDX, ...)
   */
  void
 -trySetString(setting_t * setting, char *newVal, enum source src)
 +trySetString(setting_t *setting, char *newVal, enum source src)
  {
  if (setting-value != NULL)
  {
 @@ -339,7 +339,7 @@ trySetString(setting_t * setting, char *newVal, enum 
 source src)
  }
  
  Bool
 -setOptString(int *arg, int argc, char **argv, setting_t * setting, enum 
 source src)
 +setOptString(int *arg, int argc, char **argv, setting_t *setting, enum 
 source src)
  {
  int ndx;
  char *opt;
 @@ -658,7 +658,7 @@ findFileInPath(char *name, char *subdir)
  /******/
  
  Bool
 -addStringToOptions(char *opt_str, list_t * opts)
 +addStringToOptions(char *opt_str, list_t *opts)
  {
  char *tmp, *str, *next;
  Bool ok = True;
 @@ -682,7 +682,7 @@ addStringToOptions(char *opt_str, list_t * opts)
  /******/
  
  char *
 -stringFromOptions(char *orig, list_t * newOpts)
 +stringFromOptions(char *orig, list_t *newOpts)
  {
  int len, i, nOut;
  
 -- 
 1.7.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 10/20] Switch to use IsFloating()

2011-02-21 Thread Benjamin Tissoires

Hi Peter,

Except two unnecessary parenthesis here, you can add my Reviewed-by for 
the series ;)


On 02/18/2011 04:52 AM, Peter Hutterer wrote:

This is not a straightforward search/replacement due to a long-standing
issue.

dev-u.master is the same field as dev-u.lastSlave. Thus, if dev is a master
device, a check for dev-u.master may give us false positives and false
negatives.
The switch to IsFloating() spells out these cases and modifies the
conditions accordingly to cover both cases.

Signed-off-by: Peter Huttererpeter.hutte...@who-t.net
---
  Xi/exevents.c   |6 +++---
  Xi/xipassivegrab.c  |   10 ++
  Xi/xiquerydevice.c  |2 +-
  Xi/xiquerypointer.c |2 +-
  Xi/xiwarppointer.c  |2 +-
  dix/devices.c   |8 
  dix/events.c|6 +++---
  dix/getevents.c |6 +++---
  dix/inpututils.c|2 +-
  mi/mieq.c   |6 +++---
  mi/mipointer.c  |4 ++--
  mi/misprite.c   |   16 
  xkb/xkb.c   |2 +-
  xkb/xkbAccessX.c|2 +-
  xkb/xkbActions.c|6 +++---
  15 files changed, 37 insertions(+), 43 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index b39e202..ea9daa9 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -713,7 +713,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, 
DeviceChangedEvent *dce)
  if (IsMaster(slave))
  return;

-if (!slave-u.master)
+if (IsFloating(slave))
  return; /* set floating since the event */

  if (slave-u.master-id != dce-masterid)
@@ -1009,7 +1009,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
  b = device-button;
  k = device-key;

-if (IsMaster(device) || !device-u.master)
+if (IsMaster(device) || IsFloating(device))
  CheckMotion(event, device);

  switch (event-type)
@@ -1226,7 +1226,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, 
int detail,
  DeviceIntPtr mouse;
  int btlen, len, i;

-mouse = (IsMaster(dev) || dev-u.master) ? GetMaster(dev, MASTER_POINTER) 
: dev;
+mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER);

  /* XI 2 event */
  btlen = (mouse-button) ? bits_to_bytes(mouse-button-numButtons) : 0;
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index e99b6e5..8663d12 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -162,10 +162,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
  if (!modifiers_failed)
  return BadAlloc;

-if (!IsMaster(dev)  dev-u.master)
-mod_dev = GetMaster(dev, MASTER_KEYBOARD);
-else
-mod_dev = dev;
+mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD);


parenthesis around IsFloating are not necessary... It's just to say 
something




  for (i = 0; i  stuff-num_modifiers; i++, modifiers++)
  {
@@ -280,10 +277,7 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
  if (rc != Success)
  return rc;

-if (!IsMaster(dev)  dev-u.master)
-mod_dev = GetMaster(dev, MASTER_KEYBOARD);
-else
-mod_dev = dev;
+mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD);


parenthesis...

Cheers,
Benjamin




  tempGrab.resource = client-clientAsMask;
  tempGrab.device = dev;
diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index fdd2c05..3cad8d7 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -383,7 +383,7 @@ int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment)
  DeviceIntPtr paired = GetPairedDevice(dev);
  use = IsPointerDevice(dev) ? XIMasterPointer : XIMasterKeyboard;
  *attachment = (paired ? paired-id : 0);
-} else if (master)
+} else if (!IsFloating(dev))
  {
  use = IsPointerDevice(master) ? XISlavePointer : XISlaveKeyboard;
  *attachment = master-id;
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index b521c48..26fb43a 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -93,7 +93,7 @@ ProcXIQueryPointer(ClientPtr client)
  }

  if (pDev-valuator == NULL || IsKeyboardDevice(pDev) ||
-(!IsMaster(pDev)  pDev-u.master)) /* no attached devices */
+(!IsMaster(pDev)  !IsFloating(pDev))) /* no attached devices */
  {
  client-errorValue = stuff-deviceid;
  return BadDevice;
diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c
index c01b115..a463ab9 100644
--- a/Xi/xiwarppointer.c
+++ b/Xi/xiwarppointer.c
@@ -97,7 +97,7 @@ ProcXIWarpPointer(ClientPtr client)
  return rc;
  }

-if ((!IsMaster(pDev)  pDev-u.master) ||
+if ((!IsMaster(pDev)  !IsFloating(pDev)) ||
  (IsMaster(pDev)  !IsPointerDevice(pDev)))
  {
  client-errorValue = stuff-deviceid;
diff --git a/dix/devices.c b/dix/devices.c
index 6c0dc42..a3367f7 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -987,7 +987,7 @@ CloseDownDevices(void)
   */
  for (dev = inputInfo.devices; dev; dev = dev-next)
  {
-if (!IsMaster(dev)