From owner-freebsd-hackers Mon Aug 31 17:21:09 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA09223 for freebsd-hackers-outgoing; Mon, 31 Aug 1998 17:21:09 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from moebius.space.net (moebius.Space.Net [195.30.1.25]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id RAA09203 for ; Mon, 31 Aug 1998 17:21:01 -0700 (PDT) (envelope-from maex@Space.Net) Received: (qmail 551 invoked by uid 1013); 1 Sep 1998 00:20:01 -0000 Message-ID: <19980901022000.V26849@space.net> Date: Tue, 1 Sep 1998 02:20:00 +0200 From: Markus Stumpf To: Kelly Yancey , freebsd-hackers@FreeBSD.ORG Subject: Re: determining an X window ID? References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0F1p//8PRICkK4MW" X-Mailer: Mutt 0.93.2i In-Reply-To: ; from Kelly Yancey on Sat, Aug 29, 1998 at 03:55:41AM -0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii On Sat, Aug 29, 1998 at 03:55:41AM -0400, Kelly Yancey wrote: > I have written a fairly short shell script to launch xmcd which first > checks to see if any other cd player is already running and if so, does > not launch another instance of xmcd (for when I click on the wrong thing > :) ) > Anyway, I'm running fvwm2 and thought it would sure be nice if I could > somehow have the script bring the already running cd player to the > foreground...kind of a "Here it dummy" response. It's starting to look > like this seemingly simple task is anything but. 2 things: 1) there is a programm called "xlsclients" which shows you all the clients currently using your X Server (even remote ones). This may be a better way to check for the xmcd. 2) I'll attach a small programm (xselraise.c) and a Imakefile (use xmkmf to create a Makefile). Hope that is ok with the charter of the list, as it is only about 80 lines. The program take a CLASS name (i.e. 'XMcd' for xmcd) and raises it. Note: as it raises all windows with that class, it will also raise all the popups (if mapped). You can easily modify it to take names instead of classes (wrote this a while back to raise all "xload"s) by changing the code at line 30 from if (strcmp(to_raise, class_hint.res_class) == 0) { to if (strcmp(to_raise, class_hint.res_name) == 0) { You could aso play with the return code to keep track whether it found a window to raise or not und thus get rid of xlsclients/ps. Hope thats helps! \Maex Mit freundlichen Gruessen Markus Stumpf -- SpaceNet GmbH | http://www.Space.Net/ | In a world whithout Research & Development | mailto:research@Space.Net | walls and fences, Frankfurter Ring 193a | Tel: +49 (89) 32356-0 | who needs D-80807 Muenchen | Fax: +49 (89) 32356-299 | Windows and Gates? --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=Imakefile SRCS = xselraise.c OBJS = xselraise.o # DEPLIBS = XawClientDepLibs LOCAL_LIBRARIES = XawClientLibs ComplexProgramTarget(xselraise) --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="xselraise.c" #include #include #include #include Atom _XA_WM_PROTOCOLS; char *to_raise; void RaiseIt(dpy, window) Display *dpy; Window window; { XRaiseWindow(dpy, window); XFlush(dpy); } void ParseTree(dpy, parent) Display *dpy; Window parent; { Window *children, root_return, parent_return; unsigned int num_children, i; char *win_name; XClassHint class_hint; if(XGetClassHint(dpy, parent, &class_hint)) { if (strcmp(to_raise, class_hint.res_class) == 0) { printf("raising %s \n", class_hint.res_name); RaiseIt(dpy, parent); } XFree(class_hint.res_class); XFree(class_hint.res_name); } else { XQueryTree(dpy, parent, &root_return, &parent_return, &children , &num_children); for(i = 0; i < num_children; i++) ParseTree(dpy, children[i]); } } main(argc, argv) int argc; char **argv; { Display *dpy ; if( ( dpy = XOpenDisplay(NULL) ) == NULL ) { fprintf( stderr, "Can't open display !\n" ); exit(1); } if (argc != 2) { fprintf(stderr, "%s: class to raise expected\n", argv[0]); exit(1); } to_raise = argv[1]; _XA_WM_PROTOCOLS = XInternAtom (dpy, "WM_PROTOCOLS", False); ParseTree(dpy, DefaultRootWindow(dpy)); exit(0); } --0F1p//8PRICkK4MW-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message