neat I was thinking to implement it myself; but here it is :D thanks Tamas.
On Fri, Dec 26, 2008 at 8:29 AM, Tamas TEVESZ <[email protected]> wrote: > > excerpts from my local tree, part 3 > > tree f1f97620d28a > parent 3eb00561166f > author Tamas TEVESZ <[email protected]> 1230230431 -3600 > committer Tamas TEVESZ <[email protected]> 1230230431 -3600 > revision 1618 > branch ice > > Applied Mac OS X-style windows cycling from > http://iain.cx/wm/patches/cycling-osx/0.92.0/cycling-osx.diff > > For those not familiar with the way Macs cycle windows, the Command-Tab > sequence (Alt-Tab elsewhere) switches between DIFFERENT application windows > and Command-Grave (key above tab) switches between windows owned by the > SAME application as is currently focused. So if you had three Safari and > two Finder windows open, and Safari had focus, Command-Tab would switch to > Finder; Command-Tab would switch back to Safari; Command-Grave would switch > to a different Safari window etc. > > This patch implements "something like" the above by only populating the > switchpanel with windows matching the currently-focused WWindow's > wm_instance and wm_class when the new cycling mode is activated. In > practice this means you can switch to The Next XTerm or The Next Mozilla > Window using this method. > > The configuration names for these new shortcuts are GroupNext and > GroupPrev. The patch tells WPrefs.app about them. Of course switching to > The Next Window is still possible with the (unchanged) FocusNext and > FocusPrev keys. > > Opinion: I find the Mac way of doing things annoying (because cycling to > The Last Window requires you to remember which key to use depending on what > type of application has focus) but at the same time very useful (because > easily switching to The Next Terminal.app is nice). With this patch you can > switch to The Next Window or The Next XTerm - the best of both worlds! > diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c > --- a/WPrefs.app/KeyboardShortcuts.c > +++ b/WPrefs.app/KeyboardShortcuts.c > @@ -87,6 +87,8 @@ > "SelectKey", > "FocusNextKey", > "FocusPrevKey", > + "GroupNextKey", > + "GroupPrevKey", > "NextWorkspaceKey", > "PrevWorkspaceKey", > "NextWorkspaceLayerKey", > @@ -515,6 +517,8 @@ > WMAddListItem(panel->actLs, _("Select active window")); > WMAddListItem(panel->actLs, _("Focus next window")); > WMAddListItem(panel->actLs, _("Focus previous window")); > + WMAddListItem(panel->actLs, _("Focus next group window")); > + WMAddListItem(panel->actLs, _("Focus previous group window")); > WMAddListItem(panel->actLs, _("Switch to next workspace")); > WMAddListItem(panel->actLs, _("Switch to previous workspace")); > WMAddListItem(panel->actLs, _("Switch to next ten workspaces")); > diff --git a/src/cycling.c b/src/cycling.c > --- a/src/cycling.c > +++ b/src/cycling.c > @@ -65,7 +65,7 @@ > > > void > -StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) > +StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next, Bool osx_cycling) > { > WScreen *scr = wScreenForRootWindow(event->xkey.root); > Bool done = False; > @@ -106,7 +106,7 @@ > > scr->flags.doing_alt_tab = 1; > > - swpanel = wInitSwitchPanel(scr, wwin, scr->current_workspace); > + swpanel = wInitSwitchPanel(scr, wwin, scr->current_workspace, > osx_cycling); > oldFocused = wwin; > > if (swpanel) { > @@ -142,7 +142,9 @@ > printf("Got key press\n"); > #endif > if ((wKeyBindings[WKBD_FOCUSNEXT].keycode == ev.xkey.keycode > - && wKeyBindings[WKBD_FOCUSNEXT].modifier == modifiers) > + && wKeyBindings[WKBD_FOCUSNEXT].modifier == modifiers) > + || (wKeyBindings[WKBD_GROUPNEXT].keycode == ev.xkey.keycode > + && wKeyBindings[WKBD_GROUPNEXT].modifier == modifiers) > || ev.xkey.keycode == rightKey) { > > if (swpanel) { > @@ -158,7 +160,9 @@ > } > } > } else if ((wKeyBindings[WKBD_FOCUSPREV].keycode == > ev.xkey.keycode > - && wKeyBindings[WKBD_FOCUSPREV].modifier == > modifiers) > + && wKeyBindings[WKBD_FOCUSPREV].modifier == modifiers) > + || (wKeyBindings[WKBD_GROUPPREV].keycode == > ev.xkey.keycode > + && wKeyBindings[WKBD_GROUPPREV].modifier == modifiers) > || ev.xkey.keycode == leftKey) { > > if (swpanel) { > diff --git a/src/defaults.c b/src/defaults.c > --- a/src/defaults.c > +++ b/src/defaults.c > @@ -732,6 +732,12 @@ > {"FocusPrevKey", "None", (void*)WKBD_FOCUSPREV, > NULL, getKeybind, setKeyGrab > }, > + {"GroupNextKey", "None", (void*)WKBD_FOCUSPREV, > + NULL, getKeybind, setKeyGrab > + }, > + {"GroupPrevKey", "None", (void*)WKBD_GROUPPREV, > + NULL, getKeybind, setKeyGrab > + }, > {"NextWorkspaceKey", "None", (void*)WKBD_NEXTWORKSPACE, > NULL, getKeybind, setKeyGrab > }, > diff --git a/src/event.c b/src/event.c > --- a/src/event.c > +++ b/src/event.c > @@ -1535,11 +1535,19 @@ > } > break; > case WKBD_FOCUSNEXT: > - StartWindozeCycle(wwin, event, True); > + StartWindozeCycle(wwin, event, True, False); > break; > > case WKBD_FOCUSPREV: > - StartWindozeCycle(wwin, event, False); > + StartWindozeCycle(wwin, event, False, False); > + break; > + > + case WKBD_GROUPNEXT: > + StartWindozeCycle(wwin, event, True, True); > + break; > + > + case WKBD_GROUPPREV: > + StartWindozeCycle(wwin, event, False, True); > break; > > #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP) > diff --git a/src/funcs.h b/src/funcs.h > --- a/src/funcs.h > +++ b/src/funcs.h > @@ -92,7 +92,7 @@ > unsigned int width, unsigned int height); > > > -void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next); > +void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next, Bool > osx_cycling); > > #ifdef USECPP > char *MakeCPPArgs(char *path); > diff --git a/src/keybind.h b/src/keybind.h > --- a/src/keybind.h > +++ b/src/keybind.h > @@ -48,41 +48,43 @@ > /* window */ > #define WKBD_FOCUSNEXT 19 > #define WKBD_FOCUSPREV 20 > +#define WKBD_GROUPNEXT 21 > +#define WKBD_GROUPPREV 22 > > -#define WKBD_WORKSPACE1 21 > -#define WKBD_WORKSPACE2 22 > -#define WKBD_WORKSPACE3 23 > -#define WKBD_WORKSPACE4 24 > -#define WKBD_WORKSPACE5 25 > -#define WKBD_WORKSPACE6 26 > -#define WKBD_WORKSPACE7 27 > -#define WKBD_WORKSPACE8 28 > -#define WKBD_WORKSPACE9 29 > -#define WKBD_WORKSPACE10 30 > -#define WKBD_NEXTWORKSPACE 31 > -#define WKBD_PREVWORKSPACE 32 > -#define WKBD_NEXTWSLAYER 33 > -#define WKBD_PREVWSLAYER 34 > +#define WKBD_WORKSPACE1 23 > +#define WKBD_WORKSPACE2 24 > +#define WKBD_WORKSPACE3 25 > +#define WKBD_WORKSPACE4 26 > +#define WKBD_WORKSPACE5 27 > +#define WKBD_WORKSPACE6 28 > +#define WKBD_WORKSPACE7 29 > +#define WKBD_WORKSPACE8 30 > +#define WKBD_WORKSPACE9 31 > +#define WKBD_WORKSPACE10 32 > +#define WKBD_NEXTWORKSPACE 33 > +#define WKBD_PREVWORKSPACE 34 > +#define WKBD_NEXTWSLAYER 35 > +#define WKBD_PREVWSLAYER 36 > > /* window shortcuts */ > -#define WKBD_WINDOW1 35 > -#define WKBD_WINDOW2 36 > -#define WKBD_WINDOW3 37 > -#define WKBD_WINDOW4 38 > -#define WKBD_WINDOW5 39 > -#define WKBD_WINDOW6 40 > -#define WKBD_WINDOW7 41 > -#define WKBD_WINDOW8 42 > -#define WKBD_WINDOW9 43 > -#define WKBD_WINDOW10 44 > +#define WKBD_WINDOW1 37 > +#define WKBD_WINDOW2 38 > +#define WKBD_WINDOW3 39 > +#define WKBD_WINDOW4 40 > +#define WKBD_WINDOW5 41 > +#define WKBD_WINDOW6 42 > +#define WKBD_WINDOW7 43 > +#define WKBD_WINDOW8 44 > +#define WKBD_WINDOW9 45 > +#define WKBD_WINDOW10 46 > > -#define WKBD_SWITCH_SCREEN 45 > +#define WKBD_SWITCH_SCREEN 47 > > #ifdef KEEP_XKB_LOCK_STATUS > -# define WKBD_TOGGLE 46 > -# define WKBD_TMP 47 > +# define WKBD_TOGGLE 48 > +# define WKBD_TMP 49 > #else > -# define WKBD_TMP 46 > +# define WKBD_TMP 48 > #endif > > #ifdef VIRTUAL_DESKTOP > diff --git a/src/switchpanel.c b/src/switchpanel.c > --- a/src/switchpanel.c > +++ b/src/switchpanel.c > @@ -399,7 +399,7 @@ > > > static WMArray *makeWindowListArray(WScreen *scr, WWindow *curwin, int > workspace, > - int include_unmapped) > + int include_unmapped, Bool osx_cycling) > { > WMArray *windows= WMCreateArray(10); > int fl; > @@ -410,6 +410,16 @@ > if (((!fl && canReceiveFocus(wwin) > 0) || (fl && > canReceiveFocus(wwin) < 0)) && > (!WFLAGP(wwin, skip_window_list) || > wwin->flags.internal_window) && > (wwin->flags.mapped || include_unmapped)) { > + if (osx_cycling) { > + if (!wwin->wm_instance || !curwin->wm_instance) > + continue; > + if (strcmp(wwin->wm_instance, curwin->wm_instance)) > + continue; > + if (!wwin->wm_class || !curwin->wm_class) > + continue; > + if (strcmp(wwin->wm_class, curwin->wm_class)) > + continue; > + } > WMAddToArray(windows, wwin); > } > } > @@ -422,6 +432,16 @@ > if (((!fl && canReceiveFocus(wwin) > 0) || (fl && > canReceiveFocus(wwin) < 0)) && > (!WFLAGP(wwin, skip_window_list) || > wwin->flags.internal_window) && > (wwin->flags.mapped || include_unmapped)) { > + if (osx_cycling) { > + if (!wwin->wm_instance || !curwin->wm_instance) > + continue; > + if (strcmp(wwin->wm_instance, curwin->wm_instance)) > + continue; > + if (!wwin->wm_class || !curwin->wm_class) > + continue; > + if (strcmp(wwin->wm_class, curwin->wm_class)) > + continue; > + } > WMAddToArray(windows, wwin); > } > } > @@ -434,7 +454,7 @@ > > > > -WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, int workspace) > +WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, int workspace, > Bool osx_cycling) > { > WWindow *wwin; > WSwitchPanel *panel= wmalloc(sizeof(WSwitchPanel)); > @@ -451,7 +471,7 @@ > panel->scr= scr; > > panel->windows= makeWindowListArray(scr, curwin, workspace, > - wPreferences.swtileImage!=0); > + wPreferences.swtileImage!=0, > osx_cycling); > count= WMGetArrayItemCount(panel->windows); > > if (count == 0) { > diff --git a/src/switchpanel.h b/src/switchpanel.h > --- a/src/switchpanel.h > +++ b/src/switchpanel.h > @@ -24,7 +24,7 @@ > > typedef struct SwitchPanel WSwitchPanel; > > -WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, int workspace); > +WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, int workspace, > Bool osx_cycling); > > void wSwitchPanelDestroy(WSwitchPanel *panel); > > > -- > [-] > > mkdir /nonexistent > > > -- > To unsubscribe, send mail to [email protected]. > -- To unsubscribe, send mail to [email protected].
