github.com/iDigitalFlame/xmt@v0.5.4/device/screen/screen_nix.go (about)

     1  //go:build !windows
     2  // +build !windows
     3  
     4  // Copyright (C) 2020 - 2023 iDigitalFlame
     5  //
     6  // This program is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // any later version.
    10  //
    11  // This program is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU General Public License
    17  // along with this program.  If not, see <https://www.gnu.org/licenses/>.
    18  //
    19  
    20  // Package screen is a helper package that contains generic functions that allow
    21  // for taking ScreenShots of the current display (if supported).
    22  package screen
    23  
    24  import (
    25  	"image"
    26  	"io"
    27  
    28  	"github.com/iDigitalFlame/xmt/device"
    29  )
    30  
    31  // TODO(dij): Add non-windows (Linux, MacOS) support.
    32  //            The list for this would be heavy-ish. Screenshot libraries
    33  //            https://github.com/kbinani/screenshot are nice, but are dependency
    34  //            heavy. Also MacOS requires CGO enabled, which makes it harder to
    35  //            cross-compile. Also Linux needs XOrg and doesn't seem to support
    36  //            Wayland.
    37  
    38  // Capture attempts to take a PNG-encoded screenshot of all the active
    39  // displays on the device into the supplied io.Writer.
    40  //
    41  // This function will return an error getting the screen color info fails or
    42  // encoding the image fails.
    43  //
    44  // This function calculates the dimensions of all the active displays together
    45  // and calls 'CaptureRange' underneath.
    46  //
    47  // TODO(dij): Currently works only on Windows devices.
    48  func Capture(_ io.Writer) error {
    49  	return device.ErrNoWindows
    50  }
    51  
    52  // ActiveDisplays returns the count of current active displays enabled on the
    53  // device.
    54  //
    55  // This function returns an error if any error occurs when retrieving the display
    56  // count.
    57  //
    58  // TODO(dij): Currently works only on Windows devices.
    59  func ActiveDisplays() (uint32, error) {
    60  	return 0, nil
    61  }
    62  
    63  // DisplayBounds returns the bounds of the supplied display index.
    64  //
    65  // This function will return the bounds of the first monitor if the index is out
    66  // of bounds of the current display count.
    67  //
    68  // TODO(dij): Currently works only on Windows devices.
    69  func DisplayBounds(_ uint32) (image.Rectangle, error) {
    70  	return image.Rectangle{}, nil
    71  }
    72  
    73  // CaptureRange attempts to take a PNG-encoded screenshot of the current
    74  // dimensions specified into the supplied io.Writer.
    75  //
    76  // This function will return an error getting the screen color info fails or
    77  // encoding the image fails.
    78  //
    79  // TODO(dij): Currently works only on Windows devices.
    80  func CaptureRange(_, _, _, _ uint32, _ io.Writer) error {
    81  	return device.ErrNoWindows
    82  }