Version: kdelibs-09122004 (using KDE Devel) Installed from: Compiled sources Compiler: gcc-3.3.3-cvs OS: Linux Hi, Didn't you thought that when working with any menu, all 104 keys (except arrows and enter) become useless? With small patch included, it's now possible to choose window from Window List Menu by one keypress. It's _a lot_ comfortably than use arrow keys. Imagine: Window List Menu appears by "Menu" winkey, so menu showed, you can see all windows by name, now you can choose needed window just by one press 0-9a-z key. With arrow keys you need walk through all menu, point to the window that you wanted, and press enter... Now I just chucked out my mice, it's no longer useful, finally all done by keyboard shortcuts. Issue: you can choose only 36 windows by this method, not big deal in most cases. Any suggestions? Thanks. p.s. patch for kdelibs-cvs-09122004 pp.s. you need to recompile kdesktop, because kwindowlistmenu.h affected, otherwise kdesktop will crash. --- kdelibs/kdeui/kwindowlistmenu.h Tue Jun 8 16:03:24 2004 +++ kdelibs/kdeui/kwindowlistmenu.h Tue Jun 8 17:10:06 2004 @@ -53,7 +53,10 @@ private: KWinModule* kwin_module; QMap<int,WId> map; + QMap<char,int> sc_map; protected: + QString scs; + virtual void keyPressEvent(QKeyEvent *e); virtual void virtual_hook( int id, void* data ); private: KWindowListMenuPrivate *d; --- kdelibs/kdeui/kwindowlistmenu.cpp Tue Jun 8 16:03:18 2004 +++ kdelibs/kdeui/kwindowlistmenu.cpp Tue Jun 8 17:13:24 2004 @@ -79,7 +79,8 @@ } // namespace KWindowListMenu::KWindowListMenu(QWidget *parent, const char *name) - : KPopupMenu(parent, name) + : KPopupMenu(parent, name), + scs("1234567890abcdefghijklmnopgrstuvwxyz") { #if defined Q_WS_X11 && ! defined K_WS_QTONLY //#ifndef Q_WS_QWS //FIXME @@ -123,6 +124,7 @@ clear(); map.clear(); + sc_map.clear(); int unclutter = insertItem( i18n("Unclutter Windows"), this, SLOT( slotUnclutterWindows() ) ); @@ -142,6 +144,7 @@ windows.append( KWin::windowInfo( *it, NET::WMDesktop )); } bool show_all_desktops_group = ( nd > 1 ); + size_t sc_i = 0; for (d = 1; d <= nd + (show_all_desktops_group ? 1 : 0); d++) { bool on_all_desktops = ( d > nd ); int items = 0; @@ -185,7 +188,13 @@ // Avoid creating unwanted accelerators. itemText.replace("&", "&&"); - insertItem( pm, itemText, i); + + if (sc_i < scs.length()) { + sc_map.insert(scs[sc_i].latin1(), i); + insertItem(pm, scs[sc_i] + QString(". ") + itemText, i); + sc_i++; + } + else insertItem(pm, itemText, i); map.insert(i, info->win()); if (info->win() == active_window) setItemChecked(i, true); @@ -258,6 +267,16 @@ void KWindowListMenu::slotCascadeWindows() { kapp->dcopClient()->send("kwin", "KWinInterface", "cascadeDesktop()", ""); +} + +void KWindowListMenu::keyPressEvent(QKeyEvent *e) +{ + if (scs.find(e->ascii()) >= 0) { + slotExec(sc_map[e->ascii()]); + aboutToHide(); + hide(); + } + else KPopupMenu::keyPressEvent(e); } void KWindowListMenu::virtual_hook( int id, void* data )
The patch has few technical details (BIC, no need to call aboutToHide(), scs can be simply const char[]). And I'm not sure if assigning "arbitrary" numbers to the entries would really make things faster.
>The patch has few technical details (BIC, no need to >call aboutToHide(), scs can be simply const char[]). Thanks, I'll fix it. >And I'm not sure if assigning "arbitrary" numbers >to the entries would really make things faster. It make things faster. Two opinions: 1. Window list menu just like kicker, but shows by keypress (like "Menu" key) and points to wanted window just by key, not mouse. With kicker you can't do it, you _must_ use mouse. Using arrow keys is boring (try to switch from window-1 to window-7 and back). 2. When you have about 8 windows and you don't touch (close/move to other desktops) them for a long time, you always remember that Menu_key+1 focus your konqueror with docs.kde.org, Menu_key+6 show your favorite IRC client, Menu_key+8 goes to VIM on desktop3. Yes, if you close some window - numbers will change, but there is no another way, and still it quick to accustom to new numbers. p.s. btw, honestly speaking it is not mine idea, FVWM(?) got same feature for standalone menus, I can't even patent it. ;-)
Please replace "1234567890abcdefghijklmnopgrstuvwxyz" by "abcdefghijklmnopgrstuvwxyz1234567890". Why put numbers after letters? Because with AZERTY keyboards, digits need Shift to be typed. I think you have a QUERTY keyboard and so numbers are accessable by only one key press. And we can have a more consistent naming: since if we have more than 10 windows (but less than 26) windows are all accessable by letters, and not a mix of digits and letters. What do you think about that?
This works by automatically assigning shortcut letters to the menu.