Class Display
- All Implemented Interfaces:
Proxy
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
Seat objects. Every display has a one or more seats, which
can be accessed with getDefaultSeat() and
listSeats().
Output devices are represented by Monitor objects, which can
be accessed with getMonitorAtSurface(org.gnome.gdk.Surface) and similar APIs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDisplay.Builder<B extends Display.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theClosedCallbackcallback.static interfaceFunctional interface declaration of theOpenedCallbackcallback.static interfaceFunctional interface declaration of theSeatAddedCallbackcallback.static interfaceFunctional interface declaration of theSeatRemovedCallbackcallback.static interfaceFunctional interface declaration of theSettingChangedCallbackcallback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionDisplay()Creates a new Display.Display(MemorySegment address) Create a Display proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected DisplayasParent()Returns this instance as if it were its parent type.voidbeep()Emits a short beep on this Displaystatic Display.Builder<? extends Display.Builder> builder()ADisplay.Builderobject constructs aDisplaywith the specified properties.voidclose()Closes the connection to the windowing system for the given display.Creates a newGdkGLContextfor theGdkDisplay.booleandeviceIsGrabbed(Device device) Returnstrueif there is an ongoing grab ondevicefordisplay.voidemitClosed(boolean isError) Emits the "closed" signal.voidEmits the "opened" signal.voidemitSeatAdded(@Nullable Seat seat) Emits the "seat-added" signal.voidemitSeatRemoved(@Nullable Seat seat) Emits the "seat-removed" signal.voidemitSettingChanged(String setting) Emits the "setting-changed" signal.voidflush()Flushes any requests queued for the windowing system.Returns aGdkAppLaunchContextsuitable for launching applications on the given display.Gets the clipboard used for copy/paste operations.static @Nullable DisplayGets the defaultGdkDisplay.@Nullable SeatReturns the defaultGdkSeatfor this display.Returns the dma-buf formats that are supported on this display.@Nullable MonitorgetMonitorAtSurface(Surface surface) Gets the monitor in which the largest area ofsurfaceresides.Gets the list of monitors associated with this display.getName()Gets the name of the display.Gets the clipboard used for the primary selection.booleangetSetting(String name, Value value) Retrieves a desktop-wide setting such as double-click time for thedisplay.@Nullable StringDeprecated.static @Nullable TypegetType()Get the GType of the Display classbooleanisClosed()Finds out if the display has been closed.booleanReturns whether surfaces can reasonably be expected to have their alpha channel drawn correctly on the screen.booleanisRgba()Returns whether surfaces on this this Display are created with an alpha channel.Returns the list of seats known todisplay.booleanmapKeycode(int keycode, @Nullable Out<KeymapKey[]> keys, @Nullable Out<int[]> keyvals) Returns the keyvals bound tokeycode.booleanObtains a list of keycode/group/level combinations that will generatekeyval.voidnotifyStartupComplete(String startupId) Deprecated.onClosed(Display.ClosedCallback handler) Emitted when the connection to the windowing system fordisplayis closed.onOpened(Display.OpenedCallback handler) Emitted when the connection to the windowing system fordisplayis opened.onSeatAdded(Display.SeatAddedCallback handler) Emitted whenever a new seat is made known to the windowing system.onSeatRemoved(Display.SeatRemovedCallback handler) Emitted whenever a seat is removed by the windowing system.Emitted whenever a setting changes its value.static @Nullable DisplayOpens a display.booleanChecks that OpenGL is available for this Display and ensures that it is properly initialized.voidDeprecated.This function is only useful in very special situations and should not be used by applications.booleanReturnstrueif the display supports input shapes.booleanReturns whether it's possible for a surface to draw outside of the window area.voidsync()Flushes any requests queued for the windowing system and waits until all requests have been handled.booleantranslateKey(int keycode, Set<ModifierType> state, int group, @Nullable Out<Integer> keyval, @Nullable Out<Integer> effectiveGroup, @Nullable Out<Integer> level, @Nullable Out<Set<ModifierType>> consumed) Translates the contents of aGdkEventKeyinto a keyval, effective group, and level.booleantranslateKey(int keycode, ModifierType state, int group, @Nullable Out<Integer> keyval, @Nullable Out<Integer> effectiveGroup, @Nullable Out<Integer> level, @Nullable Out<ModifierType> consumed) Translates the contents of aGdkEventKeyinto a keyval, effective group, and level.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Display
Create a Display proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Display
public Display()Creates a new Display.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getDefault
Gets the defaultGdkDisplay.This is a convenience function for:
gdk_display_manager_get_default_display (gdk_display_manager_get ())
- Returns:
- a
GdkDisplay, ornullif there is no default display
-
open
-
beep
public void beep()Emits a short beep on this Display -
close
public void close()Closes the connection to the windowing system for the given display.This cleans up associated resources.
-
createGlContext
Creates a newGdkGLContextfor theGdkDisplay.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
GdkGLContextfailed,errorwill be set. Before using the returnedGdkGLContext, you will need to callGLContext.makeCurrent()orGLContext.realize().- Returns:
- the newly created
GdkGLContext - Throws:
GErrorException- seeGError- Since:
- 4.6
-
deviceIsGrabbed
Returnstrueif there is an ongoing grab ondevicefordisplay.- Parameters:
device- aGdkDevice- Returns:
trueif there is a grab in effect fordevice.
-
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
Returns aGdkAppLaunchContextsuitable for launching applications on the given display.- Returns:
- a new
GdkAppLaunchContextfor this Display
-
getClipboard
Gets the clipboard used for copy/paste operations.- Returns:
- the display's clipboard
-
getDefaultSeat
Returns the defaultGdkSeatfor this display.Note that a display may not have a seat. In this case, this function will return
null.- Returns:
- the default seat.
-
getDmabufFormats
Returns the dma-buf formats that are supported on this display.GTK may use OpenGL or Vulkan to support some formats. Calling this function will then initialize them if they aren't yet.
The formats returned by this function can be used for negotiating buffer formats with producers such as v4l, pipewire or GStreamer.
To learn more about dma-bufs, see
DmabufTextureBuilder.This function is threadsafe. It can be called from any thread.
- Returns:
- a
GdkDmabufFormatsobject - Since:
- 4.14
-
getMonitorAtSurface
-
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
GListModelofGdkMonitor
-
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
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
Retrieves a desktop-wide setting such as double-click time for thedisplay.- Parameters:
name- the name of the settingvalue- location to store the value of the setting- Returns:
trueif the setting existed and a value was stored invalue,falseotherwise
-
getStartupNotificationId
Deprecated.Gets the startup notification ID for a Wayland display, ornullif no ID has been defined.- Returns:
- the startup notification ID for this Display
-
isClosed
public boolean isClosed()Finds out if the display has been closed.- Returns:
trueif 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
isRgba()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 this Display are created with an alpha channel.Even if a
trueis 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. UseisComposited()to check if that is the case.On modern displays, this value is always
true.- Returns:
trueif surfaces are created with an alpha channel orfalseif the display does not support this functionality.
-
listSeats
-
mapKeycode
public boolean mapKeycode(int keycode, @Nullable Out<KeymapKey[]> keys, @Nullable Out<int[]> keyvals) Returns the keyvals bound tokeycode.The Nth
GdkKeymapKeyinkeysis bound to the Nth keyval inkeyvals.When a keycode is pressed by the user, the keyval from this list of entries is selected by considering the effective keyboard group and level.
Free the returned arrays with g_free().
- Parameters:
keycode- a keycodekeys- return location for array ofGdkKeymapKeykeyvals- return location for array of keyvals- Returns:
trueif there were any entries
-
mapKeyval
Obtains a list of keycode/group/level combinations that will generatekeyval.Groups and levels are two kinds of keyboard mode; in general, the level determines whether the top or bottom symbol on a key is used, and the group determines whether the left or right symbol is used.
On US keyboards, the shift key changes the keyboard level, and there are no groups. A group switch key might convert a keyboard between Hebrew to English modes, for example.
GdkEventKeycontains agroupfield that indicates the active keyboard group. The level is computed from the modifier mask.The returned array should be freed with g_free().
- Parameters:
keyval- a keyval, such asGDK_KEY_a,GDK_KEY_Up,GDK_KEY_Return, etc.keys- return location for an array ofGdkKeymapKey- Returns:
trueif keys were found and returned
-
notifyStartupComplete
Deprecated.UsingToplevel.setStartupId(java.lang.String)is sufficientIndicates to the GUI environment that the application has finished loading, using a given identifier.GTK will call this function automatically for GtkWindow with custom startup-notification identifier unless gtk_window_set_auto_startup_notification() is called to disable that feature.
- Parameters:
startupId- a startup-notification identifier, for which notification process should be completed
-
prepareGl
Checks that OpenGL is available for this Display and ensures that it is properly initialized. When this fails, anerrorwill be set describing the error and this function returnsfalse.Note that even if this function succeeds, creating a
GdkGLContextmay 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:
trueif the display supports OpenGL- Throws:
GErrorException- seeGError- Since:
- 4.4
-
putEvent
Deprecated.This function is only useful in very special situations and should not be used by applications.Adds the given event to the event queue fordisplay.- Parameters:
event- aGdkEvent
-
supportsInputShapes
public boolean supportsInputShapes()Returnstrueif the display supports input shapes.This means that
Surface.setInputRegion(org.freedesktop.cairo.Region)can be used to modify the input shape of surfaces ondisplay.On modern displays, this value is always
true.- Returns:
trueif surfaces with modified input shape are supported
-
supportsShadowWidth
public boolean supportsShadowWidth()Returns whether it's possible for a surface to draw outside of the window area.If
trueis returned the application decides if it wants to draw shadows. Iffalseis returned, the compositor decides if it wants to draw shadows.- Returns:
trueif surfaces can draw shadows orfalseif the display does not support this functionality.- Since:
- 4.14
-
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
sync()beforeorg.gnome.gdk.Display#errorTrapPopmakes 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.
-
translateKey
public boolean translateKey(int keycode, Set<ModifierType> state, int group, @Nullable Out<Integer> keyval, @Nullable Out<Integer> effectiveGroup, @Nullable Out<Integer> level, @Nullable Out<Set<ModifierType>> consumed) Translates the contents of aGdkEventKeyinto a keyval, effective group, and level.Modifiers that affected the translation and are thus unavailable for application use are returned in
consumedModifiers.The
effectiveGroupis the group that was actually used for the translation; some keys such as Enter are not affected by the active keyboard group. Thelevelis derived fromstate.consumedModifiersgives modifiers that should be masked out fromstatewhen comparing this key press to a keyboard shortcut. For instance, on a US keyboard, theplussymbol is shifted, so when comparing a key press to a<Control>plusaccelerator<Shift>should be masked out.This function should rarely be needed, since
GdkEventKeyalready contains the translated keyval. It is exported for the benefit of virtualized test environments.- Parameters:
keycode- a keycodestate- a modifier stategroup- active keyboard groupkeyval- return location for keyvaleffectiveGroup- return location for effective grouplevel- return location for levelconsumed- return location for modifiers that were used to determine the group or level- Returns:
trueif there was a keyval bound to keycode/state/group.
-
translateKey
public boolean translateKey(int keycode, ModifierType state, int group, @Nullable Out<Integer> keyval, @Nullable Out<Integer> effectiveGroup, @Nullable Out<Integer> level, @Nullable Out<ModifierType> consumed) Translates the contents of aGdkEventKeyinto a keyval, effective group, and level.Modifiers that affected the translation and are thus unavailable for application use are returned in
consumedModifiers.The
effectiveGroupis the group that was actually used for the translation; some keys such as Enter are not affected by the active keyboard group. Thelevelis derived fromstate.consumedModifiersgives modifiers that should be masked out fromstatewhen comparing this key press to a keyboard shortcut. For instance, on a US keyboard, theplussymbol is shifted, so when comparing a key press to a<Control>plusaccelerator<Shift>should be masked out.This function should rarely be needed, since
GdkEventKeyalready contains the translated keyval. It is exported for the benefit of virtualized test environments.- Parameters:
keycode- a keycodestate- a modifier stategroup- active keyboard groupkeyval- return location for keyvaleffectiveGroup- return location for effective grouplevel- return location for levelconsumed- return location for modifiers that were used to determine the group or level- Returns:
trueif there was a keyval bound to keycode/state/group.
-
onClosed
Emitted when the connection to the windowing system fordisplayis closed.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitClosed
public void emitClosed(boolean isError) Emits the "closed" signal. SeeonClosed(org.gnome.gdk.Display.ClosedCallback). -
onOpened
Emitted when the connection to the windowing system fordisplayis opened.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitOpened
public void emitOpened()Emits the "opened" signal. SeeonOpened(org.gnome.gdk.Display.OpenedCallback). -
onSeatAdded
Emitted whenever a new seat is made known to the windowing system.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitSeatAdded
Emits the "seat-added" signal. SeeonSeatAdded(org.gnome.gdk.Display.SeatAddedCallback). -
onSeatRemoved
public SignalConnection<Display.SeatRemovedCallback> onSeatRemoved(Display.SeatRemovedCallback handler) Emitted whenever a seat is removed by the windowing system.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitSeatRemoved
Emits the "seat-removed" signal. SeeonSeatRemoved(org.gnome.gdk.Display.SeatRemovedCallback). -
onSettingChanged
public SignalConnection<Display.SettingChangedCallback> onSettingChanged(Display.SettingChangedCallback handler) Emitted whenever a setting changes its value.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitSettingChanged
Emits the "setting-changed" signal. SeeonSettingChanged(org.gnome.gdk.Display.SettingChangedCallback). -
builder
ADisplay.Builderobject constructs aDisplaywith the specified properties. Use the variousset...()methods to set properties, and finish construction withDisplay.Builder.build().- Returns:
- the builder object
-
Toplevel.setStartupId(java.lang.String)is sufficient