Re: .X11-unix and the sticky bit
Re: .X11-unix and the sticky bit
- Subject: Re: .X11-unix and the sticky bit
- From: matt shultz <email@hidden>
- Date: Wed, 14 Apr 2004 22:49:15 -0400 (EDT)
this perl script is great and does exactly what i need... however, the
program starts with an interface written in c (objective c cocoa
actually). so i need to write a c application using XGetVisualInfo. what
I have below is pretty much what i need.. However, I am having trouble
getting it to compile due to the following error
"conflicting types for 'Cursor'"
it seems that the compiler is finding a conflict between the declaration
of Cursor in X.h and in the Quickdraw framework.. I'm pretty unfamiliar
with Cocoa and Objective C, though I've been handling it find until this
point. Any experience with conflict between the standard X11 headers and
framework headers? am i doing the wrong thing by #import "Xlib.h", is
there some different way I should be doing this? using Xcode of course.
thanks!
m.
#import <Foundation/Foundation.h>
#import <Foundation/NSFileHandle.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSData.h>
#import <AppKit/AppKit.h>
#import "DropController.h"
#import "Xlib.h"
<fast forward to X11 stuff>
x11Locks = [aFileManager directoryContentsAtPath:[NSString
stringWithCString: "/tmp/.x11-unix/" ] ];
count = [x11Locks count];
{
Display * display;
XVisualInfo vinfo_template;
XVisualInfo * visualInfo;
vinfo_template.depth = 256;
for(i=0; i<count; i++){
NSRange aRange;
NSString * displayName;
lock = [x11Locks objectAtIndex:i];
aRange.location = 1;
aRange.length = [lock length] - 1;
displayName = [lock substringWithRange: aRange];
printf("display - %s -\n", [displayName cString]);
display = XOpenDisplay( [displayName cString] );
visualInfo = XGetVisualInfo(display, VisualDepthMask,vinfo_template, 1);
if(visualInfo == NULL)
printf("display %s does not match\n", [displayName cString] );
else
printf("display %s does indeed match\n", [displayName cString] );
XFree(visualInfo);
XCloseDisplay(display);
}
}
> You could write a little program to probe displays to find one that
> matches the properties you want; if you don't find one, then launch
> your own. This probing program would look at the lock files in /tmp
> (.X0-lock, .X1-lock, ...). For each of these displays, query for visual
> info (XGetVisualInfo). When you find one that is PseudoColor, use that
> one. If you don't find one, launch your own.
>
> This scheme also means that your app won't get confused if another
> user's session is already running X11 on display 5 - the probing
> application won't be able to connect to other users' servers.
>
> You can do this all from a perl script:
>
> > #!/usr/bin/perl
> > use strict;
> >
> > my $found = -1;
> > my %running;
> > foreach my $lock (`ls /tmp/.X*-lock 2>/dev/null`) {
> > $lock =~ m|([0-9]+)|;
> > my $disp = $1;
> > $running{$disp} = 1;
> > my $info = `xwininfo -root -display :$disp 2>/dev/null`;
> > if ($info =~ m|PseudoColor|) {
> > $found = $disp;
> > last;
> > }
> > }
> >
> > if ($found == -1) {
> > for (my $i = 0; ; $i++) {
> > if (!$running{$i}) {
> > print "launch new server as $i\n";
> > last;
> > }
> > }
> > } else {
> > print "found PseudoColor display $found\n";
> > }
>
> Ronnie
_______________________________________________
x11-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/x11-users
Do not post admin requests to the list. They will be ignored.