HTML::O...::Screen(3)

πŸ“¦ version 0.6.0, in alpine 3.24

✨ NAME ✨

So like, this is HTML::Object::DOM::Screen β€” the HTML Object DOM Screen Class, bestie. That's the whole vibe. It's the class that gives you the screen object, and we're gonna get into it πŸ’–


🌸 SYNOPSIS 🌸

Okay so here's how you actually summon one of these bad boys into existence:

use HTML::Object::DOM::Screen;
my $screen = HTML::Object::DOM::Screen->new ||
    die( HTML::Object::DOM::Screen->error, "\n" );

Very demure, very mindful. Either you get a $screen or you die screaming the error message with a newline. No in-between, no cap πŸ’…


πŸŽ€ VERSION πŸŽ€

v0.2.0

That's the version, bestie. Iconic. Write it down πŸ“


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so the "Screen" interface β€” and yes it's in quotes like that, that's how they wrote it β€” represents the screen. And not just a screen, the only one, under perl, on which the current window object exists. Highkey main character energy: there's literally one screen and your window lives on it πŸ‘‘

You get your hands on it using "screen" in HTML::Object::DOM::Window. That's the door, that's the way in, iykyk πŸšͺ✨


πŸ‘‘ INHERITANCE πŸ‘‘

The family tree, fr fr. This is the whole lineage, exactly as it goes:

+-----------------------+     +---------------------------+     +---------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Screen |
+-----------------------+     +---------------------------+     +---------------------------+

So HTML::Object::Element flows into HTML::Object::EventTarget, which flows into HTML::Object::DOM::Screen. Three generations of absolute royalty, and our girl is at the end of the chain eating everything that came before her πŸ“πŸ’€

πŸ’… PROPERTIES πŸ’…

Okay so this class straight-up inherits properties from its parent HTML::Object::EventTarget, bestie. Let's get into it πŸ’–

availHeight

Heads up: normally this returns undef under perl, but you can set whatever number value you want. It's giving "paint your own reality" ✨

Under JavaScript, this specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows. So basically the real estate you actually get.

Example:

use HTML::Object::DOM qw( screen window );
my $availHeight = window->screen->availHeight;

my $paletteWindow = window->open( "panels.html", "Panels", "left=0, top=0, width=200" );

Another example:

window->outerHeight = window->screen->availHeight;

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/availHeight

availLeft

Normally this returns undef under perl, but you can set whatever number value you want, no cap πŸ’…

Under JavaScript, this returns the first available pixel available from the left side of the screen.

Example:

use HTML::Object::DOM qw( screen window );
my $availLeft = window->screen->availLeft;

my $setX = window->screen->width - window->screen->availLeft;
my $setY = window->screen->height - window->screen->availTop;
# The following does absolutely nothing in perl, obviously
window->moveTo( $setX, $setY );

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/availLeft

availTop

Normally this returns undef under perl, but you can set whatever number value you want 🫢

Under JavaScript, this specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.

Example:

my $availTop = window->screen->availTop;

my $setX = window->screen->width - window->screen->availLeft;
my $setY = window->screen->height - window->screen->availTop;
# The following does absolutely nothing in perl, obviously
window->moveTo( $setX, $setY );

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/availTop

availWidth

Normally this returns undef under perl, but you can set whatever number value you want ⭐

Under JavaScript, this returns the amount of horizontal space in pixels available to the window.

Example:

my $width = window->screen->availWidth

my $screenAvailWidth = window->screen->availWidth;

say( $screenAvailWidth );

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/availWidth

colorDepth

Normally this returns undef under perl, but you can set whatever number value you want 🌈

Under JavaScript, this returns the color depth of the screen. Literally how many colors your vibe can serve.

Example:

use HTML::Object::DOM qw( screen window );
# Check the color depth of the screen
if( window->screen->colorDepth < 8 )
{
    # Use low-color version of page
}
else
{
    # Use regular, colorful page
}

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/colorDepth

height

Normally this returns undef under perl, but you can set whatever number value you want πŸŽ€

Under JavaScript, this returns the height of the screen in pixels.

Example:

my $height = window->screen->height

use HTML::Object::DOM qw( screen window );
if( window->screen->availHeight !== window->screen->height )
{
     # Something is occupying some screen real estate!
}

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/height

left

Normally this returns undef under perl, but you can set whatever number value you want πŸ¦‹

Under JavaScript, this returns the distance in pixels from the left side of the main screen to the left side of the current screen.

Example:

use HTML::Object::DOM qw( screen window );
my $left = window->screen->left;

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/left

lockOrientation

Under perl environment this returns undef by default, but you can set whatever value you want. Main character energy: you decide your own orientation πŸ’…βœ¨

Under JavaScript, this locks the screen into a specified orientation into which to lock the screen. This is either a string or an array of strings. Passing several strings lets the screen rotate only in the selected orientations.

Possible values that are not enforced under this perl interface are:

  • portrait-primary β€” It represents the orientation of the screen when it is in its primary portrait mode. A screen is considered in its primary portrait mode if the device is held in its normal position and that position is in portrait, or if the normal position of the device is in landscape and the device held turned by 90Β° clockwise. The normal position is device dependant.
  • portrait-secondary β€” It represents the orientation of the screen when it is in its secondary portrait mode. A screen is considered in its secondary portrait mode if the device is held 180Β° from its normal position and that position is in portrait, or if the normal position of the device is in landscape and the device held is turned by 90Β° counterclockwise. The normal position is device dependant.
  • landscape-primary β€” It represents the orientation of the screen when it is in its primary landscape mode. A screen is considered in its primary landscape mode if the device is held in its normal position and that position is in landscape, or if the normal position of the device is in portrait and the device held is turned by 90Β° clockwise. The normal position is device dependant.
  • landscape-secondary β€” It represents the orientation of the screen when it is in its secondary landscape mode. A screen is considered in its secondary landscape mode if the device held is 180Β° from its normal position and that position is in landscape, or if the normal position of the device is in portrait and the device held is turned by 90Β° counterclockwise. The normal position is device dependant.
  • portrait β€” It represents both portrait-primary and portrait-secondary.
  • landscape β€” It represents both landscape-primary and landscape-secondary.
  • default β€” It represents either portrait-primary and landscape-primary depends on natural orientation of devices. For example, if the panel resolution is 1280*800, default will make it landscape, if the resolution is 800*1280, default will make it to portrait.

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation

mozBrightness

Normally this returns undef under perl, but you can set whatever number value you want πŸ”₯

Under JavaScript, this Controls the brightness of a device's screen. A double between 0 and 1.0 is expected.

Example:

use HTML::Object::DOM qw( screen window );
my $screenBrightness = window->screen->mozBrightness;

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/mozBrightness

mozEnabled

Normally this is read-only, but under perl you can set whatever boolean value you want πŸ‘‘

Under JavaScript, when this is set to false, it will turn off the device's screen.

Example:

use HTML::Object::DOM qw( screen window );
my $screenEnabled = window->screen->mozEnabled

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/mozEnabled

orientation

Normally this returns undef under perl, but you can set whatever string value you want. This returns a scalar object 🌸

Under JavaScript, this returns the ScreenOrientation instance associated with this screen.

Example:

use HTML::Object::DOM qw( screen window );
my $orientation = screen->$orientation;

my $orientation = screen->orientation;

if( $orientation == "landscape-primary" )
{
    say( "That looks good." );
}
elsif( $orientation == "landscape-secondary" )
{
    say( "Mmmh... the screen is upside down!" );
}
elsif( $orientation == "portrait-secondary" || $orientation == "portrait-primary" )
{
    say( "Mmmh... you should rotate your device to landscape" );
}
elsif( $orientation == undefined )
{
    say( "The orientation API is not supported in this browser :(" );
}

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation

pixelDepth

Normally this returns undef under perl, but you can set whatever number value you want πŸ’œ

Under JavaScript, this gets the bit depth of the screen.

Example:

use HTML::Object::DOM qw( screen window );
my $depth = window->screen->pixelDepth

# if there is not adequate bit depth
# choose a simpler color
if( window->screen->pixelDepth > 8 )
{
    $doc->style->color = "#FAEBD7";
}
else
{
    $doc->style->color = "#FFFFFF";
}

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/pixelDepth

top

Normally this returns undef under perl, but you can set whatever number value you want πŸ“

Under JavaScript, this returns the distance in pixels from the top side of the current screen.

Example:

use HTML::Object::DOM qw( screen window );
my $top = window->screen->top;

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/top

width

Normally this returns undef under perl, but you can set whatever number value you want ✨

Under JavaScript, this returns the width of the screen.

Example:

use HTML::Object::DOM qw( screen window );
my $lWidth = window->screen->width

# Crude way to check that the screen is at least 1024x768
if( window->screen->width >= 1024 && window->screen->height >= 768 )
{
    # Resolution is 1024x768 or above
}

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/width


πŸŽ€ METHODS πŸŽ€

And the methods? Also inherited from its parent HTML::Object::EventTarget, obviously πŸ’…

unlockOrientation

This always returns undef under perl. Yeah, always. It's giving "no thoughts, head empty" 😭

Normally, under JavaScript, this unlocks the screen orientation (only works in fullscreen or for installed apps)

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/unlockOrientation


🌸 AUTHOR 🌸

Jacques Deguest <jack@deguest.jp> β€” the icon who made this happen πŸ‘‘

πŸ¦‹ SEE ALSO πŸ¦‹

Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Window

Okay bestie, final section, the grown-up part β€” but we're gonna make it cute anyway because that's just how we roll πŸ’…

The copyright on this whole thing belongs to DEGUEST Pte. Ltd., and it's from 2021:

Copyright(c) 2021 DEGUEST Pte. Ltd.

And yes, all the rights are reserved. Every single one of them, no cap:

All rights reserved

Now here's the fun part β€” this is free software, like genuinely free, and the terms it runs on are the exact same terms as Perl itself:

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

So like, redistribute it, modify it, do your thing β€” just under Perl's own terms. That's the whole vibe check, periodt 🫢


and that's a wrap on the whole page, bestie!! βœ¨πŸŽ€πŸ¦‹

You just read the docs for HTML::O...::Screen(3), as shipped with perl v5.42.2, and this little snapshot was dated 2026-02-15 🌸

go forth and slay your terminal, ily, bye πŸ’–πŸ‘‘

πŸ“¦ where this page comes from