-Tweak intelligence with respect to top panels, copy xtcd from 1.3
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@426 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -25,11 +25,12 @@ my $curry; | ||||
| my $wmxo; | ||||
| my $wmyo; | ||||
| my $currx; | ||||
| my $curry; | ||||
| my $screenwidth; | ||||
| my $screenheight; | ||||
| my $window_width; | ||||
| my $window_height; | ||||
| my $panel_pad=0; | ||||
| my $top_pad; | ||||
| if (defined($tilefact)) { | ||||
|    my $rootinf = `xwininfo -root`; | ||||
|    foreach (split /\n/,$rootinf) { | ||||
| @@ -39,19 +40,28 @@ if (defined($tilefact)) { | ||||
|          $screenheight=$1; | ||||
|       } | ||||
|    } | ||||
|    system("xterm -name $firstnode -title $firstnode -n $firstnode -geometry +0+0 -e /bin/sh -c \"$mydir/xtcd.pl ".$ENV{DISPLAY}." $firstnode $firstnode & $mydir/rcons $firstnode\" &"); | ||||
|    $rootinf = `xwininfo -name "Top Panel"`; | ||||
|    foreach (split /\n/,$rootinf) { | ||||
|       if (/-geometry\s+([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+)/) { | ||||
|          if ($1 > 640 and $2 < 480 and $3 == 0 and $4 == 0) {  | ||||
|             $panel_pad=$2; | ||||
|          } | ||||
|       } | ||||
|    } | ||||
|  | ||||
|  | ||||
|    system("xterm -fn 5x7 -name $firstnode -title $firstnode -n $firstnode -geometry +0+0 -e /bin/sh -c \"$mydir/xtcd.pl ".$ENV{DISPLAY}." $firstnode $firstnode & $mydir/rcons $firstnode\" &"); | ||||
|    sleep(2); #Give time for window manager to figure out everything | ||||
|    my $xinfo = `xwininfo -name $firstnode`; | ||||
|    my @xinfl = split(/\n/,$xinfo); | ||||
|    my $side_pad; | ||||
|    my $top_pad; | ||||
|    my $wmxo; | ||||
|    my $wmyo; | ||||
|    foreach (@xinfl) { | ||||
|       if (/.*Absolute upper-left X:\s*([0-9]*).*/) { | ||||
|          $side_pad = $1; | ||||
|       } elsif (/.*Absolute upper-left Y:\s*([0-9]*).*/) { | ||||
|          $top_pad = $1; | ||||
|          $top_pad = $1-$panel_pad; | ||||
|       } elsif (/.*Width:\s*([0-9]*).*/) { | ||||
|          $window_width = $1; | ||||
|       } elsif (/.*Height:\s*([0-9]*).*/) { | ||||
| @@ -66,16 +76,17 @@ if (defined($tilefact)) { | ||||
|    $screenwidth-=$wmxo; #Subtract a factor that 1.3 did, not sure why precisely | ||||
|    $screenheight-=$wmyo; | ||||
|    $currx=$window_width; | ||||
|    $curry=0; | ||||
|    $curry=$panel_pad; #+$top_pad; | ||||
|    my $maxcol = int($screenwidth/$window_width); | ||||
|    unless ($tilefact or $tilefact > $maxcol) { | ||||
|       $tilefact=$maxcol; | ||||
|    } | ||||
|    if ($tilefact==1) { | ||||
|       $curry+=$window_height; | ||||
|       $currx=0; | ||||
|    } | ||||
| } else { | ||||
|    system("xterm -name $firstnode -title $firstnode -n $firstnode -e /bin/sh -c \"$mydir/xtcd.pl ".$ENV{DISPLAY}." $firstnode $firstnode & $mydir/rcons $firstnode\" &"); | ||||
|    system("xterm -fn 5x7 -name $firstnode -title $firstnode -n $firstnode -e /bin/sh -c \"$mydir/xtcd.pl ".$ENV{DISPLAY}." $firstnode $firstnode & $mydir/rcons $firstnode\" &"); | ||||
|  | ||||
| } | ||||
| my $geometry=""; | ||||
| @@ -89,12 +100,12 @@ foreach (@nodes) { | ||||
|          $currx=0; | ||||
|          $curry+=$window_height; | ||||
|          if ($curry > $screenheight) { | ||||
|             $curry = 0; | ||||
|             $curry = $panel_pad; #+$top_pad; | ||||
|          } | ||||
|       } | ||||
|    } | ||||
|  | ||||
|    system("xterm -name $_ -title $_ -n $_ $geometry -e /bin/sh -c \"$mydir/xtcd.pl .".$ENV{DISPLAY}." $_ $_ & $mydir/rcons $_\" &"); | ||||
|    system("xterm -fn 5x7 -name $_ -title $_ -n $_ $geometry -e /bin/sh -c \"$mydir/xtcd.pl .".$ENV{DISPLAY}." $_ $_ & $mydir/rcons $_\" &"); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -103,5 +114,5 @@ foreach (@nodes) { | ||||
| #MYDIR=`dirname $0` | ||||
| #for n in $NODES | ||||
| #do | ||||
| #	xterm -name wcons -T $n -n $n -e $MYDIR/rcons $n & | ||||
| #	xterm -fn 5x7 -name wcons -T $n -n $n -e $MYDIR/rcons $n & | ||||
| #done | ||||
|   | ||||
							
								
								
									
										124
									
								
								xCAT-client-2.0/bin/xtcd.pl
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										124
									
								
								xCAT-client-2.0/bin/xtcd.pl
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,124 @@ | ||||
| #!/usr/bin/perl | ||||
|  | ||||
| #use strict; | ||||
| use IO::Socket; | ||||
| use File::Path; | ||||
| use POSIX qw(:signal_h WNOHANG); | ||||
| use Sys::Syslog qw(:DEFAULT setlogsock); | ||||
|  | ||||
| my $sock_dir = "/tmp/.xtcd"; | ||||
| mkpath($sock_dir); | ||||
| my $display = shift; | ||||
| my $node = shift; | ||||
| my $title = shift; | ||||
| my $quit = 0; | ||||
|  | ||||
| my $sock_path = "$sock_dir/$display.$node"; | ||||
|  | ||||
| $SIG{CHLD} = sub { while ( waitpid(-1,WNOHANG) > 0 ) { } }; | ||||
| $SIG{HUP} = $SIG{TERM} = $SIG{INT} = sub { $quit++ }; | ||||
|  | ||||
| unlink($sock_path); | ||||
| umask(0111); | ||||
|  | ||||
| my $listen; | ||||
|  | ||||
| $listen = IO::Socket::UNIX->new( | ||||
| 	Local => $sock_path, | ||||
| 	Listen => SOMAXCONN | ||||
| ); | ||||
| unless($listen) { | ||||
| 	print("xtcd: $display.$node cannot create a listening socket: $@"); | ||||
| 	die "cannot create a listening socket $sock_path: $@"; | ||||
| } | ||||
|  | ||||
| while(!$quit) { | ||||
| 	my $connected = $listen->accept(); | ||||
| 	my $child = launch_child(); | ||||
|  | ||||
| 	if(!defined $child) { | ||||
| 		print("xtcd: $display.$node cannot fork, exiting"); | ||||
| 		die "cannot fork"; | ||||
| 	}  | ||||
|  | ||||
| 	if($child) { | ||||
| 		close $connected; | ||||
| 	} | ||||
| 	else { | ||||
| 		close $listen; | ||||
| 		interact($connected); | ||||
| 		exit 0; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| unlink($sock_path); | ||||
| exit(0); | ||||
|  | ||||
| sub launch_child { | ||||
| 	my $signals = POSIX::SigSet->new(SIGINT,SIGCHLD,SIGTERM,SIGHUP); | ||||
| 	sigprocmask(SIG_BLOCK,$signals); | ||||
| 	my $child = fork(); | ||||
| 	unless($child) { | ||||
| 		$SIG{$_} = 'DEFAULT' foreach qw(HUP INT TERM CHLD); | ||||
| 	} | ||||
| 	sigprocmask(SIG_UNBLOCK,$signals); | ||||
| 	return $child; | ||||
| } | ||||
|  | ||||
| sub interact { | ||||
| 	my $c = shift; | ||||
| 	my $command; | ||||
|  | ||||
| 	my $commandstring = <$c>; | ||||
| 	chomp($commandstring); | ||||
|  | ||||
| 	foreach(split(/ /,$commandstring)) { | ||||
| 		$command = $_; | ||||
|  | ||||
| 		if($command eq "ping") { | ||||
| #			print $c "ok ping\n"; | ||||
| 		} | ||||
| 		elsif($command =~ /move=/) { | ||||
| 			$command =~ s/move=//; | ||||
| 			my ($x,$y) = split(/x/,$command); | ||||
| 			print "\033[3;${x};${y}t"; | ||||
| #			print $c "ok move\n"; | ||||
| 		} | ||||
| 		elsif($command =~ /font=/) { | ||||
| 			$command =~ s/font=//; | ||||
| 			print "\033]50;${command}\007"; | ||||
| #			print $c "ok font\n"; | ||||
| 		} | ||||
| 		elsif($command eq "raise") { | ||||
| 			print "\033[5t"; | ||||
| #			print $c "ok raise\n"; | ||||
| 		} | ||||
| 		elsif($command eq "lower") { | ||||
| 			print "\033[6t"; | ||||
| #			print $c "ok lower\n"; | ||||
| 		} | ||||
| 		elsif($command eq "refresh") { | ||||
| 			print "\033[7t"; | ||||
| #			print $c "ok refresh\n"; | ||||
| 		} | ||||
| 		elsif($command eq "iconify") { | ||||
| 			print "\033[2t"; | ||||
| #			print $c "ok iconify\n"; | ||||
| 		} | ||||
| 		elsif($command eq "restore") { | ||||
| 			print "\033[1t"; | ||||
| #			print $c "ok restore\n"; | ||||
| 		} | ||||
| 		elsif($command eq "title") { | ||||
| 			print "\033]2;${title}\007"; | ||||
| #			print $c "ok title\n"; | ||||
| 		} | ||||
| 		elsif($command =~ /title=/) { | ||||
| 			$command =~ s/title=//; | ||||
| 			print "\033]2;${command}\007"; | ||||
| #			print $c "ok title\n"; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	close $c; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user