Skip to content

Commit

Permalink
-d option for all desktops
Browse files Browse the repository at this point in the history
See #48.
  • Loading branch information
sagb committed Feb 23, 2018
1 parent 6f4cb2a commit c0d8af3
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
**alttab** is X11 window switcher designed for minimalistic window managers
or standalone X11 session.
```
alttab [-w N] [-mm N] [-bm N] [-mk N] [-kk N] [-t NxM] [-i NxM]
alttab [-w N] [-d N] [-mm N] [-bm N] [-mk N] [-kk N] [-t NxM] [-i NxM]
[-p str] [-s N] [-theme name] [-bg color] [-fg color] [-frame color]
[-font name] [-v|-vv]
```
Expand Down
2 changes: 1 addition & 1 deletion doc/README
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
alttab is X11 window switcher designed for minimalistic window managers
or standalone X11 session.

alttab [-w N] [-mm N] [-bm N] [-mk N] [-kk N] [-t NxM] [-i NxM]
alttab [-w N] [-d N] [-mm N] [-bm N] [-mk N] [-kk N] [-t NxM] [-i NxM]
[-p str] [-s N] [-theme name] [-bg color] [-fg color] [-frame color]
[-font name] [-v|-vv]

Expand Down
21 changes: 20 additions & 1 deletion doc/alttab.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\fBalttab\fR \- the task switcher
.
.SH "SYNOPSIS"
\fBalttab\fR [\fB\-w\fR \fIN\fR] [\fB\-mm\fR \fIN\fR] [\fB\-bm\fR \fIN\fR] [\fB\-mk\fR \fIN\fR] [\fB\-kk\fR \fIN\fR] [\fB\-t\fR \fINxM\fR] [\fB\-i\fR \fINxM\fR] [\fB\-s\fR \fIN\fR] [\fB\-theme\fR \fIname\fR] [\fB\-bg\fR \fIcolor\fR] [\fB\-fg\fR \fIcolor\fR] [\fB\-frame\fR \fIcolor\fR] [\fB\-font\fR \fIname\fR] [\fB\-v\fR|\fB\-vv\fR]
\fBalttab\fR [\fB\-w\fR \fIN\fR] [\fB\-d\fR \fIN\fR] [\fB\-mm\fR \fIN\fR] [\fB\-bm\fR \fIN\fR] [\fB\-mk\fR \fIN\fR] [\fB\-kk\fR \fIN\fR] [\fB\-t\fR \fINxM\fR] [\fB\-i\fR \fINxM\fR] [\fB\-p\fR \fIstr\fR] [\fB\-s\fR \fIN\fR] [\fB\-theme\fR \fIname\fR] [\fB\-bg\fR \fIcolor\fR] [\fB\-fg\fR \fIcolor\fR] [\fB\-frame\fR \fIcolor\fR] [\fB\-font\fR \fIname\fR] [\fB\-v\fR|\fB\-vv\fR]
.
.SH "DESCRIPTION"
The task switcher designed for minimalistic window managers or standalone X11 session\.
Expand Down Expand Up @@ -56,6 +56,25 @@ Alttab uses ratpoison own perfect remote control capability\. Additionally, altt
Fallback, worse than \fI0\fR\. Search for application windows at random nodes of window tree (WM is probably reparenting) and select only those with a name, including non\-viewable (WM is probably iconifying)\. May cause lag\. List order is random\. Tested in twm, flwm, wm2\.
.
.TP
\fB\-d\fR \fINUMBER\fR
resource: alttab\.desktops
.
.br
default: \fI0\fR
.
.IP
Show windows belonging to desktops (workspaces, groups)\. \fINUMBER\fR must be 0 or 1:
.
.IP
\fI0\fR: Current desktop\.
.
.IP
This is default, but implemented for EWMH only (\fB\-w 1\fR)\.
.
.IP
\fI1\fR: All desktops\.
.
.TP
\fB\-mm\fR \fINUM\fR
resource: alttab\.modifier\.mask
.
Expand Down
14 changes: 13 additions & 1 deletion doc/alttab.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ alttab(1) -- the task switcher

## SYNOPSIS

`alttab` [`-w` <N>] [`-mm` <N>] [`-bm` <N>] [`-mk` <N>] [`-kk` <N>] [`-t` <NxM>] [`-i` <NxM>] [`-s` <N>] [`-theme` <name>] [`-bg` <color>] [`-fg` <color>] [`-frame` <color>] [`-font` <name>] [`-v`|`-vv`]
`alttab` [`-w` <N>] [`-d` <N>] [`-mm` <N>] [`-bm` <N>] [`-mk` <N>] [`-kk` <N>] [`-t` <NxM>] [`-i` <NxM>] [`-p` <str>] [`-s` <N>] [`-theme` <name>] [`-bg` <color>] [`-fg` <color>] [`-frame` <color>] [`-font` <name>] [`-v`|`-vv`]

## DESCRIPTION

Expand Down Expand Up @@ -69,6 +69,18 @@ Most command line options have corresponding X resource, see doc/alttab.ad for e
List order is random.
Tested in twm, flwm, wm2.

* `-d` <NUMBER>:
resource: alttab.desktops
default: <0>

Show windows belonging to desktops (workspaces, groups). <NUMBER> must be 0 or 1:

<0>: Current desktop.

This is default, but implemented for EWMH only (`-w 1`).

<1>: All desktops.

* `-mm` <NUM>:
resource: alttab.modifier.mask
default: <8> (Mod1Mask aka left Alt)
Expand Down
7 changes: 5 additions & 2 deletions doc/alttab.ad
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
! Force using raw X11 interface
!alttab.windowmanager: 0

! Show windows belonging to all desktops
!alttab.desktops: 1

! Ctrl-Tab instead of Alt-Tab
!alttab.modifier.mask: 4
!alttab.modifier.keysym: 0xffe3
Expand All @@ -20,9 +23,9 @@
! grave (back apostrophe) instead of Tab
!alttab.key.keysym: 0x60

! try to not interfere with WM's window positioning
! Try to not interfere with WM's window positioning
!alttab.position: none
! or specify the switcher position explicitly
! Or specify the switcher position explicitly
!alttab.position: +100+100

! Big tiles
Expand Down
21 changes: 21 additions & 0 deletions src/alttab.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void helpexit()
fprintf(stderr, "alttab, the task switcher.\n\
Options:\n\
-w N window manager: 0=no, 1=ewmh-compatible, 2=ratpoison, 3=old fashion\n\
-d N desktop: 0=current 1=all\n\
-mm N main modifier mask\n\
-bm N backward scroll modifier mask\n\
-kk N keysym of main modifier\n\
Expand Down Expand Up @@ -111,6 +112,7 @@ int use_args_and_xrm(int *argc, char **argv)

XrmOptionDescRec xrmTable[] = {
{"-w", "*windowmanager", XrmoptionSepArg, NULL} ,
{"-d", "*desktops", XrmoptionSepArg, NULL} ,
{"-mm", "*modifier.mask", XrmoptionSepArg, NULL} ,
{"-bm", "*backscroll.mask", XrmoptionSepArg, NULL} ,
{"-mk", "*modifier.keysym", XrmoptionSepArg, NULL} ,
Expand Down Expand Up @@ -219,6 +221,25 @@ int use_args_and_xrm(int *argc, char **argv)
fprintf(stderr, "WM: %d\n", g.option_wm);
}

endptr = NULL;
char *dsindex = NULL;
int ds = DESK_DEFAULT;
g.option_desktop = DESK_DEFAULT;
XRESOURCE_LOAD_STRING(".desktops", dsindex, NULL);
if (dsindex) {
ds = strtol(dsindex, &endptr, 0);
if (*dsindex != '\0' && *endptr == '\0') {
if (ds >= DESK_MIN && ds <= DESK_MAX)
g.option_desktop = ds;
else
fprintf (stderr, "desktops argument must be from %d to %d, using default\n", DESK_MIN, DESK_MAX);
} else {
fprintf (stderr, inv, "desktops");
}
}
if (g.debug > 0)
fprintf(stderr, "desktops: %d\n", g.option_desktop);

unsigned int defaultModMask = DEFMODMASK;
unsigned int defaultBackMask = DEFBACKMASK;
KeySym defaultModSym = DEFMODKS;
Expand Down
6 changes: 6 additions & 0 deletions src/alttab.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ typedef struct {
#define WM_TWM 3
#define WM_MAX 3
int option_wm;
#define DESK_MIN 0
#define DESK_CURRENT 0
#define DESK_ALL 1
#define DESK_MAX 1
#define DESK_DEFAULT 0
int option_desktop;
char *option_font;
int option_tileW, option_tileH;
int option_iconW, option_iconH;
Expand Down
4 changes: 3 additions & 1 deletion src/ewmh.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ extern Window root;

// PRIVATE

// this constant can't be 0, 1, -1, because WMs set it to these values incoherently
// this constant can't be 0, 1, -1, MAXINT,
// because WMs set it to these values incoherently
#define DESKTOP_UNKNOWN 0xdead

//
Expand Down Expand Up @@ -155,6 +156,7 @@ int ewmh_initWinlist()

window_desktop = ewmh_getDesktopOfWindow(w);
if (current_desktop != window_desktop
&& g.option_desktop == DESK_CURRENT
&& current_desktop != DESKTOP_UNKNOWN
&& window_desktop != DESKTOP_UNKNOWN) {
if (g.debug > 1) {
Expand Down

0 comments on commit c0d8af3

Please sign in to comment.