aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-08-02 09:00:24 +0000
committermarha <marha@users.sourceforge.net>2010-08-02 09:00:24 +0000
commit240baf59a219841c5f8942c82f7ed61da9d2323b (patch)
tree76937e127002c1ba58c5a379651f20a17e866627 /xorg-server
parent6c5a4ae0c8e57225ce31fb0a39c87ec9a5eed2b5 (diff)
parentd2758df0a0091496717fe7a65c3e7563e7c82785 (diff)
downloadvcxsrv-240baf59a219841c5f8942c82f7ed61da9d2323b.tar.gz
vcxsrv-240baf59a219841c5f8942c82f7ed61da9d2323b.tar.bz2
vcxsrv-240baf59a219841c5f8942c82f7ed61da9d2323b.zip
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/configure.ac8
-rw-r--r--xorg-server/doc/xml/Makefile.am2
-rw-r--r--xorg-server/doc/xml/Xserver-spec.xml8
-rw-r--r--xorg-server/doc/xml/dtrace/Makefile.am36
-rw-r--r--xorg-server/doc/xml/dtrace/Xserver-DTrace.xml579
-rw-r--r--xorg-server/doc/xml/xmlrules.in10
-rw-r--r--xorg-server/hw/xfree86/ddc/ddc.c7
-rw-r--r--xorg-server/hw/xquartz/GL/indirect.c5
-rw-r--r--xorg-server/hw/xquartz/pbproxy/main.m328
-rw-r--r--xorg-server/xkeyboard-config/tests/genLists4Comparizon.sh43
-rw-r--r--xorg-server/xkeyboard-config/tests/listCI2.xsl21
-rw-r--r--xorg-server/xkeyboard-config/tests/listCIs.xsl20
-rw-r--r--xorg-server/xkeyboard-config/tests/mxkbledpanel/Imakefile8
-rw-r--r--xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.c605
-rw-r--r--xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.man0
-rw-r--r--xorg-server/xkeyboard-config/tests/ruby/README3
-rw-r--r--xorg-server/xkeyboard-config/tests/ruby/find_fragments.rb52
-rw-r--r--xorg-server/xkeyboard-config/tests/ruby/find_match.rb42
-rw-r--r--xorg-server/xkeyboard-config/tests/ruby/utils.rb64
-rw-r--r--xorg-server/xkeyboard-config/tests/ruby/xkbparser.rb185
-rw-r--r--xorg-server/xkeyboard-config/tests/testLayouts.pl17
-rw-r--r--xorg-server/xkeyboard-config/tests/testModels.pl15
-rw-r--r--xorg-server/xkeyboard-config/tests/testOptions.pl15
-rw-r--r--xorg-server/xkeyboard-config/tests/testShortDescriptions6
-rw-r--r--xorg-server/xkeyboard-config/tests/xkbTestFunc.pm164
-rw-r--r--xorg-server/xkeyboard-config/xslt/reg2ll.xsl23
-rw-r--r--xorg-server/xkeyboard-config/xslt/xfree86.xsl50
27 files changed, 2142 insertions, 174 deletions
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index 979f4db86..50313b616 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -32,12 +32,13 @@ AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
-# Require xorg-macros: XORG_DEFAULT_OPTIONS
+# Require xorg-macros minimum of 1.10 for XORG_CHECK_SGML_DOCTOOLS
m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.6 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.6)
+ [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.10)
XORG_DEFAULT_OPTIONS
XORG_WITH_DOXYGEN(1.6.1)
+XORG_CHECK_SGML_DOCTOOLS(1.5)
m4_ifndef([XORG_FONT_MACROS_VERSION], [m4_fatal([must install fontutil 1.1 or later before running autoconf/autogen])])
XORG_FONT_MACROS_VERSION(1.1)
@@ -2182,6 +2183,7 @@ dbe/Makefile
dix/Makefile
doc/Makefile
doc/xml/Makefile
+doc/xml/dtrace/Makefile
doc/xml/xserver.ent
fb/Makefile
record/Makefile
diff --git a/xorg-server/doc/xml/Makefile.am b/xorg-server/doc/xml/Makefile.am
index 3eba24e8c..2913eff55 100644
--- a/xorg-server/doc/xml/Makefile.am
+++ b/xorg-server/doc/xml/Makefile.am
@@ -21,6 +21,8 @@
# DEALINGS IN THE SOFTWARE.
#
+SUBDIRS = dtrace
+
XML_FILES = Xserver-spec.xml
include xmlrules.in
diff --git a/xorg-server/doc/xml/Xserver-spec.xml b/xorg-server/doc/xml/Xserver-spec.xml
index 7249d4267..a457063bd 100644
--- a/xorg-server/doc/xml/Xserver-spec.xml
+++ b/xorg-server/doc/xml/Xserver-spec.xml
@@ -357,11 +357,15 @@ Resource types are integer values starting at 1. Get
a resource type by calling
<blockquote><programlisting>
- RESTYPE CreateNewResourceType(deleteFunc)
+ RESTYPE CreateNewResourceType(deleteFunc, char *name)
</programlisting></blockquote>
deleteFunc will be called to destroy all resources with this
-type.</para>
+type. name will be used to identify this type of resource
+to clients using the X-Resource extension, to security
+extensions such as SELinux, and to tracing frameworks such as DTrace.
+[The name argument was added in xorg-server 1.8.]
+</para>
<para>
Resource classes are masks starting at 1 &lt;&lt; 31 which can
be or'ed with any resource type to provide attributes for the
diff --git a/xorg-server/doc/xml/dtrace/Makefile.am b/xorg-server/doc/xml/dtrace/Makefile.am
new file mode 100644
index 000000000..946fba7d8
--- /dev/null
+++ b/xorg-server/doc/xml/dtrace/Makefile.am
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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 (including the next
+# paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+XML_FILES = Xserver-DTrace.xml
+
+include ../xmlrules.in
+
+if XSERVER_DTRACE
+doc_DATA = $(BUILT_DOC_FILES)
+else
+noinst_DATA = $(BUILT_DOC_FILES)
+endif
+
+CLEANFILES = $(CLEAN_DOC_FILES)
+
+EXTRA_DIST = $(XML_FILES)
diff --git a/xorg-server/doc/xml/dtrace/Xserver-DTrace.xml b/xorg-server/doc/xml/dtrace/Xserver-DTrace.xml
new file mode 100644
index 000000000..e0425c8ee
--- /dev/null
+++ b/xorg-server/doc/xml/dtrace/Xserver-DTrace.xml
@@ -0,0 +1,579 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
+]>
+
+<article id="Xserver-DTrace">
+ <articleinfo>
+ <title>Xserver provider for DTrace</title>
+ <author>
+ <firstname>Alan</firstname><surname>Coopersmith</surname>
+ <affiliation>
+ <orgname>Oracle Corporation</orgname>
+ <orgdiv>Solaris Engineering</orgdiv>
+ </affiliation>
+ </author>
+ <releaseinfo>X.Org Xserver version &xserver.version;</releaseinfo>
+ <legalnotice>
+ <para>
+Copyright (c) 2005, 2006, 2007, 2010, Oracle and/or its affiliates.
+All rights reserved.
+ </para><para>
+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:
+ </para><para>
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+ </para><para>
+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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+ </para>
+ </legalnotice>
+ </articleinfo>
+
+ <sect1 id="introduction">
+ <title>Introduction</title>
+ <para>
+ This page provides details on a
+ <ulink url="http://wikis.sun.com/display/DTrace/Statically+Defined+Tracing+for+User+Applications">statically defined user application tracing provider</ulink>
+ for the
+ <ulink url="http://hub.opensolaris.org/bin/view/Community+Group+dtrace/">DTrace</ulink>
+ facility in <productname>Solaris</productname> 10,
+ <productname>MacOS X</productname> 10.5, and later releases. This
+ provider instruments various points in the X server, to allow
+ tracing what client applications are up to.
+ </para>
+
+ <para>
+ The provider was integrated into the X.Org git master repository
+ with Solaris 10 &amp; OpenSolaris support for the Xserver 1.4 release,
+ released in 2007 with X11R7.3. Support for DTrace on MacOS X
+ was added in Xserver 1.7.
+ </para>
+
+ <para>
+ These probes expose the request and reply structure of the X protocol
+ between clients and the X server, so an understanding of that basic
+ nature will aid in learning how to use these probes.
+ </para>
+ </sect1>
+
+ <sect1 id="probes">
+ <title>Available probes</title>
+
+ <para>
+ Due to the way User-Defined DTrace probes work, arguments to
+ these probes all bear undistinguished names of
+ <parameter>arg0</parameter>, <parameter>arg1</parameter>,
+ <parameter>arg2</parameter>, etc. These tables should help you
+ determine what the real data is for each of the probe arguments.
+
+ <table>
+ <title>Probes and their arguments</title>
+ <tgroup cols='7'>
+ <colspec colname="probe" colwidth="2*"/>
+ <colspec colname="desc" colwidth="3*"/>
+ <colspec colname="arg0" colwidth="1*"/>
+ <colspec colname="arg1" colwidth="1*"/>
+ <colspec colname="arg2" colwidth="1*"/>
+ <colspec colname="arg3" colwidth="1*"/>
+ <colspec colname="arg4" colwidth="1*"/>
+ <spanspec spanname="all" namest="probe" nameend="arg4"/>
+ <thead>
+ <row>
+ <entry>Probe name</entry>
+ <entry>Description</entry>
+ <entry>arg0</entry>
+ <entry>arg1</entry>
+ <entry>arg2</entry>
+ <entry>arg3</entry>
+ <entry>arg4</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry spanname="all" class="grouphead">Request Probes</entry>
+ </row>
+ <row>
+ <entry>request-start</entry>
+ <entry>Called just before processing each client request.</entry>
+ <entry><parameter>requestName</parameter></entry>
+ <entry><parameter>requestCode</parameter></entry>
+ <entry><parameter>requestLength</parameter></entry>
+ <entry><parameter>clientId</parameter></entry>
+ <entry><parameter>requestBuffer</parameter></entry>
+ </row>
+ <row>
+ <entry>request-done</entry>
+ <entry>Called just after processing each client request.</entry>
+ <entry><parameter>requestName</parameter></entry>
+ <entry><parameter>requestCode</parameter></entry>
+ <entry><parameter>sequenceNumber</parameter></entry>
+ <entry><parameter>clientId</parameter></entry>
+ <entry><parameter>resultCode</parameter></entry>
+ </row>
+ <row>
+ <entry spanname="all" class="grouphead">Event Probes</entry>
+ </row>
+ <row>
+ <entry>send-event</entry>
+ <entry>Called just before send each event to a client.</entry>
+ <entry><parameter>clientId</parameter></entry>
+ <entry><parameter>eventCode</parameter></entry>
+ <entry><parameter>eventBuffer</parameter></entry>
+ <entry nameend="arg4" class="unused"/>
+ </row>
+ <row>
+ <entry spanname="all" class="grouphead">Client Connection Probes</entry>
+ </row>
+ <row>
+ <entry>client-connect</entry>
+ <entry>Called when a new connection is opened from a client</entry>
+ <entry><parameter>clientId</parameter></entry>
+ <entry><parameter>clientFD</parameter></entry>
+ <entry nameend="arg4" class="unused"/>
+ </row>
+ <row>
+ <entry>client-auth</entry>
+ <entry>Called when client authenticates (normally just after connection opened)</entry>
+ <entry><parameter>clientId</parameter></entry>
+ <entry><parameter>clientAddr</parameter></entry>
+ <entry><parameter>clientPid</parameter></entry>
+ <entry><parameter>clientZoneId</parameter></entry>
+ <entry nameend="arg4" class="unused"/>
+ </row>
+ <row>
+ <entry>client-disconnect</entry>
+ <entry>Called when a client connection is closed</entry>
+ <entry><parameter>clientId</parameter></entry>
+ <entry nameend="arg4" class="unused"/>
+ </row>
+ <row>
+ <entry spanname="all" class="grouphead">Resource Allocation Probes</entry>
+ </row>
+ <row>
+ <entry>resource-alloc</entry>
+ <entry>Called when a new resource (pixmap, gc, colormap, etc.) is allocated</entry>
+ <entry><parameter>resourceId</parameter></entry>
+ <entry><parameter>resourceTypeId</parameter></entry>
+ <entry><parameter>resourceValue</parameter></entry>
+ <entry><parameter>resourceTypeName</parameter></entry>
+ <entry nameend="arg4" class="unused"/>
+ </row>
+ <row>
+ <entry>resource-free</entry>
+ <entry>Called when a resource is freed</entry>
+ <entry><parameter>resourceId</parameter></entry>
+ <entry><parameter>resourceTypeId</parameter></entry>
+ <entry><parameter>resourceValue</parameter></entry>
+ <entry><parameter>resourceTypeName</parameter></entry>
+ <entry nameend="arg4" class="unused"/>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
+ </sect1>
+
+ <sect1 id="arguments">
+ <title>Data Available in Probe Arguments</title>
+
+ <para>
+ To access data in arguments of type <type>string</type>, you will need
+ to use <ulink url="http://wikis.sun.com/display/DTrace/Actions+and+Subroutines#ActionsandSubroutines-{{copyinstr}}"><function>copyinstr()</function></ulink>.
+ To access data buffers referenced via <type>uintptr_t</type>'s, you will
+ need to use <ulink url="http://wikis.sun.com/display/DTrace/Actions+and+Subroutines#ActionsandSubroutines-{{copyin}}"><function>copyin()</function></ulink>.
+
+ <table>
+ <title>Probe Arguments</title>
+ <tgroup cols='3'>
+ <colspec colname="arg" colwidth="2*"/>
+ <colspec colname="type" colwidth="1*"/>
+ <colspec colname="desc" colwidth="7*"/>
+ <thead>
+ <row>
+ <entry>Argument name</entry>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><parameter>clientAddr</parameter></entry>
+ <entry><type>string</type></entry>
+ <entry>String representing address client connected from</entry>
+ </row>
+ <row>
+ <entry><parameter>clientFD</parameter></entry>
+ <entry><type>int</type></entry>
+ <entry>X server's file descriptor for server side of each connection</entry>
+ </row>
+ <row>
+ <entry><parameter>clientId</parameter></entry>
+ <entry><type>int</type></entry>
+ <entry>Unique integer identifier for each connection to the
+ X server</entry>
+ </row>
+ <row>
+ <entry><parameter>clientPid</parameter></entry>
+ <entry><type>pid_t</type></entry>
+ <entry>Process id of client, if connection is local
+ (from <function>getpeerucred()</function>)</entry>
+ </row>
+ <row>
+ <entry><parameter>clientZoneId</parameter></entry>
+ <entry><type>zoneid_t</type></entry>
+ <entry>Solaris: Zone id of client, if connection is local
+ (from <function>getpeerucred()</function>)</entry>
+ </row>
+ <row>
+ <entry><parameter>eventBuffer</parameter></entry>
+ <entry><type>uintptr_t</type></entry>
+ <entry>Pointer to buffer containing X event - decode using
+ structures in
+ &lt;<ulink url="http://cgit.freedesktop.org/xorg/proto/xproto/tree/Xproto.h"><filename class="headerfile">X11/Xproto.h</filename></ulink>&gt;
+ and similar headers for each extension</entry>
+ </row>
+ <row>
+ <entry><parameter>eventCode</parameter></entry>
+ <entry><type>uint8_t</type></entry>
+ <entry>Event number of X event</entry>
+ </row>
+ <row>
+ <entry><parameter>resourceId</parameter></entry>
+ <entry><type>uint32_t</type></entry>
+ <entry>X resource id (XID)</entry>
+ </row>
+ <row>
+ <entry><parameter>resourceTypeId</parameter></entry>
+ <entry><type>uint32_t</type></entry>
+ <entry>Resource type id</entry>
+ </row>
+ <row>
+ <entry><parameter>resourceTypeName</parameter></entry>
+ <entry><type>string</type></entry>
+ <entry>String representing X resource type
+ (<literal>"PIXMAP"</literal>, etc.)</entry>
+ </row>
+ <row>
+ <entry><parameter>resourceValue</parameter></entry>
+ <entry><type>uintptr_t</type></entry>
+ <entry>Pointer to data for X resource</entry>
+ </row>
+ <row>
+ <entry><parameter>resultCode</parameter></entry>
+ <entry><type>int</type></entry>
+ <entry>Integer code representing result status of request</entry>
+ </row>
+ <row>
+ <entry><parameter>requestBuffer</parameter></entry>
+ <entry><type>uintptr_t</type></entry>
+ <entry>Pointer to buffer containing X request - decode using
+ structures in
+ &lt;<ulink url="http://cgit.freedesktop.org/xorg/proto/xproto/tree/Xproto.h"><filename class="headerfile">X11/Xproto.h</filename></ulink>&gt;
+ and similar headers for each extension</entry>
+ </row>
+ <row>
+ <entry><parameter>requestCode</parameter></entry>
+ <entry><type>uint8_t</type></entry>
+ <entry>Request number of X request or Extension</entry>
+ </row>
+ <row>
+ <entry><parameter>requestName</parameter></entry>
+ <entry><type>string</type></entry>
+ <entry>Name of X request or Extension</entry>
+ </row>
+ <row>
+ <entry><parameter>requestLength</parameter></entry>
+ <entry><type>uint16_t</type></entry>
+ <entry>Length of X request</entry>
+ </row>
+ <row>
+ <entry><parameter>sequenceNumber</parameter></entry>
+ <entry><type>uint32_t</type></entry>
+ <entry>Number of X request in in this connection</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
+ </sect1>
+
+ <sect1 id="examples">
+ <title>Examples</title>
+
+ <example>
+ <title>Counting requests by request name</title>
+
+ <para>
+ This script simply increments a counter for each different request
+ made, and when you exit the script (such as by hitting
+ <keycombo action='simul'><keycap>Control</keycap><keycap>C</keycap>
+ </keycombo>) prints the counts.
+
+ <programlisting>
+#!/usr/sbin/dtrace -s
+
+Xserver*:::request-start
+{
+ @counts[copyinstr(arg0)] = count();
+}
+ </programlisting>
+
+ The output from a short run may appear as:
+ <screen>
+ QueryPointer 1
+ CreatePixmap 2
+ FreePixmap 2
+ PutImage 2
+ ChangeGC 10
+ CopyArea 10
+ CreateGC 14
+ FreeGC 14
+ RENDER 28
+ SetClipRectangles 40
+ </screen>
+ </para>
+
+ <para>
+ This can be rewritten slightly to cache the string containing the name
+ of the request since it will be reused many times, instead of copying
+ it over and over from the kernel:
+
+ <programlisting>
+#!/usr/sbin/dtrace -s
+
+string Xrequest[uintptr_t];
+
+Xserver*:::request-start
+/Xrequest[arg0] == ""/
+{
+ Xrequest[arg0] = copyinstr(arg0);
+}
+
+Xserver*:::request-start
+{
+ @counts[Xrequest[arg0]] = count();
+}
+ </programlisting>
+ </para>
+ </example>
+
+ <example>
+ <title>Get average CPU time per request</title>
+
+ <para>This script records the CPU time used between the probes at
+ the start and end of each request and aggregates it per request type.
+
+ <programlisting>
+#!/usr/sbin/dtrace -s
+
+Xserver*:::request-start
+{
+ reqstart = vtimestamp;
+}
+
+Xserver*:::request-done
+{
+ @times[copyinstr(arg0)] = avg(vtimestamp - reqstart);
+}
+ </programlisting>
+
+ The output from a sample run might look like:
+
+ <screen>
+ ChangeGC 889
+ MapWindow 907
+ SetClipRectangles 1319
+ PolyPoint 1413
+ PolySegment 1434
+ PolyRectangle 1828
+ FreeCursor 1895
+ FreeGC 1950
+ CreateGC 2244
+ FreePixmap 2246
+ GetInputFocus 2249
+ TranslateCoords 8508
+ QueryTree 8846
+ GetGeometry 9948
+ CreatePixmap 12111
+ AllowEvents 14090
+ GrabServer 14791
+ MIT-SCREEN-SAVER 16747
+ ConfigureWindow 22917
+ SetInputFocus 28521
+ PutImage 240841
+
+ </screen>
+ </para>
+ </example>
+
+ <example>
+ <title>Monitoring clients that connect and disconnect</title>
+
+ <para>
+ This script simply prints information about each client that
+ connects or disconnects from the server while it is running.
+ Since the provider is specified as <code>Xserver$1</code> instead
+ of <code>Xserver*</code> like previous examples, it won't monitor
+ all Xserver processes running on the machine, but instead expects
+ the process id of the X server to monitor to be specified as the
+ argument to the script.
+
+ <programlisting>
+#!/usr/sbin/dtrace -s
+
+Xserver$1:::client-connect
+{
+ printf("** Client Connect: id %d\n", arg0);
+}
+
+Xserver$1:::client-auth
+{
+ printf("** Client auth'ed: id %d =&gt; %s pid %d\n",
+ arg0, copyinstr(arg1), arg2);
+}
+
+Xserver$1:::client-disconnect
+{
+ printf("** Client Disconnect: id %d\n", arg0);
+}
+ </programlisting>
+
+ A sample run:
+
+ <screen>
+<prompt>#</prompt> <userinput>./foo.d 5790</userinput>
+<computeroutput>dtrace: script './foo.d' matched 4 probes
+CPU ID FUNCTION:NAME
+ 0 15774 CloseDownClient:client-disconnect ** Client Disconnect: id 65
+
+ 2 15774 CloseDownClient:client-disconnect ** Client Disconnect: id 64
+
+ 0 15773 EstablishNewConnections:client-connect ** Client Connect: id 64
+
+ 0 15772 AuthAudit:client-auth ** Client auth'ed: id 64 =&gt; local host pid 2034
+
+ 0 15773 EstablishNewConnections:client-connect ** Client Connect: id 65
+
+ 0 15772 AuthAudit:client-auth ** Client auth'ed: id 65 =&gt; local host pid 2034
+
+ 0 15774 CloseDownClient:client-disconnect ** Client Disconnect: id 64
+ </computeroutput>
+ </screen>
+
+ </para>
+ </example>
+
+ <example>
+ <title>Monitoring clients creating Pixmaps</title>
+
+ <para>
+ This script can be used to determine which clients are creating
+ pixmaps in the X server, printing information about each client
+ as it connects to help trace it back to the program on the other
+ end of the X connection.
+
+ <programlisting>
+#!/usr/sbin/dtrace -qs
+
+string Xrequest[uintptr_t];
+string Xrestype[uintptr_t];
+
+Xserver$1:::request-start
+/Xrequest[arg0] == ""/
+{
+ Xrequest[arg0] = copyinstr(arg0);
+}
+
+Xserver$1:::resource-alloc
+/arg3 != 0 &amp;&amp; Xrestype[arg3] == ""/
+{
+ Xrestype[arg3] = copyinstr(arg3);
+}
+
+
+Xserver$1:::request-start
+/Xrequest[arg0] == "X_CreatePixmap"/
+{
+ printf("-&gt; %s: client %d\n", Xrequest[arg0], arg3);
+}
+
+Xserver$1:::request-done
+/Xrequest[arg0] == "X_CreatePixmap"/
+{
+ printf("&lt;- %s: client %d\n", Xrequest[arg0], arg3);
+}
+
+Xserver$1:::resource-alloc
+/Xrestype[arg3] == "PIXMAP"/
+{
+ printf("** Pixmap alloc: %08x\n", arg0);
+}
+
+
+Xserver$1:::resource-free
+/Xrestype[arg3] == "PIXMAP"/
+{
+ printf("** Pixmap free: %08x\n", arg0);
+}
+
+Xserver$1:::client-connect
+{
+ printf("** Client Connect: id %d\n", arg0);
+}
+
+Xserver$1:::client-auth
+{
+ printf("** Client auth'ed: id %d =&gt; %s pid %d\n",
+ arg0, copyinstr(arg1), arg2);
+}
+
+Xserver$1:::client-disconnect
+{
+ printf("** Client Disconnect: id %d\n", arg0);
+}
+ </programlisting>
+
+ Sample output from a run of this script:
+ <screen><computeroutput>
+** Client Connect: id 17
+** Client auth'ed: id 17 =&gt; local host pid 20273
+-&gt; X_CreatePixmap: client 17
+** Pixmap alloc: 02200009
+&lt;- X_CreatePixmap: client 17
+-&gt; X_CreatePixmap: client 15
+** Pixmap alloc: 01e00180
+&lt;- X_CreatePixmap: client 15
+-&gt; X_CreatePixmap: client 15
+** Pixmap alloc: 01e00181
+&lt;- X_CreatePixmap: client 15
+-&gt; X_CreatePixmap: client 14
+** Pixmap alloc: 01c004c8
+&lt;- X_CreatePixmap: client 14
+** Pixmap free: 02200009
+** Client Disconnect: id 17
+** Pixmap free: 01e00180
+** Pixmap free: 01e00181
+ </computeroutput></screen>
+
+ </para>
+
+ </example>
+
+
+ </sect1>
+
+</article>
+
diff --git a/xorg-server/doc/xml/xmlrules.in b/xorg-server/doc/xml/xmlrules.in
index 1db7f128e..667cc2ebb 100644
--- a/xorg-server/doc/xml/xmlrules.in
+++ b/xorg-server/doc/xml/xmlrules.in
@@ -39,6 +39,14 @@ SUFFIXES = .xml .txt .html .pdf
XML_ENT_DIR = $(abs_top_builddir)/doc/xml
XMLTO_FLAGS = --searchpath $(XML_ENT_DIR)
+if HAVE_STYLESHEETS
+XMLTO_FLAGS += -m $(XSL_STYLESHEET)
+BUILT_DOC_FILES += xorg.css
+
+xorg.css: $(STYLESHEET_SRCDIR)/xorg.css
+ $(AM_V_GEN)cp -pf $(STYLESHEET_SRCDIR)/xorg.css $@
+endif
+
if HAVE_XMLTO
BUILT_DOC_FILES += $(TXT_FILES)
.xml.txt:
@@ -59,7 +67,7 @@ endif
endif
-CLEAN_DOC_FILES = $(TXT_FILES) $(HTML_FILES) $(PDF_FILES)
+CLEAN_DOC_FILES = $(TXT_FILES) $(HTML_FILES) $(PDF_FILES) xorg.css
# All the files we build depend on the entities
$(BUILT_DOC_FILES): $(XML_ENT_DIR)/xserver.ent
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c
index 3b70ce508..975e07620 100644
--- a/xorg-server/hw/xfree86/ddc/ddc.c
+++ b/xorg-server/hw/xfree86/ddc/ddc.c
@@ -102,7 +102,7 @@ resort(unsigned char *s_block)
}
static int
-DDC_checksum(unsigned char *block, int len)
+DDC_checksum(const unsigned char *block, int len)
{
int i, result = 0;
int not_null = 0;
@@ -149,7 +149,10 @@ GetEDID_DDC1(unsigned int *s_ptr)
d_pos++;
}
free(s_ptr);
- if (d_block && DDC_checksum(d_block,EDID1_LEN)) return NULL;
+ if (d_block && DDC_checksum(d_block,EDID1_LEN)) {
+ free(d_block);
+ return NULL;
+ }
return (resort(d_block));
}
diff --git a/xorg-server/hw/xquartz/GL/indirect.c b/xorg-server/hw/xquartz/GL/indirect.c
index b432ec750..718727ebe 100644
--- a/xorg-server/hw/xquartz/GL/indirect.c
+++ b/xorg-server/hw/xquartz/GL/indirect.c
@@ -271,8 +271,7 @@ static void __glXAquaContextDestroy(__GLXcontext *baseContext) {
__GLXAquaContext *context = (__GLXAquaContext *) baseContext;
- GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx 0x%x)\n",
- (unsigned int) baseContext);
+ GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx %p)\n", baseContext);
if (context != NULL) {
if (context->sid != 0 && surface_hash != NULL) {
lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
@@ -321,7 +320,7 @@ static void surface_notify(void *_arg, void *data) {
case AppleDRISurfaceNotifyDestroyed:
if (surface_hash != NULL)
x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id));
- draw->base.pDraw = NULL;
+ draw->pDraw = NULL;
draw->sid = 0;
break;
diff --git a/xorg-server/hw/xquartz/pbproxy/main.m b/xorg-server/hw/xquartz/pbproxy/main.m
index 560cf0182..cfdc7696d 100644
--- a/xorg-server/hw/xquartz/pbproxy/main.m
+++ b/xorg-server/hw/xquartz/pbproxy/main.m
@@ -1,163 +1,165 @@
-/* main.m
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- 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 ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
- */
-
-#include "pbproxy.h"
-#import "x-selection.h"
-
-#include <pthread.h>
-#include <unistd.h>
-#include <X11/extensions/applewm.h>
-
-Display *xpbproxy_dpy;
-int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
-int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
-BOOL xpbproxy_have_xfixes;
-
-extern char *display;
-
-#ifdef STANDALONE_XPBPROXY
-BOOL xpbproxy_is_standalone = NO;
-#endif
-
-x_selection *_selection_object;
-
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
-
-static inline void wait_for_server_init(void) {
- /* If the server hasn't finished initializing, wait for it... */
- if(!serverInitComplete) {
- pthread_mutex_lock(&serverInitCompleteMutex);
- while(!serverInitComplete)
- pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
- pthread_mutex_unlock(&serverInitCompleteMutex);
- }
-}
-
-static int x_io_error_handler (Display *dpy) {
- /* We lost our connection to the server. */
-
- TRACE ();
-
- /* trigger the thread to restart?
- * NO - this would be to a "deeper" problem, and restarts would just
- * make things worse...
- */
-#ifdef STANDALONE_XPBPROXY
- if(xpbproxy_is_standalone)
- exit(EXIT_FAILURE);
-#endif
-
- return 0;
-}
-
-static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
- return 0;
-}
-
-int xpbproxy_run (void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- size_t i;
-
- wait_for_server_init();
-
- for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) {
- xpbproxy_dpy = XOpenDisplay(NULL);
-
- if(!xpbproxy_dpy && display) {
- char _display[32];
- snprintf(_display, sizeof(_display), ":%s", display);
- setenv("DISPLAY", _display, TRUE);
-
- xpbproxy_dpy=XOpenDisplay(_display);
- }
- if(!xpbproxy_dpy)
- sleep(1);
- }
-
- if (xpbproxy_dpy == NULL) {
- fprintf (stderr, "xpbproxy: can't open default display\n");
- [pool release];
- return EXIT_FAILURE;
- }
-
- XSetIOErrorHandler (x_io_error_handler);
- XSetErrorHandler (x_error_handler);
-
- if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
- &xpbproxy_apple_wm_error_base)) {
- fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
- [pool release];
- return EXIT_FAILURE;
- }
-
- xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
-
- XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
- AppleWMPasteboardNotifyMask);
-
- _selection_object = [[x_selection alloc] init];
-
- if(!xpbproxy_input_register()) {
- [pool release];
- return EXIT_FAILURE;
- }
-
- [pool release];
-
- CFRunLoopRun();
-
- return EXIT_SUCCESS;
-}
-
-id xpbproxy_selection_object (void) {
- return _selection_object;
-}
-
-Time xpbproxy_current_timestamp (void) {
- /* FIXME: may want to fetch a timestamp from the server.. */
- return CurrentTime;
-}
-
-void debug_printf (const char *fmt, ...) {
- static int spew = -1;
-
- if (spew == -1) {
- char *x = getenv ("DEBUG");
- spew = (x != NULL && atoi (x) != 0);
- }
-
- if (spew) {
- va_list args;
- va_start(args, fmt);
- vfprintf (stderr, fmt, args);
- va_end(args);
- }
-}
+/* main.m
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
+
+ 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 ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization.
+ */
+
+#include "pbproxy.h"
+#import "x-selection.h"
+
+#include <pthread.h>
+#include <unistd.h>
+#include <X11/extensions/applewm.h>
+
+Display *xpbproxy_dpy;
+int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
+int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
+BOOL xpbproxy_have_xfixes;
+
+extern char *display;
+
+#ifdef STANDALONE_XPBPROXY
+BOOL xpbproxy_is_standalone = NO;
+#endif
+
+x_selection *_selection_object;
+
+extern BOOL serverInitComplete;
+extern pthread_mutex_t serverInitCompleteMutex;
+extern pthread_cond_t serverInitCompleteCond;
+
+static inline void wait_for_server_init(void) {
+ /* If the server hasn't finished initializing, wait for it... */
+ if(!serverInitComplete) {
+ pthread_mutex_lock(&serverInitCompleteMutex);
+ while(!serverInitComplete)
+ pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
+ pthread_mutex_unlock(&serverInitCompleteMutex);
+ }
+}
+
+static int x_io_error_handler (Display *dpy) {
+ /* We lost our connection to the server. */
+
+ TRACE ();
+
+ /* trigger the thread to restart?
+ * NO - this would be to a "deeper" problem, and restarts would just
+ * make things worse...
+ */
+#ifdef STANDALONE_XPBPROXY
+ if(xpbproxy_is_standalone)
+ exit(EXIT_FAILURE);
+#endif
+
+ /* Prevent _XIOError from calling exit() */
+ pthread_exit(NULL);
+ return 0;
+}
+
+static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
+ return 0;
+}
+
+int xpbproxy_run (void) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ size_t i;
+
+ wait_for_server_init();
+
+ for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) {
+ xpbproxy_dpy = XOpenDisplay(NULL);
+
+ if(!xpbproxy_dpy && display) {
+ char _display[32];
+ snprintf(_display, sizeof(_display), ":%s", display);
+ setenv("DISPLAY", _display, TRUE);
+
+ xpbproxy_dpy=XOpenDisplay(_display);
+ }
+ if(!xpbproxy_dpy)
+ sleep(1);
+ }
+
+ if (xpbproxy_dpy == NULL) {
+ fprintf (stderr, "xpbproxy: can't open default display\n");
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ XSetIOErrorHandler (x_io_error_handler);
+ XSetErrorHandler (x_error_handler);
+
+ if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
+ &xpbproxy_apple_wm_error_base)) {
+ fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
+
+ XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
+ AppleWMPasteboardNotifyMask);
+
+ _selection_object = [[x_selection alloc] init];
+
+ if(!xpbproxy_input_register()) {
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ [pool release];
+
+ CFRunLoopRun();
+
+ return EXIT_SUCCESS;
+}
+
+id xpbproxy_selection_object (void) {
+ return _selection_object;
+}
+
+Time xpbproxy_current_timestamp (void) {
+ /* FIXME: may want to fetch a timestamp from the server.. */
+ return CurrentTime;
+}
+
+void debug_printf (const char *fmt, ...) {
+ static int spew = -1;
+
+ if (spew == -1) {
+ char *x = getenv ("DEBUG");
+ spew = (x != NULL && atoi (x) != 0);
+ }
+
+ if (spew) {
+ va_list args;
+ va_start(args, fmt);
+ vfprintf (stderr, fmt, args);
+ va_end(args);
+ }
+}
diff --git a/xorg-server/xkeyboard-config/tests/genLists4Comparizon.sh b/xorg-server/xkeyboard-config/tests/genLists4Comparizon.sh
new file mode 100644
index 000000000..ccaaba7e0
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/genLists4Comparizon.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#
+# This script compares the group names which "have to be", according to the descriptions in base.xml -
+# and actually existing in the symbol files. Some differences are ok (like extra double quotes or
+# extra escaping character) - but all the rest should be in sync.
+#
+
+ROOT="`dirname $0`/.."
+F1=reg2ll.lst
+F2=gn2ll.lst
+
+xsltproc $ROOT/xslt/reg2ll.xsl $ROOT/rules/base.xml | sort | uniq > $F1
+
+for i in $ROOT/symbols/*; do
+ if [ -f $i ]; then
+ id="`basename $i`"
+ export id
+ gawk 'BEGIN{
+ FS = "\"";
+ id = ENVIRON["id"];
+ isDefault = 0;
+}
+/.*default.*/{
+ isDefault = 1;
+}
+/xkb_symbols/{
+ variant = $2;
+}/^[[:space:]]*name\[Group1\][[:space:]]*=/{
+ if (isDefault == 1)
+ {
+ printf "%s:\"%s\"\n",id,$2;
+ isDefault=0;
+ } else
+ {
+ name=$2;
+ printf "%s(%s):\"%s\"\n", id, variant, name;
+ }
+}' $i
+ fi
+done | sort | uniq > $F2
+
+diff $F1 $F2
diff --git a/xorg-server/xkeyboard-config/tests/listCI2.xsl b/xorg-server/xkeyboard-config/tests/listCI2.xsl
new file mode 100644
index 000000000..09ee37abb
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/listCI2.xsl
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ >
+<xsl:output method="text"/>
+
+ <xsl:param name="type"/>
+ <xsl:param name="parentId"/>
+
+ <xsl:template match="xkbConfigRegistry">
+ <xsl:apply-templates select=".//configItem[(name(..) = $type) and (../../../configItem/name = $parentId or ../../configItem/name = $parentId )]">
+ <xsl:sort select="name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="configItem">
+ <xsl:value-of select="./name"/><xsl:text>
+</xsl:text>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/xorg-server/xkeyboard-config/tests/listCIs.xsl b/xorg-server/xkeyboard-config/tests/listCIs.xsl
new file mode 100644
index 000000000..87e5bd9de
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/listCIs.xsl
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ >
+<xsl:output method="text"/>
+
+ <xsl:param name="type"/>
+
+ <xsl:template match="xkbConfigRegistry">
+ <xsl:apply-templates select=".//configItem[name(..) = $type]">
+ <xsl:sort select="name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="configItem">
+ <xsl:value-of select="./name"/><xsl:text>
+</xsl:text>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/xorg-server/xkeyboard-config/tests/mxkbledpanel/Imakefile b/xorg-server/xkeyboard-config/tests/mxkbledpanel/Imakefile
new file mode 100644
index 000000000..3fd46021e
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/mxkbledpanel/Imakefile
@@ -0,0 +1,8 @@
+LOCAL_LIBRARIES1 = -lXm
+ SRCS1 = mxkbledpanel.c
+ OBJS1 = mxkbledpanel.o
+
+PROGRAMS=mxkbledpanel
+
+ComplexProgramTarget_1(mxkbledpanel,$(LOCAL_LIBRARIES1),)
+
diff --git a/xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.c b/xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.c
new file mode 100644
index 000000000..5d52c52c1
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.c
@@ -0,0 +1,605 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/Intrinsic.h>
+#include <X11/XKBlib.h>
+#include <Xm/MainW.h>
+#include <Xm/RowColumn.h>
+#include <Xm/ToggleB.h>
+
+Display *theDisplay;
+XtAppContext appContext;
+int xkbEventBase;
+Widget topLevel;
+Widget leds[XkbNumIndicators];
+Atom ledAtoms[XkbNumIndicators];
+XmString ledNames[XkbNumIndicators];
+XkbDescPtr xkb_desc;
+
+void valueChangedProc(Widget,XtPointer,XmToggleButtonCallbackStruct *);
+XtCallbackRec valueChangedCB[2]={(XtCallbackProc)valueChangedProc,NULL};
+
+/************************************************************************/
+/* */
+/* Application Resources */
+/* */
+/************************************************************************/
+#define YES 1
+#define NO 0
+#define DONT_CARE -1
+
+typedef struct
+{
+ int wanted;
+ int wantAutomatic;
+ int wantExplicit;
+ int wantNamed;
+ int wantReal;
+ int wantVirtual;
+ int useUnion;
+} OptionsRec;
+
+OptionsRec options;
+
+#define Offset(field) XtOffsetOf(OptionsRec,field)
+XtResource resources[] =
+{
+ {"wanted", "Wanted", XtRInt, sizeof(int),
+ Offset(wanted), XtRImmediate, (XtPointer) DONT_CARE },
+ {"wantAutomatic", "WantAutomatic", XtRInt, sizeof(int),
+ Offset(wantAutomatic), XtRImmediate, (XtPointer) DONT_CARE},
+ {"wantExplicit", "WantExplicit", XtRInt, sizeof(int),
+ Offset(wantExplicit), XtRImmediate, (XtPointer) DONT_CARE},
+ {"wantNamed", "WantNamed", XtRInt, sizeof(int),
+ Offset(wantNamed), XtRImmediate, (XtPointer) DONT_CARE},
+ {"wantReal", "WantReal", XtRInt, sizeof(int),
+ Offset(wantReal), XtRImmediate, (XtPointer) DONT_CARE},
+ {"wantVirtual", "WantVirtual", XtRInt, sizeof(int),
+ Offset(wantVirtual), XtRImmediate, (XtPointer) DONT_CARE},
+ {"useUnion", "UseUnion", XtRInt, sizeof(int),
+ Offset(useUnion), XtRImmediate, (XtPointer) YES},
+ NULL
+};
+#undef Offset
+
+String fallbackResources[] =
+{
+ "*mainWindow.width: 100",
+ "*mainWindow.height: 50",
+ NULL
+};
+
+XrmOptionDescRec optionDesc[] =
+{
+ {"-watch", "*wanted", XrmoptionSepArg, (XtPointer) "0"},
+ {"-automatic", "*wantAutomatic", XrmoptionNoArg, (XtPointer) "0"},
+ {"+automatic", "*wantAutomatic", XrmoptionNoArg, (XtPointer) "1"},
+ {"-explicit", "*wantExplicit", XrmoptionNoArg, (XtPointer) "0"},
+ {"+explicit", "*wantExplicit", XrmoptionNoArg, (XtPointer) "1"},
+ {"-named", "*wantNamed", XrmoptionNoArg, (XtPointer) "0"},
+ {"+named", "*wantNamed", XrmoptionNoArg, (XtPointer) "1"},
+ {"-real", "*wantReal", XrmoptionNoArg, (XtPointer) "0"},
+ {"+real", "*wantReal", XrmoptionNoArg, (XtPointer) "1"},
+ {"-virtual", "*wantVirtual", XrmoptionNoArg, (XtPointer) "0"},
+ {"+virtual", "*wantVirtual", XrmoptionNoArg, (XtPointer) "1"},
+ {"-intersection", "*useUnion", XrmoptionNoArg, (XtPointer) "0"},
+ {"-union", "*useUnion", XrmoptionNoArg, (XtPointer) "1"}
+};
+
+/************************************************************************/
+/* */
+/* usage */
+/* */
+/************************************************************************/
+void usage(char *program)
+{
+ printf("Usage: %s <options>\n",program);
+ printf("Legal options include the usual X toolkit options plus:\n");
+ printf(" -help Print this message\n");
+ printf(" -indpy <name> Name of display to watch\n");
+ printf(" -watch <leds> Mask of LEDs to watch\n");
+ printf(" [-+]automatic (Don't) watch automatic LEDs\n");
+ printf(" [-+]explicit (Don't) watch explicit LEDs\n");
+ printf(" [-+]named (Don't) watch named LEDs\n");
+ printf(" [-+]real (Don't) watch real LEDs\n");
+ printf(" [-+]virtual (Don't) watch virtual LEDs\n");
+ printf(" -intersection Watch only LEDs in all desired sets\n");
+ printf(" -union Watch LEDs in any desired sets\n");
+ printf("The default set of LEDs is -intersection +named +virtual\n");
+ return;
+}
+/************************************************************************/
+/* */
+/* XkbEventHandler */
+/* */
+/* DESCRIPTION: */
+/* */
+/* Handles events generated by the Xkb server extension. */
+/* */
+/************************************************************************/
+Boolean XkbEventHandler(XEvent *event)
+{
+ XkbEvent *xkbEv = (XkbEvent *) event;
+
+ if (xkbEv->any.xkb_type==XkbIndicatorStateNotify) {
+ register int i;
+ register unsigned bit;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1)
+ if ((xkbEv->indicators.changed&bit)&&(leds[i]))
+ {
+ if (xkbEv->indicators.state&bit)
+ XmToggleButtonSetState(leds[i],True,False);
+ else
+ XmToggleButtonSetState(leds[i],False,False);
+ }
+ }
+ else if (xkbEv->any.xkb_type==XkbIndicatorMapNotify) {
+ unsigned change= xkbEv->indicators.changed;
+
+ if (XkbGetIndicatorMap(theDisplay,change,xkb_desc)!=Success)
+ fprintf(stderr,"Couldn't get changed indicator maps\n");
+ }
+
+ return True;
+
+} /* XkbEventHandler */
+
+/************************************************************************/
+/* */
+/* InitXkb */
+/* */
+/************************************************************************/
+Boolean InitXkb(Display *theDisplay)
+{
+ int i,opcode,errorBase,major,minor;
+ XkbDescPtr xkb;
+ unsigned int bit;
+ unsigned int real,virtual,named,explicit,automatic;
+ char *name;
+
+ if (!XkbQueryExtension(theDisplay,
+ &opcode,
+ &xkbEventBase,
+ &errorBase,
+ &major,
+ &minor))
+ return False;
+
+ if (!XkbUseExtension(theDisplay,&major,&minor))
+ return False;
+
+ XkbSelectEvents(theDisplay,
+ XkbUseCoreKbd,
+ XkbIndicatorStateNotifyMask|XkbIndicatorMapNotifyMask,
+ XkbIndicatorStateNotifyMask|XkbIndicatorMapNotifyMask);
+
+ XtSetEventDispatcher(theDisplay,
+ xkbEventBase+XkbEventCode,
+ XkbEventHandler);
+
+ xkb=XkbGetMap(theDisplay,0,XkbUseCoreKbd);
+ real=virtual=named=explicit=automatic=0;
+
+ if (!xkb)
+ {
+ fprintf(stderr,"Couldn't get keymap\n");
+ return False;
+ }
+ if (XkbGetIndicatorMap(theDisplay,XkbAllIndicatorsMask,xkb)!=Success)
+ {
+ fprintf(stderr,"Couldn't read indicator map\n");
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+ return False;
+ }
+ real=virtual=named=explicit=automatic=0;
+
+ if (XkbGetNames(theDisplay,XkbIndicatorNamesMask,xkb)!=Success)
+ {
+ fprintf(stderr,"Couldn't read indicator names\n");
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+ return False;
+ }
+ real=virtual=named=explicit=automatic=0;
+
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1)
+ {
+ XkbIndicatorMapPtr map= &xkb->indicators->maps[i];
+ name = NULL;
+ if (xkb->names->indicators[i]!=None)
+ {
+ named|= bit;
+ name = XGetAtomName(theDisplay,xkb->names->indicators[i]);
+ }
+ if (name != NULL)
+ {
+ ledAtoms[i] = xkb->names->indicators[i];
+ ledNames[i] = XmStringCreate(name,XmSTRING_DEFAULT_CHARSET);
+ }
+ else
+ {
+ char temp[12];
+ sprintf(temp,"led%d\0",i+1);
+ ledAtoms[i] = None;
+ ledNames[i] = XmStringCreate(temp,XmSTRING_DEFAULT_CHARSET);
+ }
+ if (xkb->indicators->phys_indicators&bit)
+ real|= bit;
+ if ((((map->which_groups!=0)&&(map->groups!=0))||
+ ((map->which_mods!=0)&&
+ ((map->mods.real_mods!=0)||(map->mods.vmods!=0)))||
+ (map->ctrls!=0))&&
+ ((map->flags&XkbIM_NoAutomatic)==0)) {
+ automatic|= bit;
+ }
+ else explicit|= bit;
+ }
+
+ virtual = ~real;
+
+ if (options.useUnion)
+ {
+ if ((options.wantReal==NO) || (options.wantReal==DONT_CARE))
+ real = 0;
+ if ((options.wantVirtual==NO) || (options.wantVirtual==DONT_CARE))
+ virtual = 0;
+ if ((options.wantNamed==NO) || (options.wantNamed==DONT_CARE))
+ named = 0;
+ if ((options.wantAutomatic==NO) || (options.wantAutomatic==DONT_CARE))
+ automatic = 0;
+ if ((options.wantExplicit==NO) || (options.wantExplicit==DONT_CARE))
+ explicit = 0;
+
+ options.wanted |= real|virtual|named|automatic|explicit;
+ }
+ else
+ {
+ if (options.wanted == DONT_CARE)
+ options.wanted = ~0;
+
+ if (options.wantReal==NO)
+ real = ~real;
+ else if (options.wantReal==DONT_CARE)
+ real = ~0;
+
+ if (options.wantVirtual==NO)
+ virtual = ~virtual;
+ else if (options.wantVirtual==DONT_CARE)
+ virtual = ~0;
+
+ if (options.wantNamed==NO)
+ named = ~named;
+ else if (options.wantNamed==DONT_CARE)
+ named = ~0;
+
+ if (options.wantAutomatic==NO)
+ automatic = ~automatic;
+ else if (options.wantAutomatic==DONT_CARE)
+ automatic = ~0;
+
+ if (options.wantExplicit==NO)
+ explicit = ~explicit;
+ else if (options.wantExplicit==DONT_CARE)
+ explicit = ~0;
+
+ options.wanted &= real&virtual&named&automatic&explicit;
+ }
+
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+ return True;
+
+} /* InitXkb */
+
+/************************************************************************/
+/* */
+/* valueChangedProc - called when a toggle button is pressed. */
+/* */
+/************************************************************************/
+void valueChangedProc(Widget w,
+ XtPointer clientData,
+ XmToggleButtonCallbackStruct *callbackData)
+{
+ int led = (int) clientData;
+ XkbDescPtr xkb;
+
+ xkb = XkbGetMap(theDisplay,0,XkbUseCoreKbd);
+ if (!xkb)
+ {
+ fprintf(stderr,"XkbGetMap failed\n");
+ return;
+ }
+
+ if (XkbGetIndicatorMap(theDisplay,XkbAllIndicatorsMask,xkb)!=Success)
+ {
+ fprintf(stderr,"GetIndicatorMap failed\n");
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+ return;
+ }
+
+ /* The 'flags' field tells whether this indicator is automatic
+ * (XkbIM_NoExplicit - 0x80), explicit (XkbIM_NoAutomatic - 0x40),
+ * or neither (both - 0xC0).
+ *
+ * If NoAutomatic is set, the server ignores the rest of the
+ * fields in the indicator map (i.e. it disables automatic control
+ * of the LED). If NoExplicit is set, the server prevents clients
+ * from explicitly changing the value of the LED (using the core
+ * protocol *or* XKB). If NoAutomatic *and* NoExplicit are set,
+ * the LED cannot be changed (unless you change the map first).
+ * If neither NoAutomatic nor NoExplicit are set, the server will
+ * change the LED according to the indicator map, but clients can
+ * override that (until the next automatic change) using the core
+ * protocol or XKB.
+ */
+ switch (xkb->indicators->maps[led].flags &
+ (XkbIM_NoExplicit|XkbIM_NoAutomatic))
+ {
+ case XkbIM_NoExplicit|XkbIM_NoAutomatic:
+ {
+ XmToggleButtonSetState(w,!callbackData->set,FALSE);
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+ return;
+ }
+
+ case XkbIM_NoAutomatic:
+ {
+ if (ledAtoms[led] != None)
+ XkbSetNamedIndicator(theDisplay,XkbUseCoreKbd,
+ ledAtoms[led],callbackData->set,
+ FALSE,NULL);
+ else
+ {
+ XKeyboardControl xkc;
+ xkc.led= led;
+ if (callbackData->set)
+ xkc.led_mode= LedModeOn;
+ else xkc.led_mode= LedModeOff;
+ XChangeKeyboardControl(theDisplay,KBLed|KBLedMode,&xkc);
+ XSync(theDisplay,0);
+ }
+
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+ return;
+ }
+
+ case XkbIM_NoExplicit:
+ break;
+ }
+
+ /* The 'ctrls' field tells what controls tell this indicator to
+ * to turn on: RepeatKeys (0x1), SlowKeys (0x2), BounceKeys (0x4),
+ * StickyKeys (0x8), MouseKeys (0x10), AccessXKeys (0x20),
+ * TimeOut (0x40), Feedback (0x80), ToggleKeys (0x100),
+ * Overlay1 (0x200), Overlay2 (0x400), GroupsWrap (0x800),
+ * InternalMods (0x1000), IgnoreLockMods (0x2000),
+ * PerKeyRepeat (0x3000), or ControlsEnabled (0x4000)
+ */
+ if (xkb->indicators->maps[led].ctrls)
+ {
+ unsigned long which = xkb->indicators->maps[led].ctrls;
+
+ XkbGetControls(theDisplay,XkbAllControlsMask,xkb);
+ if (callbackData->set)
+ xkb->ctrls->enabled_ctrls |= which;
+ else
+ xkb->ctrls->enabled_ctrls &= ~which;
+ XkbSetControls(theDisplay,which|XkbControlsEnabledMask,xkb);
+ }
+
+ /* The 'which_groups' field tells when this indicator turns on
+ * for the 'groups' field: base (0x1), latched (0x2), locked (0x4),
+ * or effective (0x8).
+ */
+ if (xkb->indicators->maps[led].groups)
+ {
+ int i;
+ unsigned int group = 1;
+
+ /* Turning on a group indicator is kind of tricky. For
+ * now, we will just Latch or Lock the first group we find
+ * if that is what this indicator does. Otherwise, we're
+ * just going to punt and get out of here.
+ */
+ if (callbackData->set)
+ {
+ for (i = XkbNumKbdGroups-1; i >= 0; i--)
+ if ((1 << i) &
+ xkb->indicators->maps[led].groups)
+ group = i;
+ if (xkb->indicators->maps[led].which_groups &
+ (XkbIM_UseLocked | XkbIM_UseEffective))
+ XkbLockGroup(theDisplay,XkbUseCoreKbd,group);
+ else if (xkb->indicators->maps[led].which_groups&XkbIM_UseLatched)
+ XkbLatchGroup(theDisplay,XkbUseCoreKbd,group);
+ else
+ {
+ XmToggleButtonSetState(w,!callbackData->set,FALSE);
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+ return;
+ }
+ }
+ /* Turning off a group indicator will mean that we just
+ * Lock the first group that this indicator doesn't watch.
+ */
+ else
+ {
+ for (i = XkbNumKbdGroups-1; i >= 0; i--)
+ if (!((1 << i) &
+ xkb->indicators->maps[led].groups))
+ group = i;
+ XkbLockGroup(theDisplay,XkbUseCoreKbd,group);
+ }
+ }
+
+ /* The 'which_mods' field tells when this indicator turns on
+ * for the modifiers: base (0x1), latched (0x2), locked (0x4),
+ * or effective (0x8).
+ *
+ * The 'real_mods' field tells whether this turns on when one of
+ * the real X modifiers is set: Shift (0x1), Lock (0x2), Control (0x4),
+ * Mod1 (0x8), Mod2 (0x10), Mod3 (0x20), Mod4 (0x40), or Mod5 (0x80).
+ *
+ * The 'virtual_mods' field tells whether this turns on when one of
+ * the virtual modifiers is set.
+ *
+ * The 'mask' field tells what real X modifiers the virtual_modifiers
+ * map to?
+ */
+ if (xkb->indicators->maps[led].mods.real_mods ||
+ xkb->indicators->maps[led].mods.mask)
+ {
+ XkbStateRec state;
+ unsigned int affect,mods;
+
+ affect = (xkb->indicators->maps[led].mods.real_mods |
+ xkb->indicators->maps[led].mods.mask);
+
+ if (callbackData->set)
+ mods = affect;
+ else
+ mods = 0;
+
+ if (xkb->indicators->maps[led].which_mods &
+ (XkbIM_UseLocked | XkbIM_UseEffective))
+ XkbLockModifiers(theDisplay,XkbUseCoreKbd,affect,mods);
+ else if (xkb->indicators->maps[led].which_mods &
+ XkbIM_UseLatched)
+ XkbLatchModifiers(theDisplay,XkbUseCoreKbd,affect,mods);
+ else
+ {
+ XmToggleButtonSetState(w,!callbackData->set,FALSE);
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+ return;
+ }
+ }
+
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,True);
+
+} /* valueChangedProc */
+
+/************************************************************************/
+/* */
+/* InitializeUI */
+/* */
+/************************************************************************/
+void InitializeUI(Widget topLevel)
+{
+ Arg argList[3];
+ char buf[256];
+ int i;
+ unsigned int bit,n;
+ Widget mainWindow,rowColumn;
+ XmString tempString;
+
+ mainWindow = (Widget) XmCreateMainWindow(topLevel,"mainWindow",NULL,0);
+ XtManageChild(mainWindow);
+ rowColumn = (Widget) XmCreateRowColumn(mainWindow,"rowColumn",NULL,0);
+ XtManageChild(rowColumn);
+
+ XkbGetIndicatorState(theDisplay,XkbUseCoreKbd,&n);
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1)
+ {
+ if (options.wanted&bit)
+ {
+ /* [[[ WDW - If we wanted to be really fancy, we
+ * would look for a "*ledxx.labelString" value
+ * in the resource database so the I18N dudes
+ * can see localized strings. ]]]
+ */
+ XtSetArg(argList[0], XmNlabelString,ledNames[i]);
+ if (n&bit) XtSetArg(argList[1], XmNset, True);
+ else XtSetArg(argList[1], XmNset, False);
+ sprintf(buf,"led%d\0",i);
+ valueChangedCB[0].closure = (XtPointer) i;
+ XtSetArg(argList[2], XmNvalueChangedCallback, valueChangedCB);
+ leds[i]= XmCreateToggleButton(rowColumn,buf,argList,3);
+ XtManageChild(leds[i]);
+ }
+ else
+ leds[i]=0;
+ }
+
+} /* InitializeUI */
+
+/************************************************************************/
+/* */
+/* main */
+/* */
+/************************************************************************/
+#if NeedFunctionPrototypes
+int main(int argc,
+ char *argv[])
+#else
+int main(argc, argv)
+ int argc;
+ char *argv[];
+#endif
+{
+ /********************************************************************/
+ /* */
+ /* Initialize the toolkit */
+ /* */
+ /********************************************************************/
+ Arg argList[2];
+ topLevel = XtAppInitialize(&appContext, "xkbleds",
+ optionDesc, XtNumber(optionDesc),
+ &argc, argv,
+ fallbackResources,
+ NULL, 0);
+ XtSetArg(argList[0], XtNallowShellResize, TRUE);
+ XtSetValues(topLevel,argList,1);
+ XtGetApplicationResources(topLevel, (XtPointer)&options, resources,
+ XtNumber(resources), NULL, 0);
+
+ if (argc > 1)
+ {
+ usage(argv[0]);
+ exit(0);
+ }
+
+ /* Defaults
+ */
+ if ((options.wanted == DONT_CARE) &&
+ (options.wantReal == DONT_CARE) &&
+ (options.wantVirtual == DONT_CARE) &&
+ (options.wantNamed == DONT_CARE) &&
+ (options.wantAutomatic == DONT_CARE) &&
+ (options.wantExplicit == DONT_CARE) &&
+ (options.useUnion == YES))
+ {
+ options.wanted = 0;
+ options.wantReal = YES;
+ options.wantNamed = YES;
+ options.wantAutomatic = YES;
+ }
+
+ /********************************************************************/
+ /* */
+ /* See if the server has XKB. */
+ /* */
+ /********************************************************************/
+ theDisplay = XtDisplay(topLevel);
+ if (!InitXkb(theDisplay))
+ {
+ fprintf(stderr,"Could not initialize XKB extension.\n");
+ exit(0);
+ }
+
+ if (options.wanted == 0)
+ {
+ fprintf(stderr,"No LED's were selected.\n\n");
+ usage(argv[0]);
+ exit(0);
+ }
+
+ /********************************************************************/
+ /* */
+ /* Set up the UI and go. */
+ /* */
+ /********************************************************************/
+ XtRealizeWidget(topLevel);
+ InitializeUI(topLevel);
+ XtAppMainLoop(appContext);
+
+ /* NOT REACHED */
+ exit(0L);
+}
diff --git a/xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.man b/xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.man
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.man
diff --git a/xorg-server/xkeyboard-config/tests/ruby/README b/xorg-server/xkeyboard-config/tests/ruby/README
new file mode 100644
index 000000000..2ddf58a82
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/ruby/README
@@ -0,0 +1,3 @@
+This is just some stuff to play with symbols/inet file, trying to analize it.
+Only maintainers might be interested. It is written in Ruby - but it will
+never be actually used in xkeyboard-config distribution.
diff --git a/xorg-server/xkeyboard-config/tests/ruby/find_fragments.rb b/xorg-server/xkeyboard-config/tests/ruby/find_fragments.rb
new file mode 100644
index 000000000..f991ad0ab
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/ruby/find_fragments.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/ruby
+#
+# $Id$
+# The script finds the fragments
+#
+
+require "xkbparser.rb"
+
+baseDir = "../.."
+
+symbolsDir = "#{baseDir}/symbols"
+#symbolsDir = "."
+
+parser = Parser.new
+
+allSyms = parser.parse("#{symbolsDir}/inet")
+
+everything = allSyms.merge
+
+everything.filter(1)
+
+#numCombinations = 1
+
+#puts "everything:"
+
+#everything.find_all do | symName, keycodes |
+#puts "#{symName}, #{keycodes.length} mappings -> "
+# keycodes.find_all do | keycode, counter |
+# puts " #{keycode} -> #{counter} occurences"
+# end
+# numCombinations *= (keycodes.length + 1)
+#end
+
+#puts "Total mappings: #{everything.length}/#{everything.full_length()}, #{numCombinations} combinations"
+#
+
+numCombinations = 0
+allSyms.find_all do | symsName, symbols |
+ puts "n: #{symsName}"
+
+ # Counting only symbols which used more than once
+ numDupSymbols = symbols.keys.inject(0) do | rv, keycode |
+ c = everything.cardinality(keycode, symbols[keycode])
+ puts "#{keycode} -> #{symbols[keycode]}, #{c}"
+ (c > 0) ? rv : rv + 1
+ end
+
+ numCombinations += (1 << numDupSymbols)
+ puts "l: #{symbols.length} d: #{numDupSymbols} c: #{numCombinations}"
+end
+
+puts "numCombinations: #{numCombinations}"
diff --git a/xorg-server/xkeyboard-config/tests/ruby/find_match.rb b/xorg-server/xkeyboard-config/tests/ruby/find_match.rb
new file mode 100644
index 000000000..43af93482
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/ruby/find_match.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/ruby
+#
+# $Id$
+# The script finds best matching xkb_symbols in symbols/in
+#
+# Parameters: $0 - the name of the file with new xkb_symbols
+# $1 - max number of non-matching mappings (0 by default)
+#
+
+require "xkbparser.rb"
+
+baseDir = "../.."
+
+symbolsDir = "#{baseDir}/symbols"
+#symbolsDir = "."
+
+parser = Parser.new
+
+allSyms = parser.parse("#{symbolsDir}/inet")
+
+newSyms = parser.parse(ARGV[0])
+limit = ARGV[1].to_i
+
+newSyms.find_all do | key, value |
+
+ if value.hidden?
+ next
+ end
+
+ puts "Existing xkb_symbols matching #{key}: "
+
+ sorted = allSyms.match_symbols(value,limit).sort_by do | symsName, diff |
+ sprintf "%03d_%s", diff.size, symsName
+ end
+
+ sorted.find_all do | symsName, diff |
+ puts " #{symsName}, up to #{allSyms[symsName].size} keys (difference #{diff.size})-> #{diff}"
+ end
+
+end
+
+
diff --git a/xorg-server/xkeyboard-config/tests/ruby/utils.rb b/xorg-server/xkeyboard-config/tests/ruby/utils.rb
new file mode 100644
index 000000000..93ff0ee5e
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/ruby/utils.rb
@@ -0,0 +1,64 @@
+#
+# $Id$
+#
+# Commont classes
+#
+
+#
+# The hash containing non-unique mappings
+# It can have a->b and a->c together
+# Also, for every mapping it counts the number of times this mapping was set
+#
+class NonuniqueCountingHash < Hash
+
+ alias get_original []
+ alias put_original []=
+
+ def []=(key, value)
+ own = self.get_original(key)
+ hash = get_original(key)
+ if hash.nil?
+ put_original(key, hash = Hash.new)
+ end
+ if hash.has_key?(value)
+ hash[value] += 1
+ else
+ hash[value] = 1
+ end
+ end
+
+ #
+ # Number of all mappings (a->b and a->c counted as 2 mappings)
+ #
+ def full_length()
+ values.inject(0) do | rv, hash |
+ rv + hash.length
+ end
+ end
+
+ def cardinality(key1, key2)
+ if has_key?(key1)
+ hash = get_original(key1)
+ if hash.has_key?(key2)
+ hash[key2]
+ else
+ 0
+ end
+ else
+ 0
+ end
+ end
+
+ def filter(limit)
+ find_all do | key, hash |
+ hash.find_all do | key1, counter |
+ if (counter <= limit)
+ hash.delete(key1)
+ end
+ end
+ if hash.empty?
+ delete(key)
+ end
+ end
+ end
+end
diff --git a/xorg-server/xkeyboard-config/tests/ruby/xkbparser.rb b/xorg-server/xkeyboard-config/tests/ruby/xkbparser.rb
new file mode 100644
index 000000000..ecf246b6c
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/ruby/xkbparser.rb
@@ -0,0 +1,185 @@
+#
+# $Id$
+#
+# Commont parsing classes for symbols/inet
+# The parsing is simplified, based on regex - it is NOT a real parser for very
+# complex XKB format
+#
+
+require "utils.rb"
+
+class Symbols < Hash
+
+ #
+ # Constructor
+ #
+ def initialize
+ @includedSyms = Array.new
+ end
+
+ # Write-only property, parent list of symbols definitions
+ def symbols_list=(symbolsList)
+ @symbolsList = symbolsList
+ end
+
+ # Whether this set of symbols is hidden or not
+ def hidden?
+ @hidden
+ end
+
+ def hidden=(h)
+ @hidden = h
+ end
+
+ #
+ # Add "dependency" - the symbols referenced using the "include" statement.
+ #
+ def add_included(other)
+ @includedSyms.push(other)
+ end
+
+ alias get_original []
+ alias keys_original keys
+
+ #
+ # Get the symbol, trying first own definitions, then walking through all
+ # dependenies
+ #
+ def [](symName)
+ own = self.get_original(symName)
+ if own.nil?
+ @includedSyms.find_all do | symsName |
+ syms = @symbolsList[symsName]
+ his = syms[symName]
+ if !his.nil?
+ own = his
+ break
+ end
+ end
+ end
+ own
+ end
+
+ #
+ # All keys - including the ones specified in the included sections
+ #
+ def keys()
+ @includedSyms.inject(keys_original) do | rv, symsName |
+ syms = @symbolsList[symsName]
+ rv | syms.keys
+ end
+ end
+
+ # Size of all keys
+ def length()
+ keys().length()
+ end
+
+ #
+ # Size - takes into account overlapping key definitions
+ #
+ def size()
+ keys.size()
+ end
+
+ #
+ # Create a hash including all elements of this hash which are not in the
+ # other hash, use symbols + and * for marking the elements which existed in
+ # the original hash (+ if not existed)
+ #
+ def -(other)
+ diff = self.class.new
+ self.find_all do | key, value |
+ existing = other[key]
+ if existing != value
+ diff[key] = [ value, existing.nil? ? '+' : '' ]
+ end
+ end
+ diff
+ end
+
+
+ def to_s
+ s = "{\n"
+ # First output included syms
+ @includedSyms.find_all do | symsName |
+ s += " include \"inet(#{symsName})\"\n"
+ end
+ # Then - own definitions
+ self.find_all do | key, value |
+ s += " key #{key} { [ #{value} ] };\n"
+ end
+ s + "}";
+ end
+
+end
+
+class SymbolsList < Hash
+
+ #
+ # Add new xkb_symbols
+ #
+ def add_symbols (symbolsName, hidden)
+ newSyms = Symbols.new
+ newSyms.symbols_list = self
+ newSyms.hidden = hidden
+ self[symbolsName] = newSyms
+ end
+
+ def to_s
+ s = "// Autogenerated\n\n"
+ self.find_all do | symbols, mapping |
+ s += "partial alphanumeric_keys\nxkb_symbols \"#{symbols}\" #{mapping};\n\n"
+ end
+ s
+ end
+
+ def match_symbols(new_symbols,limit)
+ matching = Hash.new
+ find_all do | symbols, mapping |
+ diff = new_symbols - mapping
+ if diff.size <= limit
+ matching[symbols] = diff
+ end
+ end
+ matching
+ end
+
+ def merge()
+ everything = NonuniqueCountingHash.new
+ find_all do | symsName, syms |
+ syms.find_all do | symName, keycode |
+ everything[symName] = keycode
+ end
+ end
+ everything
+ end
+
+end
+
+class Parser
+
+ def parse (fileName)
+ allSyms = SymbolsList.new;
+ currentSyms = nil
+ hidden = false
+ File.open(fileName) do | file |
+ file.each_line do | line |
+ line.scan(/xkb_symbols\s+"(\w+)"/) do | symsName |
+ currentSyms = allSyms.add_symbols(symsName[0], hidden)
+ end
+ line.scan(/^\s*key\s*<(\w+)>\s*\{\s*\[\s*(\w+)/) do | keycode, keysym |
+ currentSyms[keycode] = keysym
+ end
+ line.scan(/^partial\s+(hidden\s+)?alphanumeric_keys/) do | h |
+ hidden = !h[0].nil?
+ end
+ line.scan(/^\s*include\s+"inet\((\w+)\)"/) do | otherPart |
+ currentSyms.add_included(otherPart[0])
+ end
+ end
+ end
+ allSyms
+ end
+
+end
diff --git a/xorg-server/xkeyboard-config/tests/testLayouts.pl b/xorg-server/xkeyboard-config/tests/testLayouts.pl
new file mode 100644
index 000000000..a1d43a395
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/testLayouts.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use xkbTestFunc;
+
+xkbTestFunc::backupXkbSettings();
+
+xkbTestFunc::dumpXkbSettingsBackup();
+
+xkbTestFunc::testLevel2( "layout", "variant", 2, "(", ")", 1, 1, 0 );
+
+sleep 2;
+
+xkbTestFunc::restoreXkbSettings();
+
+print "Done!\n";
diff --git a/xorg-server/xkeyboard-config/tests/testModels.pl b/xorg-server/xkeyboard-config/tests/testModels.pl
new file mode 100644
index 000000000..ed4f99341
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/testModels.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use xkbTestFunc;
+
+xkbTestFunc::backupXkbSettings();
+
+xkbTestFunc::dumpXkbSettingsBackup();
+
+xkbTestFunc::testLevel1( "model", 1 );
+
+xkbTestFunc::restoreXkbSettings();
+
+print "Done!\n";
diff --git a/xorg-server/xkeyboard-config/tests/testOptions.pl b/xorg-server/xkeyboard-config/tests/testOptions.pl
new file mode 100644
index 000000000..57ccc58d3
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/testOptions.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use xkbTestFunc;
+
+xkbTestFunc::backupXkbSettings();
+
+xkbTestFunc::dumpXkbSettingsBackup();
+
+xkbTestFunc::testLevel2( "group", "option", 4, ":", "", 0, 0, 1 );
+
+xkbTestFunc::restoreXkbSettings();
+
+print "Done!\n";
diff --git a/xorg-server/xkeyboard-config/tests/testShortDescriptions b/xorg-server/xkeyboard-config/tests/testShortDescriptions
new file mode 100644
index 000000000..c05299e97
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/testShortDescriptions
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+awk '/shortDescr/{print toupper($0)}' ../rules/base.xml.in | sed 's/<[^>]*>//g;s/ //g' | sort | uniq > xml.sd
+awk '{print $1}' ../docs/iso3166-3.csv | sort > iso.sd
+diff -u iso.sd xml.sd | grep '+'
+
diff --git a/xorg-server/xkeyboard-config/tests/xkbTestFunc.pm b/xorg-server/xkeyboard-config/tests/xkbTestFunc.pm
new file mode 100644
index 000000000..1d7881d23
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/xkbTestFunc.pm
@@ -0,0 +1,164 @@
+package xkbTestFunc;
+
+use strict;
+use warnings;
+
+our $VERSION='1.00';
+
+our $origXkbRules;
+our $origXkbModel;
+our $origXkbLayouts;
+our $origXkbOptions;
+our $origXkbVariants;
+
+sub backupXkbSettings
+{
+ ( $origXkbRules, $origXkbModel, $origXkbLayouts, $origXkbVariants, $origXkbOptions ) = getXkbSettings();
+}
+
+sub getXkbSettings
+{
+ my ( $xkbRules, $xkbModel, $xkbLayouts, $xkbVariants, $xkbOptions );
+
+ open (XPROP, "xprop -root |") or die "Could not start xprop";
+ PROP: while (<XPROP>)
+ {
+ if (/_XKB_RULES_NAMES\(STRING\) = \"(.*)\", \"(.*)\", \"(.*)\", \"(.*)\", \"(.*)\"/)
+ {
+ ( $xkbRules, $xkbModel, $xkbLayouts, $xkbVariants, $xkbOptions ) =
+ ( $1, $2, $3, $4, $5 ) ;
+ last PROP;
+ }
+ }
+ close XPROP;
+
+ return ( $xkbRules, $xkbModel, $xkbLayouts, $xkbVariants, $xkbOptions );
+}
+
+sub setXkbSettings
+{
+ my ( $xkbRules, $xkbModel, $xkbLayouts, $xkbVariants, $xkbOptions ) = @_;
+ ( system ( "setxkbmap", "-synch",
+ "-rules", $xkbRules,
+ "-model", $xkbModel,
+ "-layout", $xkbLayouts,
+ "-variant", $xkbVariants,
+ "-option", $xkbOptions ) == 0 ) or die "Could not set xkb configuration";
+ sleep 1;
+}
+
+sub restoreXkbSettings
+{
+ setXkbSettings( $origXkbRules, $origXkbModel, $origXkbLayouts, $origXkbVariants, $origXkbOptions );
+}
+
+sub defaultXkbSettings
+{
+ return ( "base", "pc105", "us", "", "" );
+}
+
+sub dumpXkbSettings
+{
+ my ( $xkbRules, $xkbModel, $xkbLayouts, $xkbVariants, $xkbOptions ) = @_;
+ print "rules: [$xkbRules]\n" ;
+ print "model: [$xkbModel]\n" ;
+ print "layouts: [$xkbLayouts]\n" ;
+ print "variants: [$xkbVariants]\n" ;
+ print "options: [$xkbOptions]\n" ;
+}
+
+sub dumpXkbSettingsBackup
+{
+ dumpXkbSettings( $origXkbRules, $origXkbModel, $origXkbLayouts, $origXkbVariants, $origXkbOptions );
+}
+
+sub testLevel1
+{
+ my ( $type, $idx ) = @_;
+
+ open ( XSLTPROC, "xsltproc --stringparam type $type listCIs.xsl ../rules/base.xml.in |" ) or
+ die ( "Could not start xsltproc" );
+ while (<XSLTPROC>)
+ {
+ chomp();
+ if (/(\S+)/)
+ {
+ my $paramValue=$1;
+ print "--- setting $type: [$paramValue]\n";
+ my @params = defaultXkbSettings();
+ $params[$idx] = $paramValue;
+ dumpXkbSettings ( @params );
+ setXkbSettings ( @params );
+ #print "--- dump:\n";
+ #dumpXkbSettings( getXkbSettings() );
+ }
+ }
+ close XSLTPROC;
+}
+
+sub testLevel2
+{
+ my ( $type, $subtype, $idx, $delim1, $delim2, $ifCheckLevel1, $ifAddLevel1, $ifResetToDefault ) = @_;
+
+ open ( XSLTPROC, "xsltproc --stringparam type $type listCIs.xsl ../rules/base.xml.in |" ) or
+ die ( "Could not start xsltproc" );
+ while (<XSLTPROC>)
+ {
+ chomp();
+ if (/(\S+)/)
+ {
+ my $paramValue=$1;
+ print "--- scanning $type: [$paramValue]\n";
+
+ if ( $ifCheckLevel1 )
+ {
+ my @params = defaultXkbSettings();
+ if ( $ifResetToDefault )
+ {
+ setXkbSettings ( @params );
+ }
+ $params[$idx] = "$paramValue";
+ dumpXkbSettings ( @params );
+ setXkbSettings ( @params );
+ #print "--- dump:\n";
+ #dumpXkbSettings( getXkbSettings() );
+ }
+
+ open ( XSLTPROC2, "xsltproc --stringparam type $subtype --stringparam parentId $paramValue listCI2.xsl ../rules/base.xml.in |" ) or
+ die ( "Could not start xsltproc" );
+ while (<XSLTPROC2>)
+ {
+ chomp();
+ if (/(\S+)/)
+ {
+ my $paramValue2=$1;
+ print " --- $subtype: [$paramValue2]\n";
+ my @params = defaultXkbSettings();
+ if ( $ifResetToDefault )
+ {
+ setXkbSettings ( @params );
+ }
+ if ( $ifAddLevel1 )
+ {
+ $params[$idx] = "$paramValue$delim1$paramValue2$delim2";
+ }
+ else
+ {
+ $params[$idx] = "$paramValue2";
+ }
+ dumpXkbSettings ( @params );
+ setXkbSettings ( @params );
+ #print "--- dump:\n";
+ #dumpXkbSettings( getXkbSettings() );
+ }
+ }
+ close XSLTPROC2;
+ }
+ }
+ close XSLTPROC;
+}
+
+1;
+__END__
+
+No docs yet
diff --git a/xorg-server/xkeyboard-config/xslt/reg2ll.xsl b/xorg-server/xkeyboard-config/xslt/reg2ll.xsl
new file mode 100644
index 000000000..5cb4c8bec
--- /dev/null
+++ b/xorg-server/xkeyboard-config/xslt/reg2ll.xsl
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ >
+<xsl:output method="text"
+ encoding="UTF-8"
+ doctype-system="xkb.dtd"
+ indent="no"/>
+
+<xsl:template match="modelList|optionList|name|description|shortDescription|configItem"/>
+<xsl:strip-space elements="*"/>
+
+<xsl:template match="layoutList"><xsl:apply-templates select="./layout"/></xsl:template>
+
+<xsl:template match="variantList"><xsl:apply-templates select="./variant"/></xsl:template>
+
+<xsl:template match="layout"><xsl:text>
+</xsl:text><xsl:value-of select="./configItem/name"/>:"<xsl:value-of select="./configItem/description"/>"<xsl:apply-templates match="./variantList/variant"/></xsl:template>
+
+<xsl:template match="variant"><xsl:text>
+</xsl:text><xsl:value-of select="../../configItem/name"/>(<xsl:value-of select="./configItem/name"/>):"<xsl:value-of select="../../configItem/description"/> - <xsl:value-of select="./configItem/description"/>"</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xorg-server/xkeyboard-config/xslt/xfree86.xsl b/xorg-server/xkeyboard-config/xslt/xfree86.xsl
new file mode 100644
index 000000000..8b4e84976
--- /dev/null
+++ b/xorg-server/xkeyboard-config/xslt/xfree86.xsl
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ >
+<xsl:output method="xml"
+ encoding="UTF-8"
+ doctype-system="xkb.dtd"
+ indent="yes"/>
+
+ <!-- Transform all "simple" elements as they are -->
+ <xsl:template match="@*|xkbConfigRegistry|layout|layoutList|model|modelList|group|option|optionList|variant|variantList">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|*"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <!-- Tricky business: configItem -->
+ <xsl:template match="configItem">
+ <configItem xsl:space="preserve">
+ <name><xsl:value-of select="./name"/></name>
+ <!-- If there are some shortDescriptions -->
+ <xsl:if test="count(./shortDescription)!=0">
+ <!-- First, put the non-translated version -->
+ <shortDescription><xsl:value-of select="./shortDescription[not(@xml:lang)]"/></shortDescription>
+ <!-- For all translated versions ... -->
+ <xsl:for-each select="./shortDescription[@xml:lang]">
+ <!-- ... which are different from non-translated one ... -->
+ <xsl:if test="../shortDescription[not(@xml:lang)]/text() != ./text()">
+ <!-- ... - output! -->
+ <shortDescription xml:lang="{./@xml:lang}"><xsl:value-of select="./text()"/></shortDescription>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:if>
+ <!-- If there are some descriptions -->
+ <xsl:if test="count(./description)!=0">
+ <!-- First, put the non-translated version -->
+ <description><xsl:value-of select="./description[not(@xml:lang)]"/></description>
+ <!-- For all translated versions ... -->
+ <xsl:for-each select="./description[@xml:lang]">
+ <!-- ... which are different from non-translated one ... -->
+ <xsl:if test="../description[not(@xml:lang)]/text() != ./text()">
+ <!-- ... - output! -->
+ <description xml:lang="{./@xml:lang}"><xsl:value-of select="./text()"/></description>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:if>
+ </configItem>
+ </xsl:template>
+
+</xsl:stylesheet>