Re: [PATCH] Count the number of logically down buttons in buttonsDown

2009-01-15 Thread Peter Hutterer
On Mon, Jan 05, 2009 at 11:55:40AM -0500, Thomas Jaeger wrote:
 From 3f8ba578ad18b7135031197f6ec5145afcd1479a Mon Sep 17 00:00:00 2001
 From: Thomas Jaeger thjae...@gmail.com
 Date: Mon, 22 Dec 2008 00:55:09 +0100
 Subject: [PATCH] Count the number of logically down buttons in buttonsDown
 
 This fixes the following bug.  Assuming your window manager grabs
 Alt+Button1 to move windows, map Button3 to 0 via XSetPointerMapping,
 then press the physical button 3 (this shouldn't have any effect), press
 Alt and then button 1.  The press event is delivered to the application
 instead of firing the grab.

Signed off and pushed (finally). Thanks for the patch.
Can you send me the updated version of the other patch please, AFAICT there
was a minor change missing.

Cheers,
  Peter

 ---
  Xi/exevents.c  |8 
  include/inputstr.h |6 +-
  2 files changed, 9 insertions(+), 5 deletions(-)
 
 diff --git a/Xi/exevents.c b/Xi/exevents.c
 index 2aa3161..b4359a8 100644
 --- a/Xi/exevents.c
 +++ b/Xi/exevents.c
 @@ -895,10 +895,10 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int 
 count)
  *kptr |= bit;
   if (device-valuator)
   device-valuator-motionHintWindow = NullWindow;
 -b-buttonsDown++;
 - b-motionMask = DeviceButtonMotionMask;
  if (!b-map[key])
  return DONT_PROCESS;
 +b-buttonsDown++;
 + b-motionMask = DeviceButtonMotionMask;
  if (b-map[key] = 5)
   b-state |= (Button1Mask  1)  b-map[key];
   SetMaskForEvent(device-id, Motion_Filter(b), DeviceMotionNotify);
 @@ -927,10 +927,10 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int 
 count)
  *kptr = ~bit;
   if (device-valuator)
   device-valuator-motionHintWindow = NullWindow;
 -if (b-buttonsDown = 1  !--b-buttonsDown)
 - b-motionMask = 0;
  if (!b-map[key])
  return DONT_PROCESS;
 +if (b-buttonsDown = 1  !--b-buttonsDown)
 + b-motionMask = 0;
   if (b-map[key] = 5)
   b-state = ~((Button1Mask  1)  b-map[key]);
   SetMaskForEvent(device-id, Motion_Filter(b), DeviceMotionNotify);
 diff --git a/include/inputstr.h b/include/inputstr.h
 index 4719d37..515b6aa 100644
 --- a/include/inputstr.h
 +++ b/include/inputstr.h
 @@ -185,7 +185,11 @@ typedef struct _ValuatorClassRec {
  
  typedef struct _ButtonClassRec {
  CARD8numButtons;
 -CARD8buttonsDown;/* number of buttons currently down */
 +CARD8buttonsDown;/* number of buttons currently down
 +   This counts logical buttons, not 
 +physical ones, i.e if some buttons
 +are mapped to 0, they're not counted
 +here */
  unsigned short   state;
  Mask motionMask;
  CARD8down[DOWN_LENGTH];
 -- 
 1.6.0.4
 

___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg


Re: [PATCH] Count the number of logically down buttons in buttonsDown

2009-01-15 Thread Thomas Jaeger
Peter Hutterer wrote:
 On Mon, Jan 05, 2009 at 11:55:40AM -0500, Thomas Jaeger wrote:
 From 3f8ba578ad18b7135031197f6ec5145afcd1479a Mon Sep 17 00:00:00 2001
 From: Thomas Jaeger thjae...@gmail.com
 Date: Mon, 22 Dec 2008 00:55:09 +0100
 Subject: [PATCH] Count the number of logically down buttons in buttonsDown

 This fixes the following bug.  Assuming your window manager grabs
 Alt+Button1 to move windows, map Button3 to 0 via XSetPointerMapping,
 then press the physical button 3 (this shouldn't have any effect), press
 Alt and then button 1.  The press event is delivered to the application
 instead of firing the grab.
 
 Signed off and pushed (finally). Thanks for the patch.
 Can you send me the updated version of the other patch please, AFAICT there
 was a minor change missing.

Thanks.  This one should do it now.
From d6ea6d45d5d3ca74bb665f32439f440b30a8939d Mon Sep 17 00:00:00 2001
From: Thomas Jaeger thjae...@gmail.com
Date: Sat, 20 Dec 2008 16:17:02 +0100
Subject: [PATCH] Don't release grabs unless all buttons are up

Previously, only buttons = 5 would count here, but the core protocol
allows for 255 buttons.

http://lists.freedesktop.org/archives/xorg/2009-January/042092.html
---
 Xi/exevents.c |2 +-
 dix/events.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index f3f9d39..6bf9e56 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1118,7 +1118,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
 	xE-u.u.detail = key;
 	return;
 	}
-if (!b-state  device-deviceGrab.fromPassiveGrab)
+if (!b-buttonsDown  device-deviceGrab.fromPassiveGrab)
 deactivateDeviceGrab = TRUE;
 }
 
diff --git a/dix/events.c b/dix/events.c
index a042089..e23cf8f 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3929,7 +3929,7 @@ ProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count)
 	if (xE-u.u.detail == 0)
 		return;
 filters[mouse-id][Motion_Filter(butc)] = MotionNotify;
-	if (!butc-state  mouse-deviceGrab.fromPassiveGrab)
+	if (!butc-buttonsDown  mouse-deviceGrab.fromPassiveGrab)
 		deactivateGrab = TRUE;
 	break;
 	default:
-- 
1.6.0.6

___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg

Re: [PATCH] Count the number of logically down buttons in buttonsDown

2009-01-15 Thread Peter Hutterer
On Thu, Jan 15, 2009 at 08:22:17PM -0500, Thomas Jaeger wrote:
 From d6ea6d45d5d3ca74bb665f32439f440b30a8939d Mon Sep 17 00:00:00 2001
 From: Thomas Jaeger thjae...@gmail.com
 Date: Sat, 20 Dec 2008 16:17:02 +0100
 Subject: [PATCH] Don't release grabs unless all buttons are up
 
 Previously, only buttons = 5 would count here, but the core protocol
 allows for 255 buttons.
 
 http://lists.freedesktop.org/archives/xorg/2009-January/042092.html

Pushed, thanks again.

Cheers,
  Peter

 ---
  Xi/exevents.c |2 +-
  dix/events.c  |2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/Xi/exevents.c b/Xi/exevents.c
 index f3f9d39..6bf9e56 100644
 --- a/Xi/exevents.c
 +++ b/Xi/exevents.c
 @@ -1118,7 +1118,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, 
 int count)
   xE-u.u.detail = key;
   return;
   }
 -if (!b-state  device-deviceGrab.fromPassiveGrab)
 +if (!b-buttonsDown  device-deviceGrab.fromPassiveGrab)
  deactivateDeviceGrab = TRUE;
  }
  
 diff --git a/dix/events.c b/dix/events.c
 index a042089..e23cf8f 100644
 --- a/dix/events.c
 +++ b/dix/events.c
 @@ -3929,7 +3929,7 @@ ProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, 
 int count)
   if (xE-u.u.detail == 0)
   return;
  filters[mouse-id][Motion_Filter(butc)] = MotionNotify;
 - if (!butc-state  mouse-deviceGrab.fromPassiveGrab)
 + if (!butc-buttonsDown  mouse-deviceGrab.fromPassiveGrab)
   deactivateGrab = TRUE;
   break;
   default:
 -- 
 1.6.0.6

___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg


Re: [PATCH] Count the number of logically down buttons in buttonsDown

2009-01-05 Thread Keith Packard
On Mon, 2009-01-05 at 11:59 -0500, Thomas Jaeger wrote:

  if ((grab-coreGrab  !button-state)  ... ||
  (!grab-coreGrab  AllButtonsAreUp(b))

Unless I'm completely lost, you shouldn't need to make this distinction
(see previous message).

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


signature.asc
Description: This is a digitally signed message part
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg