[PATCH 0/2] misc. fixes

2014-03-07 Thread Hans de Goede
Hi All,

Here are 2 misc. systemd-logind related bug fixes. Note the 1st patch is
v2 of a patch I've send before. New in v2 is the addition if a helper function
while fixing this issue to avoid code duplication.

Regards,

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


[PATCH 2/2] systemd-logind: Fix vt-enter not working when using a legacy video driver

2014-03-07 Thread Hans de Goede
If there is only a single non kms video device (tested with the vesa driver),
then we will never get a resume signal for a drm node, so also call vtenter
when we get a resume for an input device.

Notes:
1) vtenter checks if it is ok to do the vtenter, so if there are kms video
devices the calls for input device resumes are a nop
2) This assumes that there will always be at least one server event fd
supporting input device. Since all non legacy input-drivers will be patched
to supported server fds this seems a safe assumption.

Signed-off-by: Hans de Goede hans@localhost.localdomain
---
 hw/xfree86/os-support/linux/systemd-logind.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/xfree86/os-support/linux/systemd-logind.c 
b/hw/xfree86/os-support/linux/systemd-logind.c
index abb8e44..a8406d8 100644
--- a/hw/xfree86/os-support/linux/systemd-logind.c
+++ b/hw/xfree86/os-support/linux/systemd-logind.c
@@ -347,7 +347,6 @@ message_filter(DBusConnection * connection, DBusMessage * 
message, void *data)
 
 if (pdev) {
 pdev-flags = ~XF86_PDEV_PAUSED;
-systemd_logind_vtenter();
 }
 else {
 pInfo-fd = fd;
@@ -355,6 +354,8 @@ message_filter(DBusConnection * connection, DBusMessage * 
message, void *data)
 if (info-vt_active)
 xf86EnableInputDeviceForVTSwitch(pInfo);
 }
+/* Always call vtenter(), in case there are only legacy video devs */
+systemd_logind_vtenter();
 }
 return DBUS_HANDLER_RESULT_HANDLED;
 }
-- 
1.9.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 1/2] config_odev_add*_attribute: Don't add the attribute to the list twice

2014-03-07 Thread Hans de Goede
Don't do the xorg_list_append a 2nd time when updating existing attributes,
while at it add a helper function for this to avoid code duplication.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 config/config.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/config/config.c b/config/config.c
index 7971b87..530f21d 100644
--- a/config/config.c
+++ b/config/config.c
@@ -159,23 +159,38 @@ config_odev_find_attribute(struct OdevAttributes 
*attribs, int attrib_id)
 return NULL;
 }
 
+static struct OdevAttribute *
+config_odev_find_or_add_attribute(struct OdevAttributes *attribs, int attrib)
+{
+struct OdevAttribute *oa;
+
+oa = config_odev_find_attribute(attribs, attrib);
+if (oa)
+return oa;
+
+oa = calloc(1, sizeof(struct OdevAttribute));
+if (!oa)
+return oa;
+
+oa-attrib_id = attrib;
+xorg_list_append(oa-member, attribs-list);
+
+return oa;
+}
+
 Bool
 config_odev_add_attribute(struct OdevAttributes *attribs, int attrib,
   const char *attrib_name)
 {
 struct OdevAttribute *oa;
 
-oa = config_odev_find_attribute(attribs, attrib);
-if (!oa)
-oa = calloc(1, sizeof(struct OdevAttribute));
+oa = config_odev_find_or_add_attribute(attribs, attrib);
 if (!oa)
 return FALSE;
 
-oa-attrib_id = attrib;
 free(oa-attrib_name);
 oa-attrib_name = strdup(attrib_name);
 oa-attrib_type = ODEV_ATTRIB_STRING;
-xorg_list_append(oa-member, attribs-list);
 return TRUE;
 }
 
@@ -185,16 +200,12 @@ config_odev_add_int_attribute(struct OdevAttributes 
*attribs, int attrib,
 {
 struct OdevAttribute *oa;
 
-oa = config_odev_find_attribute(attribs, attrib);
-if (!oa)
-oa = calloc(1, sizeof(struct OdevAttribute));
+oa = config_odev_find_or_add_attribute(attribs, attrib);
 if (!oa)
 return FALSE;
 
-oa-attrib_id = attrib;
 oa-attrib_value = attrib_value;
 oa-attrib_type = ODEV_ATTRIB_INT;
-xorg_list_append(oa-member, attribs-list);
 return TRUE;
 }
 
-- 
1.9.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


Re: [PATCH 2/2] systemd-logind: Fix vt-enter not working when using a legacy video driver

2014-03-07 Thread Hans de Goede
Hi

On 03/07/2014 11:22 AM, Hans de Goede wrote:
 If there is only a single non kms video device (tested with the vesa driver),
 then we will never get a resume signal for a drm node, so also call vtenter
 when we get a resume for an input device.
 
 Notes:
 1) vtenter checks if it is ok to do the vtenter, so if there are kms video
 devices the calls for input device resumes are a nop
 2) This assumes that there will always be at least one server event fd
 supporting input device. Since all non legacy input-drivers will be patched
 to supported server fds this seems a safe assumption.
 
 Signed-off-by: Hans de Goede hans@localhost.localdomain

Oops, wrong email address. Fixed in my personal tree.

Regards,

Hans
___
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 0/2] Require video drivers to report that they support server fds

2014-03-07 Thread Hans de Goede
Hi All,

Here is v2 of my patch-set which requires video drivers to report that they
support server fds.

New in v2:
-Fix drivers without a driverFunc getting seen as supporting server fds

Regards,

Hans
___
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/2] Require video drivers to report that they support server managed fds

2014-03-07 Thread Hans de Goede
This makes how we handle video drivers identical to what we do for input
drivers, and this should make live easier for old non kms drivers.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 hw/xfree86/common/xf86platformBus.c | 14 +-
 hw/xfree86/common/xf86str.h |  3 ++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/common/xf86platformBus.c 
b/hw/xfree86/common/xf86platformBus.c
index 564567e..4e80f9e 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -38,6 +38,7 @@
 #include unistd.h
 #include os.h
 #include hotplug.h
+#include systemd-logind.h
 
 #include xf86.h
 #include xf86_OSproc.h
@@ -310,7 +311,7 @@ static Bool doPlatformProbe(struct xf86_platform_device 
*dev, DriverPtr drvp,
 GDevPtr gdev, int flags, intptr_t match_data)
 {
 Bool foundScreen = FALSE;
-int entity;
+int entity, fd, major, minor;
 
 if (gdev  gdev-screen == 0  !xf86_check_platform_slot(dev))
 return FALSE;
@@ -334,6 +335,17 @@ static Bool doPlatformProbe(struct xf86_platform_device 
*dev, DriverPtr drvp,
 }
 }
 if (entity != -1) {
+if ((dev-flags  XF86_PDEV_SERVER_FD)  (!drvp-driverFunc ||
+!drvp-driverFunc(NULL, SUPPORTS_SERVER_FDS, NULL))) {
+fd = xf86_get_platform_device_int_attrib(dev, ODEV_ATTRIB_FD, -1);
+major = xf86_get_platform_device_int_attrib(dev, 
ODEV_ATTRIB_MAJOR, 0);
+minor = xf86_get_platform_device_int_attrib(dev, 
ODEV_ATTRIB_MINOR, 0);
+systemd_logind_release_fd(major, minor);
+close(fd);
+config_odev_add_int_attribute(dev-attribs, ODEV_ATTRIB_FD, -1);
+dev-flags = ~XF86_PDEV_SERVER_FD;
+}
+
 if (drvp-platformProbe(drvp, entity, flags, dev, match_data))
 foundScreen = TRUE;
 else
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index b164b7f..a81e886 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -256,7 +256,8 @@ typedef enum {
 RR_GET_INFO,
 RR_SET_CONFIG,
 RR_GET_MODE_MM,
-GET_REQUIRED_HW_INTERFACES = 10
+GET_REQUIRED_HW_INTERFACES = 10,
+SUPPORTS_SERVER_FDS = 11,
 } xorgDriverFuncOp;
 
 typedef Bool xorgDriverFuncProc(ScrnInfoPtr, xorgDriverFuncOp, void *);
-- 
1.9.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 v2 1/2] xf86platformBus: Make doPlatformProbe accept a NULL gdev argument

2014-03-07 Thread Hans de Goede
And use it from xf86platformAddDevice too, instead of directly calling
drvp-platformProbe.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 hw/xfree86/common/xf86platformBus.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/hw/xfree86/common/xf86platformBus.c 
b/hw/xfree86/common/xf86platformBus.c
index 4447e19..564567e 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -312,13 +312,13 @@ static Bool doPlatformProbe(struct xf86_platform_device 
*dev, DriverPtr drvp,
 Bool foundScreen = FALSE;
 int entity;
 
-if (gdev-screen == 0  !xf86_check_platform_slot(dev))
+if (gdev  gdev-screen == 0  !xf86_check_platform_slot(dev))
 return FALSE;
 
 entity = xf86ClaimPlatformSlot(dev, drvp, 0,
-   gdev, gdev-active);
+   gdev, gdev ? gdev-active : 0);
 
-if ((entity == -1)  (gdev-screen  0)) {
+if ((entity == -1)  gdev  (gdev-screen  0)) {
 unsigned nent;
 
 for (nent = 0; nent  xf86NumEntities; nent++) {
@@ -420,7 +420,6 @@ xf86platformAddDevice(int index)
 {
 int i, old_screens, scr_index;
 DriverPtr drvp = NULL;
-int entity;
 screenLayoutPtr layout;
 static const char *hotplug_driver_name = modesetting;
 
@@ -440,11 +439,8 @@ xf86platformAddDevice(int index)
 return -1;
 
 old_screens = xf86NumGPUScreens;
-entity = xf86ClaimPlatformSlot(xf86_platform_devices[index],
-   drvp, 0, 0, 0);
-if (!drvp-platformProbe(drvp, entity, PLATFORM_PROBE_GPU_SCREEN, 
xf86_platform_devices[index], 0)) {
-xf86UnclaimPlatformSlot(xf86_platform_devices[index], NULL);
-}
+doPlatformProbe(xf86_platform_devices[index], drvp, NULL,
+PLATFORM_PROBE_GPU_SCREEN, 0);
 if (old_screens == xf86NumGPUScreens)
 return -1;
 i = old_screens;
-- 
1.9.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 0/1] Xorg: Add a suid root wrapper

2014-03-07 Thread Hans de Goede
Hi all,

Here is the first non RFC version of my suid root wrapper patch, taking
all comments made to the RFC into account.

Please review.

Thanks  Regards,

Hans
___
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] Xorg: Add a suid root wrapper

2014-03-07 Thread Hans de Goede
With the recent systemd-logind changes it is possible to install the Xorg
binary without suid root rights and still have everything working as it
should *if* the user only has cards which are supported by kms.

This commit adds a little suid root wrapper, which is a bit weird, first we
strip the suid-root bit of the Xorg binary, and then we add a wrapper ?

The function of this wrapper is to see if a system still needs root-rights,
if it does not (it supports kms and the kms drivers are properly loaded),
then it will immediately drop all elevated rights before executing the real
Xorg binary. If it finds (some) cards which don't support kms, or no cards
at all, then it will execute the Xorg server with elevated rights so that
ie the nvidia binary driver and the vesa driver can keep working normally.

To make it possible for security concious users who don't need the root
rights to completely remove the wrapper, Xorg is started in a 3 step process
when the wrapper is enabled during build time:

1) A simple shell script which checks if the wrapper is there, if it is
  it executes the wrapper, if not it directly executes the real Xorg binary

2) The wrapper gets executed, does its checks, normally drops all elevated
  rights and then executes the real Xorg binary

3) The real Xorg binary does its thing

This allows distributions to put the wrapper binary in a separate package, and
will allow users to remove this package. IE the plan with Fedora is to make
legacy drivers depend on the wrapper pkg, and since our default install
contains some legacy drivers it will be part of the default install, but
users can later yum remove it (which will also automatically remove the
legacy driver packages as those won't work without it anyways).

The wrapper is loosely modelled after the existing Debian Xwrapper, it
uses the same config-file + config-file format, and also allows restricting
Xserver execution (through the wrapper) to console users only.

There also is a new needs_root_rights config file directive, which can
be used to override the auto-detection the wrapper does.

Hopefully this will allow Debian to replace their own wrapper with this
upstream one.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 configure.ac  |   7 ++
 hw/xfree86/Makefile.am|  14 ++-
 hw/xfree86/Xorg.sh.in |  12 +++
 hw/xfree86/xorg-wrapper.c | 211 ++
 4 files changed, 242 insertions(+), 2 deletions(-)
 create mode 100644 hw/xfree86/Xorg.sh.in
 create mode 100644 hw/xfree86/xorg-wrapper.c

diff --git a/configure.ac b/configure.ac
index 588ae59..6028ab1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -627,6 +627,7 @@ AC_ARG_ENABLE(pciaccess, 
AS_HELP_STRING([--enable-pciaccess], [Build Xorg with p
 AC_ARG_ENABLE(linux_acpi, AS_HELP_STRING([--disable-linux-acpi], [Disable 
building ACPI support on Linux (if available).]), 
[enable_linux_acpi=$enableval], [enable_linux_acpi=yes])
 AC_ARG_ENABLE(linux_apm, AS_HELP_STRING([--disable-linux-apm], [Disable 
building APM support on Linux (if available).]), [enable_linux_apm=$enableval], 
[enable_linux_apm=yes])
 AC_ARG_ENABLE(systemd-logind, AC_HELP_STRING([--enable-systemd-logind], [Build 
systemd-logind support (default: auto)]), [SYSTEMD_LOGIND=$enableval], 
[SYSTEMD_LOGIND=auto])
+AC_ARG_ENABLE(suid-wrapper, AC_HELP_STRING([--enable-suid-wrapper], [Build 
suid-root wrapper for legacy driver support on rootless xserver systems 
(default: no)]), [SUID_WRAPPER=$enableval], [SUID_WRAPPER=no])
 
 dnl DDXes.
 AC_ARG_ENABLE(xorg,  AS_HELP_STRING([--enable-xorg], [Build 
Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@ -922,6 +923,11 @@ if test x$SYSTEMD_LOGIND = xyes; then
 fi
 AM_CONDITIONAL(SYSTEMD_LOGIND, [test x$SYSTEMD_LOGIND = xyes])
 
+if test x$SUID_WRAPPER = xyes; then
+SETUID=no
+fi
+AM_CONDITIONAL(SUID_WRAPPER, [test x$SUID_WRAPPER = xyes])
+
 if test x$NEED_DBUS = xyes; then
 AC_DEFINE(NEED_DBUS, 1, [Enable D-Bus core])
 fi
@@ -2486,6 +2492,7 @@ dri3/Makefile
 present/Makefile
 hw/Makefile
 hw/xfree86/Makefile
+hw/xfree86/Xorg.sh
 hw/xfree86/common/Makefile
 hw/xfree86/common/xf86Build.h
 hw/xfree86/ddc/Makefile
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 9672904..59ba9d8 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -76,9 +76,14 @@ Xorg_DEPENDENCIES = $(LOCAL_LIBS)
 
 Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 
+if SUID_WRAPPER
+bin_PROGRAMS += Xorg.wrap
+Xorg_wrap_SOURCES = xorg-wrapper.c
+endif
+
 BUILT_SOURCES = xorg.conf.example
 DISTCLEANFILES = xorg.conf.example
-EXTRA_DIST = xorgconf.cpp
+EXTRA_DIST = xorgconf.cpp Xorg.sh.in
 
 # Without logdir, X will post an error on the terminal and will not start
 install-data-local:
@@ -93,6 +98,11 @@ if INSTALL_SETUID
chown root $(DESTDIR)$(bindir)/Xorg
chmod u+s $(DESTDIR)$(bindir)/Xorg
 endif
+if SUID_WRAPPER
+   mv $(DESTDIR)$(bindir)/Xorg 

[RFC xf86-video-ati 0/1] Add support for server managed fds

2014-03-07 Thread Hans de Goede
Hi All,

Here is a patch to add support for server managed fds to xf86-video-ati
this is RFC only atm since not all related server patches have landed yet.

With the server patches + this patch it is possible to run Xorg without
root-rights on systemd-logind using systems.

Regards,

Hans
___
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 xf86-video-ati] Add support for server managed fds

2014-03-07 Thread Hans de Goede
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 src/radeon_kms.c   | 60 +-
 src/radeon_probe.c |  5 +
 src/radeon_probe.h |  2 ++
 3 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 4a6c38e..6c5994c 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -180,7 +180,11 @@ static void RADEONFreeRec(ScrnInfoPtr pScrn)
 pRADEONEnt = pPriv-ptr;
 pRADEONEnt-fd_ref--;
 if (!pRADEONEnt-fd_ref) {
-drmClose(pRADEONEnt-fd);
+#ifdef XF86_PDEV_SERVER_FD
+if (!(pRADEONEnt-platform_dev 
+pRADEONEnt-platform_dev-flags  XF86_PDEV_SERVER_FD))
+#endif
+drmClose(pRADEONEnt-fd);
 pRADEONEnt-fd = 0;
 }
 }
@@ -599,6 +603,15 @@ static Bool radeon_open_drm_master(ScrnInfoPtr pScrn)
goto out;
 }
 
+#if defined(ODEV_ATTRIB_FD)
+if (pRADEONEnt-platform_dev) {
+info-dri2.drm_fd = xf86_get_platform_device_int_attrib(
+pRADEONEnt-platform_dev, ODEV_ATTRIB_FD, -1);
+if (info-dri2.drm_fd != -1)
+goto got_fd;
+}
+#endif
+
 #if XORG_VERSION_CURRENT = XORG_VERSION_NUMERIC(1,9,99,901,0)
 XNFasprintf(busid, pci:%04x:%02x:%02x.%d,
 dev-domain, dev-bus, dev-dev, dev-func);
@@ -636,6 +649,7 @@ static Bool radeon_open_drm_master(ScrnInfoPtr pScrn)
return FALSE;
 }
 
+ got_fd:
 pRADEONEnt-fd = info-dri2.drm_fd;
 pRADEONEnt-fd_ref = 1;
  out:
@@ -1108,6 +1122,7 @@ static Bool RADEONCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL)
 {
 ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 RADEONInfoPtr  info  = RADEONPTR(pScrn);
+RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 
 xf86DrvMsgVerb(pScrn-scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
   RADEONCloseScreen\n);
@@ -1126,7 +1141,11 @@ static Bool RADEONCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL)
 if (info-accel_state-use_vbos)
 radeon_vbo_free_lists(pScrn);
 
-drmDropMaster(info-dri2.drm_fd);
+#ifdef XF86_PDEV_SERVER_FD
+if (!(pRADEONEnt-platform_dev 
+pRADEONEnt-platform_dev-flags  XF86_PDEV_SERVER_FD))
+#endif
+drmDropMaster(info-dri2.drm_fd);
 
 drmmode_fini(pScrn, info-drmmode);
 if (info-dri2.enabled)
@@ -1158,6 +1177,7 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
 {
 ScrnInfoPtrpScrn = xf86ScreenToScrn(pScreen);
 RADEONInfoPtr  info  = RADEONPTR(pScrn);
+RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 intsubPixelOrder = SubPixelUnknown;
 char*  s;
 void *front_ptr;
@@ -1172,11 +1192,18 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
  pScrn-defaultVisual)) return FALSE;
 miSetPixmapDepths ();
 
-ret = drmSetMaster(info-dri2.drm_fd);
-if (ret) {
-ErrorF(Unable to retrieve master\n);
-return FALSE;
+#ifdef XF86_PDEV_SERVER_FD
+if (!(pRADEONEnt-platform_dev 
+pRADEONEnt-platform_dev-flags  XF86_PDEV_SERVER_FD))
+#endif
+{
+ret = drmSetMaster(info-dri2.drm_fd);
+if (ret) {
+ErrorF(Unable to retrieve master\n);
+return FALSE;
+}
 }
+
 info-directRenderingEnabled = FALSE;
 if (info-r600_shadow_fb == FALSE)
 info-directRenderingEnabled = radeon_dri2_screen_init(pScreen);
@@ -1389,15 +1416,23 @@ Bool RADEONEnterVT_KMS(VT_FUNC_ARGS_DECL)
 {
 SCRN_INFO_PTR(arg);
 RADEONInfoPtr  info  = RADEONPTR(pScrn);
+RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 int ret;
 
 xf86DrvMsgVerb(pScrn-scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
   RADEONEnterVT_KMS\n);
 
 
-ret = drmSetMaster(info-dri2.drm_fd);
-if (ret)
-   ErrorF(Unable to retrieve master\n);
+#ifdef XF86_PDEV_SERVER_FD
+if (!(pRADEONEnt-platform_dev 
+pRADEONEnt-platform_dev-flags  XF86_PDEV_SERVER_FD))
+#endif
+{
+ret = drmSetMaster(info-dri2.drm_fd);
+if (ret)
+ErrorF(Unable to retrieve master\n);
+}
+
 info-accel_state-XInited3D = FALSE;
 info-accel_state-engineMode = EXA_ENGINEMODE_UNKNOWN;
 
@@ -1414,11 +1449,16 @@ void RADEONLeaveVT_KMS(VT_FUNC_ARGS_DECL)
 {
 SCRN_INFO_PTR(arg);
 RADEONInfoPtr  info  = RADEONPTR(pScrn);
+RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 
 xf86DrvMsgVerb(pScrn-scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
   RADEONLeaveVT_KMS\n);
 
-drmDropMaster(info-dri2.drm_fd);
+#ifdef XF86_PDEV_SERVER_FD
+if (!(pRADEONEnt-platform_dev 
+pRADEONEnt-platform_dev-flags  XF86_PDEV_SERVER_FD))
+#endif
+drmDropMaster(info-dri2.drm_fd);
 
 xf86RotateFreeShadow(pScrn);
 
diff --git a/src/radeon_probe.c b/src/radeon_probe.c
index 2d3c58e..ad1e96e 100644
--- a/src/radeon_probe.c
+++ b/src/radeon_probe.c
@@ -202,6 +202,10 @@ RADEONDriverFunc(ScrnInfoPtr scrn, 

Re: [RFC xf86-video-ati 0/1] Add support for server managed fds

2014-03-07 Thread Mark Kettenis
 From: Hans de Goede hdego...@redhat.com
 Date: Fri,  7 Mar 2014 14:12:57 +0100
 
 Hi All,
 
 Here is a patch to add support for server managed fds to xf86-video-ati
 this is RFC only atm since not all related server patches have landed yet.
 
 With the server patches + this patch it is possible to run Xorg without
 root-rights on systemd-logind using systems.

One question that immediately pops up, is which component is
responsible for becoming the drm master?
___
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/6] xephyr: Build support for rendering with glamor using a -glamor option.

2014-03-07 Thread Jon TURNEY
On 25/02/2014 01:47, Eric Anholt wrote:
 v2: Avoid making the Ximage for the screen that we'll never use, and
 drive the screen pixmap creation for glamor ourselves.
 
 Signed-off-by: Eric Anholt e...@anholt.net
 Reviewed-by: Keith Packard kei...@keithp.com (v1)

It seems this needs some more #ifdef GLAMOR/#endif guards to compile
successfully when ./configured --disable-glamor

See http://tinderbox.x.org/builds/2014-03-07-0004/logs/xserver/#build

Patch attached.

From 2f16a186a27ca9a88b72337ffacb86c8afb33803 Mon Sep 17 00:00:00 2001
From: Jon TURNEY jon.tur...@dronecode.org.uk
Date: Fri, 7 Mar 2014 14:53:07 +
Subject: [PATCH] Fix xephyr build in --disable-glamor case

Fix xephyr build in --disable-glamor case, after commit
9fe052d90cca90fdf750d3a45b151be2ac7f0ebd xephyr: Build support for rendering
with glamor using a -glamor option.

See http://tinderbox.x.org/builds/2014-03-07-0004/logs/xserver/#build

Signed-off-by: Jon TURNEY jon.tur...@dronecode.org.uk
---
 hw/kdrive/ephyr/hostx.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 19c2ed2..859beca 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -309,9 +309,11 @@ hostx_init(void)
 | XCB_EVENT_MASK_STRUCTURE_NOTIFY;
 
 EPHYR_DBG(mark);
+#ifdef GLAMOR
 if (ephyr_glamor)
 HostX.conn = ephyr_glamor_connect();
 else
+#endif
 HostX.conn = xcb_connect(NULL, HostX.screen);
 if (xcb_connection_has_error(HostX.conn)) {
 fprintf(stderr, \nXephyr cannot open host display. Is DISPLAY 
set?\n);
@@ -322,11 +324,12 @@ hostx_init(void)
 HostX.winroot = xscreen-root;
 HostX.gc = xcb_generate_id(HostX.conn);
 HostX.depth = xscreen-root_depth;
-if (ephyr_glamor) {
+#ifdef GLAMOR
+if (ephyr_glamor)
 HostX.visual = ephyr_glamor_get_visual();
-} else {
+else
+#endif
 HostX.visual = xcb_aux_find_visual_by_id(xscreen,xscreen-root_visual);
-}
 
 xcb_create_gc(HostX.conn, HostX.gc, HostX.winroot, 0, NULL);
 cookie_WINDOW_STATE = xcb_intern_atom(HostX.conn, FALSE,
@@ -760,6 +763,7 @@ hostx_paint_rect(KdScreenInfo *screen,
 
 EPHYR_DBG(painting in screen %d\n, scrpriv-mynum);
 
+#ifdef GLAMOR
 if (ephyr_glamor) {
 BoxRec box;
 RegionRec region;
@@ -774,6 +778,7 @@ hostx_paint_rect(KdScreenInfo *screen,
 RegionUninit(region);
 return;
 }
+#endif
 
 /*
  *  Copy the image data updated by the shadow layer
-- 
1.8.3.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: [RFC xf86-video-ati 0/1] Add support for server managed fds

2014-03-07 Thread Hans de Goede
Hi,

On 03/07/2014 02:38 PM, Mark Kettenis wrote:
 From: Hans de Goede hdego...@redhat.com
 Date: Fri,  7 Mar 2014 14:12:57 +0100

 Hi All,

 Here is a patch to add support for server managed fds to xf86-video-ati
 this is RFC only atm since not all related server patches have landed yet.

 With the server patches + this patch it is possible to run Xorg without
 root-rights on systemd-logind using systems.
 
 One question that immediately pops up, is which component is
 responsible for becoming the drm master?

The server, well actually systemd-logind since this requires root rights, but
from the driver point of view it is the responsibility of the server,
which delegates this responsibility to systemd-logind.

Regards,

Hans

___
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] non-glamor build fix

2014-03-07 Thread Eric Anholt
I've got a few other patches with review on the list currently, but I
want to give a little more time for anyone that cares to respond.  A
build fix seems important enough that we should shove it in now, though.

The following changes since commit 78e508c9379b3976ac8e76b7aaa90ba86ad4e443:

  dix: Clear any existing selections before initializing privates (2014-03-06 
17:15:11 -0800)

are available in the git repository at:

  git://people.freedesktop.org/~anholt/xserver glamor-pull-request

for you to fetch changes up to 5350ae1d38f3c69a26421e0866ede0d2ccc3aea4:

  Fix xephyr build in --disable-glamor case (2014-03-07 12:43:52 -0800)


Jon TURNEY (1):
  Fix xephyr build in --disable-glamor case

 hw/kdrive/ephyr/hostx.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)


pgpWseM6VsnVQ.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 1/6] xephyr: Build support for rendering with glamor using a -glamor option.

2014-03-07 Thread Eric Anholt
Jon TURNEY jon.tur...@dronecode.org.uk writes:

 On 25/02/2014 01:47, Eric Anholt wrote:
 v2: Avoid making the Ximage for the screen that we'll never use, and
 drive the screen pixmap creation for glamor ourselves.
 
 Signed-off-by: Eric Anholt e...@anholt.net
 Reviewed-by: Keith Packard kei...@keithp.com (v1)

 It seems this needs some more #ifdef GLAMOR/#endif guards to compile
 successfully when ./configured --disable-glamor

 See http://tinderbox.x.org/builds/2014-03-07-0004/logs/xserver/#build

Sent out a pull request for the reviewed change.

The ifdeffing is kind of ugly, but I'm already guilty of a bunch of that
in this code.  I like the idea of static inline stubs for compiled-out
code, but it's only partially done in ephyr_glamor_glx.h so far.  We can
leave that as a cleanup for later.

It would be nice to have a cleaner version of the static inline thing
than what I've done currently.  Not sure if preprocessor macros could be
used to make doing that more sane, or less.


pgp3Vr_8NY66t.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:xf86-input-mouse 1/4] Enable MSE_MISC on NetBSD as well.

2014-03-07 Thread Thomas Klausner
Can I assume that these are ok to push after so long without negative comments? 
:)
 Thomas

On Sat, Oct 19, 2013 at 01:26:31AM +0200, Thomas Klausner wrote:
 Any comments on these four patches?
 
 Thanks,
  Thomas
 
 On Mon, Aug 19, 2013 at 11:14:30AM +0200, Thomas Klausner wrote:
  Otherwise we can't find WSMouse.
  
  From Matthew R. Green m...@netbsd.org
  Signed-off-by: Thomas Klausner w...@netbsd.org
  ---
   src/bsd_mouse.c | 4 +---
   1 file changed, 1 insertion(+), 3 deletions(-)
  
  diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
  index ca4c9d0..98e5ff3 100644
  --- a/src/bsd_mouse.c
  +++ b/src/bsd_mouse.c
  @@ -97,9 +97,7 @@ static const char *mouseDevs[] = {
   static int
   SupportedInterfaces(void)
   {
  -#if defined(__NetBSD__)
  -return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO;
  -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || 
  defined(__DragonFly__)
  +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || 
  defined(__DragonFly__) || defined(__NetBSD__)
   return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC;
   #else
   return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO | MSE_MISC;
  -- 
  1.8.3.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
  
 ___
 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


xwayland: Refactor bits of XKB functionality

2014-03-07 Thread Kristian Høgsberg
Hi list,

Here's few xkb related patches that refactor and expose xkb functionality.
There should be no change in behavior in these patches, the idea is to
expose new entry points into existing code.

This is in preparation for merging xwayland, where the X server has to
parse and apply xkb maps coming from the wayland server.  In this case we
need the ability to parse the keymap from a string and apply a keymap to
a device.

Kristian

___
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/5] xkb: Factor out a function to copy a keymap's controls unto another

2014-03-07 Thread Kristian Høgsberg
From: Rui Matos tiagoma...@gmail.com

Reviewed-by: Kristian Høgsberg k...@bitplanet.net
---
 include/xkbsrv.h |  3 +++
 xkb/xkb.c| 14 +-
 xkb/xkbUtils.c   | 23 +++
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 5d8e409..49e236d 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -837,6 +837,9 @@ extern void XkbFakeDeviceButton(DeviceIntPtr /* dev */ ,
 int /* press */ ,
 int /* button */ );
 
+extern _X_EXPORT void XkbCopyControls(XkbDescPtr /* dst */ ,
+  XkbDescPtr /* src */ );
+
 #include xkbfile.h
 #include xkbrules.h
 
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 6196a17..dc570f0 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5950,25 +5950,13 @@ ProcXkbGetKbdByName(ClientPtr client)
 if (rep.loaded) {
 XkbDescPtr old_xkb;
 xkbNewKeyboardNotify nkn;
-int i, nG, nTG;
 
 old_xkb = xkb;
 xkb = new;
 dev-key-xkbInfo-desc = xkb;
 new = old_xkb;  /* so it'll get freed automatically */
 
-*xkb-ctrls = *old_xkb-ctrls;
-for (nG = nTG = 0, i = xkb-min_key_code; i = xkb-max_key_code; i++) 
{
-nG = XkbKeyNumGroups(xkb, i);
-if (nG = XkbNumKbdGroups) {
-nTG = XkbNumKbdGroups;
-break;
-}
-if (nG  nTG) {
-nTG = nG;
-}
-}
-xkb-ctrls-num_groups = nTG;
+XkbCopyControls(xkb, old_xkb);
 
 nkn.deviceID = nkn.oldDeviceID = dev-id;
 nkn.minKeyCode = new-min_key_code;
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 1f8a839..6cf6e79 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -2090,3 +2090,26 @@ XkbMergeLockedPtrBtns(DeviceIntPtr master)
 xkbi-lockedPtrButtons |= d-key-xkbInfo-lockedPtrButtons;
 }
 }
+
+void
+XkbCopyControls(XkbDescPtr dst, XkbDescPtr src)
+{
+int i, nG, nTG;
+
+if (!dst || !src)
+return;
+
+*dst-ctrls = *src-ctrls;
+
+for (nG = nTG = 0, i = dst-min_key_code; i = dst-max_key_code; i++) {
+nG = XkbKeyNumGroups(dst, i);
+if (nG = XkbNumKbdGroups) {
+nTG = XkbNumKbdGroups;
+break;
+}
+if (nG  nTG) {
+nTG = nG;
+}
+}
+dst-ctrls-num_groups = nTG;
+}
-- 
1.9.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 3/5] xkb: Add XkbCompileKeymapFromString()

2014-03-07 Thread Kristian Høgsberg
This new function compiles a keymap from an in-memory string.  We use it
to add a new keyooard device init function,
InitKeyboardDeviceStructFromString(), which inits a keyboard device with
a keymap specified as a string instead of a rmlvo set.

Reviewed-by: Daniel Stone dan...@fooishbar.org
---
 include/input.h  |   6 +++
 include/xkbsrv.h |   4 ++
 xkb/ddxLoad.c| 129 ++-
 xkb/xkbInit.c|  44 +++
 4 files changed, 144 insertions(+), 39 deletions(-)

diff --git a/include/input.h b/include/input.h
index 93c4510..36463f2 100644
--- a/include/input.h
+++ b/include/input.h
@@ -385,6 +385,12 @@ extern _X_EXPORT Bool 
InitKeyboardDeviceStruct(DeviceIntPtr /*device */ ,
KbdCtrlProcPtr /*controlProc */
);
 
+extern _X_EXPORT Bool InitKeyboardDeviceStructFromString(DeviceIntPtr dev,
+const char *keymap,
+int keymap_length,
+BellProcPtr bell_func,
+KbdCtrlProcPtr 
ctrl_func);
+
 extern int ApplyPointerMapping(DeviceIntPtr /* pDev */ ,
CARD8 * /* map */ ,
int /* len */ ,
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index e799799..253612e 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -869,4 +869,8 @@ extern _X_EXPORT XkbDescPtr XkbCompileKeymap(DeviceIntPtr 
/* dev */ ,
  XkbRMLVOSet *  /* rmlvo */
 );
 
+extern _X_EXPORT XkbDescPtr XkbCompileKeymapFromString(DeviceIntPtr dev,
+  const char *keymap,
+  int keymap_length);
+
 #endif  /* _XKBSRV_H_ */
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index d266b36..d4281a0 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -262,6 +262,35 @@ XkbDDXOpenConfigFile(char *mapName, char *fileNameRtrn, 
int fileNameRtrnLen)
 return file;
 }
 
+static unsigned
+LoadXKM(unsigned want, unsigned need, XkbCompContextPtr ctx, XkbDescPtr 
*xkbRtrn)
+{
+FILE *file;
+char fileName[PATH_MAX];
+unsigned missing;
+
+file = XkbDDXOpenConfigFile(ctx-keymap, fileName, PATH_MAX);
+if (file == NULL) {
+LogMessage(X_ERROR, Couldn't open compiled keymap file %s\n,
+   fileName);
+return 0;
+}
+missing = XkmReadFile(file, need, want, xkbRtrn);
+if (*xkbRtrn == NULL) {
+LogMessage(X_ERROR, Error loading keymap %s\n, fileName);
+fclose(file);
+(void) unlink(fileName);
+return 0;
+}
+else {
+DebugF(Loaded XKB keymap %s, defined=0x%x\n, fileName,
+   (*xkbRtrn)-defined);
+}
+fclose(file);
+(void) unlink(fileName);
+return (need | want)  (~missing);
+}
+
 unsigned
 XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
 XkbComponentNamesPtr names,
@@ -270,9 +299,6 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
 XkbDescPtr *xkbRtrn, char *nameRtrn, int nameRtrnLen)
 {
 XkbDescPtr xkb;
-FILE *file;
-char fileName[PATH_MAX];
-unsigned missing;
 XkbCompContextRec ctx;
 
 *xkbRtrn = NULL;
@@ -292,26 +318,30 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
 LogMessage(X_ERROR, XKB: Couldn't compile keymap\n);
 return 0;
 }
-file = XkbDDXOpenConfigFile(ctx.keymap, fileName, PATH_MAX);
-if (file == NULL) {
-LogMessage(X_ERROR, Couldn't open compiled keymap file %s\n,
-   fileName);
-return 0;
-}
-missing = XkmReadFile(file, need, want, xkbRtrn);
-if (*xkbRtrn == NULL) {
-LogMessage(X_ERROR, Error loading keymap %s\n, fileName);
-fclose(file);
-(void) unlink(fileName);
+
+return LoadXKM(want, need, ctx, xkbRtrn);
+}
+
+static unsigned
+XkbDDXLoadKeymapFromString(DeviceIntPtr keybd,
+  const char *keymap, int keymap_length,
+  unsigned want,
+  unsigned need,
+  XkbDescPtr *xkbRtrn)
+{
+XkbCompContextRec ctx;
+
+*xkbRtrn = NULL;
+
+if (StartXkbComp(ctx))
+   fwrite(keymap, keymap_length, 1, ctx.out);
+
+if (!FinishXkbComp(ctx)) {
+LogMessage(X_ERROR, XKB: Couldn't compile keymap\n);
 return 0;
 }
-else {
-DebugF(Loaded XKB keymap %s, defined=0x%x\n, fileName,
-   (*xkbRtrn)-defined);
-}
-fclose(file);
-(void) unlink(fileName);
-return (need | want)  (~missing);
+
+return LoadXKM(want, need, ctx, xkbRtrn);
 }
 
 Bool
@@ -407,6 +437,29 @@ XkbCompileKeymapForDevice(DeviceIntPtr dev, XkbRMLVOSet * 
rmlvo, 

[PATCH 1/5] xkb: Add struct XkbCompContext

2014-03-07 Thread Kristian Høgsberg
This commit adds a struct that contains most of the context for starting,
running and cleaning up after xkbcomp.

Reviewed-by: Daniel Stone dan...@fooishbar.org
---
 xkb/ddxLoad.c | 76 +--
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index f458e3b..cf9faa4 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -90,14 +90,21 @@ OutputDirectory(char *outdir, size_t size)
 }
 }
 
+typedef struct XkbCompContext {
+char keymap[PATH_MAX];
+FILE *out;
+char *buf;
+char tmpname[PATH_MAX];
+const char *xkmfile;
+} XkbCompContextRec, *XkbCompContextPtr;
+
 static Bool
 XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
XkbComponentNamesPtr names,
unsigned want,
-   unsigned need, char *nameRtrn, int nameRtrnLen)
+   unsigned need, XkbCompContextPtr ctx)
 {
-FILE *out;
-char *buf = NULL, keymap[PATH_MAX], xkm_output_dir[PATH_MAX];
+char xkm_output_dir[PATH_MAX];
 
 const char *emptystring = ;
 char *xkbbasedirflag = NULL;
@@ -105,22 +112,19 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
 const char *xkbbindirsep = emptystring;
 
 #ifdef WIN32
-/* WIN32 has no popen. The input must be stored in a file which is
-   used as input for xkbcomp. xkbcomp does not read from stdin. */
-char tmpname[PATH_MAX];
-const char *xkmfile = tmpname;
+ctx-xkmfile = ctx-tmpname;
 #else
-const char *xkmfile = -;
+ctx-xkmfile = -;
 #endif
 
-snprintf(keymap, sizeof(keymap), server-%s, display);
+snprintf(ctx-keymap, sizeof(ctx-keymap), server-%s, display);
 
 OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
 
 #ifdef WIN32
-strcpy(tmpname, Win32TempDir());
-strcat(tmpname, \\xkb_XX);
-(void) mktemp(tmpname);
+strcpy(ctx-tmpname, Win32TempDir());
+strcat(ctx-tmpname, \\xkb_XX);
+(void) mktemp(ctx-tmpname);
 #endif
 
 if (XkbBaseDirectory != NULL) {
@@ -139,73 +143,69 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
 }
 }
 
-if (asprintf(buf,
+if (asprintf(ctx-buf,
  \%s%sxkbcomp\ -w %d %s -xkm \%s\ 
  -em1 %s -emp %s -eml %s \%s%s.xkm\,
  xkbbindir, xkbbindirsep,
  ((xkbDebugFlags  2) ? 1 :
   ((xkbDebugFlags  10) ? 10 : (int) xkbDebugFlags)),
- xkbbasedirflag ? xkbbasedirflag : , xkmfile,
+ xkbbasedirflag ? xkbbasedirflag : , ctx-xkmfile,
  PRE_ERROR_MSG, ERROR_PREFIX, POST_ERROR_MSG1,
- xkm_output_dir, keymap) == -1)
-buf = NULL;
+ xkm_output_dir, ctx-keymap) == -1)
+ctx-buf = NULL;
 
 free(xkbbasedirflag);
 
-if (!buf) {
+if (!ctx-buf) {
 LogMessage(X_ERROR,
XKB: Could not invoke xkbcomp: not enough memory\n);
 return FALSE;
 }
 
 #ifndef WIN32
-out = Popen(buf, w);
+ctx-out = Popen(ctx-buf, w);
 #else
-out = fopen(tmpname, w);
+ctx-out = fopen(ctx-tmpname, w);
 #endif
 
-if (out != NULL) {
+if (ctx-out != NULL) {
 #ifdef DEBUG
 if (xkbDebugFlags) {
 ErrorF([xkb] XkbDDXCompileKeymapByNames compiling keymap:\n);
 XkbWriteXKBKeymapForNames(stderr, names, xkb, want, need);
 }
 #endif
-XkbWriteXKBKeymapForNames(out, names, xkb, want, need);
+XkbWriteXKBKeymapForNames(ctx-out, names, xkb, want, need);
 #ifndef WIN32
-if (Pclose(out) == 0)
+if (Pclose(ctx-out) == 0)
 #else
-if (fclose(out) == 0  System(buf) = 0)
+if (fclose(ctx-out) == 0  System(ctx-buf) = 0)
 #endif
 {
 if (xkbDebugFlags)
-DebugF([xkb] xkb executes: %s\n, buf);
-if (nameRtrn) {
-strlcpy(nameRtrn, keymap, nameRtrnLen);
-}
-free(buf);
+DebugF([xkb] xkb executes: %s\n, ctx-buf);
+free(ctx-buf);
 #ifdef WIN32
-unlink(tmpname);
+unlink(ctx-tmpname);
 #endif
 return TRUE;
 }
 else
-LogMessage(X_ERROR, Error compiling keymap (%s)\n, keymap);
+LogMessage(X_ERROR, Error compiling keymap (%s)\n, ctx-keymap);
 #ifdef WIN32
 /* remove the temporary file */
-unlink(tmpname);
+unlink(ctx-tmpname);
 #endif
 }
 else {
 #ifndef WIN32
 LogMessage(X_ERROR, XKB: Could not invoke xkbcomp\n);
 #else
-LogMessage(X_ERROR, Could not open file %s\n, tmpname);
+LogMessage(X_ERROR, Could not open file %s\n, ctx-tmpname);
 #endif
 }
-if (nameRtrn)
-nameRtrn[0] = '\0';
-free(buf);
+ctx-keymap[0] = '\0';
+free(ctx-buf);
 return FALSE;
 }
 
@@ -256,6 +256,7 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
 FILE *file;
 char fileName[PATH_MAX];
 

[PATCH 2/5] xkb: Split out code to start and finish xkbcomp

2014-03-07 Thread Kristian Høgsberg
Using the context struct from previous commit, we can now split out
code to start xkbcomp and to finish and clean up after it.

Reviewed-by: Daniel Stone dan...@fooishbar.org
---
 xkb/ddxLoad.c | 39 ---
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index cf9faa4..d266b36 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -99,10 +99,7 @@ typedef struct XkbCompContext {
 } XkbCompContextRec, *XkbCompContextPtr;
 
 static Bool
-XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
-   XkbComponentNamesPtr names,
-   unsigned want,
-   unsigned need, XkbCompContextPtr ctx)
+StartXkbComp(XkbCompContextPtr ctx)
 {
 char xkm_output_dir[PATH_MAX];
 
@@ -168,14 +165,15 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
 ctx-out = fopen(ctx-tmpname, w);
 #endif
 
+return ctx-out != NULL;
+}
+
+static Bool
+FinishXkbComp(XkbCompContextPtr ctx)
+{
+if (!ctx-buf)
+   return FALSE;
 if (ctx-out != NULL) {
-#ifdef DEBUG
-if (xkbDebugFlags) {
-ErrorF([xkb] XkbDDXCompileKeymapByNames compiling keymap:\n);
-XkbWriteXKBKeymapForNames(stderr, names, xkb, want, need);
-}
-#endif
-XkbWriteXKBKeymapForNames(ctx-out, names, xkb, want, need);
 #ifndef WIN32
 if (Pclose(ctx-out) == 0)
 #else
@@ -209,6 +207,25 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
 return FALSE;
 }
 
+static Bool
+XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
+   XkbComponentNamesPtr names,
+   unsigned want,
+   unsigned need, XkbCompContextPtr ctx)
+{
+if (StartXkbComp(ctx)) {
+#ifdef DEBUG
+if (xkbDebugFlags) {
+ErrorF([xkb] XkbDDXCompileKeymapByNames compiling keymap:\n);
+XkbWriteXKBKeymapForNames(stderr, names, xkb, want, need);
+}
+#endif
+XkbWriteXKBKeymapForNames(ctx-out, names, xkb, want, need);
+}
+
+return FinishXkbComp(ctx);
+}
+
 static FILE *
 XkbDDXOpenConfigFile(char *mapName, char *fileNameRtrn, int fileNameRtrnLen)
 {
-- 
1.9.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 4/5] xkb: Repurpose XkbCopyDeviceKeymap to apply a given keymap to a device

2014-03-07 Thread Kristian Høgsberg
From: Rui Matos tiagoma...@gmail.com

This will also make it useful for cases when we have a new keymap to
apply to a device but don't have a source device.

Reviewed-by: Kristian Høgsberg k...@bitplanet.net
---
 Xi/exevents.c|  2 +-
 include/xkbsrv.h |  4 ++--
 xkb/xkb.c|  2 +-
 xkb/xkbUtils.c   | 14 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index e9f670e..9c207eb 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -230,7 +230,7 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
 
 mk-sourceid = device-id;
 
-if (!XkbCopyDeviceKeymap(master, device))
+if (!XkbDeviceApplyKeymap(master, device-key-xkbInfo-desc))
 FatalError(Couldn't pivot keymap from device to core!\n);
 }
 
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 253612e..5d8e409 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -820,8 +820,8 @@ extern _X_EXPORT void XkbSendNewKeyboardNotify(DeviceIntPtr 
/* kbd */ ,
 extern Bool XkbCopyKeymap(XkbDescPtr /* dst */ ,
   XkbDescPtr /* src */ );
 
-extern _X_EXPORT Bool XkbCopyDeviceKeymap(DeviceIntPtr /* dst */ ,
-  DeviceIntPtr /* src */ );
+extern _X_EXPORT Bool XkbDeviceApplyKeymap(DeviceIntPtr /* dst */ ,
+   XkbDescPtr /* src */ );
 
 extern void XkbFilterEvents(ClientPtr /* pClient */ ,
 int /* nEvents */ ,
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 31bb8d3..6196a17 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5991,7 +5991,7 @@ ProcXkbGetKbdByName(ClientPtr client)
 continue;
 
 if (tmpd != dev)
-XkbCopyDeviceKeymap(tmpd, dev);
+XkbDeviceApplyKeymap(tmpd, xkb);
 
 if (tmpd-kbdfeed  tmpd-kbdfeed-xkb_sli) {
 old_sli = tmpd-kbdfeed-xkb_sli;
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 6c6af60..1f8a839 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1999,28 +1999,28 @@ XkbCopyKeymap(XkbDescPtr dst, XkbDescPtr src)
 }
 
 Bool
-XkbCopyDeviceKeymap(DeviceIntPtr dst, DeviceIntPtr src)
+XkbDeviceApplyKeymap(DeviceIntPtr dst, XkbDescPtr desc)
 {
 xkbNewKeyboardNotify nkn;
 Bool ret;
 
-if (!dst-key || !src-key)
+if (!dst-key || !desc)
 return FALSE;
 
 memset(nkn, 0, sizeof(xkbNewKeyboardNotify));
 nkn.oldMinKeyCode = dst-key-xkbInfo-desc-min_key_code;
 nkn.oldMaxKeyCode = dst-key-xkbInfo-desc-max_key_code;
 nkn.deviceID = dst-id;
-nkn.oldDeviceID = dst-id;  /* maybe src-id? */
-nkn.minKeyCode = src-key-xkbInfo-desc-min_key_code;
-nkn.maxKeyCode = src-key-xkbInfo-desc-max_key_code;
+nkn.oldDeviceID = dst-id;
+nkn.minKeyCode = desc-min_key_code;
+nkn.maxKeyCode = desc-max_key_code;
 nkn.requestMajor = XkbReqCode;
 nkn.requestMinor = X_kbSetMap;  /* Near enough's good enough. */
 nkn.changed = XkbNKN_KeycodesMask;
-if (src-key-xkbInfo-desc-geom)
+if (desc-geom)
 nkn.changed |= XkbNKN_GeometryMask;
 
-ret = XkbCopyKeymap(dst-key-xkbInfo-desc, src-key-xkbInfo-desc);
+ret = XkbCopyKeymap(dst-key-xkbInfo-desc, desc);
 if (ret)
 XkbSendNewKeyboardNotify(dst, nkn);
 
-- 
1.9.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

Re: [PULL] non-glamor build fix

2014-03-07 Thread Keith Packard
Eric Anholt e...@anholt.net writes:

 Jon TURNEY (1):
   Fix xephyr build in --disable-glamor case

Merged.
   78e508c..5350ae1  master - master

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


pgpFkDm1LcCVZ.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: [PULL] systemd-logind integration series

2014-03-07 Thread Keith Packard
Hans de Goede hdego...@redhat.com writes:

 Hans de Goede (13):
   linux: xf86OpenConsole remove root-rights check for keeptty option
   linux: xf86OpenConsole: Don't detach from controlling tty when it is 
 our vt
   xf86Xinput: Modify API for server-managed fd support
   OdevAttribute: Add config_odev_get_attribute helper
   OdevAttribute: config_odev_add_attribute: replace existing values
   OdevAttribute: Add support for integer attributes
   OdevAttribute: Remove unowned flag from OdevAttributes head
   hotplug: Extend OdevAttributes for server-managed fd support
   systemd-logind: Add systemd-logind core
   systemd-logind: Hookup systemd-logind integration
   systemd-logind: Add delayed input device probing
   config-udev: Don't try to add drm devices twice
   xf86OpenSerial: Add support server managed fds

Merged.
   5350ae1..1c61d38  master - master

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


pgpnqCtY8QQYP.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