| 1 | package X11::WM::Sawfish::XProp; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2003 Craig B. Agricola. All rights reserved. This library is | ||||||||||||||||||||||||||||
| 4 | # free software; you can redistribute it and/or modify it under the same terms | ||||||||||||||||||||||||||||
| 5 | # as Perl itself. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use 5.005; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use X11::WM::Sawfish; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | our @ISA = qw(X11::WM::Sawfish); | |||||||||||||||||||||||||||
| 15 | 1 | our @EXPORT_OK = qw(); | |||||||||||||||||||||||||||
| 16 | 1 | our @EXPORT = qw(); | |||||||||||||||||||||||||||
| 17 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use X11::Protocol; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use constant XA_CARDINAL => 6; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use constant XA_STRING => 31; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use constant PROTOCOL_X11_VERSION => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($package, $display) = @_; | |||||||||||||||||||||||||||
| 28 | 0 | ▶ | $package = ref($package) || $package; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $package || $package
MC/DC0%0/2
ref $package || $package
ref $package
$package
Truth table0%0/3
A || B
A= ref $packageB= $package
| |||||||||||||||||||||||||||||
| 29 | 0 | my ($self) = {}; | |||||||||||||||||||||||||||
| 30 | 0 | bless($self, $package); | |||||||||||||||||||||||||||
| 31 | 0 | $self->{Display} = X11::WM::Sawfish::canonical_display_name($display); | |||||||||||||||||||||||||||
| 32 | 0 | $self->get_server_version(); | |||||||||||||||||||||||||||
| 33 | 0 | ▶ | if (!defined($self->{Display})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 0 | $!=111; # Connection refused | |||||||||||||||||||||||||||
| 35 | 0 | return(undef); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 0 | return($self); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub open_xserver { | ||||||||||||||||||||||||||
|
Subroutine
open_xserver: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | if (!defined($self->{X11})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | my ($x) = $self->{X11} = new X11::Protocol($self->{Display}); | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | if (defined($x)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | my ($value, $type, $format, $bytes_after) = | |||||||||||||||||||||||||||
| 46 | $x->GetProperty($x->root, $x->atom("_SAWFISH_REQUEST_WIN"), | ||||||||||||||||||||||||||||
| 47 | XA_CARDINAL, 0, 1, 0); | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if (($type == XA_CARDINAL) && ($format == 32)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type == 6 and $format == 32
MC/DC0%0/2
$type == 6 and $format == 32
$type == 6
$format == 32
Truth table0%0/3
A and B
A= $type == 6B= $format == 32
| |||||||||||||||||||||||||||||
| 49 | 0 | $self->{ServerRequestWindow} = unpack("I", $value); | |||||||||||||||||||||||||||
| 50 | 0 | $x->{event_handler} = "queue"; | |||||||||||||||||||||||||||
| 51 | 0 | my $event_mask = $x->pack_event_mask("PropertyChange"); | |||||||||||||||||||||||||||
| 52 | 0 | my $crwin = $x->new_rsrc(); | |||||||||||||||||||||||||||
| 53 | 0 | $x->CreateWindow($crwin, $x->root, 0, 0, 0, -100, -100, 10, 10, 0, | |||||||||||||||||||||||||||
| 54 | "event_mask" => $event_mask); | ||||||||||||||||||||||||||||
| 55 | 0 | $self->{ClientRequestWindow} = $crwin; | |||||||||||||||||||||||||||
| 56 | 0 | $self->{RequestProperty} = $x->atom("_SAWFISH_REQUEST"); | |||||||||||||||||||||||||||
| 57 | 0 | } else { $self->{X11} = undef; } | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 0 | return($self->{X11}); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub close_xserver { | ||||||||||||||||||||||||||
|
Subroutine
close_xserver: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 65 | 0 | my $x = $self->{X11}; | |||||||||||||||||||||||||||
| 66 | 0 | $x->DestroyWindow($x->{ClientRequestWindow}); | |||||||||||||||||||||||||||
| 67 | 0 | undef($self->{X11}); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub eval_form { | ||||||||||||||||||||||||||
|
Subroutine
eval_form: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 0 | my ($self, $form) = @_; | |||||||||||||||||||||||||||
| 72 | 0 | my ($resp, $state); | |||||||||||||||||||||||||||
| 73 | 0 | my $x = $self->open_xserver(); | |||||||||||||||||||||||||||
| 74 | 0 | $resp = undef; | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | if (defined($x)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | $x->ChangeProperty($self->{ClientRequestWindow}, | ||||||||||||||||||||||||||||
| 77 | $self->{RequestProperty}, | ||||||||||||||||||||||||||||
| 78 | 0 | XA_STRING, 8, 'Replace', $form); | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | # Gobble up the PropertyChangeEvent that we will get | ||||||||||||||||||||||||||||
| 81 | 0 | $x->next_event(); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | my $event = $x->pack_event('name' => 'ClientMessage', | ||||||||||||||||||||||||||||
| 84 | 'window' => $x->root, | ||||||||||||||||||||||||||||
| 85 | 'type' => $self->{RequestProperty}, | ||||||||||||||||||||||||||||
| 86 | 'format' => 32, | ||||||||||||||||||||||||||||
| 87 | 'data' => pack("LLLLL", | ||||||||||||||||||||||||||||
| 88 | PROTOCOL_X11_VERSION, | ||||||||||||||||||||||||||||
| 89 | $self->{ClientRequestWindow}, | ||||||||||||||||||||||||||||
| 90 | $self->{RequestProperty}, | ||||||||||||||||||||||||||||
| 91 | 0 | 1, 0)); | |||||||||||||||||||||||||||
| 92 | 0 | $x->SendEvent($self->{ServerRequestWindow}, 0, 0, $event); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | # Wait for Sawfish to update our request property with the results | ||||||||||||||||||||||||||||
| 95 | 0 | $x->next_event(); | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | my ($value, $type, $format, $bytes_after); | |||||||||||||||||||||||||||
| 98 | 0 | my $len = 1024; | |||||||||||||||||||||||||||
| 99 | 0 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | ($value, $type, $format, $bytes_after) = | ||||||||||||||||||||||||||||
| 101 | $x->GetProperty($self->{ClientRequestWindow}, | ||||||||||||||||||||||||||||
| 102 | $self->{RequestProperty}, | ||||||||||||||||||||||||||||
| 103 | 0 | XA_STRING, 0, $bytes_after, 0); | |||||||||||||||||||||||||||
| 104 | 0 | $len += $bytes_after; | |||||||||||||||||||||||||||
| 105 | } while ($bytes_after > 0); | ||||||||||||||||||||||||||||
| 106 | 0 | ($state, $resp) = unpack("Ca*", $value); | |||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ($state != 1) { $resp = undef; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | 0 | return($resp); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 1 | 1; | |||||||||||||||||||||||||||
| 113 | __END__ | ||||||||||||||||||||||||||||