summaryrefslogtreecommitdiffstats
path: root/kxkb/rules.cpp
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2023-01-06 15:30:57 +0200
committerMavridis Philippe <mavridisf@gmail.com>2023-03-24 15:28:11 +0200
commita67db2d4847d798c01d4fd7584c5bb9297e109e3 (patch)
tree6cb5bb70f6201fa62dec021b92e838d32a6036ec /kxkb/rules.cpp
parentb50ab13974adf6f16d72f172f0cf768a44c161da (diff)
downloadtdebase-a67db2d4847d798c01d4fd7584c5bb9297e109e3.tar.gz
tdebase-a67db2d4847d798c01d4fd7584c5bb9297e109e3.zip
Kxkb: Improve layout switching
1) New layout switching approach The new approach is based on the "grp" options group of Xkb and so enables us to use predefined X11 layout (group) switching hotkeys like "Caps Lock" or "Shift+Alt" (you can see the full list in the Options tab). The added bonus to this is that we conform to the Xkb setting. The code lets Xkb handle the keyboard layout switching hotkey(s) and is similar to the one that is used in kkbswitch, monitoring for an Xkb group (layout) change event. This solution required me to remove some hacky and obsolete code which was there to support really old pre-XFree-4.2 era systems and included the "include groups" hack. This means that the "Enable latin layout" checkbox is now gone and setxkbmap is only called when the keyboard layouts and/or options are modified, and not for every layout change. 2) Common layout switching hotkeys combobox A combobox was added to the first page of the Keyboard Layouts KCM module. It provides to the users a quick way to set a layout switching key combination. It also controls the "grp" group in the Xkb tab. A special note about this combobox is that, even if Append Mode was selected in the Xkb Options tab, this hotkey will overwrite previous hotkey options. This means that all grp: options will be forced removed before applying the option from the combobox (in contrast to specifying options via the Xkb Options tab, which, in Append Mode, will not get overwritten until next login). Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'kxkb/rules.cpp')
-rw-r--r--kxkb/rules.cpp83
1 files changed, 1 insertions, 82 deletions
diff --git a/kxkb/rules.cpp b/kxkb/rules.cpp
index 20f817602..37cdc9bc4 100644
--- a/kxkb/rules.cpp
+++ b/kxkb/rules.cpp
@@ -35,8 +35,6 @@ XkbRules::XkbRules(bool layoutsOnly):
}
loadRules(rulesFile, layoutsOnly);
- loadOldLayouts(rulesFile);
- loadGroups(::locate("config", "kxkb_groups"));
}
@@ -58,84 +56,6 @@ void XkbRules::loadRules(TQString file, bool layoutsOnly)
// fixLayouts();
}
-// void XkbRules::fixLayouts() {
-// // THIS IS TEMPORARY!!!
-// // This should be fixed in XFree86 (and actually is fixed in XFree 4.2)
-// // some handcoded ones, because the X11 rule file doesn't get them correctly, or in case
-// // the rule file wasn't found
-// static struct {
-// const char * locale;
-// const char * layout;
-// } fixedLayouts[] = {
-// { "ben", "Bengali" },
-// { "ar", "Arabic" },
-// { "ir", "Farsi" },
-// { 0, 0 }
-// };
-//
-// for(int i=0; fixedLayouts[i].layout != 0; i++ ) {
-// if( m_layouts.find(fixedLayouts[i].locale) == 0 )
-// m_layouts.insert(fixedLayouts[i].locale, fixedLayouts[i].layout);
-// }
-// }
-
-bool XkbRules::isSingleGroup(const TQString& layout)
-{
- return X11Helper::areSingleGroupsSupported()
- && !m_oldLayouts.contains(layout)
- && !m_nonLatinLayouts.contains(layout);
-}
-
-
-// check $oldlayouts and $nonlatin groups for XFree 4.3 and later
-void XkbRules::loadOldLayouts(TQString rulesFile)
-{
- OldLayouts* oldLayoutsStruct = X11Helper::loadOldLayouts( rulesFile );
- m_oldLayouts = oldLayoutsStruct->oldLayouts;
- m_nonLatinLayouts = oldLayoutsStruct->nonLatinLayouts;
-}
-
-// for multi-group layouts in XFree 4.2 and older
-// or if layout is present in $oldlayout or $nonlatin groups
-void XkbRules::loadGroups(TQString file)
-{
- TQFile f(file);
- if (f.open(IO_ReadOnly))
- {
- TQTextStream ts(&f);
- TQString locale;
- unsigned int grp;
-
- while (!ts.eof()) {
- ts >> locale >> grp;
- locale.simplifyWhiteSpace();
-
- if (locale[0] == '#' || locale.left(2) == "//" || locale.isEmpty())
- continue;
-
- m_initialGroups.insert(locale, grp);
- }
-
- f.close();
- }
-}
-
-unsigned int
-XkbRules::getDefaultGroup(const TQString& layout, const TQString& includeGroup)
-{
-// check for new one-group layouts in XFree 4.3 and older
- if( isSingleGroup(layout) ) {
- if( includeGroup.isEmpty() == false )
- return 1;
- else
- return 0;
- }
-
- TQMap<TQString, unsigned int>::iterator it = m_initialGroups.find(layout);
- return it == m_initialGroups.end() ? 0 : it.data();
-}
-
-
TQStringList
XkbRules::getAvailableVariants(const TQString& layout)
{
@@ -146,8 +66,7 @@ XkbRules::getAvailableVariants(const TQString& layout)
if( result1 )
return *result1;
- bool oldLayouts = m_oldLayouts.contains(layout);
- TQStringList* result = X11Helper::getVariants(layout, X11_DIR, oldLayouts);
+ TQStringList* result = X11Helper::getVariants(layout, X11_DIR);
m_varLists.insert(layout, result);