| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 
 | #!/usr/bin/perl -w
# Copyright 2011, 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other.  If not, see <http://www.gnu.org/licenses/>.
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
$ENV{'DISPLAY'} ||= ':0';
{
  my $X = X11::Protocol->new;
  $X->init_extension('DOUBLE-BUFFER') or die;
  # {
  #   my @version = $X->DbeGetVersion (99,99);
  #   ### @version
  # }
  # # $X->QueryPointer($X->{'root'}); # sync
  {
    ### DbeGetVisualInfo send ...
    my $window = $X->root;
    my $seq = $X->send('DbeGetVisualInfo',$window);
    sleep 1;
    ### $seq
    ### sync ...
    # foreach (1..7) {
    #   $X->send('GetAtomName',3);
    # }
    # # $X->{'connection'}->give("\0"x16384);
    # $X->flush;
    # 
    # $X->QueryPointer($X->{'root'});
    for (;;) {
      ### X handle_input ...
      $X->handle_input;
    }
    exit 0;
  }
  {
    ### DbeGetVisualInfo ...
    ### seq: $X->{'sequence_num'}
    my @infos = $X->DbeGetVisualInfo($X->root);
    ### @infos
  }
  $X->QueryPointer($X->{'root'}); # sync
  exit 0;
}
{
  my $X = X11::Protocol->new (':0');
  $X->{'event_handler'} = sub {
    my (%h) = @_;
    ### event_handler: \%h
  };
  $X->init_extension('DOUBLE-BUFFER') or die $@;
  $X->QueryPointer($X->{'root'}); # sync
  my $width = 100;
  my $height = 100;
  my $window = $X->new_rsrc;
  $X->CreateWindow ($window,
                    $X->root,         # parent
                    'InputOutput',
                    0,                # depth, from parent
                    'CopyFromParent', # visual
                    0,0,              # x,y
                    $width,$height,
                    0,                # border
                    background_pixel => $X->black_pixel,
                   );
  $X->MapWindow ($window);
  sleep 1;
  my $gc = $X->new_rsrc;
  $X->CreateGC ($gc, $window,
                foreground => 0xFF00FF,
                background => 0);
  my $buffer = $X->new_rsrc;
  $X->DbeAllocateBackBufferName ($window, $buffer, 'Copied');
  $X->QueryPointer($X->{'root'}); # sync
  $X->PolyFillRectangle ($buffer, $gc, [10,10, $width,$height]);
  $X->QueryPointer($X->{'root'}); # sync
  sleep 1;
  $X->DbeSwapBuffers ($window, 'Copied');
  $X->QueryPointer($X->{'root'}); # sync
  sleep 1;
  {
    my @attr = $X->DbeGetBackBufferAttributes ($buffer);
    ### @attr
    $X->QueryPointer($X->{'root'}); # sync
  }
  $X->DestroyWindow ($window);
  $X->QueryPointer($X->{'root'}); # sync
  {
    my @attr = $X->DbeGetBackBufferAttributes ($buffer);
    ### @attr
    $X->QueryPointer($X->{'root'}); # sync
  }
  $X->DbeDellocateBackBufferName ($buffer);
  $X->PolyFillRectangle ($buffer, $gc, [0,0, $width,$height]);
  $X->QueryPointer($X->{'root'}); # sync
  exit 0;
}
sub atom_name_maybe {
  my ($X, $atom) = @_;
  my $ret = $X->robust_req ('GetAtomName', $atom);
  if (ref $ret) {
    return @$ret;
  }
  return '[not-atom]';
}
 |