Class Monitor

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Monitor extends GObject

Represents the individual outputs that are associated with a GdkDisplay.

GdkDisplay keeps a GListModel to enumerate and monitor monitors with Display.getMonitors(). You can use Display.getMonitorAtSurface(Surface) to find a particular monitor.

  • Constructor Details

    • Monitor

      public Monitor(MemorySegment address)
      Create a Monitor instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Monitor

      public Monitor()
      Create a new Monitor.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Monitor class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Monitor asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getConnector

      public @Nullable String getConnector()

      Gets the name of the monitor's connector, if available.

      These are strings such as "eDP-1", or "HDMI-2". They depend on software and hardware configuration, and should not be relied on as stable identifiers of a specific monitor.

      Returns:
      the name of the connector
    • getDescription

      public @Nullable String getDescription()

      Gets a string describing the monitor, if available.

      This can be used to identify a monitor in the UI.

      Returns:
      the monitor description
      Since:
      4.10
    • getDisplay

      public Display getDisplay()
      Gets the display that this monitor belongs to.
      Returns:
      the display
    • getGeometry

      public void getGeometry(Rectangle geometry)

      Retrieves the size and position of the monitor within the display coordinate space.

      The returned geometry is in ”application pixels”, not in ”device pixels” (see getScale()).

      Parameters:
      geometry - a GdkRectangle to be filled with the monitor geometry
    • getHeightMm

      public int getHeightMm()
      Gets the height in millimeters of the monitor.
      Returns:
      the physical height of the monitor
    • getManufacturer

      public @Nullable String getManufacturer()

      Gets the name or PNP ID of the monitor's manufacturer.

      Note that this value might also vary depending on actual display backend.

      The PNP ID registry is located at https://uefi.org/pnp_id_list.

      Returns:
      the name of the manufacturer
    • getModel

      public @Nullable String getModel()
      Gets the string identifying the monitor model, if available.
      Returns:
      the monitor model
    • getRefreshRate

      public int getRefreshRate()

      Gets the refresh rate of the monitor, if available.

      The value is in milli-Hertz, so a refresh rate of 60Hz is returned as 60000.

      Returns:
      the refresh rate in milli-Hertz, or 0
    • getScale

      public double getScale()

      Gets the internal scale factor that maps from monitor coordinates to device pixels.

      This can be used if you want to create pixel based data for a particular monitor, but most of the time you’re drawing to a surface where it is better to use Surface.getScale() instead.

      Returns:
      the scale
      Since:
      4.14
    • getScaleFactor

      public int getScaleFactor()

      Gets the internal scale factor that maps from monitor coordinates to device pixels.

      On traditional systems this is 1, but on very high density outputs it can be a higher value (often 2).

      This can be used if you want to create pixel based data for a particular monitor, but most of the time you’re drawing to a surface where it is better to use Surface.getScaleFactor() instead.

      Returns:
      the scale factor
    • getSubpixelLayout

      public SubpixelLayout getSubpixelLayout()
      Gets information about the layout of red, green and blue primaries for pixels.
      Returns:
      the subpixel layout
    • getWidthMm

      public int getWidthMm()
      Gets the width in millimeters of the monitor.
      Returns:
      the physical width of the monitor
    • isValid

      public boolean isValid()

      Returns true if the this Monitor object corresponds to a physical monitor.

      The this Monitor becomes invalid when the physical monitor is unplugged or removed.

      Returns:
      true if the object corresponds to a physical monitor
    • onInvalidate

      Emitted when the output represented by monitor gets disconnected.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitInvalidate

      public void emitInvalidate()
      Emits the "invalidate" signal. See onInvalidate(Monitor.InvalidateCallback).
    • builder

      public static Monitor.Builder<? extends Monitor.Builder> builder()
      A Monitor.Builder object constructs a Monitor with the specified properties. Use the various set...() methods to set properties, and finish construction with Monitor.Builder.build().
      Returns:
      the builder object