forked from nonpop/xkblayout-state
-
Notifications
You must be signed in to change notification settings - Fork 0
/
XKeyboard.h
96 lines (74 loc) · 2.7 KB
/
XKeyboard.h
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
// xkeyboard.h
// Interface for a class to get keyboard layout information and change layouts
// Copyright (C) 2008 by Jay Bromley <jbromley@gmail.com>
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
//
// $Id: XKeyboard.h 29 2008-04-09 21:37:44Z jay $
//
// 2010-01-02 Kristian Setälä added code to retrieve layout variant information
#ifndef XKEYBOARD_H_1C79861A_49B3_4A95_88D6_455C22FEB222
#define XKEYBOARD_H_1C79861A_49B3_4A95_88D6_455C22FEB222
#include <vector>
#include <string>
#include <iostream>
#include <X11/Xlib.h>
typedef std::vector<std::string> StringVector;
// XKeyboard -----------------------------------------------------------
class XKeyboard
{
public:
XKeyboard();
~XKeyboard();
int groupCount() const;
StringVector groupNames() const;
StringVector groupSymbols() const;
StringVector groupVariants() const;
int currentGroupNum() const;
std::string currentGroupName() const;
std::string currentGroupSymbol() const;
std::string currentGroupVariant() const;
bool setGroupByNum(int groupNum);
bool changeGroup(int increment);
//friend std::ostream& operator<<(std::ostream& os, const XKeyboard& xkb);
private:
Bool initializeXkb();
std::string getSymbolNameByResNum(int groupResNum);
int groupNumResToXkb(int groupNumRes);
std::string getGroupNameByResNum(int groupResNum);
int groupLookup(int srcValue, StringVector fromText, StringVector toText, int count);
void accomodateGroupXkb();
Display* _display;
int _groupCount;
StringVector _groupNames;
StringVector _symbolNames;
StringVector _variantNames;
int _currentGroupNum;
int _deviceId;
int _baseEventCode;
int _baseErrorCode;
};
// XkbSymbolParser -----------------------------------------------------
class XkbSymbolParser
{
public:
typedef std::vector<std::string>::iterator StringVectorIter;
XkbSymbolParser();
~XkbSymbolParser();
void parse(const std::string& symbols, std::vector<std::string>& symbolList,
std::vector<std::string>& variantList);
private:
bool isXkbLayoutSymbol(const std::string& symbol);
StringVector _nonSymbols;
};
// Helper functions ----------------------------------------------------
int compareNoCase(const std::string& s1, const std::string& s2);
// std::ostream& operator<<(std::ostream& os, const XKeyboard& xkb);
// std::ostream& operator<<(std::ostream& os, const StringVector& v);
#endif // XKEYBOARD_H_1C79861A_49B3_4A95_88D6_455C22FEB222
// Local Variables:
// mode: c++
// End: