Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Sep 1998 02:20:00 +0200
From:      Markus Stumpf <maex-freebsd-hackers@Space.Net>
To:        Kelly Yancey <kbyanc@freedomnet.com>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: determining an X window ID?
Message-ID:  <19980901022000.V26849@space.net>
In-Reply-To: <Pine.BSD/.3.91.980829035503.7724A-100000@freedomnet.com>; from Kelly Yancey on Sat, Aug 29, 1998 at 03:55:41AM -0400
References:  <Pine.BSD/.3.91.980829035503.7724A-100000@freedomnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980901022000.V26849>