line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
1
|
|
25
|
use 5.005; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
8
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
9
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
52
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use X11::WM::Sawfish; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
216
|
|
14
|
|
|
|
|
|
|
our @ISA = qw(X11::WM::Sawfish); |
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw(); |
16
|
|
|
|
|
|
|
our @EXPORT = qw(); |
17
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
1504
|
use X11::Protocol; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use constant XA_CARDINAL => 6; |
22
|
|
|
|
|
|
|
use constant XA_STRING => 31; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use constant PROTOCOL_X11_VERSION => 1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
|
|
|
|
|
|
my ($package, $display) = @_; |
28
|
|
|
|
|
|
|
$package = ref($package) || $package; |
29
|
|
|
|
|
|
|
my ($self) = {}; |
30
|
|
|
|
|
|
|
bless($self, $package); |
31
|
|
|
|
|
|
|
$self->{Display} = X11::WM::Sawfish::canonical_display_name($display); |
32
|
|
|
|
|
|
|
$self->get_server_version(); |
33
|
|
|
|
|
|
|
if (!defined($self->{Display})) { |
34
|
|
|
|
|
|
|
$!=111; # Connection refused |
35
|
|
|
|
|
|
|
return(undef); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
return($self); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub open_xserver { |
41
|
|
|
|
|
|
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
if (!defined($self->{X11})) { |
43
|
|
|
|
|
|
|
my ($x) = $self->{X11} = new X11::Protocol($self->{Display}); |
44
|
|
|
|
|
|
|
if (defined($x)) { |
45
|
|
|
|
|
|
|
my ($value, $type, $format, $bytes_after) = |
46
|
|
|
|
|
|
|
$x->GetProperty($x->root, $x->atom("_SAWFISH_REQUEST_WIN"), |
47
|
|
|
|
|
|
|
XA_CARDINAL, 0, 1, 0); |
48
|
|
|
|
|
|
|
if (($type == XA_CARDINAL) && ($format == 32)) { |
49
|
|
|
|
|
|
|
$self->{ServerRequestWindow} = unpack("I", $value); |
50
|
|
|
|
|
|
|
$x->{event_handler} = "queue"; |
51
|
|
|
|
|
|
|
my $event_mask = $x->pack_event_mask("PropertyChange"); |
52
|
|
|
|
|
|
|
my $crwin = $x->new_rsrc(); |
53
|
|
|
|
|
|
|
$x->CreateWindow($crwin, $x->root, 0, 0, 0, -100, -100, 10, 10, 0, |
54
|
|
|
|
|
|
|
"event_mask" => $event_mask); |
55
|
|
|
|
|
|
|
$self->{ClientRequestWindow} = $crwin; |
56
|
|
|
|
|
|
|
$self->{RequestProperty} = $x->atom("_SAWFISH_REQUEST"); |
57
|
|
|
|
|
|
|
} else { $self->{X11} = undef; } |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
return($self->{X11}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub close_xserver { |
64
|
|
|
|
|
|
|
my ($self) = @_; |
65
|
|
|
|
|
|
|
my $x = $self->{X11}; |
66
|
|
|
|
|
|
|
$x->DestroyWindow($x->{ClientRequestWindow}); |
67
|
|
|
|
|
|
|
undef($self->{X11}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub eval_form { |
71
|
|
|
|
|
|
|
my ($self, $form) = @_; |
72
|
|
|
|
|
|
|
my ($resp, $state); |
73
|
|
|
|
|
|
|
my $x = $self->open_xserver(); |
74
|
|
|
|
|
|
|
$resp = undef; |
75
|
|
|
|
|
|
|
if (defined($x)) { |
76
|
|
|
|
|
|
|
$x->ChangeProperty($self->{ClientRequestWindow}, |
77
|
|
|
|
|
|
|
$self->{RequestProperty}, |
78
|
|
|
|
|
|
|
XA_STRING, 8, 'Replace', $form); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Gobble up the PropertyChangeEvent that we will get |
81
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
1, 0)); |
92
|
|
|
|
|
|
|
$x->SendEvent($self->{ServerRequestWindow}, 0, 0, $event); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Wait for Sawfish to update our request property with the results |
95
|
|
|
|
|
|
|
$x->next_event(); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my ($value, $type, $format, $bytes_after); |
98
|
|
|
|
|
|
|
my $len = 1024; |
99
|
|
|
|
|
|
|
do { |
100
|
|
|
|
|
|
|
($value, $type, $format, $bytes_after) = |
101
|
|
|
|
|
|
|
$x->GetProperty($self->{ClientRequestWindow}, |
102
|
|
|
|
|
|
|
$self->{RequestProperty}, |
103
|
|
|
|
|
|
|
XA_STRING, 0, $bytes_after, 0); |
104
|
|
|
|
|
|
|
$len += $bytes_after; |
105
|
|
|
|
|
|
|
} while ($bytes_after > 0); |
106
|
|
|
|
|
|
|
($state, $resp) = unpack("Ca*", $value); |
107
|
|
|
|
|
|
|
if ($state != 1) { $resp = undef; } |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
return($resp); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
__END__ |