#!/usr/bin/perl
### zkgqj6rkxouaqmkzrhqukdem6d.perl  -*- Perl -*-
## Test X11::Protocol vs. IPv6

### Ivan Shmakov, 2014

## To the extent possible under law, the author(s) have dedicated all
## copyright and related and neighboring rights to this software to the
## public domain worldwide.  This software is distributed without any
## warranty.

## You should have received a copy of the CC0 Public Domain Dedication
## along with this software.  If not, see
## <http://creativecommons.org/publicdomain/zero/1.0/>.

### Code:

use common::sense;
use English qw (-no_match_vars);

require Carp;
require Data::Dump;
require Encode;
require Encode::Locale;
# require IO::Socket::IP;
require X11::Protocol;

sub localize_io {
    my ($wr_p) = shift ();
    foreach my $f (@_) {
        $f->binmode (! -t $f  ? ":encoding(locale)"
                     : $wr_p  ? ":encoding(console_out)"
                     :          ":encoding(console_in)");
    }
    ## .
    @_;
}

localize_io (0, \*STDIN);
localize_io (1, \*STDERR, \*STDOUT);

my $x
    = X11::Protocol->new ();
my $w0
    = $x->{"root"};
my ($w0_root, $w0_parent, @tlw)
    = $x->req ("QueryTree", $w0);
foreach my $w (@tlw) {
    foreach my $atom ($x->req ("ListProperties", $w)) {
        my @prop
            = $x->req ("GetProperty", $w, $atom,
                       "AnyPropertyType", 0, 200, 0);
        print ($x->atom_name ($atom), " → ",
               scalar (Data::Dump::dump (\@prop)),
               "\n");
    }
}

### zkgqj6rkxouaqmkzrhqukdem6d.perl ends here
