Class Display

All Implemented Interfaces:
PointerInterface

public class Display extends Object
`GdkDisplay` objects are the GDK representation of a workstation.

Their purpose are two-fold:

- To manage and provide information about input devices (pointers, keyboards, etc)
- To manage and provide information about output devices (monitors, projectors, etc)

Most of the input device handling has been factored out into separate
[class@Gdk.Seat] objects. Every display has a one or more seats, which
can be accessed with [method@Gdk.Display.get_default_seat] and
[method@Gdk.Display.list_seats].

Output devices are represented by [class@Gdk.Monitor] objects, which can
be accessed with [method@Gdk.Display.get_monitor_at_surface] and similar APIs.

https://docs.gtk.org/gdk4/class.Display.html

  • Field Details

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • beep

      public void beep()
      Emits a short beep on @display
    • close

      public void close()
      Closes the connection to the windowing system for the given display.

      This cleans up associated resources.
    • createGlContext

      public GLContext createGlContext() throws AllocationError
      Creates a new `GdkGLContext` for the `GdkDisplay`.

      The context is disconnected from any particular surface or surface
      and cannot be used to draw to any surface. It can only be used to
      draw to non-surface framebuffers like textures.

      If the creation of the `GdkGLContext` failed, @error will be set.
      Before using the returned `GdkGLContext`, you will need to
      call [method@Gdk.GLContext.make_current] or [method@Gdk.GLContext.realize].
      Returns:
      the newly created `GdkGLContext`
      Throws:
      AllocationError
    • deviceIsGrabbed

      public boolean deviceIsGrabbed(@Nonnull Device device)
      Returns %TRUE if there is an ongoing grab on @device for @display.
      Parameters:
      device - a `GdkDevice`
      Returns:
      %TRUE if there is a grab in effect for @device.
    • flush

      public void flush()
      Flushes any requests queued for the windowing system.

      This happens automatically when the main loop blocks waiting for new events,
      but if your application is drawing without returning control to the main loop,
      you may need to call this function explicitly. A common case where this function
      needs to be called is when an application is executing drawing commands
      from a thread other than the thread where the main loop is running.

      This is most useful for X11. On windowing systems where requests are
      handled synchronously, this function will do nothing.
    • getAppLaunchContext

      public AppLaunchContext getAppLaunchContext()
      Returns a `GdkAppLaunchContext` suitable for launching
      applications on the given display.
      Returns:
      a new `GdkAppLaunchContext` for @display
    • getClipboard

      public Clipboard getClipboard()
      Gets the clipboard used for copy/paste operations.
      Returns:
      the display's clipboard
    • getDefaultSeat

      public Seat getDefaultSeat()
      Returns the default `GdkSeat` for this display.

      Note that a display may not have a seat. In this case,
      this function will return %NULL.
      Returns:
      the default seat.
    • getMonitorAtSurface

      public Monitor getMonitorAtSurface(@Nonnull Surface surface)
      Gets the monitor in which the largest area of @surface
      resides.

      Returns a monitor close to @surface if it is outside
      of all monitors.
      Parameters:
      surface - a `GdkSurface`
      Returns:
      the monitor with the largest overlap with @surface
    • getMonitors

      public ListModel getMonitors()
      Gets the list of monitors associated with this display.

      Subsequent calls to this function will always return the
      same list for the same display.

      You can listen to the GListModel::items-changed signal on
      this list to monitor changes to the monitor of this display.
      Returns:
      a `GListModel` of `GdkMonitor`
    • getName

      public Str getName()
      Gets the name of the display.
      Returns:
      a string representing the display name. This string is owned by GDK and should not be modified or freed.
    • getPrimaryClipboard

      public Clipboard getPrimaryClipboard()
      Gets the clipboard used for the primary selection.

      On backends where the primary clipboard is not supported natively,
      GDK emulates this clipboard locally.
      Returns:
      the primary clipboard
    • getSetting

      public boolean getSetting(@Nonnull Str name, @Nonnull Value value)
      Retrieves a desktop-wide setting such as double-click time
      for the @display.
      Parameters:
      name - the name of the setting
      value - location to store the value of the setting
      Returns:
      %TRUE if the setting existed and a value was stored in @value, %FALSE otherwise
    • getSetting

      public boolean getSetting(String name, @Nonnull Value value)
      Retrieves a desktop-wide setting such as double-click time
      for the @display.
      Parameters:
      name - the name of the setting
      value - location to store the value of the setting
      Returns:
      %TRUE if the setting existed and a value was stored in @value, %FALSE otherwise
    • getStartupNotificationId

      public Str getStartupNotificationId()
      Gets the startup notification ID for a Wayland display, or %NULL
      if no ID has been defined.
      Returns:
      the startup notification ID for @display
    • isClosed

      public boolean isClosed()
      Finds out if the display has been closed.
      Returns:
      %TRUE if the display is closed.
    • isComposited

      public boolean isComposited()
      Returns whether surfaces can reasonably be expected to have
      their alpha channel drawn correctly on the screen.

      Check [method@Gdk.Display.is_rgba] for whether the display
      supports an alpha channel.

      On X11 this function returns whether a compositing manager is
      compositing on @display.

      On modern displays, this value is always %TRUE.
      Returns:
      Whether surfaces with RGBA visuals can reasonably be expected to have their alpha channels drawn correctly on the screen.
    • isRgba

      public boolean isRgba()
      Returns whether surfaces on this @display are created with an
      alpha channel.

      Even if a %TRUE is returned, it is possible that the
      surface’s alpha channel won’t be honored when displaying the
      surface on the screen: in particular, for X an appropriate
      windowing manager and compositing manager must be running to
      provide appropriate display. Use [method@Gdk.Display.is_composited]
      to check if that is the case.

      On modern displays, this value is always %TRUE.
      Returns:
      %TRUE if surfaces are created with an alpha channel or %FALSE if the display does not support this functionality.
    • listSeats

      public List listSeats()
      Returns the list of seats known to @display.
      Returns:
      the list of seats known to the `GdkDisplay`
    • notifyStartupComplete

      public void notifyStartupComplete(@Nonnull Str startup_id)
      Indicates to the GUI environment that the application has
      finished loading, using a given identifier.

      GTK will call this function automatically for [class@Gtk.Window]
      with custom startup-notification identifier unless
      [method@Gtk.Window.set_auto_startup_notification]
      is called to disable that feature.
      Parameters:
      startup_id - a startup-notification identifier, for which notification process should be completed
    • notifyStartupComplete

      public void notifyStartupComplete(String startup_id)
      Indicates to the GUI environment that the application has
      finished loading, using a given identifier.

      GTK will call this function automatically for [class@Gtk.Window]
      with custom startup-notification identifier unless
      [method@Gtk.Window.set_auto_startup_notification]
      is called to disable that feature.
      Parameters:
      startup_id - a startup-notification identifier, for which notification process should be completed
    • prepareGl

      public boolean prepareGl() throws AllocationError
      Checks that OpenGL is available for @self and ensures that it is
      properly initialized.
      When this fails, an @error will be set describing the error and this
      function returns %FALSE.

      Note that even if this function succeeds, creating a `GdkGLContext`
      may still fail.

      This function is idempotent. Calling it multiple times will just
      return the same value or error.

      You never need to call this function, GDK will call it automatically
      as needed. But you can use it as a check when setting up code that
      might make use of OpenGL.
      Returns:
      %TRUE if the display supports OpenGL
      Throws:
      AllocationError
    • putEvent

      public void putEvent(@Nonnull Event event)
      Appends the given event onto the front of the event
      queue for @display.

      This function is only useful in very special situations
      and should not be used by applications.
      Parameters:
      event - a `GdkEvent`
    • supportsInputShapes

      public boolean supportsInputShapes()
      Returns %TRUE if the display supports input shapes.

      This means that [method@Gdk.Surface.set_input_region] can
      be used to modify the input shape of surfaces on @display.

      On modern displays, this value is always %TRUE.
      Returns:
      %TRUE if surfaces with modified input shape are supported
    • sync

      public void sync()
      Flushes any requests queued for the windowing system and waits until all
      requests have been handled.

      This is often used for making sure that the display is synchronized
      with the current state of the program. Calling [method@Gdk.Display.sync]
      before [method@GdkX11.Display.error_trap_pop] makes sure that any errors
      generated from earlier requests are handled before the error trap is removed.

      This is most useful for X11. On windowing systems where requests are
      handled synchronously, this function will do nothing.
    • onClosed

      public SignalHandler onClosed(Display.OnClosed signal)
      Connect to signal "closed".
      See Display.OnClosed.onClosed(boolean) for signal description.
      Field SIGNAL_ON_CLOSED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onOpened

      public SignalHandler onOpened(Display.OnOpened signal)
      Connect to signal "opened".
      See Display.OnOpened.onOpened() for signal description.
      Field SIGNAL_ON_OPENED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onSeatAdded

      public SignalHandler onSeatAdded(Display.OnSeatAdded signal)
      Connect to signal "seat-added".
      See Display.OnSeatAdded.onSeatAdded(ch.bailu.gtk.gdk.Seat) for signal description.
      Field SIGNAL_ON_SEAT_ADDED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onSeatRemoved

      public SignalHandler onSeatRemoved(Display.OnSeatRemoved signal)
      Connect to signal "seat-removed".
      See Display.OnSeatRemoved.onSeatRemoved(ch.bailu.gtk.gdk.Seat) for signal description.
      Field SIGNAL_ON_SEAT_REMOVED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onSettingChanged

      public SignalHandler onSettingChanged(Display.OnSettingChanged signal)
      Connect to signal "setting-changed".
      See Display.OnSettingChanged.onSettingChanged(ch.bailu.gtk.type.Str) for signal description.
      Field SIGNAL_ON_SETTING_CHANGED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • getDefault

      public static Display getDefault()
      Gets the default `GdkDisplay`.

      This is a convenience function for:

      gdk_display_manager_get_default_display (gdk_display_manager_get ())
      Returns:
      a `GdkDisplay`, or %NULL if there is no default display
    • open

      public static Display open(@Nonnull Str display_name)
      Opens a display.

      If opening the display fails, `NULL` is returned.
      Parameters:
      display_name - the name of the display to open
      Returns:
      a `GdkDisplay`
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()