| 1 | package X11::Resolution; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use X11::Protocol; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | X11::Resolution - Get information on the current resolution for X. | ||||||||||
| 10 | |||||||||||
| 11 | =head1 VERSION | ||||||||||
| 12 | |||||||||||
| 13 | Version 0.0.0 | ||||||||||
| 14 | |||||||||||
| 15 | =cut | ||||||||||
| 16 | |||||||||||
| 17 | 2 | our $VERSION = '0.0.0'; | |||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||
| 21 | |||||||||||
| 22 | use X11::Resolution; | ||||||||||
| 23 | |||||||||||
| 24 | my $xres=X11::Resolution->new(); | ||||||||||
| 25 | if($xres->{error}){ | ||||||||||
| 26 | print "Error:".$xres->{error}.": ".$xres->{errorString}."\n"; | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | #gets it currently the current screen | ||||||||||
| 30 | my ($x, $y)=$xres->getResolution; | ||||||||||
| 31 | if($xres->{error}){ | ||||||||||
| 32 | print "Error:".$xres->{error}.": ".$xres->{errorString}."\n"; | ||||||||||
| 33 | } | ||||||||||
| 34 | print "x=".$x."\ny=".$y."\n"; | ||||||||||
| 35 | |||||||||||
| 36 | #gets it for screen zero | ||||||||||
| 37 | my ($x, $y)=$xres->getResolution(0); | ||||||||||
| 38 | if($xres->{error}){ | ||||||||||
| 39 | print "Error:".$xres->{error}.": ".$xres->{errorString}."\n"; | ||||||||||
| 40 | } | ||||||||||
| 41 | print "x=".$x."\ny=".$y."\n"; | ||||||||||
| 42 | |||||||||||
| 43 | =head1 methodes | ||||||||||
| 44 | |||||||||||
| 45 | =head2 new | ||||||||||
| 46 | |||||||||||
| 47 | This initiates the object. | ||||||||||
| 48 | |||||||||||
| 49 | my $xres=X11::Resolution->new(); | ||||||||||
| 50 | if($xres->{error}){ | ||||||||||
| 51 | print "Error:".$xres->{error}.": ".$xres->{errorString}."\n"; | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | =cut | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub new{ | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 57 | 0 | my $self = {error=>undef, errorString=>''}; | |||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | if (!defined($ENV{DISPLAY})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 0 | warn('X11-Resolution new:1: No enviromentail variable "DISPLAY" defined'); | |||||||||
| 61 | 0 | $self->{error}=1; | |||||||||
| 62 | 0 | $self->{errorString}='No enviromentail variable "DISPLAY" defined.'; | |||||||||
| 63 | 0 | return $self; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 0 | $self->{x}=X11::Protocol->new(); | |||||||||
| 67 | |||||||||||
| 68 | 0 | bless $self; | |||||||||
| 69 | |||||||||||
| 70 | 0 | return $self | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | =head2 getResolution | ||||||||||
| 74 | |||||||||||
| 75 | This fetches the resolution for the current or a given screen. | ||||||||||
| 76 | |||||||||||
| 77 | #gets it currently the current screen | ||||||||||
| 78 | my ($x, $y)=$xres->getResolution; | ||||||||||
| 79 | if($xres->{error}){ | ||||||||||
| 80 | print "Error:".$xres->{error}.": ".$xres->{errorString}."\n"; | ||||||||||
| 81 | } | ||||||||||
| 82 | print "x=".$x."\ny=".$y."\n"; | ||||||||||
| 83 | |||||||||||
| 84 | #gets it for screen zero | ||||||||||
| 85 | my ($x, $y)=$xres->getResolution(0); | ||||||||||
| 86 | if($xres->{error}){ | ||||||||||
| 87 | print "Error:".$xres->{error}.": ".$xres->{errorString}."\n"; | ||||||||||
| 88 | } | ||||||||||
| 89 | print "x=".$x."\ny=".$y."\n"; | ||||||||||
| 90 | |||||||||||
| 91 | =cut | ||||||||||
| 92 | |||||||||||
| 93 | 0 | ▶ | sub getResolution{ | ||||||||
|
Subroutine
getResolution: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 94 | 0 | my $self=$_[0]; | |||||||||
| 95 | 0 | my $display=$_[1]; | |||||||||
| 96 | |||||||||||
| 97 | 0 | ▶ | if (!defined($display)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | 0 | $display=$ENV{DISPLAY}; | |||||||||
| 99 | |||||||||||
| 100 | 0 | $display=~s/.*\.//g; | |||||||||
| 101 | |||||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | 0 | ▶ | if (!defined($self->{x}->{'screens'}[$display])) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | 0 | warn('X11-Resolution getResolution:2: '); | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 0 | my $x=$self->{x}->{'screens'}[$display]{'width_in_pixels'}; | |||||||||
| 109 | 0 | my $y=$self->{x}->{'screens'}[$display]{'height_in_pixels'}; | |||||||||
| 110 | |||||||||||
| 111 | 0 | return $x, $y; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | =head2 errorBlank | ||||||||||
| 115 | |||||||||||
| 116 | This is a internal function and should not be called. | ||||||||||
| 117 | |||||||||||
| 118 | =cut | ||||||||||
| 119 | |||||||||||
| 120 | #blanks the error flags | ||||||||||
| 121 | 0 | ▶ | sub errorBlank{ | ||||||||
|
Subroutine
errorBlank: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 122 | 0 | my $self=$_[0]; | |||||||||
| 123 | |||||||||||
| 124 | 0 | $self->{error}=undef; | |||||||||
| 125 | 0 | $self->{errorString}=''; | |||||||||
| 126 | |||||||||||
| 127 | 0 | return 1; | |||||||||
| 128 | }; | ||||||||||
| 129 | |||||||||||
| 130 | =head1 ERROR CODES | ||||||||||
| 131 | |||||||||||
| 132 | =head2 1 | ||||||||||
| 133 | |||||||||||
| 134 | No enviromental variable 'DISPLAY' listed. | ||||||||||
| 135 | |||||||||||
| 136 | =head2 2 | ||||||||||
| 137 | |||||||||||
| 138 | None existant display. | ||||||||||
| 139 | |||||||||||
| 140 | =head1 AUTHOR | ||||||||||
| 141 | |||||||||||
| 142 | Zane C. Bowers, C<< <vvelox at vvelox.net> >> | ||||||||||
| 143 | |||||||||||
| 144 | =head1 BUGS | ||||||||||
| 145 | |||||||||||
| 146 | Please report any bugs or feature requests to C<bug-x11-resolution at rt.cpan.org>, or through | ||||||||||
| 147 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=X11-Resolution>. I will be notified, and then you'll | ||||||||||
| 148 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 149 | |||||||||||
| 150 | |||||||||||
| 151 | |||||||||||
| 152 | |||||||||||
| 153 | =head1 SUPPORT | ||||||||||
| 154 | |||||||||||
| 155 | You can find documentation for this module with the perldoc command. | ||||||||||
| 156 | |||||||||||
| 157 | perldoc X11::Resolution | ||||||||||
| 158 | |||||||||||
| 159 | |||||||||||
| 160 | You can also look for information at: | ||||||||||
| 161 | |||||||||||
| 162 | =over 4 | ||||||||||
| 163 | |||||||||||
| 164 | =item * RT: CPAN's request tracker | ||||||||||
| 165 | |||||||||||
| 166 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=X11-Resolution> | ||||||||||
| 167 | |||||||||||
| 168 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 169 | |||||||||||
| 170 | L<http://annocpan.org/dist/X11-Resolution> | ||||||||||
| 171 | |||||||||||
| 172 | =item * CPAN Ratings | ||||||||||
| 173 | |||||||||||
| 174 | L<http://cpanratings.perl.org/d/X11-Resolution> | ||||||||||
| 175 | |||||||||||
| 176 | =item * Search CPAN | ||||||||||
| 177 | |||||||||||
| 178 | L<http://search.cpan.org/dist/X11-Resolution/> | ||||||||||
| 179 | |||||||||||
| 180 | =back | ||||||||||
| 181 | |||||||||||
| 182 | |||||||||||
| 183 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 184 | |||||||||||
| 185 | |||||||||||
| 186 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 187 | |||||||||||
| 188 | Copyright 2009 Zane C. Bowers, all rights reserved. | ||||||||||
| 189 | |||||||||||
| 190 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 191 | under the same terms as Perl itself. | ||||||||||
| 192 | |||||||||||
| 193 | |||||||||||
| 194 | =cut | ||||||||||
| 195 | |||||||||||
| 196 | 2 | 1; # End of X11::Resolution | |||||||||