diff options
author | Jeremy Katz <katzj@redhat.com> | 2003-11-07 01:00:35 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2003-11-07 01:00:35 +0000 |
commit | 1f3f2124678999a833d3c93adcd4c2c8da7a299b (patch) | |
tree | ba982688357a166ba6668b13d7bd8ae432c5c1d9 | |
parent | 9aac9093750570cf4420856a9bc34935965dc1e4 (diff) | |
download | anaconda-1f3f2124678999a833d3c93adcd4c2c8da7a299b.tar.gz anaconda-1f3f2124678999a833d3c93adcd4c2c8da7a299b.tar.xz anaconda-1f3f2124678999a833d3c93adcd4c2c8da7a299b.zip |
xkb stuff isn't used anymore
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | xkb.c | 241 | ||||
-rw-r--r-- | xkb.py | 92 |
3 files changed, 1 insertions, 338 deletions
@@ -18,7 +18,7 @@ CATALOGS = po/anaconda.pot PYFILES = $(wildcard *.py) -all: subdirs mini-wm _xkb.so xmouse.so xutils.so $(CATALOGS) lang-table lang-names locale-list +all: subdirs mini-wm xmouse.so xutils.so $(CATALOGS) lang-table lang-names locale-list lang-names: lang-table PYTHONPATH="." $(PYTHON) scripts/getlangnames.py > lang-names @@ -29,10 +29,6 @@ locale-list: mini-wm: mini-wm.c gcc -o mini-wm mini-wm.c `pkg-config gtk+-x11-2.0 --cflags --libs` -Wall -Werror -_xkb.so: xkb.c - gcc -Wall -o _xkb.o -O2 -fPIC -I$(PYTHONINCLUDE) `pkg-config --cflags gtk+-2.0` -c xkb.c -Wall -Werror - gcc -o _xkb.so -shared _xkb.o /usr/X11R6/$(LIBDIR)/libxkbfile.a `pkg-config --libs gtk+-2.0` - xmouse.so: xmouse.c gcc -Wall -o xmouse.o -fPIC -I/usr/X11R6/include -I$(PYTHONINCLUDE) -I $(PYTHONINCLUDE) -c xmouse.c -Wall -Werror gcc -o xmouse.so -shared xmouse.o /usr/X11R6/$(LIBDIR)/libXxf86misc.a -L/usr/X11R6/$(LIBDIR) -lX11 -lXext diff --git a/xkb.c b/xkb.c deleted file mode 100644 index d2e8c5e81..000000000 --- a/xkb.c +++ /dev/null @@ -1,241 +0,0 @@ -#include <Python.h> -#include <stdio.h> -#include <fcntl.h> -#include <X11/Xlib.h> -#include <X11/XKBlib.h> -#include <X11/extensions/XKBrules.h> -#include <gdk/gdkx.h> -#include <assert.h> - -#define max(a,b) ((a) > (b) ? (a) : (b)) -#define min(a,b) ((a) < (b) ? (a) : (b)) - -#define MAX_COMPONENTS 400 -#define XKB_XFREE86_RULES "/usr/X11R6/lib/X11/xkb/rules/xfree86" -#define XKB_SUN_RULES "/usr/X11R6/lib/X11/xkb/rules/sun" - -static XkbRF_RulesPtr rules; - -PyObject *list_rules (); -PyObject *set_rule (PyObject *, PyObject *); -PyObject * py_get_rulesbase (); -PyObject *py_get_mousekeys (); -PyObject *py_set_mousekeys (PyObject * s, PyObject * args); - -char * get_rulesbase (); - -static PyMethodDef _xkbMethods[] = { - { "list_rules", list_rules, 1 }, - { "set_rule", set_rule, 1 }, - { "get_rulesbase", py_get_rulesbase, 1 }, - { "get_mousekeys", py_get_mousekeys, 1 }, - { "set_mousekeys", py_set_mousekeys, 1 }, - { NULL, NULL } -}; - -char * -get_rulesbase () -{ - char *rulesbase = XKB_XFREE86_RULES; -#ifdef __sparc__ - int fd; - - fd = open("/dev/kbd", O_RDONLY); - if (fd >= 0) { - rulesbase = XKB_SUN_RULES; - } -#endif - - return rulesbase; -} - -PyObject * -py_get_rulesbase () -{ - return Py_BuildValue ("s", get_rulesbase ()); -} - - -PyObject * -py_get_mousekeys () -{ - XkbDescPtr desc; - - desc = XkbGetKeyboard (GDK_DISPLAY(), - XkbAllComponentsMask, - XkbUseCoreKbd); - if (desc == NULL) { - return NULL; - } - - if (XkbGetControls (GDK_DISPLAY(), ~0, desc) != Success) { - return NULL; - } - - if (desc->ctrls->enabled_ctrls & XkbMouseKeysMask) - return Py_BuildValue ("i", 1); - else - return Py_BuildValue ("i", 0); -} - -PyObject * -py_set_mousekeys (PyObject * s, PyObject * args) -{ - int setting; - - if (!PyArg_ParseTuple(args, "i", &setting)) - return NULL; - - if (XkbChangeEnabledControls (GDK_DISPLAY(), XkbUseCoreKbd, - XkbMouseKeysMask, - setting ? XkbMouseKeysMask : 0) != True) { - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -void -init_xkb () -{ - char *lang; - PyObject *m; - m = Py_InitModule ("_xkb", _xkbMethods); - - lang = getenv ("LC_ALL"); - rules = XkbRF_Load (get_rulesbase (), (lang) ? lang : "C", True, True); - if (!rules) - Py_FatalError ("unable to load XKB rules database"); - - if (PyErr_Occurred ()) - Py_FatalError ("can't initialize module _xkb"); -} - -PyObject * -set_rule (PyObject *self, PyObject *args) -{ - XkbRF_VarDefsRec defs; - XkbComponentNamesRec rnames; - - if (!PyArg_ParseTuple (args, "ssss", &defs.model, &defs.layout, &defs.variant, &defs.options)) - return NULL; - - if (!strcmp (defs.model, "")) - defs.model = NULL; - if (!strcmp (defs.layout, "")) - defs.layout = NULL; - if (!strcmp (defs.variant, "")) - defs.variant = NULL; - if (!strcmp (defs.options, "")) - defs.options = NULL; - - XkbRF_GetComponents (rules, &defs, &rnames); - - XkbGetKeyboardByName (GDK_DISPLAY (), XkbUseCoreKbd, &rnames, - XkbGBN_AllComponentsMask, - XkbGBN_AllComponentsMask, True); - - XkbRF_SetNamesProp (GDK_DISPLAY (), get_rulesbase (), &defs); - - return Py_BuildValue ("i", 1); -} - -PyObject * -list_rules () -{ - PyObject *models, *layouts, *variants, *options, *py_rules; - int num_comp; - int i; - - models = PyDict_New (); - num_comp = min (rules->models.num_desc, MAX_COMPONENTS); - for (i = 0; i < num_comp; i++) - { - PyObject *desc, *name; - - name = PyString_FromString (rules->models.desc[i].name); - desc = PyString_FromString (rules->models.desc[i].desc); - PyDict_SetItem (models, name, desc); - } - - layouts = PyDict_New (); - num_comp = min (rules->layouts.num_desc, MAX_COMPONENTS); - for (i = 0; i < num_comp; i++) - { - PyObject *desc, *name; - - name = PyString_FromString (rules->layouts.desc[i].name); - desc = PyString_FromString (rules->layouts.desc[i].desc); - PyDict_SetItem (layouts, name, desc); - } - - variants = PyDict_New (); - num_comp = min (rules->variants.num_desc, MAX_COMPONENTS); - for (i = 0; i < num_comp; i++) - { - PyObject *desc, *name; - - name = PyString_FromString (rules->variants.desc[i].name); - desc = PyString_FromString (rules->variants.desc[i].desc); - PyDict_SetItem (variants, name, desc); - } - - options = PyDict_New (); - num_comp = min (rules->options.num_desc, MAX_COMPONENTS); - for (i = 0; i < num_comp; i++) - { - PyObject *desc, *name; - - name = PyString_FromString (rules->options.desc[i].name); - desc = PyString_FromString (rules->options.desc[i].desc); - PyDict_SetItem (options, name, desc); - } - - py_rules = PyTuple_New (4); - - PyTuple_SET_ITEM (py_rules, 0, models); - PyTuple_SET_ITEM (py_rules, 1, layouts); - PyTuple_SET_ITEM (py_rules, 2, variants); - PyTuple_SET_ITEM (py_rules, 3, options); - - return py_rules; -} - -int main (int argc, char **argv) -{ - int major, minor, event, error, reason; - int max; - Display *dpy; - XkbComponentNamesRec ptrns = { NULL, NULL, NULL, NULL, NULL, "*" }; - XkbComponentListPtr comps; - - - major = XkbMajorVersion; - minor = XkbMinorVersion; -/* if (!XkbQueryExtension(dpy, &op, &event, &error, &major, &minor)) */ -/* { */ -/* fprintf (stderr, "no xkb\n"); */ -/* } */ - - dpy = XkbOpenDisplay (NULL, &event, &error, &major, &minor, &reason); - assert (dpy != NULL); - - max = MAX_COMPONENTS; - comps = XkbListComponents (dpy, XkbUseCoreKbd, &ptrns, &max); - assert (comps != NULL); -/* for (i = 0; i < comps->num_geometry; i++) */ -/* { */ -/* printf ("%s\n", comps->geometry[i].name); */ -/* } */ - - - list_rules (); - -/* xkb = XkbGetKeyboard (dpy, XkbAllComponentsMask, XkbUseCoreKbd); */ -/* xkb->names = NULL; */ -/* XkbGetNames (dpy, XkbGeometryNameMask, xkb); */ -/* printf ("%s\n", XkbAtomText (dpy, xkb->names->geometry, 3)); */ - - return 0; -} diff --git a/xkb.py b/xkb.py deleted file mode 100644 index 6a9693097..000000000 --- a/xkb.py +++ /dev/null @@ -1,92 +0,0 @@ -# -# xkb.py - interface to query xkb from X server -# -# Matt Wilson <msw@redhat.com> -# -# Copyright 1999-2001 Red Hat, Inc. -# -# This software may be freely redistributed under the terms of the GNU -# library public license. -# -# You should have received a copy of the GNU Library Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# - -import _xkb -import tree -import string -import os - -class XKB: - def __init__ (self): - self.rules = _xkb.list_rules () - - def getRules (self): - return self.rules - - def getModels (self): - return self.rules[0] - - def getLayouts (self): - return self.rules[1] - - def getVariants (self): - return self.rules[2] - - def getOptions (self): - keys = self.rules[3].keys (); keys.sort () - groups = () - for x in keys: - groups = tree.merge (groups, string.split (x, ":")) - return (groups, self.rules[3]) - - def setRule (self, model, layout, variant, options): - if model == None: model = "" - if layout == None: layout = "" - if variant == None: variant = "" - if options == None: options = "" - - args = () - - if (model): - args = args + ("-model", model) - if (layout): - args = args + ("-layout", layout) - if (variant): - args = args + ("-variant", variant) - - path = ("/usr/X11R6/bin/setxkbmap",) - child = os.fork () - if (child == 0): - os.execv (path[0], path + args) - - try: - pid, status = os.waitpid(child, 0) - except OSError, (errno, msg): - print __name__, "waitpid:", msg - return - - # don't use any of our code, since it seems to corrupt - # lots of memory - return _xkb.set_rule (model, layout, variant, options) - - def getRulesBase (self): - return _xkb.get_rulesbase () - - def setMouseKeys (self, flag): - return _xkb.set_mousekeys (flag) - - def getMouseKeys (self): - return _xkb.get_mousekeys () - -if __name__ == "__main__": - xkb = XKB() - print xkb.getVariants() - - - - - - - |