aboutsummaryrefslogtreecommitdiff
path: root/src/CommandDialog.cc
diff options
context:
space:
mode:
authormathias <mathias>2005-05-06 09:22:53 (GMT)
committermathias <mathias>2005-05-06 09:22:53 (GMT)
commit6c057c6903151aab92309310087d5af455ecefce (patch)
tree1d4c98ad1637df09b89593b3e6a4a70245db4602 /src/CommandDialog.cc
parent7d4f711204ab0b51d45eaff332708f529c11c9f5 (diff)
downloadfluxbox_pavel-6c057c6903151aab92309310087d5af455ecefce.zip
fluxbox_pavel-6c057c6903151aab92309310087d5af455ecefce.tar.bz2
Fix for #1160244, #1099704, #1094107:
if the xkb-extension is enabled and the user switches between his/her keyboardlayouts fluxbox's keybhandling doesn't work well anymore because xkeyevent.state contains also xkb-related flags and thus we have to handle that with caution. KeyUtils now contain 'isolateModifierMask()' to really work only on the modifiers. why not as part of cleanMods() ? because the XLookupString return false results, eg TextBox's would only print chars from the first keyboardlayout.
Diffstat (limited to 'src/CommandDialog.cc')
-rw-r--r--src/CommandDialog.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc
index 317f7ef..80c8962 100644
--- a/src/CommandDialog.cc
+++ b/src/CommandDialog.cc
@@ -33,6 +33,7 @@
33#include "FbTk/ImageControl.hh" 33#include "FbTk/ImageControl.hh"
34#include "FbTk/EventManager.hh" 34#include "FbTk/EventManager.hh"
35#include "FbTk/StringUtil.hh" 35#include "FbTk/StringUtil.hh"
36#include "FbTk/KeyUtil.hh"
36#include "FbTk/App.hh" 37#include "FbTk/App.hh"
37 38
38#include <X11/keysym.h> 39#include <X11/keysym.h>
@@ -43,11 +44,11 @@
43#include <stdexcept> 44#include <stdexcept>
44using namespace std; 45using namespace std;
45 46
46CommandDialog::CommandDialog(BScreen &screen, 47CommandDialog::CommandDialog(BScreen &screen,
47 const std::string &title, const std::string precommand) : 48 const std::string &title, const std::string precommand) :
48 FbTk::FbWindow(screen.rootWindow().screenNumber(), 0, 0, 200, 1, ExposureMask), 49 FbTk::FbWindow(screen.rootWindow().screenNumber(), 0, 0, 200, 1, ExposureMask),
49 m_textbox(*this, screen.winFrameTheme().font(), ""), 50 m_textbox(*this, screen.winFrameTheme().font(), ""),
50 m_label(*this, screen.winFrameTheme().font(), title), 51 m_label(*this, screen.winFrameTheme().font(), title),
51 m_gc(m_textbox), 52 m_gc(m_textbox),
52 m_screen(screen), 53 m_screen(screen),
53 m_move_x(0), 54 m_move_x(0),
@@ -121,12 +122,13 @@ void CommandDialog::motionNotifyEvent(XMotionEvent &event) {
121} 122}
122 123
123void CommandDialog::keyPressEvent(XKeyEvent &event) { 124void CommandDialog::keyPressEvent(XKeyEvent &event) {
124 if (event.state) 125 unsigned int state = FbTk::KeyUtil::instance().isolateModifierMask(event.state);
126 if (state)
125 return; 127 return;
126 128
127 KeySym ks; 129 KeySym ks;
128 char keychar[1]; 130 char keychar;
129 XLookupString(&event, keychar, 1, &ks, 0); 131 XLookupString(&event, &keychar, 1, &ks, 0);
130 132
131 if (ks == XK_Return) { 133 if (ks == XK_Return) {
132 hide(); // hide and return focus to a FluxboxWindow 134 hide(); // hide and return focus to a FluxboxWindow
@@ -135,7 +137,7 @@ void CommandDialog::keyPressEvent(XKeyEvent &event) {
135 parseLine(m_precommand + m_textbox.text())); 137 parseLine(m_precommand + m_textbox.text()));
136 if (cmd.get()) 138 if (cmd.get())
137 cmd->execute(); 139 cmd->execute();
138 // post execute 140 // post execute
139 if (*m_postcommand != 0) 141 if (*m_postcommand != 0)
140 m_postcommand->execute(); 142 m_postcommand->execute();
141 143
@@ -152,7 +154,7 @@ void CommandDialog::tabComplete() {
152 try { 154 try {
153 string::size_type first = m_textbox.text().find_last_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ" 155 string::size_type first = m_textbox.text().find_last_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
154 "abcdefghijklmnopqrstuvwxyz" 156 "abcdefghijklmnopqrstuvwxyz"
155 "0123456789", 157 "0123456789",
156 m_textbox.cursorPosition()); 158 m_textbox.cursorPosition());
157 if (first == string::npos) 159 if (first == string::npos)
158 first = 0; 160 first = 0;
@@ -173,7 +175,7 @@ void CommandDialog::tabComplete() {
173 175
174 if (!matches.empty()) { 176 if (!matches.empty()) {
175 // sort and apply larges match 177 // sort and apply larges match
176 std::sort(matches.begin(), matches.end(), less<string>()); 178 std::sort(matches.begin(), matches.end(), less<string>());
177 m_textbox.setText(m_textbox.text() + matches[0].substr(prefix.size())); 179 m_textbox.setText(m_textbox.text() + matches[0].substr(prefix.size()));
178 } else 180 } else
179 XBell(FbTk::App::instance()->display(), 0); 181 XBell(FbTk::App::instance()->display(), 0);
@@ -204,7 +206,7 @@ void CommandDialog::init() {
204 206
205 // setup label 207 // setup label
206 // we listen to motion notify too 208 // we listen to motion notify too
207 m_label.setEventMask(m_label.eventMask() | ButtonPressMask | ButtonMotionMask); 209 m_label.setEventMask(m_label.eventMask() | ButtonPressMask | ButtonMotionMask);
208 m_label.setGC(m_screen.winFrameTheme().labelTextFocusGC()); 210 m_label.setGC(m_screen.winFrameTheme().labelTextFocusGC());
209 m_label.show(); 211 m_label.show();
210 212
@@ -234,7 +236,7 @@ void CommandDialog::init() {
234void CommandDialog::updateSizes() { 236void CommandDialog::updateSizes() {
235 m_label.moveResize(0, 0, 237 m_label.moveResize(0, 0,
236 width(), m_textbox.font().height() + 2); 238 width(), m_textbox.font().height() + 2);
237 239
238 m_textbox.moveResize(2, m_label.height(), 240 m_textbox.moveResize(2, m_label.height(),
239 width() - 4, m_textbox.font().height() + 2); 241 width() - 4, m_textbox.font().height() + 2);
240} 242}