Organize src/ and test/ headers - Add context.h and move context-related functions from xkb-priv.h to it. - Move xkb_context definition back to context.c. - Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it. - Rename xkb-priv.h to map.h since it only contains keymap-related definitions and declarations now. - Remove unnecessary includes and some and some other small cleanups. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652
diff --git a/Makefile.am b/Makefile.am
index b83d992..b3452e2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,17 +66,19 @@ libxkbcommon_la_SOURCES = \
src/atom.c \
src/atom.h \
src/context.c \
+ src/context.h \
src/darray.h \
src/keymap-dump.c \
src/keysym.c \
+ src/keysym.h \
src/keysym-utf.c \
src/list.h \
src/map.c \
+ src/map.h \
src/state.c \
src/text.c \
src/text.h \
- src/utils.h \
- src/xkb-priv.h
+ src/utils.h
BUILT_SOURCES = \
src/xkbcomp/parser.c \
diff --git a/src/atom.c b/src/atom.c
index 66cf2cf..a775023 100644
--- a/src/atom.c
+++ b/src/atom.c
@@ -70,6 +70,7 @@
*
********************************************************/
+#include "utils.h"
#include "atom.h"
struct atom_node {
diff --git a/src/atom.h b/src/atom.h
index 851e0b0..f1abf1b 100644
--- a/src/atom.h
+++ b/src/atom.h
@@ -24,7 +24,9 @@
#ifndef ATOM_H
#define ATOM_H
-#include "xkb-priv.h"
+typedef uint32_t xkb_atom_t;
+
+#define XKB_ATOM_NONE 0
struct atom_table;
diff --git a/src/context.c b/src/context.c
index b116884..6710fe2 100644
--- a/src/context.c
+++ b/src/context.c
@@ -28,12 +28,30 @@
#include <sys/stat.h>
#include <ctype.h>
#include <errno.h>
-#include <stdarg.h>
-#include <stdio.h>
#include <unistd.h>
-#include "xkb-priv.h"
-#include "atom.h"
+#include "xkbcommon/xkbcommon.h"
+#include "utils.h"
+#include "context.h"
+
+struct xkb_context {
+ int refcnt;
+
+ ATTR_PRINTF(3, 0) void (*log_fn)(struct xkb_context *ctx,
+ enum xkb_log_level level,
+ const char *fmt, va_list args);
+ enum xkb_log_level log_level;
+ int log_verbosity;
+ void *user_data;
+
+ darray(char *) includes;
+ darray(char *) failed_includes;
+
+ /* xkbcomp needs to assign sequential IDs to XkbFile's it creates. */
+ unsigned file_id;
+
+ struct atom_table *atom_table;
+};
/**
* Append one directory to the context's include path.
diff --git a/src/context.h b/src/context.h
new file mode 100644
index 0000000..1a87815
--- /dev/null
+++ b/src/context.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * 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.
+ *
+ * Author: Daniel Stone <daniel@fooishbar.org>
+ */
+
+#ifndef CONTEXT_H
+#define CONTEXT_H
+
+#include "atom.h"
+
+unsigned
+xkb_context_take_file_id(struct xkb_context *ctx);
+
+unsigned int
+xkb_context_num_failed_include_paths(struct xkb_context *ctx);
+
+const char *
+xkb_context_failed_include_path_get(struct xkb_context *ctx,
+ unsigned int idx);
+
+/*
+ * Returns XKB_ATOM_NONE if @string was not previously interned,
+ * otherwise returns the atom.
+ */
+xkb_atom_t
+xkb_atom_lookup(struct xkb_context *ctx, const char *string);
+
+xkb_atom_t
+xkb_atom_intern(struct xkb_context *ctx, const char *string);
+
+/**
+ * If @string is dynamically allocated, free'd immediately after
+ * being interned, and not used afterwards, use this function
+ * instead of xkb_atom_intern to avoid some unnecessary allocations.
+ * The caller should not use or free the passed in string afterwards.
+ */
+xkb_atom_t
+xkb_atom_steal(struct xkb_context *ctx, char *string);
+
+char *
+xkb_atom_strdup(struct xkb_context *ctx, xkb_atom_t atom);
+
+const char *
+xkb_atom_text(struct xkb_context *ctx, xkb_atom_t atom);
+
+ATTR_PRINTF(3, 4) void
+xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
+ const char *fmt, ...);
+
+#define xkb_log_cond_level(ctx, level, ...) do { \
+ if (xkb_get_log_level(ctx) >= (level)) \
+ xkb_log((ctx), (level), __VA_ARGS__); \
+} while (0)
+
+#define xkb_log_cond_verbosity(ctx, level, vrb, ...) do { \
+ if (xkb_get_log_verbosity(ctx) >= (vrb)) \
+ xkb_log_cond_level((ctx), (level), __VA_ARGS__); \
+} while (0)
+
+/*
+ * The format is not part of the argument list in order to avoid the
+ * "ISO C99 requires rest arguments to be used" warning when only the
+ * format is supplied without arguments. Not supplying it would still
+ * result in an error, though.
+ */
+#define log_dbg(ctx, ...) \
+ xkb_log_cond_level((ctx), XKB_LOG_LEVEL_DEBUG, __VA_ARGS__)
+#define log_info(ctx, ...) \
+ xkb_log_cond_level((ctx), XKB_LOG_LEVEL_INFO, __VA_ARGS__)
+#define log_warn(ctx, ...) \
+ xkb_log_cond_level((ctx), XKB_LOG_LEVEL_WARNING, __VA_ARGS__)
+#define log_err(ctx, ...) \
+ xkb_log_cond_level((ctx), XKB_LOG_LEVEL_ERROR, __VA_ARGS__)
+#define log_wsgo(ctx, ...) \
+ xkb_log_cond_level((ctx), XKB_LOG_LEVEL_CRITICAL, __VA_ARGS__)
+#define log_vrb(ctx, vrb, ...) \
+ xkb_log_cond_verbosity((ctx), XKB_LOG_LEVEL_WARNING, (vrb), __VA_ARGS__)
+
+#endif
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index e913f60..f3ff1ed 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -49,12 +49,7 @@
* Author: Daniel Stone <daniel@fooishbar.org>
*/
-#include <stdarg.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-#include "xkb-priv.h"
+#include "map.h"
#include "text.h"
#define VMOD_HIDE_VALUE 0
diff --git a/src/keysym-utf.c b/src/keysym-utf.c
index 66de078..ed18035 100644
--- a/src/keysym-utf.c
+++ b/src/keysym-utf.c
@@ -34,7 +34,7 @@
* This software is in the public domain. Share and enjoy!
*
*/
-#include <stdint.h>
+
#include "xkbcommon/xkbcommon.h"
#include "utils.h"
diff --git a/src/keysym.c b/src/keysym.c
index 1c95194..da1d219 100644
--- a/src/keysym.c
+++ b/src/keysym.c
@@ -47,12 +47,10 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "xkb-priv.h"
+#include "xkbcommon/xkbcommon.h"
+#include "utils.h"
#include "ks_tables.h"
+#include "keysym.h"
XKB_EXPORT void
xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
diff --git a/src/keysym.h b/src/keysym.h
new file mode 100644
index 0000000..6f2280b
--- /dev/null
+++ b/src/keysym.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1985, 1987, 1990, 1998 The Open Group
+ *
+ * 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
+ * AUTHORS 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 names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+/*
+ * Copyright © 2009 Dan Nicholson
+ *
+ * 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.
+ */
+
+#ifndef KEYSYM_H
+#define KEYSYM_H
+
+bool
+xkb_keysym_is_lower(xkb_keysym_t keysym);
+
+bool
+xkb_keysym_is_upper(xkb_keysym_t keysym);
+
+bool
+xkb_keysym_is_keypad(xkb_keysym_t keysym);
+
+#endif
diff --git a/src/map.c b/src/map.c
index 20538d6..b75622f 100644
--- a/src/map.c
+++ b/src/map.c
@@ -50,7 +50,7 @@
*
* ********************************************************/
-#include "xkb-priv.h"
+#include "map.h"
#include "text.h"
struct xkb_keymap *
diff --git a/src/map.h b/src/map.h
new file mode 100644
index 0000000..b770504
--- /dev/null
+++ b/src/map.h
@@ -0,0 +1,446 @@
+/*
+ * Copyright 1985, 1987, 1990, 1998 The Open Group
+ *
+ * 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
+ * AUTHORS 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 names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+/************************************************************
+ * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ ********************************************************/
+
+/*
+ * Copyright © 2009 Dan Nicholson
+ * Copyright © 2012 Intel Corporation
+ * Copyright © 2012 Ran Benita
+ *
+ * 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.
+ *
+ * Author: Daniel Stone <daniel@fooishbar.org>
+ * Dan Nicholson <dbn.lists@gmail.com>
+ */
+
+#ifndef MAP_H
+#define MAP_H
+
+#include "xkbcommon/xkbcommon.h"
+#include "utils.h"
+#include "context.h"
+
+typedef uint32_t xkb_level_index_t;
+
+#define XKB_LEVEL_INVALID 0xffffffff
+
+#define XKB_KEY_NAME_LENGTH 4
+
+/* These should all be dynamic. */
+#define XKB_NUM_GROUPS 4
+#define XKB_NUM_INDICATORS 32
+#define XKB_NUM_VIRTUAL_MODS 16
+#define XKB_NUM_CORE_MODS 8
+
+enum xkb_action_type {
+ ACTION_TYPE_NONE = 0,
+ ACTION_TYPE_MOD_SET,
+ ACTION_TYPE_MOD_LATCH,
+ ACTION_TYPE_MOD_LOCK,
+ ACTION_TYPE_GROUP_SET,
+ ACTION_TYPE_GROUP_LATCH,
+ ACTION_TYPE_GROUP_LOCK,
+ ACTION_TYPE_PTR_MOVE,
+ ACTION_TYPE_PTR_BUTTON,
+ ACTION_TYPE_PTR_LOCK,
+ ACTION_TYPE_PTR_DEFAULT,
+ ACTION_TYPE_TERMINATE,
+ ACTION_TYPE_SWITCH_VT,
+ ACTION_TYPE_CTRL_SET,
+ ACTION_TYPE_CTRL_LOCK,
+ ACTION_TYPE_KEY_REDIRECT,
+ ACTION_TYPE_PRIVATE,
+ _ACTION_TYPE_NUM_ENTRIES
+};
+
+enum xkb_action_flags {
+ ACTION_LOCK_CLEAR = (1 << 0),
+ ACTION_LATCH_TO_LOCK = (1 << 1),
+ ACTION_LOCK_NO_LOCK = (1 << 2),
+ ACTION_LOCK_NO_UNLOCK = (1 << 3),
+ ACTION_MODS_LOOKUP_MODMAP = (1 << 4),
+ ACTION_ABSOLUTE_SWITCH = (1 << 5),
+ ACTION_ABSOLUTE_X = (1 << 6),
+ ACTION_ABSOLUTE_Y = (1 << 7),
+ ACTION_NO_ACCEL = (1 << 8),
+ ACTION_SAME_SCREEN = (1 << 9),
+};
+
+enum xkb_action_controls {
+ CONTROL_REPEAT = (1 << 0),
+ CONTROL_SLOW = (1 << 1),
+ CONTROL_DEBOUNCE = (1 << 2),
+ CONTROL_STICKY = (1 << 3),
+ CONTROL_MOUSEKEYS = (1 << 4),
+ CONTROL_MOUSEKEYS_ACCEL = (1 << 5),
+ CONTROL_AX = (1 << 6),
+ CONTROL_AX_TIMEOUT = (1 << 7),
+ CONTROL_AX_FEEDBACK = (1 << 8),
+ CONTROL_BELL = (1 << 9),
+ CONTROL_IGNORE_GROUP_LOCK = (1 << 10),
+ CONTROL_ALL = \
+ (CONTROL_REPEAT | CONTROL_SLOW | CONTROL_DEBOUNCE | CONTROL_STICKY | \
+ CONTROL_MOUSEKEYS | CONTROL_MOUSEKEYS_ACCEL | CONTROL_AX | \
+ CONTROL_AX_TIMEOUT | CONTROL_AX_FEEDBACK | CONTROL_BELL | \
+ CONTROL_IGNORE_GROUP_LOCK)
+};
+
+enum xkb_match_operation {
+ MATCH_NONE = 0,
+ MATCH_ANY_OR_NONE = 1,
+ MATCH_ANY = 2,
+ MATCH_ALL = 3,
+ MATCH_EXACTLY = 4,
+ MATCH_OP_MASK = \
+ (MATCH_NONE | MATCH_ANY_OR_NONE | MATCH_ANY | MATCH_ALL | \
+ MATCH_EXACTLY),
+ MATCH_LEVEL_ONE_ONLY = (1 << 7),
+};
+
+struct xkb_mods {
+ xkb_mod_mask_t mods; /* original real+virtual mods in definition */
+ xkb_mod_mask_t mask; /* computed effective mask */
+};
+
+struct xkb_mod_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ struct xkb_mods mods;
+};
+
+struct xkb_group_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ int32_t group;
+};
+
+struct xkb_controls_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ enum xkb_action_controls ctrls;
+};
+
+struct xkb_pointer_default_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ int8_t value;
+};
+
+struct xkb_switch_screen_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ int8_t screen;
+};
+
+struct xkb_redirect_key_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ xkb_keycode_t new_kc;
+ uint8_t mods_mask;
+ uint8_t mods;
+ uint16_t vmods_mask;
+ uint16_t vmods;
+};
+
+struct xkb_pointer_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ int16_t x;
+ int16_t y;
+};
+
+struct xkb_pointer_button_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ uint8_t count;
+ int8_t button;
+};
+
+struct xkb_private_action {
+ enum xkb_action_type type;
+ enum xkb_action_flags flags;
+ uint8_t data[7];
+};
+
+union xkb_action {
+ enum xkb_action_type type;
+ struct xkb_mod_action mods;
+ struct xkb_group_action group;
+ struct xkb_controls_action ctrls;
+ struct xkb_pointer_default_action dflt;
+ struct xkb_switch_screen_action screen;
+ struct xkb_redirect_key_action redirect; /* XXX wholly unnecessary? */
+ struct xkb_pointer_action ptr;
+ struct xkb_pointer_button_action btn;
+ struct xkb_private_action priv;
+};
+
+struct xkb_kt_map_entry {
+ xkb_level_index_t level;
+ struct xkb_mods mods;
+ struct xkb_mods preserve;
+};
+
+struct xkb_key_type {
+ struct xkb_mods mods;
+ xkb_level_index_t num_levels;
+ struct xkb_kt_map_entry *map;
+ unsigned int num_entries;
+ xkb_atom_t name;
+ xkb_atom_t *level_names;
+};
+
+struct xkb_sym_interpret {
+ xkb_keysym_t sym;
+ bool repeat;
+ enum xkb_match_operation match;
+ uint8_t mods;
+ xkb_mod_index_t virtual_mod;
+ union xkb_action act;
+};
+
+struct xkb_indicator_map {
+ xkb_atom_t name;
+ enum xkb_state_component which_groups;
+ uint32_t groups;
+ enum xkb_state_component which_mods;
+ struct xkb_mods mods;
+ enum xkb_action_controls ctrls;
+};
+
+struct xkb_key_alias {
+ char real[XKB_KEY_NAME_LENGTH];
+ char alias[XKB_KEY_NAME_LENGTH];
+};
+
+struct xkb_controls {
+ unsigned char groups_wrap;
+ struct xkb_mods internal;
+ struct xkb_mods ignore_lock;
+ unsigned short repeat_delay;
+ unsigned short repeat_interval;
+ unsigned short slow_keys_delay;
+ unsigned short debounce_delay;
+ unsigned short ax_options;
+ unsigned short ax_timeout;
+ unsigned short axt_opts_mask;
+ unsigned short axt_opts_values;
+ unsigned int axt_ctrls_mask;
+ unsigned int axt_ctrls_values;
+};
+
+/* Such an awkward name. Oh well. */
+enum xkb_range_exceed_type {
+ RANGE_SATURATE,
+ RANGE_WRAP,
+ RANGE_REDIRECT,
+};
+
+enum xkb_explicit_components {
+ EXPLICIT_INTERP = (1 << 0),
+ EXPLICIT_VMODMAP = (1 << 1),
+ EXPLICIT_REPEAT = (1 << 2),
+};
+
+struct xkb_key {
+ char name[XKB_KEY_NAME_LENGTH];
+
+ enum xkb_explicit_components explicit;
+ xkb_group_mask_t explicit_groups;
+
+ unsigned char modmap;
+ xkb_mod_mask_t vmodmap;
+
+ bool repeats;
+
+ union xkb_action *actions;
+
+ unsigned kt_index[XKB_NUM_GROUPS];
+
+ xkb_group_index_t num_groups;
+ /* How many levels the largest group has. */
+ xkb_level_index_t width;
+
+ enum xkb_range_exceed_type out_of_range_group_action;
+ xkb_group_index_t out_of_range_group_number;
+
+ /* per level/group index into 'syms' */
+ int *sym_index;
+ /* per level/group */
+ unsigned int *num_syms;
+ xkb_keysym_t *syms;
+};
+
+/* Common keyboard description structure */
+struct xkb_keymap {
+ struct xkb_context *ctx;
+
+ int refcnt;
+ enum xkb_map_compile_flags flags;
+
+ unsigned int enabled_ctrls;
+
+ xkb_keycode_t min_key_code;
+ xkb_keycode_t max_key_code;
+
+ darray(struct xkb_key) keys;
+
+ /* aliases in no particular order */
+ darray(struct xkb_key_alias) key_aliases;
+
+ struct xkb_key_type *types;
+ unsigned int num_types;
+
+ darray(struct xkb_sym_interpret) sym_interpret;
+
+ /* vmod -> mod mapping */
+ xkb_mod_mask_t vmods[XKB_NUM_VIRTUAL_MODS];
+ xkb_atom_t vmod_names[XKB_NUM_VIRTUAL_MODS];
+
+ /* Number of groups in the key with the most groups. */
+ xkb_group_index_t num_groups;
+ xkb_atom_t group_names[XKB_NUM_GROUPS];
+
+ struct xkb_indicator_map indicators[XKB_NUM_INDICATORS];
+
+ char *keycodes_section_name;
+ char *symbols_section_name;
+ char *types_section_name;
+ char *compat_section_name;
+};
+
+static inline const struct xkb_key *
+XkbKey(struct xkb_keymap *keymap, xkb_keycode_t kc)
+{
+ if (kc < keymap->min_key_code || kc > keymap->max_key_code)
+ return NULL;
+ return &darray_item(keymap->keys, kc);
+}
+
+static inline xkb_keycode_t
+XkbKeyGetKeycode(struct xkb_keymap *keymap, const struct xkb_key *key)
+{
+ /* Hack to avoid having to keep the keycode inside the xkb_key. */
+ return (xkb_keycode_t)(key - keymap->keys.item);
+}
+
+#define xkb_foreach_key(iter, keymap) \
+ darray_foreach(iter, keymap->keys)
+
+static inline struct xkb_key_type *
+XkbKeyType(struct xkb_keymap *keymap, const struct xkb_key *key,
+ xkb_group_index_t group)
+{
+ return &keymap->types[key->kt_index[group]];
+}
+
+static inline xkb_level_index_t
+XkbKeyGroupWidth(struct xkb_keymap *keymap, const struct xkb_key *key,
+ xkb_group_index_t group)
+{
+ return XkbKeyType(keymap, key, group)->num_levels;
+}
+
+static inline unsigned int
+XkbKeyNumSyms(const struct xkb_key *key, xkb_group_index_t group,
+ xkb_level_index_t level)
+{
+ return key->num_syms[group * key->width + level];
+}
+
+static inline const xkb_keysym_t *
+XkbKeySymEntry(const struct xkb_key *key, xkb_group_index_t group,
+ xkb_level_index_t level)
+{
+ return &key->syms[key->sym_index[group * key->width + level]];
+}
+
+static inline const union xkb_action *
+XkbKeyActionEntry(const struct xkb_key *key, xkb_group_index_t group,
+ xkb_level_index_t level)
+{
+ return &key->actions[key->width * group + level];
+}
+
+struct xkb_keymap *
+xkb_map_new(struct xkb_context *ctx);
+
+xkb_group_index_t
+xkb_key_get_group(struct xkb_state *state, const struct xkb_key *key);
+
+xkb_level_index_t
+xkb_key_get_level(struct xkb_state *state, const struct xkb_key *key,
+ xkb_group_index_t group);
+
+int
+xkb_key_get_syms_by_level(struct xkb_keymap *keymap,
+ const struct xkb_key *key,
+ xkb_group_index_t group, xkb_level_index_t level,
+ const xkb_keysym_t **syms_out);
+
+#endif
diff --git a/src/state.c b/src/state.c
index 2776506..14a95af 100644
--- a/src/state.c
+++ b/src/state.c
@@ -59,10 +59,7 @@
* - messages (very unlikely)
*/
-#include <assert.h>
-#include <stdarg.h>
-
-#include "xkb-priv.h"
+#include "map.h"
struct xkb_filter {
union xkb_action action;
diff --git a/src/text.c b/src/text.c
index 6151145..eb38314 100644
--- a/src/text.c
+++ b/src/text.c
@@ -24,6 +24,7 @@
*
********************************************************/
+#include "map.h"
#include "text.h"
bool
diff --git a/src/text.h b/src/text.h
index 98a6374..56d2ec9 100644
--- a/src/text.h
+++ b/src/text.h
@@ -24,8 +24,6 @@
#ifndef TEXT_H
#define TEXT_H
-#include "xkb-priv.h"
-
typedef struct {
const char *name;
unsigned int value;
diff --git a/src/utils.h b/src/utils.h
index 6f5233b..9f0505c 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -24,8 +24,12 @@
#ifndef UTILS_H
#define UTILS_H 1
+#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
+#include <strings.h>
+
+#include "darray.h"
/*
* We sometimes malloc strings and then expose them as const char*'s. This
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
deleted file mode 100644
index dfb2645..0000000
--- a/src/xkb-priv.h
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * Copyright 1985, 1987, 1990, 1998 The Open Group
- *
- * 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
- * AUTHORS 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 names of the authors or their
- * institutions shall not be used in advertising or otherwise to promote the
- * sale, use or other dealings in this Software without prior written
- * authorization from the authors.
- */
-
-/************************************************************
- * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting
- * documentation, and that the name of Silicon Graphics not be
- * used in advertising or publicity pertaining to distribution
- * of the software without specific prior written permission.
- * Silicon Graphics makes no representation about the suitability
- * of this software for any purpose. It is provided "as is"
- * without any express or implied warranty.
- *
- * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- * THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- ********************************************************/
-
-/*
- * Copyright © 2009 Dan Nicholson
- * Copyright © 2012 Intel Corporation
- * Copyright © 2012 Ran Benita
- *
- * 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.
- *
- * Author: Daniel Stone <daniel@fooishbar.org>
- * Dan Nicholson <dbn.lists@gmail.com>
- */
-
-#ifndef XKB_PRIV_H
-#define XKB_PRIV_H
-
-#include <stdbool.h>
-#include <string.h>
-#include <strings.h>
-
-#include "xkbcommon/xkbcommon.h"
-#include "utils.h"
-#include "darray.h"
-
-typedef uint32_t xkb_level_index_t;
-typedef uint32_t xkb_atom_t;
-
-#define XKB_ATOM_NONE 0
-#define XKB_LEVEL_INVALID 0xffffffff
-
-#define XKB_KEY_NAME_LENGTH 4
-
-/* These should all be dynamic. */
-#define XKB_NUM_GROUPS 4
-#define XKB_NUM_INDICATORS 32
-#define XKB_NUM_VIRTUAL_MODS 16
-#define XKB_NUM_CORE_MODS 8
-
-struct xkb_context {
- int refcnt;
-
- ATTR_PRINTF(3, 0) void (*log_fn)(struct xkb_context *ctx,
- enum xkb_log_level level,
- const char *fmt, va_list args);
- enum xkb_log_level log_level;
- int log_verbosity;
- void *user_data;
-
- darray(char *) includes;
- darray(char *) failed_includes;
-
- /* xkbcomp needs to assign sequential IDs to XkbFile's it creates. */
- unsigned file_id;
-
- struct atom_table *atom_table;
-};
-
-/**
- * Legacy names for the components of an XKB keymap, also known as KcCGST.
- */
-struct xkb_component_names {
- char *keycodes;
- char *types;
- char *compat;
- char *symbols;
-};
-
-enum xkb_action_type {
- ACTION_TYPE_NONE = 0,
- ACTION_TYPE_MOD_SET,
- ACTION_TYPE_MOD_LATCH,
- ACTION_TYPE_MOD_LOCK,
- ACTION_TYPE_GROUP_SET,
- ACTION_TYPE_GROUP_LATCH,
- ACTION_TYPE_GROUP_LOCK,
- ACTION_TYPE_PTR_MOVE,
- ACTION_TYPE_PTR_BUTTON,
- ACTION_TYPE_PTR_LOCK,
- ACTION_TYPE_PTR_DEFAULT,
- ACTION_TYPE_TERMINATE,
- ACTION_TYPE_SWITCH_VT,
- ACTION_TYPE_CTRL_SET,
- ACTION_TYPE_CTRL_LOCK,
- ACTION_TYPE_KEY_REDIRECT,
- ACTION_TYPE_PRIVATE,
- _ACTION_TYPE_NUM_ENTRIES
-};
-
-enum xkb_action_flags {
- ACTION_LOCK_CLEAR = (1 << 0),
- ACTION_LATCH_TO_LOCK = (1 << 1),
- ACTION_LOCK_NO_LOCK = (1 << 2),
- ACTION_LOCK_NO_UNLOCK = (1 << 3),
- ACTION_MODS_LOOKUP_MODMAP = (1 << 4),
- ACTION_ABSOLUTE_SWITCH = (1 << 5),
- ACTION_ABSOLUTE_X = (1 << 6),
- ACTION_ABSOLUTE_Y = (1 << 7),
- ACTION_NO_ACCEL = (1 << 8),
- ACTION_SAME_SCREEN = (1 << 9),
-};
-
-enum xkb_action_controls {
- CONTROL_REPEAT = (1 << 0),
- CONTROL_SLOW = (1 << 1),
- CONTROL_DEBOUNCE = (1 << 2),
- CONTROL_STICKY = (1 << 3),
- CONTROL_MOUSEKEYS = (1 << 4),
- CONTROL_MOUSEKEYS_ACCEL = (1 << 5),
- CONTROL_AX = (1 << 6),
- CONTROL_AX_TIMEOUT = (1 << 7),
- CONTROL_AX_FEEDBACK = (1 << 8),
- CONTROL_BELL = (1 << 9),
- CONTROL_IGNORE_GROUP_LOCK = (1 << 10),
- CONTROL_ALL = \
- (CONTROL_REPEAT | CONTROL_SLOW | CONTROL_DEBOUNCE | CONTROL_STICKY | \
- CONTROL_MOUSEKEYS | CONTROL_MOUSEKEYS_ACCEL | CONTROL_AX | \
- CONTROL_AX_TIMEOUT | CONTROL_AX_FEEDBACK | CONTROL_BELL | \
- CONTROL_IGNORE_GROUP_LOCK)
-};
-
-enum xkb_match_operation {
- MATCH_NONE = 0,
- MATCH_ANY_OR_NONE = 1,
- MATCH_ANY = 2,
- MATCH_ALL = 3,
- MATCH_EXACTLY = 4,
- MATCH_OP_MASK = \
- (MATCH_NONE | MATCH_ANY_OR_NONE | MATCH_ANY | MATCH_ALL | \
- MATCH_EXACTLY),
- MATCH_LEVEL_ONE_ONLY = (1 << 7),
-};
-
-struct xkb_mods {
- xkb_mod_mask_t mods; /* original real+virtual mods in definition */
- xkb_mod_mask_t mask; /* computed effective mask */
-};
-
-struct xkb_mod_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- struct xkb_mods mods;
-};
-
-struct xkb_group_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- int32_t group;
-};
-
-struct xkb_controls_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- enum xkb_action_controls ctrls;
-};
-
-struct xkb_pointer_default_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- int8_t value;
-};
-
-struct xkb_switch_screen_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- int8_t screen;
-};
-
-struct xkb_redirect_key_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- xkb_keycode_t new_kc;
- uint8_t mods_mask;
- uint8_t mods;
- uint16_t vmods_mask;
- uint16_t vmods;
-};
-
-struct xkb_pointer_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- int16_t x;
- int16_t y;
-};
-
-struct xkb_pointer_button_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- uint8_t count;
- int8_t button;
-};
-
-struct xkb_private_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- uint8_t data[7];
-};
-
-union xkb_action {
- enum xkb_action_type type;
- struct xkb_mod_action mods;
- struct xkb_group_action group;
- struct xkb_controls_action ctrls;
- struct xkb_pointer_default_action dflt;
- struct xkb_switch_screen_action screen;
- struct xkb_redirect_key_action redirect; /* XXX wholly unnecessary? */
- struct xkb_pointer_action ptr;
- struct xkb_pointer_button_action btn;
- struct xkb_private_action priv;
-};
-
-struct xkb_kt_map_entry {
- xkb_level_index_t level;
- struct xkb_mods mods;
- struct xkb_mods preserve;
-};
-
-struct xkb_key_type {
- struct xkb_mods mods;
- xkb_level_index_t num_levels;
- struct xkb_kt_map_entry *map;
- unsigned int num_entries;
- xkb_atom_t name;
- xkb_atom_t *level_names;
-};
-
-struct xkb_sym_interpret {
- xkb_keysym_t sym;
- bool repeat;
- enum xkb_match_operation match;
- uint8_t mods;
- xkb_mod_index_t virtual_mod;
- union xkb_action act;
-};
-
-struct xkb_indicator_map {
- xkb_atom_t name;
- enum xkb_state_component which_groups;
- uint32_t groups;
- enum xkb_state_component which_mods;
- struct xkb_mods mods;
- enum xkb_action_controls ctrls;
-};
-
-struct xkb_key_alias {
- char real[XKB_KEY_NAME_LENGTH];
- char alias[XKB_KEY_NAME_LENGTH];
-};
-
-struct xkb_controls {
- unsigned char groups_wrap;
- struct xkb_mods internal;
- struct xkb_mods ignore_lock;
- unsigned short repeat_delay;
- unsigned short repeat_interval;
- unsigned short slow_keys_delay;
- unsigned short debounce_delay;
- unsigned short ax_options;
- unsigned short ax_timeout;
- unsigned short axt_opts_mask;
- unsigned short axt_opts_values;
- unsigned int axt_ctrls_mask;
- unsigned int axt_ctrls_values;
-};
-
-/* Such an awkward name. Oh well. */
-enum xkb_range_exceed_type {
- RANGE_SATURATE,
- RANGE_WRAP,
- RANGE_REDIRECT,
-};
-
-enum xkb_explicit_components {
- EXPLICIT_INTERP = (1 << 0),
- EXPLICIT_VMODMAP = (1 << 1),
- EXPLICIT_REPEAT = (1 << 2),
-};
-
-struct xkb_key {
- char name[XKB_KEY_NAME_LENGTH];
-
- enum xkb_explicit_components explicit;
- xkb_group_mask_t explicit_groups;
-
- unsigned char modmap;
- xkb_mod_mask_t vmodmap;
-
- bool repeats;
-
- union xkb_action *actions;
-
- unsigned kt_index[XKB_NUM_GROUPS];
-
- xkb_group_index_t num_groups;
- /* How many levels the largest group has. */
- xkb_level_index_t width;
-
- enum xkb_range_exceed_type out_of_range_group_action;
- xkb_group_index_t out_of_range_group_number;
-
- /* per level/group index into 'syms' */
- int *sym_index;
- /* per level/group */
- unsigned int *num_syms;
- xkb_keysym_t *syms;
-};
-
-/* Common keyboard description structure */
-struct xkb_keymap {
- struct xkb_context *ctx;
-
- int refcnt;
- enum xkb_map_compile_flags flags;
-
- unsigned int enabled_ctrls;
-
- xkb_keycode_t min_key_code;
- xkb_keycode_t max_key_code;
-
- darray(struct xkb_key) keys;
-
- /* aliases in no particular order */
- darray(struct xkb_key_alias) key_aliases;
-
- struct xkb_key_type *types;
- unsigned int num_types;
-
- darray(struct xkb_sym_interpret) sym_interpret;
-
- /* vmod -> mod mapping */
- xkb_mod_mask_t vmods[XKB_NUM_VIRTUAL_MODS];
- xkb_atom_t vmod_names[XKB_NUM_VIRTUAL_MODS];
-
- /* Number of groups in the key with the most groups. */
- xkb_group_index_t num_groups;
- xkb_atom_t group_names[XKB_NUM_GROUPS];
-
- struct xkb_indicator_map indicators[XKB_NUM_INDICATORS];
-
- char *keycodes_section_name;
- char *symbols_section_name;
- char *types_section_name;
- char *compat_section_name;
-};
-
-static inline const struct xkb_key *
-XkbKey(struct xkb_keymap *keymap, xkb_keycode_t kc)
-{
- if (kc < keymap->min_key_code || kc > keymap->max_key_code)
- return NULL;
- return &darray_item(keymap->keys, kc);
-}
-
-static inline xkb_keycode_t
-XkbKeyGetKeycode(struct xkb_keymap *keymap, const struct xkb_key *key)
-{
- /* Hack to avoid having to keep the keycode inside the xkb_key. */
- return (xkb_keycode_t)(key - keymap->keys.item);
-}
-
-#define xkb_foreach_key(iter, keymap) \
- darray_foreach(iter, keymap->keys)
-
-static inline struct xkb_key_type *
-XkbKeyType(struct xkb_keymap *keymap, const struct xkb_key *key,
- xkb_group_index_t group)
-{
- return &keymap->types[key->kt_index[group]];
-}
-
-static inline xkb_level_index_t
-XkbKeyGroupWidth(struct xkb_keymap *keymap, const struct xkb_key *key,
- xkb_group_index_t group)
-{
- return XkbKeyType(keymap, key, group)->num_levels;
-}
-
-static inline unsigned int
-XkbKeyNumSyms(const struct xkb_key *key, xkb_group_index_t group,
- xkb_level_index_t level)
-{
- return key->num_syms[group * key->width + level];
-}
-
-static inline const xkb_keysym_t *
-XkbKeySymEntry(const struct xkb_key *key, xkb_group_index_t group,
- xkb_level_index_t level)
-{
- return &key->syms[key->sym_index[group * key->width + level]];
-}
-
-static inline const union xkb_action *
-XkbKeyActionEntry(const struct xkb_key *key, xkb_group_index_t group,
- xkb_level_index_t level)
-{
- return &key->actions[key->width * group + level];
-}
-
-struct xkb_keymap *
-xkb_map_new(struct xkb_context *ctx);
-
-/*
- * Returns XKB_ATOM_NONE if @string was not previously interned,
- * otherwise returns the atom.
- */
-xkb_atom_t
-xkb_atom_lookup(struct xkb_context *ctx, const char *string);
-
-xkb_atom_t
-xkb_atom_intern(struct xkb_context *ctx, const char *string);
-
-/**
- * If @string is dynamically allocated, free'd immediately after
- * being interned, and not used afterwards, use this function
- * instead of xkb_atom_intern to avoid some unnecessary allocations.
- * The caller should not use or free the passed in string afterwards.
- */
-xkb_atom_t
-xkb_atom_steal(struct xkb_context *ctx, char *string);
-
-char *
-xkb_atom_strdup(struct xkb_context *ctx, xkb_atom_t atom);
-
-const char *
-xkb_atom_text(struct xkb_context *ctx, xkb_atom_t atom);
-
-xkb_group_index_t
-xkb_key_get_group(struct xkb_state *state, const struct xkb_key *key);
-
-xkb_level_index_t
-xkb_key_get_level(struct xkb_state *state, const struct xkb_key *key,
- xkb_group_index_t group);
-
-extern int
-xkb_key_get_syms_by_level(struct xkb_keymap *keymap,
- const struct xkb_key *key,
- xkb_group_index_t group, xkb_level_index_t level,
- const xkb_keysym_t **syms_out);
-
-extern unsigned
-xkb_context_take_file_id(struct xkb_context *ctx);
-
-unsigned int
-xkb_context_num_failed_include_paths(struct xkb_context *ctx);
-
-const char *
-xkb_context_failed_include_path_get(struct xkb_context *ctx,
- unsigned int idx);
-
-bool
-xkb_keysym_is_lower(xkb_keysym_t keysym);
-
-bool
-xkb_keysym_is_upper(xkb_keysym_t keysym);
-
-bool
-xkb_keysym_is_keypad(xkb_keysym_t keysym);
-
-ATTR_PRINTF(3, 4) void
-xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
- const char *fmt, ...);
-
-#define xkb_log_cond_level(ctx, level, ...) do { \
- if (xkb_get_log_level(ctx) >= (level)) \
- xkb_log((ctx), (level), __VA_ARGS__); \
-} while (0)
-
-#define xkb_log_cond_verbosity(ctx, level, vrb, ...) do { \
- if (xkb_get_log_verbosity(ctx) >= (vrb)) \
- xkb_log_cond_level((ctx), (level), __VA_ARGS__); \
-} while (0)
-
-/*
- * The format is not part of the argument list in order to avoid the
- * "ISO C99 requires rest arguments to be used" warning when only the
- * format is supplied without arguments. Not supplying it would still
- * result in an error, though.
- */
-#define log_dbg(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_DEBUG, __VA_ARGS__)
-#define log_info(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_INFO, __VA_ARGS__)
-#define log_warn(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_WARNING, __VA_ARGS__)
-#define log_err(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_ERROR, __VA_ARGS__)
-#define log_wsgo(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_CRITICAL, __VA_ARGS__)
-#define log_vrb(ctx, vrb, ...) \
- xkb_log_cond_verbosity((ctx), XKB_LOG_LEVEL_WARNING, (vrb), __VA_ARGS__)
-
-#endif /* XKB_PRIV_H */
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index cd4c1a3..badbbf2 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -47,8 +47,6 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <stdarg.h>
-#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index fce0dd3..9c4fb1c 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -58,6 +58,7 @@
#include "vmod.h"
#include "keycodes.h"
#include "include.h"
+#include "keysym.h"
enum key_repeat {
KEY_REPEAT_UNDEFINED = 0,
diff --git a/src/xkbcomp/xkbcomp-priv.h b/src/xkbcomp/xkbcomp-priv.h
index 6175f69..a06b4d4 100644
--- a/src/xkbcomp/xkbcomp-priv.h
+++ b/src/xkbcomp/xkbcomp-priv.h
@@ -27,9 +27,16 @@
#ifndef XKBCOMP_PRIV_H
#define XKBCOMP_PRIV_H
-#include "xkb-priv.h"
+#include "map.h"
#include "ast.h"
+struct xkb_component_names {
+ char *keycodes;
+ char *types;
+ char *compat;
+ char *symbols;
+};
+
bool
XkbParseFile(struct xkb_context *ctx, FILE *file, const char *file_name,
XkbFile **out);
diff --git a/test/common.c b/test/common.c
index 3049555..372c642 100644
--- a/test/common.c
+++ b/test/common.c
@@ -30,17 +30,12 @@
* Ran Benita <ran234@gmail.com>
*/
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
#include <limits.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include "xkbcommon/xkbcommon.h"
#include "test.h"
const char *
diff --git a/test/context.c b/test/context.c
index d6acd05..e151dd0 100644
--- a/test/context.c
+++ b/test/context.c
@@ -23,10 +23,8 @@
* Author: Daniel Stone <daniel@fooishbar.org>
*/
-#include <assert.h>
-
-#include "xkbcommon/xkbcommon.h"
#include "test.h"
+#include "context.h"
int
main(void)
diff --git a/test/filecomp.c b/test/filecomp.c
index c3a425c..dca4fe5 100644
--- a/test/filecomp.c
+++ b/test/filecomp.c
@@ -21,11 +21,6 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "xkbcommon/xkbcommon.h"
#include "test.h"
static int
diff --git a/test/interactive.c b/test/interactive.c
index d132d15..332f57c 100644
--- a/test/interactive.c
+++ b/test/interactive.c
@@ -28,9 +28,6 @@
#include <limits.h>
#include <locale.h>
#include <signal.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
@@ -38,7 +35,6 @@
#include <sys/epoll.h>
#include <linux/input.h>
-#include "xkbcommon/xkbcommon.h"
#include "test.h"
struct keyboard {
diff --git a/test/keyseq.c b/test/keyseq.c
index c7d0918..33510c3 100644
--- a/test/keyseq.c
+++ b/test/keyseq.c
@@ -21,13 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <assert.h>
-#include <stdarg.h>
-#include <stdio.h>
-
#include <linux/input.h>
-#include "xkbcommon/xkbcommon.h"
#include "test.h"
enum {
diff --git a/test/keysym.c b/test/keysym.c
index ba22d55..1bf704b 100644
--- a/test/keysym.c
+++ b/test/keysym.c
@@ -21,10 +21,6 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "test.h"
static int
diff --git a/test/log.c b/test/log.c
index bad2cb2..cf59045 100644
--- a/test/log.c
+++ b/test/log.c
@@ -21,13 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <assert.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "test.h"
-#include "xkb-priv.h"
+#include "context.h"
#pragma GCC diagnostic ignored "-Wmissing-format-attribute"
diff --git a/test/rmlvo-to-kccgst.c b/test/rmlvo-to-kccgst.c
index ec2c0c4..338cbb8 100644
--- a/test/rmlvo-to-kccgst.c
+++ b/test/rmlvo-to-kccgst.c
@@ -24,7 +24,7 @@
#include <unistd.h>
#include "test.h"
-#include "xkb-priv.h"
+#include "xkbcomp-priv.h"
#include "rules.h"
int
diff --git a/test/rules-file.c b/test/rules-file.c
index 5ddd074..b2091de 100644
--- a/test/rules-file.c
+++ b/test/rules-file.c
@@ -21,14 +21,10 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <assert.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <string.h>
#include <time.h>
#include "test.h"
-#include "xkb-priv.h"
+#include "xkbcomp-priv.h"
#include "rules.h"
#define BENCHMARK_ITERATIONS 20000
diff --git a/test/rulescomp.c b/test/rulescomp.c
index 3b4de26..5457d00 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -21,11 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <assert.h>
-#include <stdio.h>
#include <time.h>
-#include "xkbcommon/xkbcommon.h"
#include "test.h"
#define BENCHMARK_ITERATIONS 1000
diff --git a/test/test.h b/test/test.h
index a3fdee0..2a9b0fa 100644
--- a/test/test.h
+++ b/test/test.h
@@ -23,6 +23,8 @@
* Author: Daniel Stone <daniel@fooishbar.org>
*/
+#include <assert.h>
+
#include "xkbcommon/xkbcommon.h"
#include "utils.h"
diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h
index 8c6ab72..f741837 100644
--- a/xkbcommon/xkbcommon.h
+++ b/xkbcommon/xkbcommon.h
@@ -80,7 +80,6 @@
#ifndef _XKBCOMMON_H_
#define _XKBCOMMON_H_
-#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>