From 1bd2463a2b76340ae356364dff944deba9774cfe Mon Sep 17 00:00:00 2001
From: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Date: Tue, 28 Jun 2016 20:30:42 +0200
Subject: libNX_X11 data files: Install libNX_X11 related data files.

  - Update XErrorDB to latest X.org version.
  - Install XErrorDB, XKeysymDB and Xcms.txt to /usr/{local/}share/nx/.
  - Assure that libNX_X11 finds those files at the
    named location.
  - Update debian/ packaging files.
  - Update nx-libs.spec packaging file.

Fixes ArcticaProject/nx-libs#153
---
 Makefile                                           |   3 +
 debian/nx-x11-common.install                       |   3 +
 .../016_nx-X11_install-location.debian.patch       |  20 ++++
 nx-X11/config/cf/Imake.tmpl                        |  20 ++++
 nx-X11/lib/X11/Imakefile                           |   6 +-
 nx-X11/lib/X11/XErrorDB                            | 106 ++++++++++++++++++++-
 nx-libs.spec                                       |   3 +
 7 files changed, 154 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 470a46d6e..455fa859f 100644
--- a/Makefile
+++ b/Makefile
@@ -164,6 +164,9 @@ install-full:
 	$(INSTALL_FILE) etc/nxagent.keyboard $(DESTDIR)$(ETCDIR_NX)/
 
 	$(INSTALL_DIR) $(DESTDIR)$(PREFIX)/share/nx
+	$(INSTALL_FILE) nx-X11/lib/X11/XErrorDB $(DESTDIR)$(PREFIX)/share/nx/
+	$(INSTALL_FILE) nx-X11/lib/X11/XKeysymDB $(DESTDIR)$(PREFIX)/share/nx/
+	$(INSTALL_FILE) nx-X11/lib/X11/Xcms.txt $(DESTDIR)$(PREFIX)/share/nx/
 	$(INSTALL_SYMLINK) $(ETCDIR_NX)/rgb $(DESTDIR)$(PREFIX)/share/nx/rgb
 	$(INSTALL_FILE) VERSION $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxagent
 	$(INSTALL_FILE) VERSION $(DESTDIR)$(PREFIX)/share/nx/VERSION.nxproxy
diff --git a/debian/nx-x11-common.install b/debian/nx-x11-common.install
index b6fc46613..d3f7b4c3b 100644
--- a/debian/nx-x11-common.install
+++ b/debian/nx-x11-common.install
@@ -1 +1,4 @@
 usr/share/nx/SecurityPolicy
+usr/share/nx/XErrorDB
+usr/share/nx/XKeysymDB
+usr/share/nx/Xcms.txt
diff --git a/debian/patches/016_nx-X11_install-location.debian.patch b/debian/patches/016_nx-X11_install-location.debian.patch
index ddd92eeb3..ee5bb66cf 100644
--- a/debian/patches/016_nx-X11_install-location.debian.patch
+++ b/debian/patches/016_nx-X11_install-location.debian.patch
@@ -15,3 +15,23 @@ Last-Update: 2012-12-31
  #ifndef AlternateUsrLibDir
  #define AlternateUsrLibDir NO
  #endif
+@@ -767,7 +767,7 @@
+ #define AlternateUsrDataDir YES
+ #endif
+ #else
+-#define UsrDataDir Concat4(/usr/local,/,share,/nx)
++#define UsrDataDir Concat4(/usr,/,share,/nx)
+ #ifndef AlternateUsrDataDir
+ #define AlternateUsrDataDir NO
+ #endif
+--- a/nx-X11/config/cf/site.def
++++ b/nx-X11/config/cf/site.def
+@@ -72,7 +72,7 @@
+ #ifdef AfterVendorCF
+ 
+ #ifndef ProjectRoot
+-#define ProjectRoot /usr/local
++#define ProjectRoot /usr
+ #endif
+ 
+ /*
diff --git a/nx-X11/config/cf/Imake.tmpl b/nx-X11/config/cf/Imake.tmpl
index d540f418b..b5753b5c7 100644
--- a/nx-X11/config/cf/Imake.tmpl
+++ b/nx-X11/config/cf/Imake.tmpl
@@ -759,6 +759,25 @@ TCLIBDIR = TclLibDir
 #define AlternateUsrLibDir YES
 #endif
 #endif
+
+#ifndef UsrDataDir
+#ifdef ProjectRoot
+#define UsrDataDir Concat4(ProjectRoot,/,share,/nx)
+#ifndef AlternateUsrDataDir
+#define AlternateUsrDataDir YES
+#endif
+#else
+#define UsrDataDir Concat4(/usr/local,/,share,/nx)
+#ifndef AlternateUsrDataDir
+#define AlternateUsrDataDir NO
+#endif
+#endif
+#else
+#ifndef AlternateUsrDataDir
+#define AlternateUsrDataDir YES
+#endif
+#endif
+
 #ifndef VarDirectory
 #ifdef ProjectVar
 #define VarDirectory ProjectVar
@@ -1656,6 +1675,7 @@ TCLIBDIR = TclLibDir
 
           INCROOT = IncRoot		/* base of where to put header files */
         USRLIBDIR = UsrLibDir		/* nonshared libraries */
+       USRDATADIR = UsrDataDir		/* arch-indep files (XErrorDB, etc.) */
            VARDIR = VarDirectory	/* usually /var */
         VARLIBDIR = VarLibDir		/* xdm runtime files */
   SYSTEMUSRLIBDIR = SystemUsrLibDir	/* system's "/usr/lib" */
diff --git a/nx-X11/lib/X11/Imakefile b/nx-X11/lib/X11/Imakefile
index cc87d6e7b..186cd963d 100644
--- a/nx-X11/lib/X11/Imakefile
+++ b/nx-X11/lib/X11/Imakefile
@@ -152,9 +152,9 @@ EXTRA_LIBRARIES = /**/
 
     XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines
 
-     EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\"
-     KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\"
-     CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\"
+     EDB_DEFINES = -DERRORDB=\"$(USRDATADIR)/XErrorDB\"
+     KDB_DEFINES = -DKEYSYMDB=\"$(USRDATADIR)/XKeysymDB\"
+     CMS_DEFINES = -DXCMSDB=\"$(USRDATADIR)/Xcms.txt\"
 #if HasSnprintf
     MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11
 #endif
diff --git a/nx-X11/lib/X11/XErrorDB b/nx-X11/lib/X11/XErrorDB
index 80a3310b2..c2efa1044 100644
--- a/nx-X11/lib/X11/XErrorDB
+++ b/nx-X11/lib/X11/XErrorDB
@@ -1,5 +1,3 @@
-! $Xorg: XErrorDB,v 1.3 2000/08/17 19:44:59 cpqbld Exp $
-! $XdotOrg: xc/lib/X11/XErrorDB,v 1.4 2005/10/21 18:44:24 ajax Exp $
 !
 ! Copyright 1993, 1995, 1998  The Open Group
 
@@ -25,7 +23,6 @@
 ! other dealings in this Software without prior written authorization
 ! from The Open Group.
 !
-! $XFree86: xc/lib/X11/XErrorDB,v 3.40 2002/12/21 17:51:42 dawes Exp $
 !
 ! these are used in XGetErrorMessage.
 XlibMessage.XError: X Error of failed request
@@ -235,6 +232,20 @@ XRequest.XInputExtension.32:X_DeviceBell
 XRequest.XInputExtension.33:X_SetDeviceValuators
 XRequest.XInputExtension.34:X_GetDeviceControl
 XRequest.XInputExtension.35:X_ChangeDeviceControl
+XRequest.XInputExtension.36: X_ListDeviceProperties
+XRequest.XInputExtension.37: X_ChangeDeviceProperty
+XRequest.XInputExtension.38: X_DeleteDeviceProperty
+XRequest.XInputExtension.39: X_GetDeviceProperty
+XProtoError.XInputExtension.0: XI_BadDevice (invalid Device parameter)
+XlibMessage.XInputExtension.0: Device id in failed request: 0x%lx
+XProtoError.XInputExtension.1: XI_BadEvent (invalid Event parameter)
+XlibMessage.XInputExtension.1: Event id in failed request: 0x%lx
+XProtoError.XInputExtension.2: XI_BadMode (invalid Mode parameter)
+XlibMessage.XInputExtension.2: Mode id in failed request: 0x%lx
+XProtoError.XInputExtension.3: XI_DeviceBusy
+XlibMessage.XInputExtension.3: Device id in failed request: 0x%lx
+XProtoError.XInputExtension.4: XI_BadClass (invalid Class parameter)
+XlibMessage.XInputExtension.4: Class id in failed request: 0x%lx
 ! MIT-SHM extension, experimental, not an X Consortium standard
 XRequest.MIT-SHM.0: X_ShmQueryVersion
 XRequest.MIT-SHM.1: X_ShmAttach
@@ -386,6 +397,7 @@ XlibMessage.X3D-PEX.14: Resource id in failed request:  0x%lx
 XRequest.XTEST.0: X_XTestGetVersion
 XRequest.XTEST.1: X_XTestCompareCursor
 XRequest.XTEST.2: X_XTestFakeInput
+XRequest.XTEST.3: X_XTestGrabControl
 ! BIG-REQUESTS extension, an X Consortium standard
 XRequest.BIG-REQUESTS.0: X_BigReqEnable
 ! XIE extension, an X Consortium standard
@@ -498,6 +510,18 @@ XRequest.GLX.17: X_GLXVendorPrivateWithReply
 XRequest.GLX.18: X_GLXQueryExtensionsString
 XRequest.GLX.19: X_GLXQueryServerString
 XRequest.GLX.20: X_GLXClientInfo
+XRequest.GLX.21: X_GLXGetFBConfigs
+XRequest.GLX.22: X_GLXCreatePixmap
+XRequest.GLX.23: X_GLXDestroyPixmap
+XRequest.GLX.24: X_GLXCreateNewContext
+XRequest.GLX.25: X_GLXQueryContext
+XRequest.GLX.26: X_GLXMakeContextCurrent
+XRequest.GLX.27: X_GLXCreatePbuffer
+XRequest.GLX.28: X_GLXDestroyPbuffer
+XRequest.GLX.29: X_GLXGetDrawableAttributes
+XRequest.GLX.30: X_GLXChangeDrawableAttributes
+XRequest.GLX.31: X_GLXCreateWindow
+XRequest.GLX.32: X_GLXDestroyWindow
 ! GL Non-rendering Commands
 XRequest.GLX.103: X_GLXDeleteLists
 XRequest.GLX.102: X_GLXEndList
@@ -555,6 +579,11 @@ XProtoError.GLX.5: GLXBadCurrentWindow
 XProtoError.GLX.6: GLXBadRenderRequest
 XProtoError.GLX.7: GLXBadLargeRequest
 XProtoError.GLX.8: GLXUnsupportedPrivateRequest
+XProtoError.GLX.9: GLXBadFBConfig
+XProtoError.GLX.10: GLXBadPbuffer
+XProtoError.GLX.11: GLXBadCurrentDrawable
+XProtoError.GLX.12: GLXBadWindow
+XProtoError.GLX.13: GLXBadProfileARB
 ! XC-MISC extension, an X Consortium standard
 XRequest.XC-MISC.0: XCMiscGetVersion
 XRequest.XC-MISC.1: XCMiscGetXIDRange
@@ -618,7 +647,7 @@ XProtoError.XFree86-Misc.5: XF86MiscModInDevDisabled
 XProtoError.XFree86-Misc.6: XF86MiscModInDevClientNotLocal
 XProtoError.XFree86-Misc.7: XF86MiscNoModule
 ! XFree86-DGA  -- not an X Consortium standard
-XRequest.XFree86-DGA.0: XDGAQueryVersion
+XRequest.XFree86-DGA.0: XF86DGAQueryVersion
 XRequest.XFree86-DGA.1: XF86DGAGetVideoLL
 XRequest.XFree86-DGA.2: XF86DGADirectVideo
 XRequest.XFree86-DGA.3: XF86DGAGetViewPortSize
@@ -843,6 +872,50 @@ XRequest.RANDR.2: RRSetScreenConfig
 XRequest.RANDR.3: RROldScreenChangeSelectInput
 XRequest.RANDR.4: RRSelectInput
 XRequest.RANDR.5: RRGetScreenInfo
+XRequest.RANDR.6: RRGetScreenSizeRange
+XRequest.RANDR.7: RRSetScreenSize
+XRequest.RANDR.8: RRGetScreenResources
+XRequest.RANDR.9: RRGetOutputInfo
+XRequest.RANDR.10: RRListOutputProperties
+XRequest.RANDR.11: RRQueryOutputProperty
+XRequest.RANDR.12: RRConfigureOutputProperty
+XRequest.RANDR.13: RRChangeOutputProperty
+XRequest.RANDR.14: RRDeleteOutputProperty
+XRequest.RANDR.15: RRGetOutputProperty
+XRequest.RANDR.16: RRCreateMode
+XRequest.RANDR.17: RRDestroyMode
+XRequest.RANDR.18: RRAddOutputMode
+XRequest.RANDR.19: RRDeleteOutputMode
+XRequest.RANDR.20: RRGetCrtcInfo
+XRequest.RANDR.21: RRSetCrtcConfig
+XRequest.RANDR.22: RRGetCrtcGammaSize
+XRequest.RANDR.23: RRGetCrtcGamma
+XRequest.RANDR.24: RRSetCrtcGamma
+XRequest.RANDR.25: RRGetScreenResourcesCurrent
+XRequest.RANDR.26: RRSetCrtcTransform
+XRequest.RANDR.27: RRGetCrtcTransform
+XRequest.RANDR.28: RRGetPanning
+XRequest.RANDR.29: RRSetPanning
+XRequest.RANDR.30: RRSetOutputPrimary
+XRequest.RANDR.31: RRGetOutputPrimary
+XRequest.RANDR.32: RRGetProviders
+XRequest.RANDR.33: RRGetProviderInfo
+XRequest.RANDR.34: RRSetProviderOffloadSink
+XRequest.RANDR.35: RRSetProviderOutputSource
+XRequest.RANDR.36: RRListProviderProperties
+XRequest.RANDR.37: RRQueryProviderProperty
+XRequest.RANDR.38: RRConfigureProviderProperty
+XRequest.RANDR.39: RRChangeProviderProperty
+XRequest.RANDR.40: RRDeleteProviderProperty
+XRequest.RANDR.41: RRGetProviderProperty
+XProtoError.RANDR.0: BadRROutput (invalid Output parameter)
+XlibMessage.RANDR.0: Output id in failed request: 0x%lx
+XProtoError.RANDR.1: BadRRCrtc (invalid Crtc parameter)
+XlibMessage.RANDR.1: Crtc id in failed request: 0x%lx
+XProtoError.RANDR.2: BadRRMode (invalid Mode parameter)
+XlibMessage.RANDR.2: Mode id in failed request: 0x%lx
+XProtoError.RANDR.3: BadRRProvider (invalid Provider parameter)
+XlibMessage.RANDR.3: Provider id in failed request: 0x%lx
 ! RENDER
 XRequest.RENDER.0: RenderQueryVersion
 XRequest.RENDER.1: RenderQueryPictFormats
@@ -875,6 +948,12 @@ XRequest.RENDER.27: RenderCreateCursor
 XRequest.RENDER.28: RenderSetPictureTransform
 XRequest.RENDER.29: RenderQueryFilters
 XRequest.RENDER.30: RenderSetPictureFilter
+XRequest.RENDER.31: RenderCreateAnimCursor
+XRequest.RENDER.32: RenderAddTraps
+XRequest.RENDER.33: RenderCreateSolidFill
+XRequest.RENDER.34: RenderCreateLinearGradient
+XRequest.RENDER.35: RenderCreateRadialGradient
+XRequest.RENDER.36: RenderCreateConicalGradient
 XProtoError.RENDER.0: RenderBadFormat (invalid PictFormat parameter)
 XlibMessage.RENDER.0: PictFormat id in failed request: 0x%lx
 XProtoError.RENDER.1: RenderBadPicture (invalid Picture parameter)
@@ -915,6 +994,8 @@ XRequest.XFIXES.25: XFixesGetCursorImageAndName
 XRequest.XFIXES.26: XFixesChangeCursor
 XRequest.XFIXES.27: XFixesChangeCursorByName
 XRequest.XFIXES.28: XFixesExpandRegion
+XRequest.XFIXES.29: XFixesHideCursor
+XRequest.XFIXES.30: XFixesShowCursor
 XProtoError.XFIXES.0: BadRegion (invalid Region parameter)
 XlibMessage.XFIXES.0: Region id in failed request:  0x%lx
 ! DAMAGE extension
@@ -922,3 +1003,20 @@ XRequest.DAMAGE.0: XDamageQueryVersion
 XRequest.DAMAGE.1: XDamageCreate
 XRequest.DAMAGE.2: XDamageDestroy
 XRequest.DAMAGE.3: XDamageSubtract
+XRequest.DAMAGE.4: XDamageAdd
+XProtoError.DAMAGE.0: BadDamage (invalid Damage parameter)
+XlibMessage.DAMAGE.0: Damage id in failed request: 0x%lx
+! DRI2 extension
+XRequest.DRI2.0: DRI2QueryVersion
+XRequest.DRI2.1: DRI2Connect
+XRequest.DRI2.2: DRI2Authenticate
+XRequest.DRI2.3: DRI2CreateDrawable
+XRequest.DRI2.4: DRI2DestroyDrawable
+XRequest.DRI2.5: DRI2GetBuffers
+XRequest.DRI2.6: DRI2CopyRegion
+XRequest.DRI2.7: DRI2GetBuffersWithFormat
+XRequest.DRI2.8: DRI2SwapBuffers
+XRequest.DRI2.9: DRI2GetMSC
+XRequest.DRI2.10: DRI2WaitMSC
+XRequest.DRI2.11: DRI2WaitSBC
+XRequest.DRI2.12: DRI2SwapInterval
diff --git a/nx-libs.spec b/nx-libs.spec
index 418a83bdd..b4388db38 100644
--- a/nx-libs.spec
+++ b/nx-libs.spec
@@ -403,6 +403,9 @@ rm -r %{buildroot}%{_includedir}/nx-X11/Xtrans
 %dir %{_libdir}/nx
 %dir %{_datadir}/nx
 %{_datadir}/nx/SecurityPolicy
+%{_datadir}/nx/XErrorDB
+%{_datadir}/nx/XKeysymDB
+%{_datadir}/nx/Xcms.txt
 
 %files -n libNX_X11-6
 %defattr(-,root,root)
-- 
cgit v1.2.3