diff options
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r-- | src/FbTk/Menu.cc | 114 |
1 files changed, 58 insertions, 56 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 480569f..9206ade 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -1,4 +1,4 @@ | |||
1 | // Menu.cc for FbTk - Fluxbox Toolkit | 1 | // Menu.cc for FbTk - Fluxbox Toolkit |
2 | // Copyright (c) 2001 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) | 2 | // Copyright (c) 2001 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) |
3 | // | 3 | // |
4 | // Basemenu.cc for blackbox - an X11 Window manager | 4 | // Basemenu.cc for blackbox - an X11 Window manager |
@@ -63,10 +63,13 @@ | |||
63 | #else | 63 | #else |
64 | #include <string.h> | 64 | #include <string.h> |
65 | #endif | 65 | #endif |
66 | #include <iostream> | ||
67 | #include <typeinfo> | 66 | #include <typeinfo> |
68 | 67 | ||
69 | using namespace std; | 68 | #ifdef DEBUG |
69 | #include <iostream> | ||
70 | using std::cout; | ||
71 | using std::endl; | ||
72 | #endif // DEBUG | ||
70 | 73 | ||
71 | namespace FbTk { | 74 | namespace FbTk { |
72 | 75 | ||
@@ -126,7 +129,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): | |||
126 | menu.persub = | 129 | menu.persub = |
127 | menu.minsub = 0; | 130 | menu.minsub = 0; |
128 | 131 | ||
129 | long event_mask = ButtonPressMask | ButtonReleaseMask | | 132 | long event_mask = ButtonPressMask | ButtonReleaseMask | |
130 | ButtonMotionMask | KeyPressMask | ExposureMask | FocusChangeMask; | 133 | ButtonMotionMask | KeyPressMask | ExposureMask | FocusChangeMask; |
131 | // create menu window | 134 | // create menu window |
132 | menu.window = FbTk::FbWindow(tm.screenNum(), | 135 | menu.window = FbTk::FbWindow(tm.screenNum(), |
@@ -140,7 +143,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): | |||
140 | 143 | ||
141 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); | 144 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); |
142 | evm.add(*this, menu.window); | 145 | evm.add(*this, menu.window); |
143 | 146 | ||
144 | 147 | ||
145 | event_mask |= EnterWindowMask | LeaveWindowMask; | 148 | event_mask |= EnterWindowMask | LeaveWindowMask; |
146 | //create menu title | 149 | //create menu title |
@@ -171,7 +174,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): | |||
171 | Menu::~Menu() { | 174 | Menu::~Menu() { |
172 | 175 | ||
173 | menu.window.hide(); | 176 | menu.window.hide(); |
174 | 177 | ||
175 | if (shown && shown->window() == window()) | 178 | if (shown && shown->window() == window()) |
176 | shown = 0; | 179 | shown = 0; |
177 | 180 | ||
@@ -216,9 +219,9 @@ int Menu::insert(MenuItem *item, int pos) { | |||
216 | int Menu::remove(unsigned int index) { | 219 | int Menu::remove(unsigned int index) { |
217 | if (index >= menuitems.size()) { | 220 | if (index >= menuitems.size()) { |
218 | #ifdef DEBUG | 221 | #ifdef DEBUG |
219 | std::cout << "Bad index (" << index << ") given to Menu::remove()" | 222 | cout << "Bad index (" << index << ") given to Menu::remove()" |
220 | << " -- should be between 0 and " << menuitems.size() | 223 | << " -- should be between 0 and " << menuitems.size() |
221 | << " inclusive." << std::endl; | 224 | << " inclusive." << endl; |
222 | #endif // DEBUG | 225 | #endif // DEBUG |
223 | return -1; | 226 | return -1; |
224 | } | 227 | } |
@@ -240,8 +243,8 @@ int Menu::remove(unsigned int index) { | |||
240 | // } else | 243 | // } else |
241 | // tmp->internal_hide(); | 244 | // tmp->internal_hide(); |
242 | } | 245 | } |
243 | 246 | ||
244 | 247 | ||
245 | delete item; | 248 | delete item; |
246 | } | 249 | } |
247 | 250 | ||
@@ -276,7 +279,7 @@ void Menu::nextItem() { | |||
276 | 279 | ||
277 | int old_which_press = m_which_press; | 280 | int old_which_press = m_which_press; |
278 | m_active_index = -1; | 281 | m_active_index = -1; |
279 | if (validIndex(old_which_press) && | 282 | if (validIndex(old_which_press) && |
280 | menuitems[old_which_press] != 0) { | 283 | menuitems[old_which_press] != 0) { |
281 | if (menuitems[old_which_press]->submenu()) { | 284 | if (menuitems[old_which_press]->submenu()) { |
282 | // we need to do this explicitly on the menu.window | 285 | // we need to do this explicitly on the menu.window |
@@ -302,10 +305,10 @@ void Menu::nextItem() { | |||
302 | return; | 305 | return; |
303 | } | 306 | } |
304 | 307 | ||
305 | m_active_index = m_which_press; | 308 | m_active_index = m_which_press; |
306 | 309 | ||
307 | clearItem(m_which_press); | 310 | clearItem(m_which_press); |
308 | 311 | ||
309 | } | 312 | } |
310 | 313 | ||
311 | void Menu::prevItem() { | 314 | void Menu::prevItem() { |
@@ -318,7 +321,7 @@ void Menu::prevItem() { | |||
318 | if (menuitems[old_which_press]->submenu()) { | 321 | if (menuitems[old_which_press]->submenu()) { |
319 | // we need to do this explicitly on the menu.window | 322 | // we need to do this explicitly on the menu.window |
320 | // since it might hide the parent if we use Menu::hide | 323 | // since it might hide the parent if we use Menu::hide |
321 | menuitems[old_which_press]->submenu()->internal_hide(); | 324 | menuitems[old_which_press]->submenu()->internal_hide(); |
322 | } | 325 | } |
323 | clearItem(old_which_press); | 326 | clearItem(old_which_press); |
324 | } | 327 | } |
@@ -371,7 +374,7 @@ void Menu::enterParent() { | |||
371 | 374 | ||
372 | m_active_index = -1; | 375 | m_active_index = -1; |
373 | //clearItem(m_which_press); | 376 | //clearItem(m_which_press); |
374 | m_which_press = -1; // dont select any in this | 377 | m_which_press = -1; // dont select any in this |
375 | // hide self | 378 | // hide self |
376 | m_visible = false; | 379 | m_visible = false; |
377 | menu.window.hide(); | 380 | menu.window.hide(); |
@@ -411,7 +414,7 @@ void Menu::updateMenu(int active_index) { | |||
411 | menu.sublevels++; | 414 | menu.sublevels++; |
412 | } | 415 | } |
413 | 416 | ||
414 | if (menu.sublevels < menu.minsub) | 417 | if (menu.sublevels < menu.minsub) |
415 | menu.sublevels = menu.minsub; | 418 | menu.sublevels = menu.minsub; |
416 | 419 | ||
417 | menu.persub = menuitems.size() / menu.sublevels; | 420 | menu.persub = menuitems.size() / menu.sublevels; |
@@ -432,7 +435,7 @@ void Menu::updateMenu(int active_index) { | |||
432 | 435 | ||
433 | 436 | ||
434 | if (new_width == 0) { | 437 | if (new_width == 0) { |
435 | if (menu.item_w > 0) | 438 | if (menu.item_w > 0) |
436 | new_width = menu.item_w; | 439 | new_width = menu.item_w; |
437 | else | 440 | else |
438 | new_width = 1; | 441 | new_width = 1; |
@@ -476,12 +479,12 @@ void Menu::updateMenu(int active_index) { | |||
476 | } | 479 | } |
477 | 480 | ||
478 | if (m_title_vis) { | 481 | if (m_title_vis) { |
479 | menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), | 482 | menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), |
480 | width() + menu.title.borderWidth(), theme().titleHeight()); | 483 | width() + menu.title.borderWidth(), theme().titleHeight()); |
481 | } | 484 | } |
482 | 485 | ||
483 | menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + | 486 | menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + |
484 | menu.title.borderWidth()*2 : 0), | 487 | menu.title.borderWidth()*2 : 0), |
485 | width(), menu.frame_h); | 488 | width(), menu.frame_h); |
486 | 489 | ||
487 | if (m_title_vis && m_need_update) { | 490 | if (m_title_vis && m_need_update) { |
@@ -497,7 +500,7 @@ void Menu::updateMenu(int active_index) { | |||
497 | menu.title.setBackgroundPixmap(menu.title_pixmap); | 500 | menu.title.setBackgroundPixmap(menu.title_pixmap); |
498 | } | 501 | } |
499 | 502 | ||
500 | if (tmp) | 503 | if (tmp) |
501 | m_image_ctrl.removeImage(tmp); | 504 | m_image_ctrl.removeImage(tmp); |
502 | } | 505 | } |
503 | 506 | ||
@@ -509,7 +512,7 @@ void Menu::updateMenu(int active_index) { | |||
509 | menu.frame.setBackgroundColor(frame_tex.color()); | 512 | menu.frame.setBackgroundColor(frame_tex.color()); |
510 | } else { | 513 | } else { |
511 | menu.frame_pixmap = | 514 | menu.frame_pixmap = |
512 | m_image_ctrl.renderImage(width(), menu.frame_h, frame_tex); | 515 | m_image_ctrl.renderImage(width(), menu.frame_h, frame_tex); |
513 | menu.frame.setBackgroundPixmap(menu.frame_pixmap); | 516 | menu.frame.setBackgroundPixmap(menu.frame_pixmap); |
514 | } | 517 | } |
515 | 518 | ||
@@ -543,7 +546,7 @@ void Menu::show() { | |||
543 | 546 | ||
544 | shown = this; | 547 | shown = this; |
545 | } | 548 | } |
546 | 549 | ||
547 | } | 550 | } |
548 | 551 | ||
549 | 552 | ||
@@ -559,7 +562,7 @@ void Menu::hide() { | |||
559 | 562 | ||
560 | while ((! p->m_torn) && p->m_parent && p->m_parent->isVisible()) | 563 | while ((! p->m_torn) && p->m_parent && p->m_parent->isVisible()) |
561 | p = p->m_parent; | 564 | p = p->m_parent; |
562 | 565 | ||
563 | p->internal_hide(); | 566 | p->internal_hide(); |
564 | } else if (!m_torn) // if we dont have a parent then do hide here | 567 | } else if (!m_torn) // if we dont have a parent then do hide here |
565 | internal_hide(); | 568 | internal_hide(); |
@@ -577,7 +580,7 @@ void Menu::grabInputFocus() { | |||
577 | void Menu::clearWindow() { | 580 | void Menu::clearWindow() { |
578 | menu.title.clear(); | 581 | menu.title.clear(); |
579 | menu.frame.clear(); | 582 | menu.frame.clear(); |
580 | 583 | ||
581 | // clear foreground bits of frame items | 584 | // clear foreground bits of frame items |
582 | for (size_t i = 0; i < menuitems.size(); i++) { | 585 | for (size_t i = 0; i < menuitems.size(); i++) { |
583 | clearItem(i, false); // no clear | 586 | clearItem(i, false); // no clear |
@@ -598,7 +601,7 @@ void Menu::internal_hide() { | |||
598 | tmp->submenu()->internal_hide(); | 601 | tmp->submenu()->internal_hide(); |
599 | } | 602 | } |
600 | 603 | ||
601 | // if we have an active index we need to redraw it | 604 | // if we have an active index we need to redraw it |
602 | // as non active | 605 | // as non active |
603 | int old = m_active_index; | 606 | int old = m_active_index; |
604 | m_active_index = -1; | 607 | m_active_index = -1; |
@@ -683,11 +686,11 @@ void Menu::drawSubmenu(unsigned int index) { | |||
683 | item->submenu()->m_parent = this; | 686 | item->submenu()->m_parent = this; |
684 | 687 | ||
685 | item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height); | 688 | item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height); |
686 | 689 | ||
687 | int sbl = index / menu.persub, i = index - (sbl * menu.persub); | 690 | int sbl = index / menu.persub, i = index - (sbl * menu.persub); |
688 | int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()); | 691 | int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()); |
689 | int new_y; | 692 | int new_y; |
690 | 693 | ||
691 | if (m_alignment == ALIGNTOP) { | 694 | if (m_alignment == ALIGNTOP) { |
692 | new_y = (y() + ((m_title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - | 695 | new_y = (y() + ((m_title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - |
693 | ((item->submenu()->m_title_vis) ? | 696 | ((item->submenu()->m_title_vis) ? |
@@ -698,7 +701,7 @@ void Menu::drawSubmenu(unsigned int index) { | |||
698 | ((item->submenu()->m_title_vis) ? | 701 | ((item->submenu()->m_title_vis) ? |
699 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); | 702 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); |
700 | } | 703 | } |
701 | 704 | ||
702 | if (m_alignment == ALIGNBOTTOM && | 705 | if (m_alignment == ALIGNBOTTOM && |
703 | (new_y + item->submenu()->height()) > (y() + height())) { | 706 | (new_y + item->submenu()->height()) > (y() + height())) { |
704 | new_y = (y() + height() - item->submenu()->height()); | 707 | new_y = (y() + height() - item->submenu()->height()); |
@@ -709,7 +712,7 @@ void Menu::drawSubmenu(unsigned int index) { | |||
709 | if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { | 712 | if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { |
710 | new_x = x() - item->submenu()->width() - menu.window.borderWidth(); | 713 | new_x = x() - item->submenu()->width() - menu.window.borderWidth(); |
711 | } | 714 | } |
712 | 715 | ||
713 | if (new_x < m_screen_x) | 716 | if (new_x < m_screen_x) |
714 | new_x = m_screen_x; | 717 | new_x = m_screen_x; |
715 | 718 | ||
@@ -717,7 +720,7 @@ void Menu::drawSubmenu(unsigned int index) { | |||
717 | new_y = m_screen_y + m_screen_height - item->submenu()->height() - | 720 | new_y = m_screen_y + m_screen_height - item->submenu()->height() - |
718 | menu.window.borderWidth() * 2; | 721 | menu.window.borderWidth() * 2; |
719 | } | 722 | } |
720 | 723 | ||
721 | item->submenu()->m_moving = m_moving; | 724 | item->submenu()->m_moving = m_moving; |
722 | m_which_sub = index; | 725 | m_which_sub = index; |
723 | 726 | ||
@@ -732,7 +735,7 @@ void Menu::drawSubmenu(unsigned int index) { | |||
732 | item->showSubmenu(); | 735 | item->showSubmenu(); |
733 | item->submenu()->raise(); | 736 | item->submenu()->raise(); |
734 | } | 737 | } |
735 | 738 | ||
736 | 739 | ||
737 | } else | 740 | } else |
738 | m_which_sub = -1; | 741 | m_which_sub = -1; |
@@ -743,11 +746,11 @@ void Menu::drawSubmenu(unsigned int index) { | |||
743 | bool Menu::hasSubmenu(unsigned int index) const { | 746 | bool Menu::hasSubmenu(unsigned int index) const { |
744 | if (index >= menuitems.size()) //boundary check | 747 | if (index >= menuitems.size()) //boundary check |
745 | return false; | 748 | return false; |
746 | 749 | ||
747 | if (!menuitems[index]->submenu()) //has submenu? | 750 | if (!menuitems[index]->submenu()) //has submenu? |
748 | return false; | 751 | return false; |
749 | 752 | ||
750 | return true; | 753 | return true; |
751 | } | 754 | } |
752 | #endif // NOT_USED | 755 | #endif // NOT_USED |
753 | 756 | ||
@@ -767,9 +770,9 @@ int Menu::drawItem(FbDrawable &drawable, unsigned int index, | |||
767 | if (exclusive_drawable) | 770 | if (exclusive_drawable) |
768 | item_x = item_y = 0; | 771 | item_x = item_y = 0; |
769 | 772 | ||
770 | item->draw(drawable, theme(), highlight, | 773 | item->draw(drawable, theme(), highlight, |
771 | exclusive_drawable, true, // draw fg, draw bg | 774 | exclusive_drawable, true, // draw fg, draw bg |
772 | item_x, item_y, | 775 | item_x, item_y, |
773 | menu.item_w, theme().itemHeight()); | 776 | menu.item_w, theme().itemHeight()); |
774 | 777 | ||
775 | return item_y; | 778 | return item_y; |
@@ -830,8 +833,8 @@ bool Menu::isItemSelectable(unsigned int index) const { | |||
830 | if (index >= menuitems.size()) return false; | 833 | if (index >= menuitems.size()) return false; |
831 | 834 | ||
832 | const MenuItem *item = find(index); | 835 | const MenuItem *item = find(index); |
833 | return (!item || | 836 | return (!item || |
834 | (typeid(*item) == typeid(FbTk::MenuSeparator)) || | 837 | (typeid(*item) == typeid(FbTk::MenuSeparator)) || |
835 | !item->isEnabled()) ? false : true; | 838 | !item->isEnabled()) ? false : true; |
836 | } | 839 | } |
837 | 840 | ||
@@ -842,7 +845,7 @@ void Menu::handleEvent(XEvent &event) { | |||
842 | s_focused = 0; | 845 | s_focused = 0; |
843 | } else if (event.type == FocusIn) { | 846 | } else if (event.type == FocusIn) { |
844 | if (s_focused != this) | 847 | if (s_focused != this) |
845 | s_focused = this; | 848 | s_focused = this; |
846 | } | 849 | } |
847 | } | 850 | } |
848 | 851 | ||
@@ -891,9 +894,9 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { | |||
891 | 894 | ||
892 | if (re.button == 3) | 895 | if (re.button == 3) |
893 | internal_hide(); | 896 | internal_hide(); |
894 | 897 | ||
895 | } else if (re.window == menu.frame) { | 898 | } else if (re.window == menu.frame) { |
896 | 899 | ||
897 | int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), | 900 | int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), |
898 | ix = sbl * menu.item_w, iy = i * theme().itemHeight(), | 901 | ix = sbl * menu.item_w, iy = i * theme().itemHeight(), |
899 | w = (sbl * menu.persub) + i, | 902 | w = (sbl * menu.persub) + i, |
@@ -940,14 +943,13 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { | |||
940 | 943 | ||
941 | } else if (!(me.state & Button1Mask) && me.window == menu.frame) { | 944 | } else if (!(me.state & Button1Mask) && me.window == menu.frame) { |
942 | stopHide(); | 945 | stopHide(); |
943 | int sbl = (me.x / menu.item_w), | 946 | int sbl = (me.x / menu.item_w), |
944 | i = (me.y / theme().itemHeight()), | 947 | i = (me.y / theme().itemHeight()), |
945 | w = (sbl * menu.persub) + i; | 948 | w = (sbl * menu.persub) + i; |
946 | 949 | ||
947 | if (w == m_active_index) | 950 | if (w == m_active_index) |
948 | return; | 951 | return; |
949 | 952 | ||
950 | |||
951 | 953 | ||
952 | if (validIndex(m_active_index) && w != m_active_index) { | 954 | if (validIndex(m_active_index) && w != m_active_index) { |
953 | int old_active_index = m_active_index; | 955 | int old_active_index = m_active_index; |
@@ -965,7 +967,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { | |||
965 | item->submenu()->startHide(); | 967 | item->submenu()->startHide(); |
966 | m_which_sub = -1; | 968 | m_which_sub = -1; |
967 | } | 969 | } |
968 | } | 970 | } |
969 | 971 | ||
970 | } | 972 | } |
971 | 973 | ||
@@ -1012,7 +1014,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { | |||
1012 | clearItem(w); | 1014 | clearItem(w); |
1013 | } | 1015 | } |
1014 | } | 1016 | } |
1015 | 1017 | ||
1016 | } | 1018 | } |
1017 | } | 1019 | } |
1018 | 1020 | ||
@@ -1057,7 +1059,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1057 | char keychar[1]; | 1059 | char keychar[1]; |
1058 | XLookupString(&event, keychar, 1, &ks, 0); | 1060 | XLookupString(&event, keychar, 1, &ks, 0); |
1059 | // a modifier key by itself doesn't do anything | 1061 | // a modifier key by itself doesn't do anything |
1060 | if (IsModifierKey(ks)) | 1062 | if (IsModifierKey(ks)) |
1061 | return; | 1063 | return; |
1062 | 1064 | ||
1063 | switch (ks) { | 1065 | switch (ks) { |
@@ -1068,7 +1070,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1068 | nextItem(); | 1070 | nextItem(); |
1069 | break; | 1071 | break; |
1070 | case XK_Left: // enter parent if we have one | 1072 | case XK_Left: // enter parent if we have one |
1071 | enterParent(); | 1073 | enterParent(); |
1072 | break; | 1074 | break; |
1073 | case XK_Right: // enter submenu if we have one | 1075 | case XK_Right: // enter submenu if we have one |
1074 | enterSubmenu(); | 1076 | enterSubmenu(); |
@@ -1078,7 +1080,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1078 | break; | 1080 | break; |
1079 | case XK_Return: | 1081 | case XK_Return: |
1080 | // send fake button 1 click | 1082 | // send fake button 1 click |
1081 | if (validIndex(m_which_press) && | 1083 | if (validIndex(m_which_press) && |
1082 | isItemEnabled(m_which_press)) { | 1084 | isItemEnabled(m_which_press)) { |
1083 | if (event.state & ShiftMask) | 1085 | if (event.state & ShiftMask) |
1084 | menuitems[m_which_press]->click(3, event.time); | 1086 | menuitems[m_which_press]->click(3, event.time); |
@@ -1114,7 +1116,7 @@ void Menu::reconfigure() { | |||
1114 | 1116 | ||
1115 | updateMenu(); | 1117 | updateMenu(); |
1116 | } | 1118 | } |
1117 | 1119 | ||
1118 | 1120 | ||
1119 | void Menu::openSubmenu() { | 1121 | void Menu::openSubmenu() { |
1120 | 1122 | ||
@@ -1127,10 +1129,10 @@ void Menu::openSubmenu() { | |||
1127 | return; | 1129 | return; |
1128 | 1130 | ||
1129 | clearItem(item); | 1131 | clearItem(item); |
1130 | 1132 | ||
1131 | if (menuitems[item]->submenu() != 0) { | 1133 | if (menuitems[item]->submenu() != 0) { |
1132 | // stop hide timer, so it doesnt hides the menu if we | 1134 | // stop hide timer, so it doesnt hides the menu if we |
1133 | // have the same submenu as the last shown submenu | 1135 | // have the same submenu as the last shown submenu |
1134 | // (window menu for clients inside workspacemenu for example) | 1136 | // (window menu for clients inside workspacemenu for example) |
1135 | menuitems[item]->submenu()->m_hide_timer.stop(); | 1137 | menuitems[item]->submenu()->m_hide_timer.stop(); |
1136 | drawSubmenu(item); | 1138 | drawSubmenu(item); |
@@ -1148,7 +1150,7 @@ void Menu::startHide() { | |||
1148 | timeout.tv_sec = 0; | 1150 | timeout.tv_sec = 0; |
1149 | timeout.tv_usec = theme().delayClose() * 1000; // transformed to usec | 1151 | timeout.tv_usec = theme().delayClose() * 1000; // transformed to usec |
1150 | m_hide_timer.setTimeout(timeout); | 1152 | m_hide_timer.setTimeout(timeout); |
1151 | m_hide_timer.start(); | 1153 | m_hide_timer.start(); |
1152 | } | 1154 | } |
1153 | 1155 | ||
1154 | void Menu::stopHide() { | 1156 | void Menu::stopHide() { |
@@ -1158,7 +1160,7 @@ void Menu::stopHide() { | |||
1158 | void Menu::update(FbTk::Subject *subj) { | 1160 | void Menu::update(FbTk::Subject *subj) { |
1159 | 1161 | ||
1160 | m_need_update = true; | 1162 | m_need_update = true; |
1161 | 1163 | ||
1162 | Menuitems::iterator it = menuitems.begin(); | 1164 | Menuitems::iterator it = menuitems.begin(); |
1163 | Menuitems::iterator it_end = menuitems.end(); | 1165 | Menuitems::iterator it_end = menuitems.end(); |
1164 | for (; it != it_end; ++it) { | 1166 | for (; it != it_end; ++it) { |
@@ -1167,7 +1169,7 @@ void Menu::update(FbTk::Subject *subj) { | |||
1167 | reconfigure(); | 1169 | reconfigure(); |
1168 | } | 1170 | } |
1169 | 1171 | ||
1170 | 1172 | ||
1171 | void Menu::setScreen(int x, int y, int w, int h) { | 1173 | void Menu::setScreen(int x, int y, int w, int h) { |
1172 | m_screen_x = x; | 1174 | m_screen_x = x; |
1173 | m_screen_y = y; | 1175 | m_screen_y = y; |
@@ -1208,7 +1210,7 @@ void Menu::clearItem(int index, bool clear) { | |||
1208 | if (! item) return; | 1210 | if (! item) return; |
1209 | 1211 | ||
1210 | item->draw(menu.frame, theme(), highlight, | 1212 | item->draw(menu.frame, theme(), highlight, |
1211 | true, false, item_x, item_y, | 1213 | true, false, item_x, item_y, |
1212 | item_w, item_h); | 1214 | item_w, item_h); |
1213 | } | 1215 | } |
1214 | 1216 | ||