From d2758df0a0091496717fe7a65c3e7563e7c82785 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 2 Aug 2010 08:29:58 +0000 Subject: xserver libX11 libXdmcp git update 2-8-2010 --- xorg-server/configure.ac | 8 +- xorg-server/doc/xml/Makefile.am | 2 + xorg-server/doc/xml/Xserver-spec.xml | 8 +- xorg-server/doc/xml/dtrace/Makefile.am | 36 ++ xorg-server/doc/xml/dtrace/Xserver-DTrace.xml | 579 ++++++++++++++++++++ xorg-server/doc/xml/xmlrules.in | 10 +- xorg-server/hw/xfree86/ddc/ddc.c | 7 +- xorg-server/hw/xquartz/GL/indirect.c | 5 +- xorg-server/hw/xquartz/pbproxy/main.m | 328 +++++------ .../xkeyboard-config/tests/genLists4Comparizon.sh | 43 ++ xorg-server/xkeyboard-config/tests/listCI2.xsl | 21 + xorg-server/xkeyboard-config/tests/listCIs.xsl | 20 + .../xkeyboard-config/tests/mxkbledpanel/Imakefile | 8 + .../tests/mxkbledpanel/mxkbledpanel.c | 605 +++++++++++++++++++++ .../tests/mxkbledpanel/mxkbledpanel.man | 0 xorg-server/xkeyboard-config/tests/ruby/README | 3 + .../xkeyboard-config/tests/ruby/find_fragments.rb | 52 ++ .../xkeyboard-config/tests/ruby/find_match.rb | 42 ++ xorg-server/xkeyboard-config/tests/ruby/utils.rb | 64 +++ .../xkeyboard-config/tests/ruby/xkbparser.rb | 185 +++++++ xorg-server/xkeyboard-config/tests/testLayouts.pl | 17 + xorg-server/xkeyboard-config/tests/testModels.pl | 15 + xorg-server/xkeyboard-config/tests/testOptions.pl | 15 + .../xkeyboard-config/tests/testShortDescriptions | 6 + xorg-server/xkeyboard-config/tests/xkbTestFunc.pm | 164 ++++++ xorg-server/xkeyboard-config/xslt/reg2ll.xsl | 23 + xorg-server/xkeyboard-config/xslt/xfree86.xsl | 50 ++ 27 files changed, 2142 insertions(+), 174 deletions(-) create mode 100644 xorg-server/doc/xml/dtrace/Makefile.am create mode 100644 xorg-server/doc/xml/dtrace/Xserver-DTrace.xml create mode 100644 xorg-server/xkeyboard-config/tests/genLists4Comparizon.sh create mode 100644 xorg-server/xkeyboard-config/tests/listCI2.xsl create mode 100644 xorg-server/xkeyboard-config/tests/listCIs.xsl create mode 100644 xorg-server/xkeyboard-config/tests/mxkbledpanel/Imakefile create mode 100644 xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.c create mode 100644 xorg-server/xkeyboard-config/tests/mxkbledpanel/mxkbledpanel.man create mode 100644 xorg-server/xkeyboard-config/tests/ruby/README create mode 100644 xorg-server/xkeyboard-config/tests/ruby/find_fragments.rb create mode 100644 xorg-server/xkeyboard-config/tests/ruby/find_match.rb create mode 100644 xorg-server/xkeyboard-config/tests/ruby/utils.rb create mode 100644 xorg-server/xkeyboard-config/tests/ruby/xkbparser.rb create mode 100644 xorg-server/xkeyboard-config/tests/testLayouts.pl create mode 100644 xorg-server/xkeyboard-config/tests/testModels.pl create mode 100644 xorg-server/xkeyboard-config/tests/testOptions.pl create mode 100644 xorg-server/xkeyboard-config/tests/testShortDescriptions create mode 100644 xorg-server/xkeyboard-config/tests/xkbTestFunc.pm create mode 100644 xorg-server/xkeyboard-config/xslt/reg2ll.xsl create mode 100644 xorg-server/xkeyboard-config/xslt/xfree86.xsl (limited to 'xorg-server') 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
- RESTYPE CreateNewResourceType(deleteFunc) + RESTYPE CreateNewResourceType(deleteFunc, char *name)
deleteFunc will be called to destroy all resources with this -type. +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.] + Resource classes are masks starting at 1 << 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 @@ + + %defs; +]> + +
+ + Xserver provider for DTrace + + AlanCoopersmith + + Oracle Corporation + Solaris Engineering + + + X.Org Xserver version &xserver.version; + + +Copyright (c) 2005, 2006, 2007, 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. + + + + + + Introduction + + This page provides details on a + statically defined user application tracing provider + for the + DTrace + facility in Solaris 10, + MacOS X 10.5, and later releases. This + provider instruments various points in the X server, to allow + tracing what client applications are up to. + + + + The provider was integrated into the X.Org git master repository + with Solaris 10 & 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. + + + + 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. + + + + + Available probes + + + Due to the way User-Defined DTrace probes work, arguments to + these probes all bear undistinguished names of + arg0, arg1, + arg2, etc. These tables should help you + determine what the real data is for each of the probe arguments. + + + Probes and their arguments + + + + + + + + + + + + Probe name + Description + arg0 + arg1 + arg2 + arg3 + arg4 + + + + + Request Probes + + + request-start + Called just before processing each client request. + requestName + requestCode + requestLength + clientId + requestBuffer + + + request-done + Called just after processing each client request. + requestName + requestCode + sequenceNumber + clientId + resultCode + + + Event Probes + + + send-event + Called just before send each event to a client. + clientId + eventCode + eventBuffer + + + + Client Connection Probes + + + client-connect + Called when a new connection is opened from a client + clientId + clientFD + + + + client-auth + Called when client authenticates (normally just after connection opened) + clientId + clientAddr + clientPid + clientZoneId + + + + client-disconnect + Called when a client connection is closed + clientId + + + + Resource Allocation Probes + + + resource-alloc + Called when a new resource (pixmap, gc, colormap, etc.) is allocated + resourceId + resourceTypeId + resourceValue + resourceTypeName + + + + resource-free + Called when a resource is freed + resourceId + resourceTypeId + resourceValue + resourceTypeName + + + + +
+
+
+ + + Data Available in Probe Arguments + + + To access data in arguments of type string, you will need + to use copyinstr(). + To access data buffers referenced via uintptr_t's, you will + need to use copyin(). + + + Probe Arguments + + + + + + + Argument name + Type + Description + + + + + clientAddr + string + String representing address client connected from + + + clientFD + int + X server's file descriptor for server side of each connection + + + clientId + int + Unique integer identifier for each connection to the + X server + + + clientPid + pid_t + Process id of client, if connection is local + (from getpeerucred()) + + + clientZoneId + zoneid_t + Solaris: Zone id of client, if connection is local + (from getpeerucred()) + + + eventBuffer + uintptr_t + Pointer to buffer containing X event - decode using + structures in + <X11/Xproto.h> + and similar headers for each extension + + + eventCode + uint8_t + Event number of X event + + + resourceId + uint32_t + X resource id (XID) + + + resourceTypeId + uint32_t + Resource type id + + + resourceTypeName + string + String representing X resource type + ("PIXMAP", etc.) + + + resourceValue + uintptr_t + Pointer to data for X resource + + + resultCode + int + Integer code representing result status of request + + + requestBuffer + uintptr_t + Pointer to buffer containing X request - decode using + structures in + <X11/Xproto.h> + and similar headers for each extension + + + requestCode + uint8_t + Request number of X request or Extension + + + requestName + string + Name of X request or Extension + + + requestLength + uint16_t + Length of X request + + + sequenceNumber + uint32_t + Number of X request in in this connection + + + +
+
+
+ + + Examples + + + Counting requests by request name + + + This script simply increments a counter for each different request + made, and when you exit the script (such as by hitting + ControlC + ) prints the counts. + + +#!/usr/sbin/dtrace -s + +Xserver*:::request-start +{ + @counts[copyinstr(arg0)] = count(); +} + + + The output from a short run may appear as: + + QueryPointer 1 + CreatePixmap 2 + FreePixmap 2 + PutImage 2 + ChangeGC 10 + CopyArea 10 + CreateGC 14 + FreeGC 14 + RENDER 28 + SetClipRectangles 40 + + + + + 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: + + +#!/usr/sbin/dtrace -s + +string Xrequest[uintptr_t]; + +Xserver*:::request-start +/Xrequest[arg0] == ""/ +{ + Xrequest[arg0] = copyinstr(arg0); +} + +Xserver*:::request-start +{ + @counts[Xrequest[arg0]] = count(); +} + + + + + + Get average CPU time per request + + This script records the CPU time used between the probes at + the start and end of each request and aggregates it per request type. + + +#!/usr/sbin/dtrace -s + +Xserver*:::request-start +{ + reqstart = vtimestamp; +} + +Xserver*:::request-done +{ + @times[copyinstr(arg0)] = avg(vtimestamp - reqstart); +} + + + The output from a sample run might look like: + + + 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 + + + + + + + Monitoring clients that connect and disconnect + + + 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 Xserver$1 instead + of Xserver* 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. + + +#!/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 => %s pid %d\n", + arg0, copyinstr(arg1), arg2); +} + +Xserver$1:::client-disconnect +{ + printf("** Client Disconnect: id %d\n", arg0); +} + + + A sample run: + + +# ./foo.d 5790 +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 => local host pid 2034 + + 0 15773 EstablishNewConnections:client-connect ** Client Connect: id 65 + + 0 15772 AuthAudit:client-auth ** Client auth'ed: id 65 => local host pid 2034 + + 0 15774 CloseDownClient:client-disconnect ** Client Disconnect: id 64 + + + + + + + + Monitoring clients creating Pixmaps + + + 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. + + +#!/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 && Xrestype[arg3] == ""/ +{ + Xrestype[arg3] = copyinstr(arg3); +} + + +Xserver$1:::request-start +/Xrequest[arg0] == "X_CreatePixmap"/ +{ + printf("-> %s: client %d\n", Xrequest[arg0], arg3); +} + +Xserver$1:::request-done +/Xrequest[arg0] == "X_CreatePixmap"/ +{ + printf("<- %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 => %s pid %d\n", + arg0, copyinstr(arg1), arg2); +} + +Xserver$1:::client-disconnect +{ + printf("** Client Disconnect: id %d\n", arg0); +} + + + Sample output from a run of this script: + +** Client Connect: id 17 +** Client auth'ed: id 17 => local host pid 20273 +-> X_CreatePixmap: client 17 +** Pixmap alloc: 02200009 +<- X_CreatePixmap: client 17 +-> X_CreatePixmap: client 15 +** Pixmap alloc: 01e00180 +<- X_CreatePixmap: client 15 +-> X_CreatePixmap: client 15 +** Pixmap alloc: 01e00181 +<- X_CreatePixmap: client 15 +-> X_CreatePixmap: client 14 +** Pixmap alloc: 01c004c8 +<- X_CreatePixmap: client 14 +** Pixmap free: 02200009 +** Client Disconnect: id 17 +** Pixmap free: 01e00180 +** Pixmap free: 01e00181 + + + + + + + + + +
+ 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 -#include -#include - -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 +#include +#include + +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 @@ + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + 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 +#include +#include +#include +#include +#include +#include +#include + +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 \n",program); + printf("Legal options include the usual X toolkit options plus:\n"); + printf(" -help Print this message\n"); + printf(" -indpy Name of display to watch\n"); + printf(" -watch 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;iindicators.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;iindicators->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 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 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 () + { + 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 () + { + 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 () + { + 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 () + { + 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 @@ + + + + + + + + + + + + +:"" + + +():" - " + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3