summaryrefslogtreecommitdiffstats
path: root/src/VButton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VButton.cpp')
-rw-r--r--src/VButton.cpp97
1 files changed, 74 insertions, 23 deletions
diff --git a/src/VButton.cpp b/src/VButton.cpp
index 1959990..95d31e2 100644
--- a/src/VButton.cpp
+++ b/src/VButton.cpp
@@ -28,61 +28,112 @@ void VButton::setupTexts(Display *display)
{
// normal text
KeySym keysym_c = XkbKeycodeToKeysym(display, keycode, 0, 0);
- TQChar c((uint)keysym2ucs(keysym_c));
- if (c == '&')
+ TQChar nc((uint)keysym2ucs(keysym_c));
+ if (nc == '&')
{
setText("&&");
}
else
{
- setText(c);
+ setText(nc);
}
// shift text
keysym_c = XkbKeycodeToKeysym(display, keycode, 0, 1);
+ TQChar sc = (uint)keysym2ucs(keysym_c);
+ if (sc == '&')
+ {
+ setShiftText("&&");
+ }
+ else
+ {
+ setShiftText(sc);
+ }
+
+ // altGr text
+ keysym_c = XkbKeycodeToKeysym(display, keycode, 0, 2);
+ TQChar c = (uint)keysym2ucs(keysym_c);
+ if (c == " ")
+ {
+ // use normal text in case altGr does not provide extra characters.
+ // This is required at least on US keyboards, where altGr works as Alt.
+ c = nc;
+ }
+ if (c == '&')
+ {
+ altGrText = "&&";
+ }
+ else
+ {
+ altGrText = c;
+ }
+
+ // altGr + shift text
+ keysym_c = XkbKeycodeToKeysym(display, keycode, 0, 3);
c = (uint)keysym2ucs(keysym_c);
+ if (c == " ")
+ {
+ // use shift text in case altGr does not provide extra characters.
+ // This is required at least on US keyboards, where altGr works as Alt.
+ c = sc;
+ }
if (c == '&')
{
- setShiftText("&&");
+ altGrShiftText = "&&";
}
else
{
- setShiftText(c);
+ altGrShiftText = c;
}
}
-void VButton::shiftCapsPressed(bool shift, bool caps)
+void VButton::shiftCapsAltGrPressed(bool shift, bool caps, bool altGrState)
{
- if (isAlpha)
+ if (altGrState)
{
- // Alpha button, both shift and caps affect its state
- if (caps && shift)
- {
- TQPushButton::setText(capsShiftText);
- }
- else if (caps)
- {
- TQPushButton::setText(capsText);
- }
- else if (shift)
+ // Caps does not seem to make any difference when AltGr is pressed
+ if (shift)
{
- TQPushButton::setText(shiftText);
+ TQPushButton::setText(altGrShiftText);
}
else
{
- TQPushButton::setText(normalText);
+ TQPushButton::setText(altGrText);
}
}
else
{
- // Non alpha button, only shift affects its state
- if (shift)
+ if (isAlpha)
{
- TQPushButton::setText(shiftText);
+ // Alpha button, both shift and caps affect its state
+ if (caps && shift)
+ {
+ TQPushButton::setText(capsShiftText);
+ }
+ else if (caps)
+ {
+ TQPushButton::setText(capsText);
+ }
+ else if (shift)
+ {
+ TQPushButton::setText(shiftText);
+ }
+ else
+ {
+ TQPushButton::setText(normalText);
+ }
}
else
{
- TQPushButton::setText(normalText);
+ // Non alpha button, only shift affects its state
+ if (shift)
+ {
+ TQPushButton::setText(shiftText);
+ }
+ else
+ {
+ TQPushButton::setText(normalText);
+ }
}
}
}