[PATCH 2/2] present: Fix use of vsynced pageflips and honor PresentOptionAsync. (v3)

2014-12-03 Thread Mario Kleiner
Pageflips for Pixmap presents were not synchronized to vblank on
drivers with support for PresentCapabilityAsync, due to some
missing init for vblank-sync_flips. The PresentOptionAsync
flag was completely ignored for pageflipped presents.

Vsynced flips only worked by accident on the intel-ddx, as that
driver doesn't have PresentCapabilityAsync support.

On nouveau-ddx, which supports PresentCapabilityAsync, this
always caused non-vsynced pageflips with pretty ugly tearing.

This patch fixes the problem, as tested on top of XOrg 1.16.2
on nouveau and intel.

Please also apply to XOrg 1.17 and XOrg 1.16.2 stable.

Applying on top of XOrg 1.16.2 may require cherry-picking
commit 2051514652481a83bd7cf22e57cb0fcd40333f33
which trivially fixes lack of support for protocol option
PresentOptionCopy - get two bug fixes for the price of one!

Signed-off-by: Mario Kleiner mario.kleiner...@gmail.com
---
 present/present.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/present/present.c b/present/present.c
index e5d3fd5..be1c9f1 100644
--- a/present/present.c
+++ b/present/present.c
@@ -834,7 +834,7 @@ present_pixmap(WindowPtr window,
 vblank-notifies = notifies;
 vblank-num_notifies = num_notifies;
 
-if (!screen_priv-info || !(screen_priv-info-capabilities  
PresentCapabilityAsync))
+if (!(options  PresentOptionAsync))
 vblank-sync_flip = TRUE;
 
 if (!(options  PresentOptionCopy) 
-- 
1.9.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/2] present: Avoid crashes in DebugPresent(), a bit more info.

2014-12-03 Thread Mario Kleiner
DebugPresent() crashed the server when a dri3 drawable
was closed while a pageflipped present was still pending,
due to vblank-window- Null-Ptr deref, so debug builds
caused new problems to debug.

E.g.,

glXSwapBuffers(...);
glXDestroyWindow(...);
- Pageflip for non-existent window completes - boom.

Also often happens when switching desktop compositor on/off
due to Present unflips, or when logging out of session.

Also add info if a Present is queued for copyswap or pageflip,
if the present is vsynced, and the serial no of the Present
request, to aid debugging of pageflip and vsync issues. The
serial number is useful as Mesa's dri3/present backend encodes
its sendSBC in the serial number, so one can easily correlate
server debug output with Mesa and with the SBC values returned
to actual OpenGL client applications via OML_sync_control and
INTEL_swap_events extension, makes debugging quite a bit more
easy.

Please also cherry-pick this for a 1.16.x stable update.

Signed-off-by: Mario Kleiner mario.kleiner...@gmail.com
---
 present/present.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/present/present.c b/present/present.c
index ac9047e..e5d3fd5 100644
--- a/present/present.c
+++ b/present/present.c
@@ -440,7 +440,7 @@ present_flip_notify(present_vblank_ptr vblank, uint64_t 
ust, uint64_t crtc_msc)
 DebugPresent((\tn %lld %p %8lld: %08lx - %08lx\n,
   vblank-event_id, vblank, vblank-target_msc,
   vblank-pixmap ? vblank-pixmap-drawable.id : 0,
-  vblank-window-drawable.id));
+  vblank-window ? vblank-window-drawable.id : 0));
 
 assert (vblank == screen_priv-flip_pending);
 
@@ -859,10 +859,10 @@ present_pixmap(WindowPtr window,
 }
 
 if (pixmap)
-DebugPresent((q %lld %p %8lld: %08lx - %08lx (crtc %p)\n,
+DebugPresent((q %lld %p %8lld: %08lx - %08lx (crtc %p) flip %d vsync 
%d serial %d\n,
   vblank-event_id, vblank, target_msc,
   vblank-pixmap-drawable.id, vblank-window-drawable.id,
-  target_crtc));
+  target_crtc, vblank-flip, vblank-sync_flip, 
vblank-serial));
 
 xorg_list_add(vblank-event_queue, present_exec_queue);
 vblank-queued = TRUE;
@@ -955,7 +955,7 @@ present_vblank_destroy(present_vblank_ptr vblank)
 DebugPresent((\td %lld %p %8lld: %08lx - %08lx\n,
   vblank-event_id, vblank, vblank-target_msc,
   vblank-pixmap ? vblank-pixmap-drawable.id : 0,
-  vblank-window-drawable.id));
+  vblank-window ? vblank-window-drawable.id : 0));
 
 /* Drop pixmap reference */
 if (vblank-pixmap)
-- 
1.9.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

DRI3/Present fixes for XServers 1.16 and 1.17rc - (v2)

2014-12-03 Thread Mario Kleiner
Hi,

an updated set of patches to fix the bugs i found in the
xserver dri3/present implementation and one bug in intel-ddx
uxa/dri3/present implementation. Axel Davys comments made me
rethink my original xserver patch and the new solution is
simple and better and afaics how this was actually intended
to work in the server, the server properly using the present_check_flip
ddx driver function.

Patch 1/2 fixes and slightly improves DebugPresent() macros for
the server to avoid crashes at logout, compositor en/disable or
closing windows while flips are pending when the server is compiled
with debug macros on.

Patch 2/2 fixes the use of PresentOptionAsync for page-flipped present,
and makes Present working on nouveau without horrible tearing.

These patches apply to master, 1.17rc and 1.16.2. They were tested
on top of 1.16.2 with the dri3/present backends of nouveau master
(glamor and exa) and intel master (sna and fixed uxa) on single-display
and dual-display, also ran through my hardware timing test equipment.

Patch uxa/present is a required fix for intel-ddx uxa backend, so
intel_present_check_flip no longer lies to the server about its
capabilities.

Can the x-server patches please also be included into the 1.16 series?

thanks,
-mario

___
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] uxa/present: Handle sync_flip flag in intel_present_check_flip()

2014-12-03 Thread Mario Kleiner
Make sure we reject async flips if we don't support
async flips.

Signed-off-by: Mario Kleiner mario.kleiner...@gmail.com
---
 src/uxa/intel_present.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/uxa/intel_present.c b/src/uxa/intel_present.c
index d20043f..d2aa9ee 100644
--- a/src/uxa/intel_present.c
+++ b/src/uxa/intel_present.c
@@ -58,6 +58,8 @@ struct intel_present_vblank_event {
uint64_tevent_id;
 };
 
+static Bool intel_present_has_async_flip(ScreenPtr screen);
+
 static uint32_t pipe_select(int pipe)
 {
if (pipe  1)
@@ -266,6 +268,9 @@ intel_present_check_flip(RRCrtcPtr  crtc,
 if (!bo)
 return FALSE;
 
+if (!sync_flip  !intel_present_has_async_flip(screen))
+return FALSE;
+
return TRUE;
 }
 
-- 
1.9.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: tile property contents

2014-12-03 Thread Aaron Plattner

On 12/02/2014 07:04 PM, Dave Airlie wrote:

On 3 December 2014 at 10:01, Aaron Plattner aplatt...@nvidia.com wrote:

On 10/13/2014 08:23 PM, Dave Airlie wrote:


Hi,

So I've been hacking on mutter and the gnome pieces for tiling, and
I've at least fixed mutter locally so maximise windows works and the
heads are in the right order.

Now I've strung all the pieces together using a single KMS property
that X.org propogates, and mutter picks up and propagates over dbus as
well,

Currently I've ascii encoded the property into a blob,


ver:tileid:flags:maxhtiles:maxvtiles:h_tile_loc:v_tile_loc:tile_w:tile_h

I'm thinking of dropping the version field and just exposing TILE2
property if we need it later to add more values,



Nifty.  Is there a randrproto.txt spec for this planned?



Well for KMS its a kernel property and is documented there,
I suppose randrproto should also contain the info.


What format does this ID need to be in?  It looks like monitors are
identified by (vendor id, product id, serial number) tuples in the DisplayID
extension block so it would make sense to just concatenate that into one
giant number as the tileid.  Having to centrally manage these (in the
kernel??) seems like overkill.


I don't mind, but central management is what we've done, it wasn't a lot
of work, you could munge the vendor/product/serial, but maybe
DisplayId won't be the only game in town in the future and I'd hate
to tie things to it.


Alright.  At least for now, we can just centrally manage group IDs in 
our X driver until we move that stuff to the kernel.



group - unique per group
flags: bit 0 : single monitor enclosure
maxhtiles: total number of horiz tiles
maxvtiles: total number of vert tiles
h_tile_loc: horiz location of this output in tile group
v_tile_loc: vert location of this output in tile group
tile_w: width of this tile
tile_h: height of this tile.

Now we extract all of these from the DisplayID v1.3 block, and I'm
wondering if maybe I shouldn't just export the whole DisplayID tiling
info block instead, it however encodes a few other pieces of
information, including bezel info, and some flags specifying behaviour
in some cases.



I don't know whether the other flags would be useful, but one important one
is the native resolution field.  At least one monitor I've seen fails to
work if you drive the normal EDID preferred timings on both tiles.


I think the last two fields are copied from that, the tile w/h, I can't see
any mention of a specific native res flag.


Oh, got it.  I was confused by this because our DisplayID parsing 
library calls this field 'native_resolution'.


--
Aaron
___
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] ephyr: Implement per-screen colormaps

2014-12-03 Thread Adam Jackson
From: Michele Baldessari mich...@redhat.com

Xephyr's pseudocolor emulation added in:

commit 81a3b6fe27567b4f91033ece69996aa6bf8d01a3
Author: Matthew Allum breakf...@10.am
Date:   Mon Nov 8 22:39:47 2004 +

Add support to Xephyr for lower depths than hosts

only tracks one global colormap for the whole (Xephyr) display.  Move
this to per-screen state so each screen's colormap can be correct.

[ajax: rebased to 1.17, cleaned up commit message]
Reviewed-by: Adam Jackson a...@redhat.com
Signed-off-by: Michele Baldessari mich...@redhat.com
---
 hw/kdrive/ephyr/ephyr.c |  2 +-
 hw/kdrive/ephyr/ephyr.h |  1 +
 hw/kdrive/ephyr/hostx.c | 11 ++-
 hw/kdrive/ephyr/hostx.h |  2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 93a48a9..907bbeb 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -1292,7 +1292,7 @@ ephyrPutColors(ScreenPtr pScreen, int n, xColorItem * 
pdefs)
 if (p  max)
 max = p;
 
-hostx_set_cmap_entry(p,
+hostx_set_cmap_entry(pScreen, p,
  pdefs-red  8,
  pdefs-green  8, pdefs-blue  8);
 pdefs++;
diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h
index 2395a7f..18bfe11 100644
--- a/hw/kdrive/ephyr/ephyr.h
+++ b/hw/kdrive/ephyr/ephyr.h
@@ -83,6 +83,7 @@ typedef struct _ephyrScrPriv {
 
 KdScreenInfo *screen;
 int mynum;  /* Screen number */
+unsigned long cmap[256];
 
 /**
  * Per-screen Xlib-using state for glamor (private to
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 8d6d5e8..f64861b 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -82,8 +82,6 @@ struct EphyrHostXVars {
 KdScreenInfo **screens;
 
 long damage_debug_msec;
-
-unsigned long cmap[256];
 };
 
 /* memset ( missing ) instead of below  */
@@ -751,9 +749,12 @@ hostx_calculate_color_shift(unsigned long mask)
 }
 
 void
-hostx_set_cmap_entry(unsigned char idx,
+hostx_set_cmap_entry(ScreenPtr pScreen, unsigned char idx,
  unsigned char r, unsigned char g, unsigned char b)
 {
+KdScreenPriv(pScreen);
+KdScreenInfo *screen = pScreenPriv-screen;
+EphyrScrPriv *scrpriv = screen-driver;
 /* need to calculate the shifts for RGB because server could be BGR. */
 /* XXX Not sure if this is correct for 8 on 16, but this works for 8 on 24.*/
 static int rshift, bshift, gshift = 0;
@@ -765,7 +766,7 @@ hostx_set_cmap_entry(unsigned char idx,
 gshift = hostx_calculate_color_shift(HostX.visual-green_mask);
 bshift = hostx_calculate_color_shift(HostX.visual-blue_mask);
 }
-HostX.cmap[idx] = ((r  rshift)  HostX.visual-red_mask) |
+scrpriv-cmap[idx] = ((r  rshift)  HostX.visual-red_mask) |
 ((g  gshift)  HostX.visual-green_mask) |
 ((b  bshift)  HostX.visual-blue_mask);
 }
@@ -1017,7 +1018,7 @@ hostx_paint_rect(KdScreenInfo *screen,
 unsigned char pixel =
 *(unsigned char *) (scrpriv-fb_data + idx);
 xcb_image_put_pixel(scrpriv-ximg, x, y,
-HostX.cmap[pixel]);
+scrpriv-cmap[pixel]);
 break;
 }
 default:
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index 87acd5a..93aaa50 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -141,7 +141,7 @@ hostx_get_visual_masks(KdScreenInfo *screen,
CARD32 *rmsk, CARD32 *gmsk, CARD32 *bmsk);
 void
 
-hostx_set_cmap_entry(unsigned char idx,
+hostx_set_cmap_entry(ScreenPtr pScreen, unsigned char idx,
  unsigned char r, unsigned char g, unsigned char b);
 
 void *hostx_screen_init(KdScreenInfo *screen,
-- 
1.9.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 0/3] GLX fixes for indirect contexts

2014-12-03 Thread Adam Jackson
On Tue, 2014-11-11 at 15:23 +, Jon TURNEY wrote:
 On 22/04/2014 04:56, Keith Packard wrote:
  Jon TURNEY writes:
 
  Fixes for a few problems with GLX and indirect contexts.
 
  I can reproduce [1/3] and [2/3] on X server 1.15.1, mesa 10.1.0 (from 
  Ubuntu
  14.04), but not on X server 1.14.5 mesa 9.2.1 (from Ubuntu 13.10), so 
  these are
  probably regressions in 1.15 and may be candidates for that branch.
 
  Jon TURNEY (3):
 Revert glx: Simplify glXDestroyContext
 glx: Flush context which is being made non-current due to drawable
   going away
 glx: Fix crash when a client exits without deleting GL contexts
 
  I'd love to have Adam take a look at these and see if they seem
  reasonable enough.
 
 Ping?  Any chance these might be considered for 1.17?

2/3 looks a little ugly; is there a reason FlushContext's logic can't be
inlined into the caller?

Other than that these all look fine.  With or without fixing the above,
series is:

Reviewed-by: Adam Jackson a...@redhat.com

- ajax

___
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

issue with FamilyLocal ie AF_UNIX and local accounts

2014-12-03 Thread Alban Browaeys
This affect gnome-initial-setup  program that fails with no protocol
specified.

I can reproduce with DISPLAY=:0 xhost from a root console (with xorg
session setup to allow si:localuser:rootgdmgnome-intial-setup as
exhibited by the same  xhost command  run with 2566835b reverted from
xserver .

Best,
Alban

Bug report:
https://bugs.freedesktop.org/show_bug.cgi?id=86865

ie family local go through the validhosts checks

xserver returns early in ClientAuthorized  InvalidHost without checking
via get_pwnam after the 2566835b commit (Eliminate uninitialized value
warnings from access.c) . This is with FamilyLocal , ConvertAddress
returns immediatly thus addr is kept null (family is set to 256. Then
the commit that eliminate uninitialized value went too far as to check
for addr null before siAddrMatch .

siAddrMatch called into get_pwname before this commit via
siLocalCredAddrMatch then siLocalCredGetId.

This breaks gdm initial setup (gnoem-continuous which is at
1.16.99.901 . Tested against master too .

The attached patch removed the check for null an addr before siAddrMatch
and addrEqual (the latter for consistency as in the same context ).

___
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 xkill] Use secondary mouse pointers

2014-12-03 Thread Kyle Mills

From 0903416a020ef8fe5ada9799a2c532433df3b520 Mon Sep 17 00:00:00 2001
From: khonkhortisan khonkhorti...@gmail.com
Date: Sun, 30 Nov 2014 20:57:47 -0800
Subject: [PATCH xkill] Use secondary mouse pointers

---
 configure.ac  |   2 +-
 man/xkill.man |   8 +++-
 xkill.c   | 130 +-
 3 files changed, 110 insertions(+), 30 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6af4b04..32b68c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ XORG_MACROS_VERSION(1.8)
 XORG_DEFAULT_OPTIONS
 
 # Checks for pkg-config packages
-PKG_CHECK_MODULES(XKILL, [x11 xmuu xproto = 7.0.22])
+PKG_CHECK_MODULES(XKILL, [xi x11 xmuu xproto = 7.0.22])
 
 AC_CONFIG_FILES([
 	Makefile
diff --git a/man/xkill.man b/man/xkill.man
index 6cddc0a..23a2c4c 100644
--- a/man/xkill.man
+++ b/man/xkill.man
@@ -27,7 +27,7 @@
 xkill - kill a client by its X resource
 .SH SYNOPSIS
 .B xkill
-[\-display \fIdisplayname\fP] [\-id \fIresource\fP] [\-button number] [\-frame] [\-all] [\-version]
+[\-display \fIdisplayname\fP] [\-id \fIresource\fP] [\-pointer id] [\-button number] [\-frame] [\-all] [\-version]
 .SH DESCRIPTION
 .PP
 .I Xkill
@@ -48,6 +48,12 @@ This option specifies the X identifier for the resource whose creator is
 to be aborted.  If no resource is specified, \fIxkill\fP will display a
 special cursor with which you should select a window to be kill.
 .TP 8
+.B \-pointer \fIid\fP
+This option specifies the id of a mouse pointer that may be used in
+selecting a window to kill. This id must match the number given by xinput(1).
+If the pointer is specified, any other pointers are ignored.
+By default, every pointer is used.
+.TP 8
 .B \-button \fInumber\fP
 This option specifies the number of pointer button
 that should be used in selecting a window to kill.
diff --git a/xkill.c b/xkill.c
index 32cb0cc..1e6a26c 100644
--- a/xkill.c
+++ b/xkill.c
@@ -45,6 +45,7 @@ from The Open Group.
 
 #include X11/Xos.h
 #include X11/Xlib.h
+#include X11/extensions/XInput2.h
 #include X11/cursorfont.h
 #include X11/Xproto.h
 
@@ -52,11 +53,12 @@ from The Open Group.
 
 static char *ProgramName;
 
+#define SelectPointerAny (-1)
 #define SelectButtonAny (-1)
 #define SelectButtonFirst (-2)
 
 static int parse_button ( char *s, int *buttonp );
-static XID get_window_id ( Display *dpy, int screen, int button, const char *msg );
+static XID get_window_id ( Display *dpy, int screen, int pointer_id, int button, const char *msg );
 static int catch_window_errors ( Display *dpy, XErrorEvent *ev );
 static int kill_all_windows ( Display *dpy, int screenno, Bool top );
 static int verify_okay_to_kill ( Display *dpy, int screenno );
@@ -80,6 +82,7 @@ usage(const char *errmsg)
 -display displaynameX server to contact\n
 -id resourceresource whose client is to be killed\n
 -frame  don't ignore window manager frames\n
+-pointer id specific mouse pointer to use for killing a window\n
 -button number  specific button to be pressed to select window\n
 -allkill all clients with top level windows\n
 -versionprint version and exit\n
@@ -101,12 +104,14 @@ main(int argc, char *argv[])
 char *displayname = NULL;		/* name of server to contact */
 int screenno;			/* screen number of dpy */
 XID id = None;			/* resource to kill */
+int pointer_id;			/* number of mouse pointer to grab */
 char *button_name = NULL;		/* name of button for window select */
 int button;/* button number or negative for all */
 Bool kill_all = False;
 Bool top = False;
 
 ProgramName = argv[0];
+pointer_id = SelectPointerAny;
 button = SelectButtonFirst;
 
 for (i = 1; i  argc; i++) {
@@ -127,6 +132,10 @@ main(int argc, char *argv[])
 		Exit (1, dpy);
 		}
 		continue;
+	  case 'p':
+		if (++i = argc) usage (-pointer requires an argument);
+		pointer_id = strtoul (argv[i], NULL, 0);
+		continue;
 	  case 'b':			/* -button number */
 		if (++i = argc) usage (-button requires an argument);
 		button_name = argv[i];
@@ -208,7 +217,7 @@ main(int argc, char *argv[])
 		button = (int) ((unsigned int) pointer_map[0]);
 	}
 	}
-	if ((id = get_window_id (dpy, screenno, button,
+	if ((id = get_window_id (dpy, screenno, pointer_id, button,
 the window whose client you wish to kill))) {
 	if (id == RootWindow(dpy,screenno)) id = None;
 	else if (!top) {
@@ -270,15 +279,18 @@ parse_button(char *s, int *buttonp)
 }
 
 static XID 
-get_window_id(Display *dpy, int screen, int button, const char *msg)
+get_window_id(Display *dpy, int screen, int pointer_id, int button, const char *msg)
 {
 Cursor cursor;		/* cursor to use when selecting */
 Window root;		/* the current root */
 Window retwin = None;	/* the window that got selected */
 int retbutton = -1;		/* button used to select window */
 int pressed = 0;		/* count of number 

Re: [PATCH xkill] Use secondary mouse pointers

2014-12-03 Thread Peter Hutterer
On Wed, Dec 03, 2014 at 07:56:43PM -0800, Kyle Mills wrote:
 From 0903416a020ef8fe5ada9799a2c532433df3b520 Mon Sep 17 00:00:00 2001
 From: khonkhortisan khonkhorti...@gmail.com
 Date: Sun, 30 Nov 2014 20:57:47 -0800
 Subject: [PATCH xkill] Use secondary mouse pointers

I am honestly wondering: why?

Cheers,
   Peter

 ---
  configure.ac  |   2 +-
  man/xkill.man |   8 +++-
  xkill.c   | 130 
 +-
  3 files changed, 110 insertions(+), 30 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
 index 6af4b04..32b68c0 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -38,7 +38,7 @@ XORG_MACROS_VERSION(1.8)
  XORG_DEFAULT_OPTIONS
  
  # Checks for pkg-config packages
 -PKG_CHECK_MODULES(XKILL, [x11 xmuu xproto = 7.0.22])
 +PKG_CHECK_MODULES(XKILL, [xi x11 xmuu xproto = 7.0.22])
  
  AC_CONFIG_FILES([
   Makefile
 diff --git a/man/xkill.man b/man/xkill.man
 index 6cddc0a..23a2c4c 100644
 --- a/man/xkill.man
 +++ b/man/xkill.man
 @@ -27,7 +27,7 @@
  xkill - kill a client by its X resource
  .SH SYNOPSIS
  .B xkill
 -[\-display \fIdisplayname\fP] [\-id \fIresource\fP] [\-button number] 
 [\-frame] [\-all] [\-version]
 +[\-display \fIdisplayname\fP] [\-id \fIresource\fP] [\-pointer id] [\-button 
 number] [\-frame] [\-all] [\-version]
  .SH DESCRIPTION
  .PP
  .I Xkill
 @@ -48,6 +48,12 @@ This option specifies the X identifier for the resource 
 whose creator is
  to be aborted.  If no resource is specified, \fIxkill\fP will display a
  special cursor with which you should select a window to be kill.
  .TP 8
 +.B \-pointer \fIid\fP
 +This option specifies the id of a mouse pointer that may be used in
 +selecting a window to kill. This id must match the number given by xinput(1).
 +If the pointer is specified, any other pointers are ignored.
 +By default, every pointer is used.
 +.TP 8
  .B \-button \fInumber\fP
  This option specifies the number of pointer button
  that should be used in selecting a window to kill.
 diff --git a/xkill.c b/xkill.c
 index 32cb0cc..1e6a26c 100644
 --- a/xkill.c
 +++ b/xkill.c
 @@ -45,6 +45,7 @@ from The Open Group.
  
  #include X11/Xos.h
  #include X11/Xlib.h
 +#include X11/extensions/XInput2.h
  #include X11/cursorfont.h
  #include X11/Xproto.h
  
 @@ -52,11 +53,12 @@ from The Open Group.
  
  static char *ProgramName;
  
 +#define SelectPointerAny (-1)
  #define SelectButtonAny (-1)
  #define SelectButtonFirst (-2)
  
  static int parse_button ( char *s, int *buttonp );
 -static XID get_window_id ( Display *dpy, int screen, int button, const char 
 *msg );
 +static XID get_window_id ( Display *dpy, int screen, int pointer_id, int 
 button, const char *msg );
  static int catch_window_errors ( Display *dpy, XErrorEvent *ev );
  static int kill_all_windows ( Display *dpy, int screenno, Bool top );
  static int verify_okay_to_kill ( Display *dpy, int screenno );
 @@ -80,6 +82,7 @@ usage(const char *errmsg)
  -display displaynameX server to contact\n
  -id resourceresource whose client is to be killed\n
  -frame  don't ignore window manager frames\n
 +-pointer id specific mouse pointer to use for killing a 
 window\n
  -button number  specific button to be pressed to select 
 window\n
  -allkill all clients with top level windows\n
  -versionprint version and exit\n
 @@ -101,12 +104,14 @@ main(int argc, char *argv[])
  char *displayname = NULL;/* name of server to contact */
  int screenno;/* screen number of dpy */
  XID id = None;   /* resource to kill */
 +int pointer_id;  /* number of mouse pointer to grab */
  char *button_name = NULL;/* name of button for window 
 select */
  int button;  /* button number or negative 
 for all */
  Bool kill_all = False;
  Bool top = False;
  
  ProgramName = argv[0];
 +pointer_id = SelectPointerAny;
  button = SelectButtonFirst;
  
  for (i = 1; i  argc; i++) {
 @@ -127,6 +132,10 @@ main(int argc, char *argv[])
   Exit (1, dpy);
   }
   continue;
 +   case 'p':
 + if (++i = argc) usage (-pointer requires an argument);
 + pointer_id = strtoul (argv[i], NULL, 0);
 + continue;
 case 'b': /* -button number */
   if (++i = argc) usage (-button requires an argument);
   button_name = argv[i];
 @@ -208,7 +217,7 @@ main(int argc, char *argv[])
   button = (int) ((unsigned int) pointer_map[0]);
   }
   }
 - if ((id = get_window_id (dpy, screenno, button,
 + if ((id = get_window_id (dpy, screenno, pointer_id, button,
   the window whose client you wish to kill))) {
   if (id == RootWindow(dpy,screenno)) id = None;