Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate various enhancements from the Net #2

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Add option -S to sort window list in stacking order
  • Loading branch information
wandrien authored and kfogel committed Sep 9, 2018
commit 4d08030463819d6479bc138af522cbdb9a222a59
40 changes: 27 additions & 13 deletions main.c
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
" -h Print help.\n" \
"\n" \
"Options:\n" \
" -S List windows in stacking order (bottom to top).\n" \
" -i Interpret <WIN> as a numerical window ID.\n" \
" -p Include PIDs in the window list. Very few\n" \
" X applications support this feature.\n" \
@@ -232,6 +233,7 @@ static struct {
int show_class;
int show_pid;
int show_geometry;
int stacking_order;
int match_by_id;
int match_by_cls;
int full_window_title_match;
@@ -267,12 +269,15 @@ int main (int argc, char **argv) { /* {{{ */
}
}

while ((opt = getopt(argc, argv, "FGVvhlupidjmxa:r:s:c:t:w:k:o:n:g:e:y:b:z:E:N:I:T:R:")) != -1) {
while ((opt = getopt(argc, argv, "FGVvhSlupidjmxa:r:s:c:t:w:k:o:n:g:e:y:b:z:E:N:I:T:R:")) != -1) {
missing_option = 0;
switch (opt) {
case 'F':
options.full_window_title_match = 1;
break;
case 'S':
options.stacking_order = 1;
break;
case 'G':
options.show_geometry = 1;
break;
@@ -1304,18 +1309,27 @@ static int longest_str (gchar **strv) {/*{{{*/
}/*}}}*/

static Window *get_client_list (Display *disp, unsigned long *size) {/*{{{*/
Window *client_list;

if ((client_list = (Window *)get_property(disp, DefaultRootWindow(disp),
XA_WINDOW, "_NET_CLIENT_LIST", size)) == NULL) {
if ((client_list = (Window *)get_property(disp, DefaultRootWindow(disp),
XA_CARDINAL, "_WIN_CLIENT_LIST", size)) == NULL) {
fputs("Cannot get client list properties. \n"
"(_NET_CLIENT_LIST or _WIN_CLIENT_LIST)"
"\n", stderr);
return NULL;
}
}
Window *client_list = NULL;
char * msg = NULL;

if (options.stacking_order)
{
msg = "_NET_CLIENT_LIST_STACKING";
client_list = (Window *) get_property(disp, DefaultRootWindow(disp),
XA_WINDOW, "_NET_CLIENT_LIST_STACKING", size);
}
else
{
msg = "_NET_CLIENT_LIST or _WIN_CLIENT_LIST";
client_list = (Window *)get_property(disp, DefaultRootWindow(disp),
XA_WINDOW, "_NET_CLIENT_LIST", size);
if (!client_list)
client_list = (Window *)get_property(disp, DefaultRootWindow(disp),
XA_CARDINAL, "_WIN_CLIENT_LIST", size);
}

if (!client_list)
fprintf(stderr, "Cannot get client list properties.\n(%s)\n", msg);

return client_list;
}/*}}}*/
4 changes: 4 additions & 0 deletions wmctrl.1
Original file line number Diff line number Diff line change
@@ -219,6 +219,10 @@ Include geometry information in the output of the
.B \-l
action.

.TP
.B \-S
List windows in stacking order (bottom to top).

.TP
.B \-i
Interpret window arguments