[PATCH app/xdm] dm: Don't crash if argc == 0

2015-05-27 Thread Egbert Eich
From: Egbert Eich e...@suse.de

It is not guaranteed that argc  0. So make sure we don't crash
if no valid command line arguments are given.

Signed-off-by: Egbert Eich e...@suse.de
---
 xdm/dm.c | 47 +++
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/xdm/dm.c b/xdm/dm.c
index 603cc63..bdc830a 100644
--- a/xdm/dm.c
+++ b/xdm/dm.c
@@ -129,8 +129,13 @@ main (int argc, char **argv)
 if (((oldumask = umask(022))  002) == 002)
(void) umask (oldumask);
 #ifndef NOXDMTITLE
-Title = argv[0];
-TitleLen = (argv[argc - 1] + strlen(argv[argc - 1])) - Title;
+if (argc  0) {
+Title = argv[0];
+TitleLen = (argv[argc - 1] + strlen(argv[argc - 1])) - Title;
+} else {
+Title = NULL;
+TitleLen = 0;
+}
 #endif
 
 #ifdef USESECUREWARE
@@ -1074,25 +1079,27 @@ void SetTitle (char *name, ...)
 char   *s;
 va_listargs;
 
-va_start(args,name);
-*p++ = '-';
---left;
-s = name;
-while (s)
-{
-   while (*s  left  0)
-   {
-   *p++ = *s++;
-   left--;
-   }
-   s = va_arg (args, char *);
-}
-while (left  0)
-{
-   *p++ = ' ';
-   --left;
+if (p != NULL  left  0) {
+va_start(args,name);
+*p++ = '-';
+--left;
+s = name;
+while (s)
+{
+while (*s  left  0)
+{
+*p++ = *s++;
+left--;
+}
+s = va_arg (args, char *);
+}
+while (left  0)
+{
+*p++ = ' ';
+--left;
+}
+va_end(args);
 }
-va_end(args);
 # endif
 }
 #endif
-- 
1.8.4.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 app/xdm] Fix notorious execution scenario for xdm

2015-05-27 Thread Egbert Eich
I ran across a notorious scenario where xdm was executed
with argc was 0. This caused xdm to segfault.
While this scenario was most likely invalid, it unveiled
a rather minor issue in xdm's arument handling.
So here is a fix.

Egbert Eich (1):
  dm: Don't crash if argc == 0

 xdm/dm.c | 47 +++
 1 file changed, 27 insertions(+), 20 deletions(-)

-- 
1.8.4.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 libX11-xcb] add XCBGetXDisplay

2015-05-27 Thread Mike Blumenkrantz
This patch is useful for people working with XWayland, where the X11
connection must be opened from a file descriptor.From c5e4bf50a722670e0ac1b05509834874251c0c9c Mon Sep 17 00:00:00 2001
From: Mike Blumenkrantz zm...@osg.samsung.com
Date: Wed, 27 May 2015 08:37:05 -0400
Subject: [PATCH] add XCBGetXDisplay

a method for creating a Display object from an xcb connection

Signed-off-by: Mike Blumenkrantz zm...@osg.samsung.com
---
 include/X11/Xlib-xcb.h |   1 +
 src/x11_xcb.c  | 562 +
 2 files changed, 563 insertions(+)

diff --git a/include/X11/Xlib-xcb.h b/include/X11/Xlib-xcb.h
index a21e2be..240a25c 100644
--- a/include/X11/Xlib-xcb.h
+++ b/include/X11/Xlib-xcb.h
@@ -11,6 +11,7 @@
 _XFUNCPROTOBEGIN
 
 xcb_connection_t *XGetXCBConnection(Display *dpy);
+Display *XCBGetXDisplay(xcb_connection_t *c);
 
 enum XEventQueueOwner { XlibOwnsEventQueue = 0, XCBOwnsEventQueue };
 void XSetEventQueueOwner(Display *dpy, enum XEventQueueOwner owner);
diff --git a/src/x11_xcb.c b/src/x11_xcb.c
index 3ddf403..0dabf6d 100644
--- a/src/x11_xcb.c
+++ b/src/x11_xcb.c
@@ -1,9 +1,78 @@
 /* Copyright (C) 2003,2006 Jamey Sharp, Josh Triplett
  * This file is licensed under the MIT license. See the file COPYING. */
 
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
 #include Xlibint.h
 #include Xxcbint.h
 
+#include X11/Xatom.h
+#include X11/Xresource.h
+#include stdio.h
+#include Xintconn.h
+
+#ifdef XKB
+#include XKBlib.h
+#endif /* XKB */
+
+#ifdef XTHREADS
+#include locking.h
+int  (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
+void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
+
+#define InitDisplayLock(d)	(_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success)
+#define FreeDisplayLock(d)	if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d)
+#else
+#define InitDisplayLock(dis) Success
+#define FreeDisplayLock(dis)
+#endif /* XTHREADS */
+
+static xReq _dummy_request = {
+	0, 0, 0
+};
+
+/* OutOfMemory is called if malloc fails.  XOpenDisplay returns NULL
+   after this returns. */
+
+static void OutOfMemory(Display *dpy)
+{
+if(dpy-xcb-connection)
+	xcb_disconnect(dpy-xcb-connection);
+_XFreeDisplayStructure (dpy);
+}
+
+
+static int _XCBConnectX(Display *dpy, _Xconst char *display, int *screenp, xcb_connection_t *c)
+{
+	char *host;
+	int n = 0;
+
+	dpy-fd = -1;
+
+	dpy-xcb = Xcalloc(1, sizeof(_X11XCBPrivate));
+	if(!dpy-xcb)
+		return 0;
+
+	if(!xcb_parse_display(display, host, n, screenp))
+		return 0;
+	/* host and n are unused, but xcb_parse_display requires them */
+	free(host);
+
+	dpy-fd = xcb_get_file_descriptor(c);
+
+	dpy-xcb-connection = c;
+	dpy-xcb-next_xid = xcb_generate_id(dpy-xcb-connection);
+
+	dpy-xcb-event_notify = xcondition_malloc();
+	dpy-xcb-reply_notify = xcondition_malloc();
+	if (!dpy-xcb-event_notify || !dpy-xcb-reply_notify)
+		return 0;
+	xcondition_init(dpy-xcb-event_notify);
+	xcondition_init(dpy-xcb-reply_notify);
+	return !xcb_connection_has_error(c);
+}
+
 xcb_connection_t *XGetXCBConnection(Display *dpy)
 {
 	return dpy-xcb-connection;
@@ -13,3 +82,496 @@ void XSetEventQueueOwner(Display *dpy, enum XEventQueueOwner owner)
 {
 	dpy-xcb-event_owner = owner;
 }
+
+Display *XCBGetXDisplay(xcb_connection_t *c)
+{
+	register Display *dpy;		/* New Display object being created. */
+	register int i;
+	int j, k;			/* random iterator indexes */
+	char *display_name;		/* pointer to display name */
+	char *setup = NULL;		/* memory allocated at startup */
+	int iscreen;			/* screen number */
+	xConnSetupPrefix prefix;	/* prefix information */
+	int vendorlen;			/* length of vendor string */
+	union {
+		xConnSetup *setup;
+		char *failure;
+		char *vendor;
+		xPixmapFormat *sf;
+		xWindowRoot *rp;
+		xDepth *dp;
+		xVisualType *vp;
+	} u;/* proto data returned from server */
+	long setuplength;	/* number of bytes in setup message */
+	long usedbytes = 0; /* number of bytes we have processed */
+	unsigned long mask;
+	long int conn_buf_size;
+	char *xlib_buffer_size;
+
+	if ((display_name = getenv(DISPLAY)) == NULL) {
+		/* Oops! No DISPLAY environment variable - error. */
+		return(NULL);
+	}
+
+	/*
+	 * Set the default error handlers.  This allows the global variables to
+	 * default to NULL for use with shared libraries.
+	 */
+	if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL);
+	if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL);
+
+	/*
+	 * Attempt to allocate a display structure. Return NULL if allocation fails.
+	 */
+	if ((dpy = Xcalloc(1, sizeof(Display))) == NULL) {
+		return(NULL);
+	}
+
+	if ((dpy-display_name = strdup(display_name)) == NULL) {
+		OutOfMemory(dpy);
+		return(NULL);
+	}
+
+/*
+ * Call the Connect routine to set up the transport connection object.
+ * If 0 is returned, the connection failed.
+ */
+
+	if(!_XCBConnectX(dpy, display_name, iscreen, c)) {
+		OutOfMemory(dpy);
+		return NULL;
+	}
+
+	/* Initialize as much of the display structure as we can.
+	 * Initialize 

Re: [PATCH xwayland 4/4] xwayland: Make the XYToWindowProc implementation aware of touchpoints

2015-05-27 Thread Jasper St. Pierre
I'm planning on removing this hook and just make compositors deal with
the fallout. Unfortunately, it hasn't been merged yet.

http://patchwork.freedesktop.org/patch/43021/

On Wed, May 27, 2015 at 9:42 AM, Carlos Garnacho carl...@gnome.org wrote:
 For these, we must first lookup the DIX sequence from the Sprite, we can
 then lookup the DDX ID/xwl_touch from xwayland's touch device.

 Signed-off-by: Carlos Garnacho carl...@gnome.org
 ---
  hw/xwayland/xwayland-input.c | 68 
 +++-
  1 file changed, 55 insertions(+), 13 deletions(-)

 diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
 index 3229c54..9d554a8 100644
 --- a/hw/xwayland/xwayland-input.c
 +++ b/hw/xwayland/xwayland-input.c
 @@ -818,29 +818,71 @@ DDXRingBell(int volume, int pitch, int duration)
  {
  }

 -static WindowPtr
 -xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
 +static int32_t
 +lookup_sprite_touch_client_id (SpritePtr sprite)
  {
 -struct xwl_seat *xwl_seat = NULL;
  DeviceIntPtr device;
 +int i;

  for (device = inputInfo.devices; device; device = device-next) {
 -if (device-deviceProc == xwl_pointer_proc 
 -device-spriteInfo-sprite == sprite) {
 -xwl_seat = device-public.devicePrivate;
 -break;
 +if (!device-touch)
 +continue;
 +
 +for (i = 0; i  device-touch-num_touches; i++) {
 +TouchPointInfoPtr ti = device-touch-touches + i;
 +
 +if (sprite == ti-sprite)
 +return ti-client_id;
  }
  }

 -if (xwl_seat == NULL) {
 -/* XTEST device */
 -sprite-spriteTraceGood = 1;
 -return sprite-spriteTrace[0];
 +return 0;
 +}
 +
 +static struct xwl_touch *
 +xwl_touch_lookup_from_client_id (struct xwl_seat *xwl_seat, int32_t 
 client_id)
 +{
 +DeviceIntPtr touch = xwl_seat-touch;
 +int i;
 +
 +for (i = 0; i  touch-last.num_touches; i++) {
 +DDXTouchPointInfoPtr ddx_ti = touch-last.touches + i;
 +
 +if (ddx_ti-client_id == client_id)
 +return xwl_seat_lookup_touch(xwl_seat, ddx_ti-ddx_id);
 +}
 +
 +return NULL;
 +}
 +
 +static WindowPtr
 +xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
 +{
 +struct xwl_screen *xwl_screen;
 +struct xwl_seat *xwl_seat = NULL;
 +struct xwl_window *xwl_window = NULL;
 +struct xwl_touch *xwl_touch;
 +int32_t client_id;
 +
 +xwl_screen = xwl_screen_get(screen);
 +
 +xorg_list_for_each_entry(xwl_seat, xwl_screen-seat_list, link) {
 +if (xwl_seat-pointer-spriteInfo-sprite == sprite) {
 +xwl_window = xwl_seat-focus_window;
 +} else if ((client_id = lookup_sprite_touch_client_id (sprite)) != 
 0) {
 +xwl_touch = xwl_touch_lookup_from_client_id (xwl_seat, 
 client_id);
 +
 +if (xwl_touch)
 +xwl_window = xwl_touch-window;
 +}
 +
 +if (xwl_window)
 +break;
  }

 -if (xwl_seat-focus_window) {
 +if (xwl_window) {
  sprite-spriteTraceGood = 2;
 -sprite-spriteTrace[1] = xwl_seat-focus_window-window;
 +sprite-spriteTrace[1] = xwl_window-window;
  return miSpriteTrace(sprite, x, y);
  }
  else {
 --
 2.4.1

 ___
 wayland-devel mailing list
 wayland-de...@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/wayland-devel



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

[RFC] xserver 1.17.2 candidate branch

2015-05-27 Thread Adam Jackson
I've put together a candidate branch for a 1.17.2 release, see pull
request below.  I've tried to pick up as many fixes from master as
possible without pulling in the more disruptive changes to glamor or
randr.

If anybody has suggestions or complaints please speak up, I'd like to
get this out early next week if possible (and 1.17.3 is always an
option later if we need it).

---

The following changes since commit 3b0d1ba2266d2780bfc111bab74885b90458eca4:

  Release 1.17.1 (2015-02-10 14:43:59 -0800)

are available in the git repository at:

  ssh://people.freedesktop.org/~ajax/xserver.git server-1.17-branch

for you to fetch changes up to 27846c49e883a47d80a33fd2979ee4357f776ffd:

  backtrace.c: Fix word cast to a pointer (2015-05-27 09:56:34 -0400)


Aaron Plattner (2):
  xfree86: Fix xf86_check_platform_slot's handling of PCI
  xfree86: Add GPU screens even if there are no active GDevs

Adel Gadllah (1):
  modesetting: Fix software cursor fallback

Alan Coopersmith (2):
  Clear ListenTransConns entries in CloseWellKnownConnections
  Accept x86_64 as well as i*86 for $host_cpu in Solaris on x86

Brent Collins (1):
  shm: Fix xselinux resource initialization for xinerama pixmaps

Chris Wilson (1):
  shm: Fix use-after-free in ShmDestroyPixmap

Colin Harrison (2):
  os/xdmcp.c: Include Xtrans.h when building for WIN32
  os/utils.c: Don't try to build os_move_fd() for WIN32

Dave Airlie (1):
  os/access: fix regression in server interpreted auth

Dima Ryazanov (1):
  xwayland: Implement smooth scrolling

Egbert Eich (6):
  symbols: Fix sdksyms.sh to cope with gcc5
  Xephyr: Don't crash when no command line argument is specified
  Xephyr: Print default server display number if none is specified
  Xephyr: Fix compile when debugging is enabled
  Xephyr: Fix screen image draw for the non-Glamor  non-XHSM case
  Xephyr: Fix broken image when endianess of client machine and 
host-Xserver differ

Emil Velikov (2):
  randr: remove chatty error messages
  randr: use randr: prefix in ErrorF()

Hans de Goede (1):
  Re-enable non serverfd input devices immediately on vtenter

Jason Gerecke (2):
  xfree86: Return NULL from xf86CompatOutput if no compat_output is defined
  dix: Do not allow device transform to be set on valuatorless devices

Jon TURNEY (9):
  ephyr: Avoid a segfault with 'DISPLAY= Xephy -glamor'
  os: XDMCP options like -query etc. should imply -listen tcp
  os: Teach vpnprintf() how to handle %*.*s
  hw/xwin/glx: Refactor parsing of the proto XML element
  hw/xwin/glx: Improve code generator to deal with latest Khronos OpenGL 
registry XML
  hw/xwin: Report Cygwin version information in log
  glamor: Fix build when configured --enable-glamor --disable-xshmfence
  hw/xwin/winclipboard: Link xwinclip with -lpthread
  hw/xnest: Fix build for MinGW

Jonathan Gray (2):
  glamor: remove const from the return type of 
glamor_get_drawable_location()
  glamor: fix build when DRI3 is not defined

Jürg Billeter (1):
  int10: Fix error check for pci_device_map_legacy

Keith Packard (1):
  mi: Partial pie-slice filled arcs may need more space for spans

Maarten Lankhorst (4):
  glamor: only use (un)pack_subimage when available
  glamor: do not check for gl errors in glamor_build_program
  glamor: Use GL_FRAMEBUFFER instead of GL_READ_FRAMEBUFFER
  glamor: GL_TEXTURE_MAX_LEVEL is not available on GLES2

Michal Srb (1):
  Expose GetMaster to modules.

Michel Dänzer (2):
  Add AC_SYS_LARGEFILE defines to dix-config.h
  modesetting: Include dix-config.h from dumb_bo.c

Olivier Fourdan (4):
  ephyr: Fail if glamor is requested but not usable
  xwayland: Add dependency on glamor libs
  glamor: check max native ALU instructions
  dix: Fix image byte order on big endian hardware

Peter Hutterer (1):
  config: remove 10-evdev.conf, let the evdev driver install that file

Ray Strode (5):
  systemd-logind: filter out non-signal messages from message filter
  systemd-logind: don't second guess D-Bus default timeout
  xwayland: Enable access control on open sockets [CVE-2015-3164 1/3]
  os: support new implicit local user access mode [CVE-2015-3164 2/3]
  xwayland: default to local user if no xauth file given. [CVE-2015-3164 
3/3]

Robert Ancell (1):
  xwayland: Fix error strings

Rui Matos (1):
  dix/events: Set currentTime to the given time stamp in NoticeTime

Vicente Olivert Riera (1):
  backtrace.c: Fix word cast to a pointer

 Xext/shm.c   |  10 +-
 config/10-evdev.conf |  40 
 config/Makefile.am   |   4 +-
 configure.ac |   6 +-
 dix/devices.c|   3 +
 dix/events.c   

Re: [PATCH] xwayland: Throttle our cursor surface updates with a frame callback

2015-05-27 Thread Keith Packard
Rui Matos tiagoma...@gmail.com writes:

 In some extreme cases with animated cursors at a high frame rate we
 could end up filling the wl_display outgoing buffer and end up with
 wl_display_flush() failing.

 In any case, using the frame callback to throttle ourselves is the
 right thing to do.

 Signed-off-by: Rui Matos tiagoma...@gmail.com
 ---


 On Tue, May 26, 2015 at 10:58 PM, Keith Packard kei...@keithp.com wrote:
 Looks like there have been some other updates in this area? Can I get
 one of you to build a patch on master?

 Sorry, my master branch was a couple of weeks old. Rebased.

Merged.
   806470b..cbb7eb7  master - master

-- 
-keith


signature.asc
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

[PATCH xwayland 3/4] xwayland: Remove related touchpoints when unrealizing windows

2015-05-27 Thread Carlos Garnacho
These sequences are forgotten to all purposes.

Signed-off-by: Carlos Garnacho carl...@gnome.org
---
 hw/xwayland/xwayland-input.c | 14 ++
 hw/xwayland/xwayland.c   |  6 +++---
 hw/xwayland/xwayland.h   |  2 ++
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 6916317..3229c54 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -850,6 +850,20 @@ xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int 
x, int y)
 }
 
 void
+xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window)
+{
+struct xwl_touch *xwl_touch, *next_xwl_touch;
+
+xorg_list_for_each_entry_safe(xwl_touch, next_xwl_touch,
+  xwl_seat-touches, link_touch) {
+if (xwl_touch-window-window == window) {
+xorg_list_del(xwl_touch-link_touch);
+free(xwl_touch);
+}
+}
+}
+
+void
 InitInput(int argc, char *argv[])
 {
 ScreenPtr pScreen = screenInfo.screens[0];
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index bc92beb..f25bc00 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -287,10 +287,10 @@ xwl_unrealize_window(WindowPtr window)
 xwl_screen = xwl_screen_get(screen);
 
 xorg_list_for_each_entry(xwl_seat, xwl_screen-seat_list, link) {
-if (!xwl_seat-focus_window)
-continue;
-if (xwl_seat-focus_window-window == window)
+if (xwl_seat-focus_window  xwl_seat-focus_window-window == window)
 xwl_seat-focus_window = NULL;
+
+xwl_seat_clear_touch(xwl_seat, window);
 }
 
 screen-UnrealizeWindow = xwl_screen-UnrealizeWindow;
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index d40348d..86d2649 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -160,6 +160,8 @@ void xwl_seat_set_cursor(struct xwl_seat *xwl_seat);
 
 void xwl_seat_destroy(struct xwl_seat *xwl_seat);
 
+void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window);
+
 Bool xwl_screen_init_output(struct xwl_screen *xwl_screen);
 
 struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
-- 
2.4.1

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

[PATCH xwayland 1/4] xwayland: Add xwl_touch struct

2015-05-27 Thread Carlos Garnacho
This struct holds information about each individual, ongoing touchpoint.
A list of these is held by the xwl_seat.

Signed-off-by: Carlos Garnacho carl...@gnome.org
---
 hw/xwayland/xwayland-input.c | 10 ++
 hw/xwayland/xwayland.h   |  9 +
 2 files changed, 19 insertions(+)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index a6fbab5..9d355a5 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -554,11 +554,21 @@ create_input_device(struct xwl_screen *xwl_screen, 
uint32_t id)
 xwl_seat-cursor = wl_compositor_create_surface(xwl_screen-compositor);
 wl_seat_add_listener(xwl_seat-seat, seat_listener, xwl_seat);
 wl_array_init(xwl_seat-keys);
+
+xorg_list_init(xwl_seat-touches);
 }
 
 void
 xwl_seat_destroy(struct xwl_seat *xwl_seat)
 {
+struct xwl_touch *xwl_touch, *next_xwl_touch;
+
+xorg_list_for_each_entry_safe(xwl_touch, next_xwl_touch,
+  xwl_seat-touches, link_touch) {
+xorg_list_del(xwl_touch-link_touch);
+free(xwl_touch);
+}
+
 RemoveDevice(xwl_seat-pointer, FALSE);
 RemoveDevice(xwl_seat-keyboard, FALSE);
 wl_seat_destroy(xwl_seat-seat);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 28b0c99..3384a43 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -107,6 +107,13 @@ struct xwl_window {
 
 #define MODIFIER_META 0x01
 
+struct xwl_touch {
+struct xwl_window *window;
+int32_t id;
+int x, y;
+struct xorg_list link_touch;
+};
+
 struct xwl_seat {
 DeviceIntPtr pointer;
 DeviceIntPtr keyboard;
@@ -124,6 +131,8 @@ struct xwl_seat {
 struct wl_callback *cursor_frame_cb;
 Bool cursor_needs_update;
 
+struct xorg_list touches;
+
 size_t keymap_size;
 char *keymap;
 struct wl_surface *keyboard_focus;
-- 
2.4.1

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

[PATCH xwayland 2/4] xwayland: Implement the wl_touch interface

2015-05-27 Thread Carlos Garnacho
A DeviceIntPtr with touch valuators is also created in order to deliver
the translated touch events. The lifetime of xwl_touch structs is tied
to the wayland ones, finishing in either wl_touch.up() or wl_touch.cancel()

Signed-off-by: Carlos Garnacho carl...@gnome.org
---
 hw/xwayland/xwayland-input.c | 206 ++-
 hw/xwayland/xwayland.h   |   2 +
 2 files changed, 205 insertions(+), 3 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 9d355a5..6916317 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -148,6 +148,61 @@ xwl_keyboard_proc(DeviceIntPtr device, int what)
 return BadMatch;
 }
 
+static int
+xwl_touch_proc(DeviceIntPtr device, int what)
+{
+#define NTOUCHPOINTS 20
+#define NBUTTONS 1
+#define NAXES 2
+struct xwl_seat *xwl_seat = device-public.devicePrivate;
+Atom btn_labels[NBUTTONS] = { 0 };
+Atom axes_labels[NAXES] = { 0 };
+BYTE map[NBUTTONS + 1] = { 0 };
+
+switch (what) {
+case DEVICE_INIT:
+device-public.on = FALSE;
+
+axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_X);
+axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y);
+
+if (!InitValuatorClassDeviceStruct(device, NAXES, axes_labels,
+   GetMotionHistorySize(), Absolute))
+return BadValue;
+
+if (!InitButtonClassDeviceStruct(device, NBUTTONS, btn_labels, map))
+return BadValue;
+
+if (!InitTouchClassDeviceStruct(device, NTOUCHPOINTS,
+XIDirectTouch, NAXES))
+return BadValue;
+
+/* Valuators */
+/* FIXME: devices might be mapped to a single wl_output */
+InitValuatorAxisStruct(device, 0, axes_labels[0],
+   0, xwl_seat-xwl_screen-width,
+   1, 0, 1, Absolute);
+InitValuatorAxisStruct(device, 1, axes_labels[1],
+   0, xwl_seat-xwl_screen-height,
+   1, 0, 1, Absolute);
+return Success;
+
+case DEVICE_ON:
+device-public.on = TRUE;
+return Success;
+
+case DEVICE_OFF:
+case DEVICE_CLOSE:
+device-public.on = FALSE;
+return Success;
+}
+
+return BadMatch;
+#undef NAXES
+#undef NBUTTONS
+#undef NTOUCHPOINTS
+}
+
 static void
 pointer_handle_enter(void *data, struct wl_pointer *pointer,
  uint32_t serial, struct wl_surface *surface,
@@ -449,6 +504,129 @@ static const struct wl_keyboard_listener 
keyboard_listener = {
 keyboard_handle_modifiers,
 };
 
+static struct xwl_touch *
+xwl_seat_lookup_touch(struct xwl_seat *xwl_seat, int32_t id)
+{
+struct xwl_touch *xwl_touch, *next_xwl_touch;
+
+xorg_list_for_each_entry_safe(xwl_touch, next_xwl_touch,
+  xwl_seat-touches, link_touch) {
+if (xwl_touch-id == id)
+return xwl_touch;
+}
+
+return NULL;
+}
+
+static void
+xwl_touch_send_event(struct xwl_touch *xwl_touch,
+ struct xwl_seat *xwl_seat, int type)
+{
+int32_t dx, dy;
+ValuatorMask mask;
+
+dx = xwl_touch-window-window-drawable.x;
+dy = xwl_touch-window-window-drawable.y;
+
+valuator_mask_zero(mask);
+valuator_mask_set(mask, 0, dx + xwl_touch-x);
+valuator_mask_set(mask, 1, dy + xwl_touch-y);
+QueueTouchEvents(xwl_seat-touch, type, xwl_touch-id, 0, mask);
+}
+
+static void
+touch_handle_down(void *data, struct wl_touch *wl_touch,
+  uint32_t serial, uint32_t time,
+  struct wl_surface *surface,
+  int32_t id, wl_fixed_t sx_w, wl_fixed_t sy_w)
+{
+struct xwl_seat *xwl_seat = data;
+struct xwl_touch *xwl_touch;
+
+if (surface == NULL)
+return;
+
+xwl_touch = calloc(sizeof *xwl_touch, 1);
+if (xwl_touch == NULL) {
+ErrorF(touch_handle_down ENOMEM);
+return;
+}
+
+xwl_touch-window = wl_surface_get_user_data(surface);
+xwl_touch-id = id;
+xwl_touch-x = wl_fixed_to_int(sx_w);
+xwl_touch-y = wl_fixed_to_int(sy_w);
+xorg_list_add(xwl_touch-link_touch, xwl_seat-touches);
+
+xwl_touch_send_event(xwl_touch, xwl_seat, XI_TouchBegin);
+}
+
+static void
+touch_handle_up(void *data, struct wl_touch *wl_touch,
+uint32_t serial, uint32_t time, int32_t id)
+{
+struct xwl_touch *xwl_touch;
+struct xwl_seat *xwl_seat = data;
+
+xwl_touch = xwl_seat_lookup_touch(xwl_seat, id);
+
+if (!xwl_touch)
+return;
+
+xwl_touch_send_event(xwl_touch, xwl_seat, XI_TouchEnd);
+xorg_list_del(xwl_touch-link_touch);
+free(xwl_touch);
+}
+
+static void
+touch_handle_motion(void *data, struct wl_touch *wl_touch,
+uint32_t time, int32_t id,
+wl_fixed_t sx_w, wl_fixed_t sy_w)
+{
+   

[PATCH xwayland 0/4] Implement wl_touch

2015-05-27 Thread Carlos Garnacho
Hey,

Here's some patches to implement/bridge wl_touch in xwayland, sent these 
patches some months ago but they went unnoticed and later forgotten. I rebased 
on top of master and they still work alright. Not sure if this is a better 
timing, but...

Cheers,
  Carlos

 hw/xwayland/xwayland-input.c | 298 ---
 hw/xwayland/xwayland.c   |   6 +-
 hw/xwayland/xwayland.h   |  13 ++
 3 files changed, 298 insertions(+), 19 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

[PATCH xwayland 4/4] xwayland: Make the XYToWindowProc implementation aware of touchpoints

2015-05-27 Thread Carlos Garnacho
For these, we must first lookup the DIX sequence from the Sprite, we can
then lookup the DDX ID/xwl_touch from xwayland's touch device.

Signed-off-by: Carlos Garnacho carl...@gnome.org
---
 hw/xwayland/xwayland-input.c | 68 +++-
 1 file changed, 55 insertions(+), 13 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 3229c54..9d554a8 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -818,29 +818,71 @@ DDXRingBell(int volume, int pitch, int duration)
 {
 }
 
-static WindowPtr
-xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
+static int32_t
+lookup_sprite_touch_client_id (SpritePtr sprite)
 {
-struct xwl_seat *xwl_seat = NULL;
 DeviceIntPtr device;
+int i;
 
 for (device = inputInfo.devices; device; device = device-next) {
-if (device-deviceProc == xwl_pointer_proc 
-device-spriteInfo-sprite == sprite) {
-xwl_seat = device-public.devicePrivate;
-break;
+if (!device-touch)
+continue;
+
+for (i = 0; i  device-touch-num_touches; i++) {
+TouchPointInfoPtr ti = device-touch-touches + i;
+
+if (sprite == ti-sprite)
+return ti-client_id;
 }
 }
 
-if (xwl_seat == NULL) {
-/* XTEST device */
-sprite-spriteTraceGood = 1;
-return sprite-spriteTrace[0];
+return 0;
+}
+
+static struct xwl_touch *
+xwl_touch_lookup_from_client_id (struct xwl_seat *xwl_seat, int32_t client_id)
+{
+DeviceIntPtr touch = xwl_seat-touch;
+int i;
+
+for (i = 0; i  touch-last.num_touches; i++) {
+DDXTouchPointInfoPtr ddx_ti = touch-last.touches + i;
+
+if (ddx_ti-client_id == client_id)
+return xwl_seat_lookup_touch(xwl_seat, ddx_ti-ddx_id);
+}
+
+return NULL;
+}
+
+static WindowPtr
+xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
+{
+struct xwl_screen *xwl_screen;
+struct xwl_seat *xwl_seat = NULL;
+struct xwl_window *xwl_window = NULL;
+struct xwl_touch *xwl_touch;
+int32_t client_id;
+
+xwl_screen = xwl_screen_get(screen);
+
+xorg_list_for_each_entry(xwl_seat, xwl_screen-seat_list, link) {
+if (xwl_seat-pointer-spriteInfo-sprite == sprite) {
+xwl_window = xwl_seat-focus_window;
+} else if ((client_id = lookup_sprite_touch_client_id (sprite)) != 0) {
+xwl_touch = xwl_touch_lookup_from_client_id (xwl_seat, client_id);
+
+if (xwl_touch)
+xwl_window = xwl_touch-window;
+}
+
+if (xwl_window)
+break;
 }
 
-if (xwl_seat-focus_window) {
+if (xwl_window) {
 sprite-spriteTraceGood = 2;
-sprite-spriteTrace[1] = xwl_seat-focus_window-window;
+sprite-spriteTrace[1] = xwl_window-window;
 return miSpriteTrace(sprite, x, y);
 }
 else {
-- 
2.4.1

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

Re: [PATCH libX11-xcb] add XCBGetXDisplay

2015-05-27 Thread Uli Schlachter
Hi,

Am 27.05.2015 um 14:42 schrieb Mike Blumenkrantz:
[...]
 From c5e4bf50a722670e0ac1b05509834874251c0c9c Mon Sep 17 00:00:00 2001
 From: Mike Blumenkrantz zm...@osg.samsung.com
 Date: Wed, 27 May 2015 08:37:05 -0400
 Subject: [PATCH] add XCBGetXDisplay
 
 a method for creating a Display object from an xcb connection

This commit message might be improved a bit.

 Signed-off-by: Mike Blumenkrantz zm...@osg.samsung.com
 ---
  include/X11/Xlib-xcb.h |   1 +
  src/x11_xcb.c  | 562 
 +
  2 files changed, 563 insertions(+)
 
 diff --git a/include/X11/Xlib-xcb.h b/include/X11/Xlib-xcb.h
 index a21e2be..240a25c 100644
 --- a/include/X11/Xlib-xcb.h
 +++ b/include/X11/Xlib-xcb.h
 @@ -11,6 +11,7 @@
  _XFUNCPROTOBEGIN
  
  xcb_connection_t *XGetXCBConnection(Display *dpy);
 +Display *XCBGetXDisplay(xcb_connection_t *c);
  
  enum XEventQueueOwner { XlibOwnsEventQueue = 0, XCBOwnsEventQueue };
  void XSetEventQueueOwner(Display *dpy, enum XEventQueueOwner owner);
 diff --git a/src/x11_xcb.c b/src/x11_xcb.c
 index 3ddf403..0dabf6d 100644
 --- a/src/x11_xcb.c
 +++ b/src/x11_xcb.c
 @@ -1,9 +1,78 @@
[...]

Where did you copy these more than 500 lines from and why can't it be shared
with XOpenDisplay() (I guess that is where this code comes from)?

 + if ((display_name = getenv(DISPLAY)) == NULL) {
 + /* Oops! No DISPLAY environment variable - error. */
 + return(NULL);
 + }

Why does this function require $DISPLAY? That is totally unrelated to the XCB
connection that you give it.

Also, there is no documentation for this new function and I guess calling
XCloseDisplay() on it will also close the XCB connection. That doesn't seem 
right.

Cheers,
Uli
-- 
Happiness can't be found -- it finds you.
 - Majic
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 5/5] render: Eliminate temporary mask when drawing glyphs

2015-05-27 Thread Chris Wilson
On Tue, May 26, 2015 at 01:47:55PM -0700, Keith Packard wrote:
 The temporary mask was supposed to do a better job when drawing glyphs
 sharing pixels than just drawing them one at a time. However, the way
 it was defined assumed that the glyphs didn't actually overlap, and
 the computational cost for this minor adjustment is quite high.

Nak. The mask is expected by users, who *already* discard the mask when
they know that the rendering will be identical without it.

The existing renderproto was written to render a union of the glyph path,
which accounts for overlapping glyphs quite succinctly.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 2/3] present: Query the Window's CRTC every time

2015-05-27 Thread Michel Dänzer
On 27.05.2015 06:30, Keith Packard wrote:
 Michel Dänzer mic...@daenzer.net writes:
 
 The problem I was hitting was that this code was running for an MSC wait
 when the CRTC referenced by window_priv-crtc was already disabled for
 DPMS off. This caused hangs at the GNOME lock screen. This patch seems
 to fix that problem.
 
 Why isn't your queue_vblank function bailing when asked to queue a
 request for a CRTC which is disabled? If it simply fails,
 present_execute will get called immediately and the client would
 continue happily along.

That would mean all PresentNotifyMSC requests would send their
PresentCompleteKindNotifyMS events immediately during DPMS off, wouldn't
it? Won't that confuse apps which actually care about the MSC values and
timing?

I guess that could be solved by making present_queue_vblank() fall back
to present_fake_queue_vblank() if the driver hook fails.


 So, I vote for applying this patch (possibly with a better commit log)
 to master ASAP and backporting it to stable branches.
 
 It looks like this will only solve the problem of how to deal with new
 PresentNotifyMSC requests; any PresentPixmap or PresentNotifyMSC
 requests which are pending when the CRTC is disabled may end up getting
 wedged too?

That's possible, but it's a different issue. Let's fix the known hangs
happening in practice now and then worry about potential other hangs?


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] renderproto: Fix compositeglyph dst position. eliminate use of mask-format

2015-05-27 Thread Chris Wilson
On Tue, May 26, 2015 at 01:55:09PM -0700, Keith Packard wrote:
 Change the definition of composite glyphs from using an explicit
 dst-x/dst-y location to match current implementation which uses the
 dx/dy values from the first glyphitem for the destination location.
 
 Define the source pattern origin to align with that first glyph
 location.
 
 Eliminate use of the mask-format in composite glyphs to clean up
 rendering.

Pardon? You are changing the expected rendering from being a union of
the glyphs to rendering individual glyphs. That's a big change for the
users who expect a union of the glyph path when specifying a mask - plus
the effect the mask has for allowing combining a mixture of glyph
formats without unwanted fringing.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 1/3] present: Copy unflip contents back to the Screen Pixmap

2015-05-27 Thread Michel Dänzer
On 27.05.2015 07:12, Keith Packard wrote:
 Michel Dänzer mic...@daenzer.net writes:
 
 Keith, this is also an important fix:

 On 06.02.2015 17:25, Chris Wilson wrote:
 As we unflip after the flip Window no longer passes the pixel ownership
 test for the full Screen Pixmap, we can no longer utilize that Window to
 copy the contents back to the backing pixmap. To first flip means that
 the Window was originally backed by the Screen Pixmap and wholly covered
 the Pixmap, thus we need to copy the last frame contents to the Screen
 Pixmap when the flip chain is complete.

 Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk

 Without this fix, one can momentarily see stale screen contents when
 unflipping, e.g. when quitting a fullscreen app or switching from
 fullscreen to windowed mode.
 
 This patch does look correct - the original code was trying to copy
 the old window contents into the new window clip list before the
 related window configuration operation was completed. Copying the bits
 to the screen pixmap neatly routes around that ordering problem.
 
 A more efficient fix would involve only copying regions that aren't
 getting explicitly painted by various expose processing; but so few
 windows use non-None backgrounds that it probably won't make any actual
 difference in practice.

Also, while that might be slightly more efficient, it might again make
stale contents momentarily visible on unflip?


Anyway, thanks for pushing this fix, but I hope you realize that the
hangs fixed by the other patch we're discussing are far more severe.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 2/3] present: Query the Window's CRTC every time

2015-05-27 Thread Chris Wilson
On Tue, May 26, 2015 at 02:30:32PM -0700, Keith Packard wrote:
 Michel Dänzer mic...@daenzer.net writes:
 
  The old code also called present_get_crtc() unless pixmap == NULL, so
  the problem couldn't affect flips but only MSC waits.
 
 The original code was trying to let the client control which CRTC to
 track for each window. For PresentPixmap requests, there's an explicit
 CRTC argument, which allows the client to select the right one. For
 PresentNotifyMSC, there's no such argument.
 
 So, the code was trying to respect the client's wishes by using
 whichever CRTC was last associated with the window -- either implicitly
 through the last call to present_get_crtc or explicitly from the last
 crtc passed to PresentPixmap for the same window.
 
 Probably the right thing to do is to add an explicit CRTC parameter to
 PresentNotifyMSC, and then have both requests call present_get_crtc when
 an explicit CRTC is not provided.
 
 That doesn't solve the problem when an explicitly requested CRTC is
 disabled though, so this fix doesn't address the root cause, only one of
 the symptoms.
 
  The problem I was hitting was that this code was running for an MSC wait
  when the CRTC referenced by window_priv-crtc was already disabled for
  DPMS off. This caused hangs at the GNOME lock screen. This patch seems
  to fix that problem.
 
 Why isn't your queue_vblank function bailing when asked to queue a
 request for a CRTC which is disabled? If it simply fails,
 present_execute will get called immediately and the client would
 continue happily along.

Oh, but it does fail gracefully. The problem is not that but that it
sends a garbage msc to a valid CRTC.

  So, I vote for applying this patch (possibly with a better commit log)
  to master ASAP and backporting it to stable branches.
 
 It looks like this will only solve the problem of how to deal with new
 PresentNotifyMSC requests; any PresentPixmap or PresentNotifyMSC
 requests which are pending when the CRTC is disabled may end up getting
 wedged too?

Queued events are flushed when the CRTC is disabled.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
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 libX11-xcb] add XCBGetXDisplay

2015-05-27 Thread Mike Blumenkrantz
On Wed, 27 May 2015 22:18:08 +0200
Uli Schlachter psyc...@znc.in wrote:

 Hi,
 
 Am 27.05.2015 um 14:42 schrieb Mike Blumenkrantz:
 [...]
  From c5e4bf50a722670e0ac1b05509834874251c0c9c Mon Sep 17 00:00:00
  2001 From: Mike Blumenkrantz zm...@osg.samsung.com
  Date: Wed, 27 May 2015 08:37:05 -0400
  Subject: [PATCH] add XCBGetXDisplay
  
  a method for creating a Display object from an xcb connection
 
 This commit message might be improved a bit.

I've added more details.

 
  Signed-off-by: Mike Blumenkrantz zm...@osg.samsung.com
  ---
   include/X11/Xlib-xcb.h |   1 +
   src/x11_xcb.c  | 562
  + 2 files changed,
  563 insertions(+)
  
  diff --git a/include/X11/Xlib-xcb.h b/include/X11/Xlib-xcb.h
  index a21e2be..240a25c 100644
  --- a/include/X11/Xlib-xcb.h
  +++ b/include/X11/Xlib-xcb.h
  @@ -11,6 +11,7 @@
   _XFUNCPROTOBEGIN
   
   xcb_connection_t *XGetXCBConnection(Display *dpy);
  +Display *XCBGetXDisplay(xcb_connection_t *c);
   
   enum XEventQueueOwner { XlibOwnsEventQueue = 0,
  XCBOwnsEventQueue }; void XSetEventQueueOwner(Display *dpy, enum
  XEventQueueOwner owner); diff --git a/src/x11_xcb.c b/src/x11_xcb.c
  index 3ddf403..0dabf6d 100644
  --- a/src/x11_xcb.c
  +++ b/src/x11_xcb.c
  @@ -1,9 +1,78 @@
 [...]
 
 Where did you copy these more than 500 lines from and why can't it be
 shared with XOpenDisplay() (I guess that is where this code comes
 from)?

It was recommended to me by Daniel Stone that I not touch anything
directly in libX11 to avoid potentially introducing regressions, so I
did copy most of XOpenDisplay() here.

 
  +   if ((display_name = getenv(DISPLAY)) == NULL) {
  +   /* Oops! No DISPLAY environment variable - error.
  */
  +   return(NULL);
  +   }
 
 Why does this function require $DISPLAY? That is totally unrelated to
 the XCB connection that you give it.

True, I'll fix that.

 
 Also, there is no documentation for this new function and I guess
 calling XCloseDisplay() on it will also close the XCB connection.
 That doesn't seem right.

Thanks for the pointer about documentation, I forgot to add it.

It's my assumption that anyone using this function will be using it to
manage their connection with libX11, and so this is the desired
behavior. It will be specified in the documentation.

 
 Cheers,
 Uli

Thanks for these suggestions. I have made some updates and attached a
new version of the patch.

Regards,
MikeFrom 3b3ae17fb4055f0cc1c45f2242ffeb6afe88e69b Mon Sep 17 00:00:00 2001
From: Mike Blumenkrantz zm...@osg.samsung.com
Date: Wed, 27 May 2015 20:56:07 -0400
Subject: [PATCH] add XCBGetXDisplay() to x11-xcb

this is a method for creating a Display object from an existing xcb connection.
it is useful for cases where the initial connection must be made with xcb,
but the developer wants to continue using xlib after, eg. xwayland setup which
requires use of xcb_connect_to_fd()
---
 include/X11/Xlib-xcb.h |   1 +
 man/Makefile.am|   1 +
 man/XCBGetXDisplay.man |  45 +
 src/x11_xcb.c  | 533 +
 4 files changed, 580 insertions(+)
 create mode 100644 man/XCBGetXDisplay.man

diff --git a/include/X11/Xlib-xcb.h b/include/X11/Xlib-xcb.h
index a21e2be..240a25c 100644
--- a/include/X11/Xlib-xcb.h
+++ b/include/X11/Xlib-xcb.h
@@ -11,6 +11,7 @@
 _XFUNCPROTOBEGIN
 
 xcb_connection_t *XGetXCBConnection(Display *dpy);
+Display *XCBGetXDisplay(xcb_connection_t *c);
 
 enum XEventQueueOwner { XlibOwnsEventQueue = 0, XCBOwnsEventQueue };
 void XSetEventQueueOwner(Display *dpy, enum XEventQueueOwner owner);
diff --git a/man/Makefile.am b/man/Makefile.am
index ef1a745..ae4c9e5 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -85,6 +85,7 @@ libman_PRE = \
 	XGetWindowAttributes.man \
 	XGetWindowProperty.man \
 	XGetXCBConnection.man \
+	XCBGetXDisplay.man \
 	XGrabButton.man \
 	XGrabKeyboard.man \
 	XGrabKey.man \
diff --git a/man/XCBGetXDisplay.man b/man/XCBGetXDisplay.man
new file mode 100644
index 000..5147b3d
--- /dev/null
+++ b/man/XCBGetXDisplay.man
@@ -0,0 +1,45 @@
+.\ Copyright \(co 2006 Josh Triplett
+.\
+.\ 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 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 X 

Re: [PATCH try2] dix: Send KeyPress and KeyRelease events to the XACE_KEY_AVAIL hook

2015-05-27 Thread Peter Hutterer
Hi Andrew,

sorry about the long delay here.

On Fri, May 15, 2015 at 03:10:13PM -0500, Andrew Eikum wrote:
 While it's documented in the XACE spec, the XACE_KEY_AVAIL hook is
 currently never actually invoked by the xserver.
 
 This hook was added in 13c6713c82 (25 Aug 2006), but as the keyboard
 processing was moved into XKB, the hook was forgotten and silently
 dropped. The code calling this hook was removed by 7af53799c (4 Jan
 2009), but it was probably already unused before that.
 
 This patch re-adds support for this hook. The count hook parameter is
 unused.
 
 Signed-off-by: Andrew Eikum aei...@codeweavers.com
 ---
 
 Change from previous patch: Daniel S on IRC suggested placing the hook
 into ProcessDeviceEvent, as that's where the X server does most of the
 actual event prep and handling before dispatch to clients.
 
 I noticed while testing this that my XACE plugin got multiple calls for
 a single physical keypress. One came from the physical keyboard device,
 and another from the Virtual core keyboard. I thought about doing some
 sort of filtering to prevent duplicate events, but I think it's better
 to ask the XACE plugin to do its own discrimination based on the device.

yeah, that's intentional, the key events feed through the real device into
the VCK and then are sent to the caller. this allows clients (and XACE) to
restrict access to specific devices or the keyboard focus in general.

 Pending approval, updates to the XACE spec documentation for the count
 parameter, and to warn about duplicate events, will follow.

that documentation is wrong (well, it says it's unsure so I guess that's ok
then :)

many moons ago events from input devices would be stored in an xEvent struct
and pushed to the internal event queue (events are generated during SIGIO).
xEvents have size limits and are restricted to two axes. XI 1.x works around
that by having one DeviceMotion (etc.) event followed by a couple of
DeviceValuator events (up to 6). so for 'core devices' count was 1 and the
event was a core X event, for extension devices count was 1-7.

two things happened:
* the distinction between core/extension devices went dodo, all devices can
  send extension events now
* we switched to InternalEvents for the event queue which have no size
  restriction, now we convert to the xEvent when we know we have to send one
  of those

either way, EventToCore and EventToXI take care of this appropriately.

 ---
  Xi/exevents.c | 12 
  1 file changed, 12 insertions(+)
 
 diff --git a/Xi/exevents.c b/Xi/exevents.c
 index 1c586d0..859c29f 100644
 --- a/Xi/exevents.c
 +++ b/Xi/exevents.c
 @@ -1730,6 +1730,18 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr 
 device)
  break;
  }
  
 +/* send KeyPress and KeyRelease events to XACE plugins */
 +if (XaceHooks[XACE_KEY_AVAIL] 

I don't think accessing the hooks directly is a good idea. I understand this
optimizes things but it'd be better to have a XaceHookIsSet() helper for
this.

 +(event-type == ET_KeyPress || event-type == ET_KeyRelease)) {
 +xEvent *core;
 +int count;
 +
 +if (EventToCore(ev, core, count) == Success) {
 +XaceHook(XACE_KEY_AVAIL, core, device, 0);
 +free(core);
 +}

to be strict in line with the old code you'd also have to do EventToXI here.
Not that I think anyone is using this (given that it took 5 years for the
removal to be noticed :)

other than that, I think this is the right place to put it.

Cheers,
   Peter


 +}
 +
  if (DeviceEventCallback  !syncEvents.playingEvents) {
  DeviceEventInfoRec eventinfo;
  SpritePtr pSprite = device-spriteInfo-sprite;
 -- 
 2.4.0
 
___
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] glamor: don't do render ops with matching source/dest

2015-05-27 Thread Dave Airlie
From: Dave Airlie airl...@redhat.com

XRender defines this, GL really doesn't like it.

kwin 4.x and qt 4.x seem to make this happen for the
gradient in the titlebar, and on radeonsi/r600 hw
this draws all kinds of wrong.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 glamor/glamor_render.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index efca367..b3046b4 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1149,6 +1149,14 @@ glamor_composite_with_shader(CARD8 op,
 glamor_composite_shader *shader = NULL, *shader_ca = NULL;
 struct blendinfo op_info, op_info_ca;
 
+if (source_pixmap == dest_pixmap) {
+glamor_fallback(source and dest pixmaps are the same\n);
+return ret;
+}
+if (mask_pixmap == dest_pixmap) {
+glamor_fallback(mask and dest pixmaps are the same\n);
+return ret;
+}
 if (!glamor_composite_choose_shader(op, source, mask, dest,
 source_pixmap, mask_pixmap, 
dest_pixmap,
 source_pixmap_priv, mask_pixmap_priv,
-- 
1.8.3.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: [RFC] xserver 1.17.2 candidate branch

2015-05-27 Thread Peter Hutterer
On Wed, May 27, 2015 at 10:14:22AM -0400, Adam Jackson wrote:
 I've put together a candidate branch for a 1.17.2 release, see pull
 request below.  I've tried to pick up as many fixes from master as
 possible without pulling in the more disruptive changes to glamor or
 randr.
 
 If anybody has suggestions or complaints please speak up, I'd like to
 get this out early next week if possible (and 1.17.3 is always an
 option later if we need it).
 
 ---
 
 The following changes since commit 3b0d1ba2266d2780bfc111bab74885b90458eca4:
 
   Release 1.17.1 (2015-02-10 14:43:59 -0800)
 
 are available in the git repository at:
 
   ssh://people.freedesktop.org/~ajax/xserver.git server-1.17-branch
 
 for you to fetch changes up to 27846c49e883a47d80a33fd2979ee4357f776ffd:
 
   backtrace.c: Fix word cast to a pointer (2015-05-27 09:56:34 -0400)
 

[...]

 Peter Hutterer (1):
   config: remove 10-evdev.conf, let the evdev driver install that file

drop this one please, I haven't released evdev yet with the fix in and
anyway it's safer to have two components install the same file than have it
missing and potentially end up with no input devices.

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] glamor: don't do render ops with matching source/dest (v2)

2015-05-27 Thread Dave Airlie
From: Dave Airlie airl...@redhat.com

XRender defines this, GL really doesn't like it.

kwin 4.x and qt 4.x seem to make this happen for the
gradient in the titlebar, and on radeonsi/r600 hw
this draws all kinds of wrong.

v2: bump this up a level, and check it earlier.
(I assume the  was for this case.)

Signed-off-by: Dave Airlie airl...@redhat.com
---
 glamor/glamor_render.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index efca367..05eee91 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1481,7 +1481,14 @@ glamor_composite_clipped_region(CARD8 op,
 }
 }
 
-/*X, self copy? */
+if (temp_src_pixmap == dest_pixmap) {
+glamor_fallback(source and dest pixmaps are the same\n);
+goto out;
+}
+if (temp_mask_pixmap == dest_pixmap) {
+glamor_fallback(mask and dest pixmaps are the same\n);
+goto out;
+}
 
 x_dest += dest-pDrawable-x;
 y_dest += dest-pDrawable-y;
-- 
1.8.3.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