diff options
author | Henrik Kinnunen <fluxgen@fluxbox.org> | 2008-09-28 08:53:16 (GMT) |
---|---|---|
committer | Henrik Kinnunen <fluxgen@fluxbox.org> | 2008-09-28 08:53:16 (GMT) |
commit | f2c8868724ebcaa6afaac4a71093f77b7eeaa23f (patch) | |
tree | e64111d54d58f819e261f4fa552fae8e111b30e8 /src/FbTk | |
parent | bcf37890b617730cfded161b9a3d18f7c377e724 (diff) | |
parent | 04a1d2a83b96eb6d1b1958e4f3e25ffdf295aa4d (diff) | |
download | fluxbox_paul-f2c8868724ebcaa6afaac4a71093f77b7eeaa23f.zip fluxbox_paul-f2c8868724ebcaa6afaac4a71093f77b7eeaa23f.tar.bz2 |
Merge branch 'master' of fluxbox@git.fluxbox.org:fluxbox
Conflicts:
ChangeLog
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/EventHandler.hh | 1 | ||||
-rw-r--r-- | src/FbTk/EventManager.cc | 23 | ||||
-rw-r--r-- | src/FbTk/EventManager.hh | 3 | ||||
-rw-r--r-- | src/FbTk/Menu.cc | 9 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 2 | ||||
-rw-r--r-- | src/FbTk/Shape.cc | 7 | ||||
-rw-r--r-- | src/FbTk/TextBox.cc | 111 |
7 files changed, 60 insertions, 96 deletions
diff --git a/src/FbTk/EventHandler.hh b/src/FbTk/EventHandler.hh index 39ea294..b78e344 100644 --- a/src/FbTk/EventHandler.hh +++ b/src/FbTk/EventHandler.hh | |||
@@ -56,7 +56,6 @@ public: | |||
56 | virtual void leaveNotifyEvent(XCrossingEvent &) { } | 56 | virtual void leaveNotifyEvent(XCrossingEvent &) { } |
57 | virtual void enterNotifyEvent(XCrossingEvent &) { } | 57 | virtual void enterNotifyEvent(XCrossingEvent &) { } |
58 | 58 | ||
59 | virtual void notifyUngrabKeyboard() { } | ||
60 | virtual void grabButtons() { } | 59 | virtual void grabButtons() { } |
61 | }; | 60 | }; |
62 | 61 | ||
diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc index 31d0293..ae52908 100644 --- a/src/FbTk/EventManager.cc +++ b/src/FbTk/EventManager.cc | |||
@@ -65,25 +65,14 @@ EventHandler *EventManager::find(Window win) { | |||
65 | return m_eventhandlers[win]; | 65 | return m_eventhandlers[win]; |
66 | } | 66 | } |
67 | 67 | ||
68 | bool EventManager::grabKeyboard(EventHandler &ev, Window win) { | 68 | bool EventManager::grabKeyboard(Window win) { |
69 | if (m_grabbing_keyboard) | ||
70 | ungrabKeyboard(); | ||
71 | |||
72 | int ret = XGrabKeyboard(App::instance()->display(), win, False, | 69 | int ret = XGrabKeyboard(App::instance()->display(), win, False, |
73 | GrabModeAsync, GrabModeAsync, CurrentTime); | 70 | GrabModeAsync, GrabModeAsync, CurrentTime); |
74 | 71 | return (ret == Success); | |
75 | if (ret == Success) { | ||
76 | m_grabbing_keyboard = &ev; | ||
77 | return true; | ||
78 | } | ||
79 | return false; | ||
80 | } | 72 | } |
81 | 73 | ||
82 | void EventManager::ungrabKeyboard() { | 74 | void EventManager::ungrabKeyboard() { |
83 | XUngrabKeyboard(App::instance()->display(), CurrentTime); | 75 | XUngrabKeyboard(App::instance()->display(), CurrentTime); |
84 | if (m_grabbing_keyboard) | ||
85 | m_grabbing_keyboard->notifyUngrabKeyboard(); | ||
86 | m_grabbing_keyboard = 0; | ||
87 | } | 76 | } |
88 | 77 | ||
89 | Window EventManager::getEventWindow(XEvent &ev) { | 78 | Window EventManager::getEventWindow(XEvent &ev) { |
@@ -190,10 +179,14 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) { | |||
190 | evhand->exposeEvent(ev.xexpose); | 179 | evhand->exposeEvent(ev.xexpose); |
191 | break; | 180 | break; |
192 | case EnterNotify: | 181 | case EnterNotify: |
193 | evhand->enterNotifyEvent(ev.xcrossing); | 182 | if (ev.xcrossing.mode != NotifyGrab && |
183 | ev.xcrossing.mode != NotifyUngrab) | ||
184 | evhand->enterNotifyEvent(ev.xcrossing); | ||
194 | break; | 185 | break; |
195 | case LeaveNotify: | 186 | case LeaveNotify: |
196 | evhand->leaveNotifyEvent(ev.xcrossing); | 187 | if (ev.xcrossing.mode != NotifyGrab && |
188 | ev.xcrossing.mode != NotifyUngrab) | ||
189 | evhand->leaveNotifyEvent(ev.xcrossing); | ||
197 | break; | 190 | break; |
198 | default: | 191 | default: |
199 | evhand->handleEvent(ev); | 192 | evhand->handleEvent(ev); |
diff --git a/src/FbTk/EventManager.hh b/src/FbTk/EventManager.hh index 79a25ce..fdcfe9c 100644 --- a/src/FbTk/EventManager.hh +++ b/src/FbTk/EventManager.hh | |||
@@ -42,9 +42,8 @@ public: | |||
42 | void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); } | 42 | void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); } |
43 | void remove(Window win) { unregisterEventHandler(win); } | 43 | void remove(Window win) { unregisterEventHandler(win); } |
44 | 44 | ||
45 | bool grabKeyboard(EventHandler &ev, Window win); | 45 | bool grabKeyboard(Window win); |
46 | void ungrabKeyboard(); | 46 | void ungrabKeyboard(); |
47 | EventHandler *grabbingKeyboard() { return m_grabbing_keyboard; } | ||
48 | 47 | ||
49 | EventHandler *find(Window win); | 48 | EventHandler *find(Window win); |
50 | 49 | ||
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 7d50302..7cb5599 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -219,6 +219,8 @@ int Menu::insert(MenuItem *item, int pos) { | |||
219 | } else { | 219 | } else { |
220 | menuitems.insert(menuitems.begin() + pos, item); | 220 | menuitems.insert(menuitems.begin() + pos, item); |
221 | fixMenuItemIndices(); | 221 | fixMenuItemIndices(); |
222 | if (m_active_index >= pos) | ||
223 | m_active_index++; | ||
222 | } | 224 | } |
223 | m_need_update = true; // we need to redraw the menu | 225 | m_need_update = true; // we need to redraw the menu |
224 | return menuitems.size(); | 226 | return menuitems.size(); |
@@ -233,7 +235,7 @@ int Menu::remove(unsigned int index) { | |||
233 | if (index >= menuitems.size()) { | 235 | if (index >= menuitems.size()) { |
234 | #ifdef DEBUG | 236 | #ifdef DEBUG |
235 | cout << "Bad index (" << index << ") given to Menu::remove()" | 237 | cout << "Bad index (" << index << ") given to Menu::remove()" |
236 | << " -- should be between 0 and " << menuitems.size() | 238 | << " -- should be between 0 and " << menuitems.size()-1 |
237 | << " inclusive." << endl; | 239 | << " inclusive." << endl; |
238 | #endif // DEBUG | 240 | #endif // DEBUG |
239 | return -1; | 241 | return -1; |
@@ -271,6 +273,9 @@ int Menu::remove(unsigned int index) { | |||
271 | else if (static_cast<unsigned int>(m_which_sub) > index) | 273 | else if (static_cast<unsigned int>(m_which_sub) > index) |
272 | m_which_sub--; | 274 | m_which_sub--; |
273 | 275 | ||
276 | if (static_cast<unsigned int>(m_active_index) > index) | ||
277 | m_active_index--; | ||
278 | |||
274 | m_need_update = true; // we need to redraw the menu | 279 | m_need_update = true; // we need to redraw the menu |
275 | 280 | ||
276 | return menuitems.size(); | 281 | return menuitems.size(); |
@@ -366,7 +371,7 @@ void Menu::enableTitle() { | |||
366 | setTitleVisibility(true); | 371 | setTitleVisibility(true); |
367 | } | 372 | } |
368 | 373 | ||
369 | void Menu::updateMenu(int active_index) { | 374 | void Menu::updateMenu() { |
370 | if (m_title_vis) { | 375 | if (m_title_vis) { |
371 | menu.item_w = theme()->titleFont().textWidth(menu.label, | 376 | menu.item_w = theme()->titleFont().textWidth(menu.label, |
372 | menu.label.size()); | 377 | menu.label.size()); |
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index ee57a23..519a78b 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -109,7 +109,7 @@ public: | |||
109 | void setLabel(const FbString &labelstr); | 109 | void setLabel(const FbString &labelstr); |
110 | /// move menu to x,y | 110 | /// move menu to x,y |
111 | virtual void move(int x, int y); | 111 | virtual void move(int x, int y); |
112 | virtual void updateMenu(int active_index = -1); | 112 | virtual void updateMenu(); |
113 | void setItemSelected(unsigned int index, bool val); | 113 | void setItemSelected(unsigned int index, bool val); |
114 | void setItemEnabled(unsigned int index, bool val); | 114 | void setItemEnabled(unsigned int index, bool val); |
115 | void setMinimumSublevels(int m) { menu.minsub = m; } | 115 | void setMinimumSublevels(int m) { menu.minsub = m; } |
diff --git a/src/FbTk/Shape.cc b/src/FbTk/Shape.cc index 6cc46f8..7c14832 100644 --- a/src/FbTk/Shape.cc +++ b/src/FbTk/Shape.cc | |||
@@ -56,9 +56,9 @@ Pixmap makePixmap(FbWindow &drawable, const unsigned char rows[]) { | |||
56 | Display *disp = App::instance()->display(); | 56 | Display *disp = App::instance()->display(); |
57 | 57 | ||
58 | const size_t data_size = 8 * 8; | 58 | const size_t data_size = 8 * 8; |
59 | // we use calloc here so we get consistent C alloc/free with XDestroyImage | 59 | // we use malloc here so we get consistent C alloc/free with XDestroyImage |
60 | // and no warnings in valgrind :) | 60 | // and no warnings in valgrind :) |
61 | char *data = (char *)calloc(data_size, sizeof (char)); | 61 | char *data = (char *)malloc(data_size * sizeof (char)); |
62 | if (data == 0) | 62 | if (data == 0) |
63 | return 0; | 63 | return 0; |
64 | 64 | ||
@@ -141,6 +141,9 @@ Shape::~Shape() { | |||
141 | } | 141 | } |
142 | 142 | ||
143 | void Shape::initCorners(int screen_num) { | 143 | void Shape::initCorners(int screen_num) { |
144 | if (!m_win->window()) | ||
145 | return; | ||
146 | |||
144 | if (s_corners.size() == 0) | 147 | if (s_corners.size() == 0) |
145 | s_corners.resize(ScreenCount(App::instance()->display())); | 148 | s_corners.resize(ScreenCount(App::instance()->display())); |
146 | 149 | ||
diff --git a/src/FbTk/TextBox.cc b/src/FbTk/TextBox.cc index b8cdcde..87ad609 100644 --- a/src/FbTk/TextBox.cc +++ b/src/FbTk/TextBox.cc | |||
@@ -230,31 +230,6 @@ void TextBox::keyPressEvent(XKeyEvent &event) { | |||
230 | if ((event.state & ControlMask) == ControlMask) { | 230 | if ((event.state & ControlMask) == ControlMask) { |
231 | 231 | ||
232 | switch (ks) { | 232 | switch (ks) { |
233 | case XK_b: | ||
234 | cursorBackward(); | ||
235 | break; | ||
236 | case XK_f: | ||
237 | cursorForward(); | ||
238 | break; | ||
239 | case XK_a: | ||
240 | cursorHome(); | ||
241 | break; | ||
242 | case XK_e: | ||
243 | cursorEnd(); | ||
244 | break; | ||
245 | case XK_d: | ||
246 | deleteForward(); | ||
247 | break; | ||
248 | case XK_k: | ||
249 | killToEnd(); | ||
250 | break; | ||
251 | case XK_c: | ||
252 | cursorHome(); | ||
253 | m_text = ""; | ||
254 | m_start_pos = 0; | ||
255 | m_cursor_pos = 0; | ||
256 | m_end_pos = 0; | ||
257 | break; | ||
258 | case XK_Left: { | 233 | case XK_Left: { |
259 | unsigned int pos = findEmptySpaceLeft(); | 234 | unsigned int pos = findEmptySpaceLeft(); |
260 | if (pos < m_start_pos){ | 235 | if (pos < m_start_pos){ |
@@ -311,13 +286,6 @@ void TextBox::keyPressEvent(XKeyEvent &event) { | |||
311 | } | 286 | } |
312 | break; | 287 | break; |
313 | } | 288 | } |
314 | } else if ((event.state & ShiftMask)== ShiftMask || | ||
315 | (event.state & 0x80) == 0x80) { // shif and altgr | ||
316 | if (isprint(keychar[0])) { | ||
317 | std::string val; | ||
318 | val += keychar[0]; | ||
319 | insertText(val); | ||
320 | } | ||
321 | } | 289 | } |
322 | 290 | ||
323 | } else { // no state | 291 | } else { // no state |
@@ -341,49 +309,46 @@ void TextBox::keyPressEvent(XKeyEvent &event) { | |||
341 | case XK_Delete: | 309 | case XK_Delete: |
342 | deleteForward(); | 310 | deleteForward(); |
343 | break; | 311 | break; |
344 | default: | 312 | case XK_KP_Insert: |
345 | switch (ks) { | 313 | keychar[0] = '0'; |
346 | case XK_KP_Insert: | 314 | break; |
347 | keychar[0] = '0'; | 315 | case XK_KP_End: |
348 | break; | 316 | keychar[0] = '1'; |
349 | case XK_KP_End: | 317 | break; |
350 | keychar[0] = '1'; | 318 | case XK_KP_Down: |
351 | break; | 319 | keychar[0] = '2'; |
352 | case XK_KP_Down: | 320 | break; |
353 | keychar[0] = '2'; | 321 | case XK_KP_Page_Down: |
354 | break; | 322 | keychar[0] = '3'; |
355 | case XK_KP_Page_Down: | 323 | break; |
356 | keychar[0] = '3'; | 324 | case XK_KP_Left: |
357 | break; | 325 | keychar[0] = '4'; |
358 | case XK_KP_Left: | 326 | break; |
359 | keychar[0] = '4'; | 327 | case XK_KP_Begin: |
360 | break; | 328 | keychar[0] = '5'; |
361 | case XK_KP_Begin: | 329 | break; |
362 | keychar[0] = '5'; | 330 | case XK_KP_Right: |
363 | break; | 331 | keychar[0] = '6'; |
364 | case XK_KP_Right: | 332 | break; |
365 | keychar[0] = '6'; | 333 | case XK_KP_Home: |
366 | break; | 334 | keychar[0] = '7'; |
367 | case XK_KP_Home: | 335 | break; |
368 | keychar[0] = '7'; | 336 | case XK_KP_Up: |
369 | break; | 337 | keychar[0] = '8'; |
370 | case XK_KP_Up: | 338 | break; |
371 | keychar[0] = '8'; | 339 | case XK_KP_Page_Up: |
372 | break; | 340 | keychar[0] = '9'; |
373 | case XK_KP_Page_Up: | 341 | break; |
374 | keychar[0] = '9'; | 342 | case XK_KP_Delete: |
375 | break; | 343 | keychar[0] = ','; |
376 | case XK_KP_Delete: | 344 | break; |
377 | keychar[0] = ','; | ||
378 | break; | ||
379 | }; | ||
380 | if (isprint(keychar[0])) { | ||
381 | std::string val; | ||
382 | val += keychar[0]; | ||
383 | insertText(val); | ||
384 | } | ||
385 | } | 345 | } |
386 | } | 346 | } |
347 | if (isprint(keychar[0])) { | ||
348 | std::string val; | ||
349 | val += keychar[0]; | ||
350 | insertText(val); | ||
351 | } | ||
387 | clear(); | 352 | clear(); |
388 | } | 353 | } |
389 | 354 | ||