diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Menu.cc | 58 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 4 | ||||
-rw-r--r-- | src/Screen.cc | 26 | ||||
-rw-r--r-- | src/Screen.hh | 20 |
4 files changed, 72 insertions, 36 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 40f81c8..7128152 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -109,7 +109,8 @@ Menu::Menu(FbTk::ThemeProxy<MenuTheme> &tm, ImageControl &imgctrl): | |||
109 | m_alignment(ALIGNDONTCARE), | 109 | m_alignment(ALIGNDONTCARE), |
110 | m_active_index(-1), | 110 | m_active_index(-1), |
111 | m_shape(0), | 111 | m_shape(0), |
112 | m_need_update(true) { | 112 | m_need_update(true), |
113 | m_single_trigger(false) { | ||
113 | // setup timers | 114 | // setup timers |
114 | 115 | ||
115 | RefCount<Command<void> > show_cmd(new SimpleCommand<Menu>(*this, &Menu::openSubmenu)); | 116 | RefCount<Command<void> > show_cmd(new SimpleCommand<Menu>(*this, &Menu::openSubmenu)); |
@@ -861,6 +862,10 @@ bool Menu::isItemSelectable(unsigned int index) const { | |||
861 | return (!item || !item->isEnabled()) ? false : true; | 862 | return (!item || !item->isEnabled()) ? false : true; |
862 | } | 863 | } |
863 | 864 | ||
865 | bool Menu::isSingleTrigger() const { | ||
866 | |||
867 | return m_single_trigger || (parent() && parent()->isSingleTrigger()); | ||
868 | } | ||
864 | 869 | ||
865 | void Menu::handleEvent(XEvent &event) { | 870 | void Menu::handleEvent(XEvent &event) { |
866 | if (event.type == FocusOut) { | 871 | if (event.type == FocusOut) { |
@@ -1123,19 +1128,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1123 | break; | 1128 | break; |
1124 | case XK_KP_Enter: | 1129 | case XK_KP_Enter: |
1125 | case XK_Return: | 1130 | case XK_Return: |
1126 | resetTypeAhead(); | 1131 | goto click_on_item; |
1127 | if (validIndex(m_active_index) && | ||
1128 | isItemEnabled(m_active_index)) { | ||
1129 | // send fake button click | ||
1130 | int button = (event.state & ShiftMask) ? 3 : 1; | ||
1131 | if (menuitems[m_active_index]->submenu() != 0 && button == 1) | ||
1132 | enterSubmenu(); | ||
1133 | else { | ||
1134 | find(m_active_index)->click(button, event.time, event.state); | ||
1135 | m_need_update = true; | ||
1136 | updateMenu(); | ||
1137 | } | ||
1138 | } | ||
1139 | break; | 1132 | break; |
1140 | case XK_Tab: | 1133 | case XK_Tab: |
1141 | case XK_ISO_Left_Tab: | 1134 | case XK_ISO_Left_Tab: |
@@ -1150,15 +1143,38 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1150 | drawTypeAheadItems(); | 1143 | drawTypeAheadItems(); |
1151 | break; | 1144 | break; |
1152 | default: | 1145 | default: |
1153 | m_type_ahead.putCharacter(keychar[0]); | 1146 | { |
1154 | // if current item doesn't match new search string, find the next one | 1147 | m_type_ahead.putCharacter(keychar[0]); |
1155 | drawTypeAheadItems(); | 1148 | drawTypeAheadItems(); |
1156 | if (!m_matches.empty() && (!validIndex(m_active_index) || | 1149 | // if current item doesn't match new search string, find the next one |
1157 | std::find(m_matches.begin(), m_matches.end(), | 1150 | if (!m_matches.empty() && (!validIndex(m_active_index) || |
1158 | find(m_active_index)) == m_matches.end())) | 1151 | std::find(m_matches.begin(), m_matches.end(), |
1159 | cycleItems(false); | 1152 | find(m_active_index)) == m_matches.end())) |
1153 | cycleItems(false); | ||
1154 | |||
1155 | if (isSingleTrigger() && m_matches.size() == 1) { | ||
1156 | goto click_on_item; | ||
1157 | } | ||
1158 | } | ||
1160 | break; | 1159 | break; |
1161 | } | 1160 | } |
1161 | return; | ||
1162 | |||
1163 | // TODO: 'goto' is just the temporary solution to this code sharing | ||
1164 | click_on_item: | ||
1165 | resetTypeAhead(); | ||
1166 | if (validIndex(m_active_index) && | ||
1167 | isItemEnabled(m_active_index)) { | ||
1168 | // send fake button click | ||
1169 | int button = (event.state & ShiftMask) ? 3 : 1; | ||
1170 | if (menuitems[m_active_index]->submenu() != 0 && button == 1) | ||
1171 | enterSubmenu(); | ||
1172 | else { | ||
1173 | find(m_active_index)->click(button, event.time, event.state); | ||
1174 | m_need_update = true; | ||
1175 | updateMenu(); | ||
1176 | } | ||
1177 | } | ||
1162 | } | 1178 | } |
1163 | 1179 | ||
1164 | void Menu::leaveNotifyEvent(XCrossingEvent &ce) { | 1180 | void Menu::leaveNotifyEvent(XCrossingEvent &ce) { |
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index bd830b4..114872b 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -91,6 +91,9 @@ public: | |||
91 | 91 | ||
92 | void setScreen(int x, int y, int w, int h); | 92 | void setScreen(int x, int y, int w, int h); |
93 | 93 | ||
94 | void setSingleTrigger(bool flag) { m_single_trigger = flag; }; | ||
95 | bool isSingleTrigger() const; | ||
96 | |||
94 | /** | 97 | /** |
95 | @name event handlers | 98 | @name event handlers |
96 | */ | 99 | */ |
@@ -201,6 +204,7 @@ private: | |||
201 | Menuitems menuitems; | 204 | Menuitems menuitems; |
202 | TypeAhead<Menuitems, MenuItem *> m_type_ahead; | 205 | TypeAhead<Menuitems, MenuItem *> m_type_ahead; |
203 | Menuitems m_matches; | 206 | Menuitems m_matches; |
207 | bool m_single_trigger; | ||
204 | 208 | ||
205 | void resetTypeAhead(); | 209 | void resetTypeAhead(); |
206 | void drawTypeAheadItems(); | 210 | void drawTypeAheadItems(); |
diff --git a/src/Screen.cc b/src/Screen.cc index 86799da..a35a7eb 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -276,22 +276,30 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, | |||
276 | auto_raise(rm, true, scrname+".autoRaise", altscrname+".AutoRaise"), | 276 | auto_raise(rm, true, scrname+".autoRaise", altscrname+".AutoRaise"), |
277 | click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), | 277 | click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), |
278 | default_deco(rm, "NORMAL", scrname+".defaultDeco", altscrname+".DefaultDeco"), | 278 | default_deco(rm, "NORMAL", scrname+".defaultDeco", altscrname+".DefaultDeco"), |
279 | tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"), | ||
280 | windowmenufile(rm, Fluxbox::instance()->getDefaultDataFilename("windowmenu"), scrname+".windowMenu", altscrname+".WindowMenu"), | ||
281 | typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay", altscrname+".NoFocusWhileTypingDelay"), | 279 | typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay", altscrname+".NoFocusWhileTypingDelay"), |
282 | workspaces(rm, 4, scrname+".workspaces", altscrname+".Workspaces"), | 280 | workspaces(rm, 4, scrname+".workspaces", altscrname+".Workspaces"), |
283 | edge_snap_threshold(rm, 10, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), | 281 | edge_snap_threshold(rm, 10, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), |
284 | focused_alpha(rm, 255, scrname+".window.focus.alpha", altscrname+".Window.Focus.Alpha"), | 282 | focused_alpha(rm, 255, scrname+".window.focus.alpha", altscrname+".Window.Focus.Alpha"), |
285 | unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"), | 283 | unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"), |
284 | |||
285 | tooltip_delay(rm, 500, scrname + ".tooltipDelay", altscrname+".TooltipDelay"), | ||
286 | |||
286 | menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"), | 287 | menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"), |
287 | menu_delay(rm, 200, scrname + ".menuDelay", altscrname+".MenuDelay"), | 288 | menu_delay(rm, 200, scrname + ".menuDelay", altscrname+".MenuDelay"), |
288 | tab_width(rm, 64, scrname + ".tab.width", altscrname+".Tab.Width"), | ||
289 | tooltip_delay(rm, 500, scrname + ".tooltipDelay", altscrname+".TooltipDelay"), | ||
290 | allow_remote_actions(rm, false, scrname+".allowRemoteActions", altscrname+".AllowRemoteActions"), | ||
291 | clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"), | 289 | clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"), |
290 | windowmenufile(rm, Fluxbox::instance()->getDefaultDataFilename("windowmenu"), scrname+".windowMenu", altscrname+".WindowMenu"), | ||
291 | windowmenu_singletrigger(rm, false, scrname+".menu.window.singleTrigger", altscrname+".Menu.Window.SingleTrigger"), | ||
292 | rootmenu_singletrigger(rm, false, scrname+".menu.root.singleTrigger", altscrname+".Menu.Root.SingleTrigger"), | ||
293 | workspacemenu_singletrigger(rm, false, scrname+".menu.workspace.singleTrigger", altscrname+".Menu.Workspace.SingleTrigger"), | ||
294 | |||
295 | tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"), | ||
296 | tab_width(rm, 64, scrname + ".tab.width", altscrname+".Tab.Width"), | ||
292 | tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"), | 297 | tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"), |
293 | max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"), | 298 | max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"), |
294 | default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { | 299 | default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar"), |
300 | |||
301 | allow_remote_actions(rm, false, scrname+".allowRemoteActions", altscrname+".AllowRemoteActions") | ||
302 | { | ||
295 | 303 | ||
296 | 304 | ||
297 | } | 305 | } |
@@ -335,8 +343,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
335 | // TODO fluxgen: check if this is the right place (it was not -lis) | 343 | // TODO fluxgen: check if this is the right place (it was not -lis) |
336 | // | 344 | // |
337 | // Create the first one, initXinerama will expand this if needed. | 345 | // Create the first one, initXinerama will expand this if needed. |
338 | m_head_areas.resize(1); | 346 | m_head_areas.push_back(new HeadArea()); |
339 | m_head_areas[0] = new HeadArea(); | ||
340 | 347 | ||
341 | initXinerama(); | 348 | initXinerama(); |
342 | 349 | ||
@@ -1413,8 +1420,11 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, | |||
1413 | 1420 | ||
1414 | void BScreen::initMenus() { | 1421 | void BScreen::initMenus() { |
1415 | m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber())); | 1422 | m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber())); |
1423 | m_workspacemenu->setSingleTrigger(*resource.workspacemenu_singletrigger); | ||
1416 | m_rootmenu->reloadHelper()->setMainFile(Fluxbox::instance()->getMenuFilename()); | 1424 | m_rootmenu->reloadHelper()->setMainFile(Fluxbox::instance()->getMenuFilename()); |
1425 | m_rootmenu->setSingleTrigger(*resource.rootmenu_singletrigger); | ||
1417 | m_windowmenu->reloadHelper()->setMainFile(windowMenuFilename()); | 1426 | m_windowmenu->reloadHelper()->setMainFile(windowMenuFilename()); |
1427 | m_windowmenu->setSingleTrigger(*resource.windowmenu_singletrigger); | ||
1418 | } | 1428 | } |
1419 | 1429 | ||
1420 | 1430 | ||
diff --git a/src/Screen.hh b/src/Screen.hh index de3a5a1..52b075b 100644 --- a/src/Screen.hh +++ b/src/Screen.hh | |||
@@ -517,19 +517,25 @@ private: | |||
517 | max_ignore_inc, max_disable_move, max_disable_resize, | 517 | max_ignore_inc, max_disable_move, max_disable_resize, |
518 | workspace_warping, show_window_pos, auto_raise, click_raises; | 518 | workspace_warping, show_window_pos, auto_raise, click_raises; |
519 | FbTk::Resource<std::string> default_deco; | 519 | FbTk::Resource<std::string> default_deco; |
520 | FbTk::Resource<FbWinFrame::TabPlacement> tab_placement; | ||
521 | FbTk::Resource<std::string> windowmenufile; | ||
522 | FbTk::Resource<unsigned int> typing_delay; | 520 | FbTk::Resource<unsigned int> typing_delay; |
523 | FbTk::Resource<int> workspaces, edge_snap_threshold, focused_alpha, | 521 | FbTk::Resource<int> workspaces, edge_snap_threshold, |
524 | unfocused_alpha, menu_alpha, menu_delay, | 522 | focused_alpha, unfocused_alpha, tooltip_delay; |
525 | tab_width, tooltip_delay; | 523 | |
526 | FbTk::Resource<bool> allow_remote_actions; | 524 | FbTk::Resource<int> menu_alpha; |
525 | FbTk::Resource<int> menu_delay; | ||
527 | FbTk::Resource<bool> clientmenu_use_pixmap; | 526 | FbTk::Resource<bool> clientmenu_use_pixmap; |
527 | FbTk::Resource<std::string> windowmenufile; | ||
528 | FbTk::Resource<bool> windowmenu_singletrigger; | ||
529 | FbTk::Resource<bool> rootmenu_singletrigger; | ||
530 | FbTk::Resource<bool> workspacemenu_singletrigger; | ||
531 | |||
532 | FbTk::Resource<FbWinFrame::TabPlacement> tab_placement; | ||
533 | FbTk::Resource<int> tab_width; | ||
528 | FbTk::Resource<bool> tabs_use_pixmap; | 534 | FbTk::Resource<bool> tabs_use_pixmap; |
529 | FbTk::Resource<bool> max_over_tabs; | 535 | FbTk::Resource<bool> max_over_tabs; |
530 | FbTk::Resource<bool> default_internal_tabs; | 536 | FbTk::Resource<bool> default_internal_tabs; |
531 | 537 | ||
532 | 538 | FbTk::Resource<bool> allow_remote_actions; | |
533 | } resource; | 539 | } resource; |
534 | 540 | ||
535 | /// Holds manage resources that screen destroys | 541 | /// Holds manage resources that screen destroys |