Class DisplayManager

All Implemented Interfaces:
Proxy

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

Offers notification when displays appear or disappear.

GdkDisplayManager is a singleton object.

You can use get() to obtain the GdkDisplayManager singleton, but that should be rarely necessary. Typically, initializing GTK opens a display that you can work with without ever accessing the GdkDisplayManager.

The GDK library can be built with support for multiple backends. The GdkDisplayManager object determines which backend is used at runtime.

In the rare case that you need to influence which of the backends is being used, you can use Gdk.setAllowedBackends(String). Note that you need to call this function before initializing GTK.

Backend-specific code

When writing backend-specific code that is supposed to work with multiple GDK backends, you have to consider both compile time and runtime. At compile time, use the GDK_WINDOWING_X11, GDK_WINDOWING_WIN32 macros, etc. to find out which backends are present in the GDK library you are building your application against. At runtime, use type-check macros like GDK_IS_X11_DISPLAY() to find out which backend is in use:

#ifdef GDK_WINDOWING_X11
  if (GDK_IS_X11_DISPLAY (display))
    {
      // make X11-specific calls here
    }
  else
#endif
#ifdef GDK_WINDOWING_MACOS
  if (GDK_IS_MACOS_DISPLAY (display))
    {
      // make Quartz-specific calls here
    }
  else
#endif
  g_error ("Unsupported GDK backend");
  • Constructor Details

    • DisplayManager

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

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

    • getType

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

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

      protected DisplayManager 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
    • get

      public static DisplayManager get()

      Gets the singleton GdkDisplayManager object.

      When called for the first time, this function consults the GDK_BACKEND environment variable to find out which of the supported GDK backends to use (in case GDK has been compiled with multiple backends).

      Applications can use Gdk.setAllowedBackends(String) to limit what backends will be used.

      Returns:
      The global GdkDisplayManager singleton
    • getDefaultDisplay

      public @Nullable Display getDefaultDisplay()
      Gets the default GdkDisplay.
      Returns:
      a GdkDisplay
    • listDisplays

      public SList<Display> listDisplays()
      List all currently open displays.
      Returns:
      a newly allocated GSList of GdkDisplay objects
    • openDisplay

      public @Nullable Display openDisplay(@Nullable String name)
      Opens a display.
      Parameters:
      name - the name of the display to open
      Returns:
      a GdkDisplay, or null if the display could not be opened
    • setDefaultDisplay

      public void setDefaultDisplay(Display display)
      Sets display as the default display.
      Parameters:
      display - a GdkDisplay
    • onDisplayOpened

      Emitted when a display is opened.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitDisplayOpened

      public void emitDisplayOpened(@Nullable Display display)
      Emits the "display-opened" signal. See onDisplayOpened(DisplayManager.DisplayOpenedCallback).
    • builder

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